/* * Copyright 2005-2014 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2005-2008 Ned Ludd - * Copyright 2005-2014 Mike Frysinger - * * All the junk in one trunk! */ #ifndef _PORTING_H #define _PORTING_H #ifdef HAVE_CONFIG_H # include "config.h" /* make sure we have EPREFIX, if set */ #endif #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #ifndef _FILE_OFFSET_BITS #define _FILE_OFFSET_BITS 64 /* #471024 */ #endif #ifdef _AIX #define _LINUX_SOURCE_COMPAT #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(__sun) && defined(__SVR4) /* workaround non-const defined name in option struct, such that we * don't get a zillion of warnings */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 struct option { const char *name; int has_arg; int *flag; int val; }; extern int getopt_long(int, char * const *, const char *, const struct option *, int *); #else #include #endif #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr))) #ifndef BUFSIZE # define BUFSIZE 8192 #endif #ifndef MIN #define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif #ifndef MAX #define MAX(x, y) ((x) < (y) ? (y) : (x)) #endif /* Easy enough to glue to older versions */ #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif #ifndef O_PATH #define O_PATH 0 #endif #ifndef CONFIG_EPREFIX #define CONFIG_EPREFIX "/" #endif #define likely(x) __builtin_expect((x), 1) #define unlikely(x) __builtin_expect((x), 0) #endif