Browse Source

add missing compatibilty headers

OPENBSD_5_7
Brent Cook 10 years ago
parent
commit
558f0dd84f
6 changed files with 149 additions and 3 deletions
  1. +0
    -3
      .gitignore
  2. +33
    -0
      include/stdlib.h
  3. +69
    -0
      include/string.h
  4. +12
    -0
      include/sys/socket.h
  5. +10
    -0
      include/sys/time.h
  6. +25
    -0
      include/sys/types.h

+ 0
- 3
.gitignore View File

@ -60,9 +60,6 @@ config.c
control.c
include/imsg.h
include/md5.h
include/stdlib.h
include/string.h
include/sys/
log.c
ntp.c
ntp.h


+ 33
- 0
include/stdlib.h View File

@ -0,0 +1,33 @@
/*
* stdlib.h compatibility shim
* Public domain
*/
#include_next <stdlib.h>
#ifndef LIBCOMPAT_STDLIB_H
#define LIBCOMPAT_STDLIB_H
#include <sys/stat.h>
#include <sys/time.h>
#include <stdint.h>
#ifndef HAVE_ARC4RANDOM_BUF
uint32_t arc4random(void);
uint32_t arc4random_uniform(uint32_t);
#endif
#ifndef HAVE_REALLOCARRAY
void *reallocarray(void *, size_t, size_t);
#endif
#ifndef HAVE_SETPROCTITLE
void setproctitle(const char *fmt, ...);
#endif
#ifndef HAVE_STRTONUM
long long strtonum(const char *nptr, long long minval,
long long maxval, const char **errstr);
#endif
#endif

+ 69
- 0
include/string.h View File

@ -0,0 +1,69 @@
/*
* Public domain
* string.h compatibility shim
*/
#include_next <string.h>
#ifndef LIBCOMPAT_STRING_H
#define LIBCOMPAT_STRING_H
#include <sys/types.h>
#if defined(__sun) || defined(__hpux)
/* Some functions historically defined in string.h were placed in strings.h by
* SUS. Use the same hack as OS X and FreeBSD use to work around on Solaris and HPUX.
*/
#include <strings.h>
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif
#ifndef HAVE_STRLCAT
size_t strlcat(char *dst, const char *src, size_t siz);
#endif
#ifndef HAVE_STRNDUP
char * strndup(const char *str, size_t maxlen);
/* the only user of strnlen is strndup, so only build it if needed */
#ifndef HAVE_STRNLEN
size_t strnlen(const char *str, size_t maxlen);
#endif
#endif
#ifndef HAVE_EXPLICIT_BZERO
void explicit_bzero(void *, size_t);
#endif
#ifndef HAVE_TIMINGSAFE_BCMP
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
#endif
#ifndef HAVE_TIMINGSAFE_MEMCMP
int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
#endif
#ifndef HAVE_MEMMEM
void * memmem(const void *big, size_t big_len, const void *little,
size_t little_len);
#endif
#ifdef _WIN32
#include <errno.h>
static inline char *
posix_strerror(int errnum)
{
if (errnum == ECONNREFUSED) {
return "Connection refused";
}
return strerror(errnum);
}
#define strerror(errnum) posix_strerror(errnum)
#endif
#endif

+ 12
- 0
include/sys/socket.h View File

@ -0,0 +1,12 @@
/*
* Public domain
* sys/socket.h compatibility shim
*/
#include_next <sys/socket.h>
#ifndef SA_LEN
#define SA_LEN(X) \
(((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \
((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr))
#endif

+ 10
- 0
include/sys/time.h View File

@ -0,0 +1,10 @@
/*
* Public domain
* sys/time.h compatibility shim
*/
#include_next <sys/time.h>
#include <stdint.h>
int adjfreq(const int64_t *freq, int64_t *oldfreq);

+ 25
- 0
include/sys/types.h View File

@ -0,0 +1,25 @@
/*
* Public domain
* sys/types.h compatibility shim
*/
#include_next <sys/types.h>
#ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H
#define LIBCRYPTOCOMPAT_SYS_TYPES_H
#include <stdint.h>
#ifdef __MINGW32__
#include <_bsd_types.h>
#endif
#if !defined(HAVE_ATTRIBUTE__DEAD) && !defined(__dead)
#define __dead
#endif
#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__)
# define __bounded__(x, y, z)
#endif
#endif

Loading…
Cancel
Save