compat.h revision b3bb775c6b735a7f6021dea799601fbfdb656e58
#ifndef COMPAT_H
#define COMPAT_H
#if defined (HAVE_INTTYPES_H) && defined(__osf__)
# include <inttypes.h>
#endif
/* well, this is obviously wrong since it assumes it's 64bit, but older
GCCs don't define it and we really want it. */
#ifndef LLONG_MAX
# define LLONG_MAX 9223372036854775807LL
#endif
#ifndef __cplusplus
#ifdef HAVE__BOOL
typedef _Bool bool;
#else
typedef int bool;
#endif
#endif
#if defined (HAVE_UOFF_T)
/* native support */
#elif defined (UOFF_T_INT)
typedef unsigned int uoff_t;
#elif defined (UOFF_T_LONG)
typedef unsigned long uoff_t;
#elif defined (UOFF_T_LONG_LONG)
typedef unsigned long long uoff_t;
#else
#endif
#ifndef HAVE_UINTMAX_T
# if SIZEOF_LONG_LONG > 0
typedef unsigned long long uintmax_t;
# else
typedef unsigned long uintmax_t;
# endif
#endif
#ifndef HAVE_UINT_FAST32_T
# if SIZEOF_INT >= 4
typedef unsigned int uint_fast32_t;
# else
typedef unsigned long uint_fast32_t;
# endif
#endif
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
#ifdef HAVE_SYS_SYSMACROS_H
# include <sys/sysmacros.h>
# ifdef HAVE_SYS_MKDEV_H
# endif
#elif !defined (DEV_T_STRUCT)
# define CMP_DEV_T(a, b) ((a) == (b))
#else
#endif
#ifdef HAVE_STAT_XTIM
# define HAVE_ST_NSECS
#elif defined (HAVE_STAT_XTIMESPEC)
# define HAVE_ST_NSECS
#else
#endif
#ifdef HAVE_ST_NSECS
/* TRUE if a nanosecond timestamp from struct stat matches another nanosecond.
If nanoseconds aren't supported in struct stat, returns always TRUE (useful
with NFS if some hosts support nanoseconds and others don't). */
#else
#endif
/* strcasecmp(), strncasecmp() */
#ifndef HAVE_STRCASECMP
# ifdef HAVE_STRICMP
# define strcasecmp stricmp
# define strncasecmp strnicmp
# else
# define strcasecmp my_strcasecmp
# define strncasecmp my_strncasecmp
# endif
#endif
#ifndef HAVE_INET_ATON
# define inet_aton my_inet_aton
#endif
#ifndef HAVE_VSYSLOG
# define vsyslog my_vsyslog
#endif
#ifndef HAVE_GETPAGESIZE
# define getpagesize my_getpagesize
int my_getpagesize(void);
#endif
#ifndef HAVE_FDATASYNC
#endif
struct const_iovec {
const void *iov_base;
};
#ifndef HAVE_STRUCT_IOVEC
struct iovec {
void *iov_base;
};
#endif
/* IOV_MAX should be in limits.h nowadays. Linux still (2005) requires
defining _XOPEN_SOURCE to get that value. UIO_MAXIOV works with it though,
so use it instead. 16 is the lowest acceptable value for all OSes. */
#ifndef IOV_MAX
# ifdef UIO_MAXIOV
# define IOV_MAX UIO_MAXIOV
# else
# define IOV_MAX 16
# endif
#endif
#ifndef HAVE_WRITEV
struct iovec;
#endif
#if !defined (HAVE_PREAD) || defined (PREAD_WRAPPERS)
# ifndef IN_COMPAT_C
# endif
#endif
#ifndef HAVE_SETEUID
# define seteuid my_seteuid
#endif
#ifndef HAVE_SETEGID
# define setegid my_setegid
#endif
#ifndef HAVE_LIBGEN_H
# define basename my_basename
char *my_basename(char *path);
#endif
#ifndef HAVE_STRTOULL
# define strtoull my_strtoull
#endif
/* ctype.h isn't safe with signed chars,
use our own instead if really needed */
#define i_isxdigit(x) isxdigit((int) (unsigned char) (x))
#ifndef EOVERFLOW
#endif
#ifdef EDQUOT
#else
#endif
/* EPERM is returned sometimes if device doesn't support such modification */
#ifdef EROFS
#else
#endif
/* EBUSY is given by some NFS implementations */
#define EDESTDIREXISTS(errno) \
#endif