Annotation of embedaddon/ntp/sntp/libopts/compat/compat.h, revision 1.1

1.1     ! misho       1: /*  -*- Mode: C -*-  */
        !             2: 
        !             3: /**
        !             4:  * \file compat.h --- fake the preprocessor into handlng portability
        !             5:  *
        !             6:  *  Time-stamp:      "2010-07-16 15:11:57 bkorb"
        !             7:  *
        !             8:  *  compat.h is free software.
        !             9:  *  This file is part of AutoGen.
        !            10:  *
        !            11:  *  AutoGen Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
        !            12:  *
        !            13:  *  AutoGen is free software: you can redistribute it and/or modify it
        !            14:  *  under the terms of the GNU General Public License as published by the
        !            15:  *  Free Software Foundation, either version 3 of the License, or
        !            16:  *  (at your option) any later version.
        !            17:  *
        !            18:  *  AutoGen is distributed in the hope that it will be useful, but
        !            19:  *  WITHOUT ANY WARRANTY; without even the implied warranty of
        !            20:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        !            21:  *  See the GNU General Public License for more details.
        !            22:  *
        !            23:  *  You should have received a copy of the GNU General Public License along
        !            24:  *  with this program.  If not, see <http://www.gnu.org/licenses/>.
        !            25:  *
        !            26:  *  As a special exception, Bruce Korb gives permission for additional
        !            27:  *  uses of the text contained in the release of compat.h.
        !            28:  *
        !            29:  *  The exception is that, if you link the compat.h library with other
        !            30:  *  files to produce an executable, this does not by itself cause the
        !            31:  *  resulting executable to be covered by the GNU General Public License.
        !            32:  *  Your use of that executable is in no way restricted on account of
        !            33:  *  linking the compat.h library code into it.
        !            34:  *
        !            35:  *  This exception does not however invalidate any other reasons why
        !            36:  *  the executable file might be covered by the GNU General Public License.
        !            37:  *
        !            38:  *  This exception applies only to the code released by Bruce Korb under
        !            39:  *  the name compat.h.  If you copy code from other sources under the
        !            40:  *  General Public License into a copy of compat.h, as the General Public
        !            41:  *  License permits, the exception does not apply to the code that you add
        !            42:  *  in this way.  To avoid misleading anyone as to the status of such
        !            43:  *  modified files, you must delete this exception notice from them.
        !            44:  *
        !            45:  *  If you write modifications of your own for compat.h, it is your choice
        !            46:  *  whether to permit this exception to apply to your modifications.
        !            47:  *  If you do not wish that, delete this exception notice.
        !            48:  */
        !            49: #ifndef COMPAT_H_GUARD
        !            50: #define COMPAT_H_GUARD 1
        !            51: 
        !            52: #if defined(HAVE_CONFIG_H)
        !            53: #  include <config.h>
        !            54: 
        !            55: #elif defined(_WIN32) && !defined(__CYGWIN__)
        !            56: #  include "windows-config.h"
        !            57: 
        !            58: #else
        !            59: #  error "compat.h" requires "config.h"
        !            60:    choke me.
        !            61: #endif
        !            62: 
        !            63: 
        !            64: #ifndef HAVE_STRSIGNAL
        !            65:    char * strsignal( int signo );
        !            66: #endif
        !            67: 
        !            68: #define  _GNU_SOURCE    1 /* for strsignal in GNU's libc */
        !            69: #define  __USE_GNU      1 /* exact same thing as above   */
        !            70: #define  __EXTENSIONS__ 1 /* and another way to call for it */
        !            71: 
        !            72: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        !            73:  *
        !            74:  *  SYSTEM HEADERS:
        !            75:  */
        !            76: #include <sys/types.h>
        !            77: #ifdef HAVE_SYS_MMAN_H
        !            78: #  include <sys/mman.h>
        !            79: #endif
        !            80: #include <sys/param.h>
        !            81: #if HAVE_SYS_PROCSET_H
        !            82: #  include <sys/procset.h>
        !            83: #endif
        !            84: #include <sys/stat.h>
        !            85: #include <sys/wait.h>
        !            86: 
        !            87: #if defined( HAVE_SOLARIS_SYSINFO )
        !            88: #  include <sys/systeminfo.h>
        !            89: #elif defined( HAVE_UNAME_SYSCALL )
        !            90: #  include <sys/utsname.h>
        !            91: #endif
        !            92: 
        !            93: #ifdef DAEMON_ENABLED
        !            94: #  if HAVE_SYS_STROPTS_H
        !            95: #  include <sys/stropts.h>
        !            96: #  endif
        !            97: 
        !            98: #  if HAVE_SYS_SOCKET_H
        !            99: #  include <sys/socket.h>
        !           100: #  endif
        !           101: 
        !           102: #  if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H)
        !           103: #    error This system cannot support daemon processing
        !           104:      Choke Me.
        !           105: #  endif
        !           106: 
        !           107: #  if HAVE_SYS_POLL_H
        !           108: #  include <sys/poll.h>
        !           109: #  endif
        !           110: 
        !           111: #  if HAVE_SYS_SELECT_H
        !           112: #  include <sys/select.h>
        !           113: #  endif
        !           114: 
        !           115: #  if HAVE_NETINET_IN_H
        !           116: #  include <netinet/in.h>
        !           117: #  endif
        !           118: 
        !           119: #  if HAVE_SYS_UN_H
        !           120: #  include <sys/un.h>
        !           121: #  endif
        !           122: #endif
        !           123: 
        !           124: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        !           125:  *
        !           126:  *  USER HEADERS:
        !           127:  */
        !           128: #include <stdio.h>
        !           129: #include <assert.h>
        !           130: #include <ctype.h>
        !           131: 
        !           132: /*
        !           133:  *  Directory opening stuff:
        !           134:  */
        !           135: # if defined (_POSIX_SOURCE)
        !           136: /* Posix does not require that the d_ino field be present, and some
        !           137:    systems do not provide it. */
        !           138: #    define REAL_DIR_ENTRY(dp) 1
        !           139: # else /* !_POSIX_SOURCE */
        !           140: #    define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
        !           141: # endif /* !_POSIX_SOURCE */
        !           142: 
        !           143: # if defined (HAVE_DIRENT_H)
        !           144: #   include <dirent.h>
        !           145: #   define D_NAMLEN(dirent) strlen((dirent)->d_name)
        !           146: # else /* !HAVE_DIRENT_H */
        !           147: #   define dirent direct
        !           148: #   define D_NAMLEN(dirent) (dirent)->d_namlen
        !           149: #   if defined (HAVE_SYS_NDIR_H)
        !           150: #     include <sys/ndir.h>
        !           151: #   endif /* HAVE_SYS_NDIR_H */
        !           152: #   if defined (HAVE_SYS_DIR_H)
        !           153: #     include <sys/dir.h>
        !           154: #   endif /* HAVE_SYS_DIR_H */
        !           155: #   if defined (HAVE_NDIR_H)
        !           156: #     include <ndir.h>
        !           157: #   endif /* HAVE_NDIR_H */
        !           158: # endif /* !HAVE_DIRENT_H */
        !           159: 
        !           160: #include <errno.h>
        !           161: #ifdef HAVE_FCNTL_H
        !           162: # include <fcntl.h>
        !           163: #endif
        !           164: #ifndef O_NONBLOCK
        !           165: # define O_NONBLOCK FNDELAY
        !           166: #endif
        !           167: 
        !           168: #if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H)
        !           169: #  include <libgen.h>
        !           170: #endif
        !           171: 
        !           172: #if defined(HAVE_LIMITS_H)  /* this is also in options.h */
        !           173: #  include <limits.h>
        !           174: #elif defined(HAVE_SYS_LIMITS_H)
        !           175: #  include <sys/limits.h>
        !           176: #endif /* HAVE_LIMITS/SYS_LIMITS_H */
        !           177: 
        !           178: #include <memory.h>
        !           179: #include <setjmp.h>
        !           180: #include <signal.h>
        !           181: 
        !           182: #if defined( HAVE_STDINT_H )
        !           183: #  include <stdint.h>
        !           184: #elif defined( HAVE_INTTYPES_H )
        !           185: #  include <inttypes.h>
        !           186: #endif
        !           187: 
        !           188: #include <stdlib.h>
        !           189: #include <string.h>
        !           190: 
        !           191: #include <time.h>
        !           192: 
        !           193: #ifdef HAVE_UTIME_H
        !           194: #  include <utime.h>
        !           195: #endif
        !           196: 
        !           197: #ifdef HAVE_UNISTD_H
        !           198: #  include <unistd.h>
        !           199: #endif
        !           200: 
        !           201: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
        !           202:  *
        !           203:  *  FIXUPS and CONVIENCE STUFF:
        !           204:  */
        !           205: #ifdef __cplusplus
        !           206: #   define EXTERN extern "C"
        !           207: #else
        !           208: #   define EXTERN extern
        !           209: #endif
        !           210: 
        !           211: /* some systems #def errno! and others do not declare it!! */
        !           212: #ifndef errno
        !           213:    extern int errno;
        !           214: #endif
        !           215: 
        !           216: /* Some machines forget this! */
        !           217: 
        !           218: # ifndef EXIT_FAILURE
        !           219: #   define EXIT_SUCCESS 0
        !           220: #   define EXIT_FAILURE 1
        !           221: # endif
        !           222: 
        !           223: #ifndef NUL
        !           224: #  define NUL '\0'
        !           225: #endif
        !           226: 
        !           227: #ifndef NULL
        !           228: #  define NULL 0
        !           229: #endif
        !           230: 
        !           231: #if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H)
        !           232: #  include <sys/param.h>
        !           233: #endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */
        !           234: 
        !           235: #if !defined (MAXPATHLEN) && defined (PATH_MAX)
        !           236: #  define MAXPATHLEN PATH_MAX
        !           237: #endif /* !MAXPATHLEN && PATH_MAX */
        !           238: 
        !           239: #if !defined (MAXPATHLEN) && defined(_MAX_PATH)
        !           240: #  define PATH_MAX _MAX_PATH
        !           241: #  define MAXPATHLEN _MAX_PATH
        !           242: #endif
        !           243: 
        !           244: #if !defined (MAXPATHLEN)
        !           245: #  define MAXPATHLEN ((size_t)4096)
        !           246: #endif /* MAXPATHLEN */
        !           247: 
        !           248: #define AG_PATH_MAX  ((size_t)MAXPATHLEN)
        !           249: 
        !           250: #ifndef LONG_MAX
        !           251: #  define LONG_MAX      ~(1L << (8*sizeof(long) -1))
        !           252: #  define INT_MAX       ~(1 << (8*sizeof(int) -1))
        !           253: #endif
        !           254: 
        !           255: #ifndef ULONG_MAX
        !           256: #  define ULONG_MAX     ~(OUL)
        !           257: #  define UINT_MAX      ~(OU)
        !           258: #endif
        !           259: 
        !           260: #ifndef SHORT_MAX
        !           261: #  define SHORT_MAX     ~(1 << (8*sizeof(short) - 1))
        !           262: #else
        !           263: #  define USHORT_MAX    ~(OUS)
        !           264: #endif
        !           265: 
        !           266: #ifndef HAVE_INT8_T
        !           267:   typedef signed char           int8_t;
        !           268: # define  HAVE_INT8_T           1
        !           269: #endif
        !           270: #ifndef HAVE_UINT8_T
        !           271:   typedef unsigned char         uint8_t;
        !           272: # define  HAVE_UINT8_T          1
        !           273: #endif
        !           274: #ifndef HAVE_INT16_T
        !           275:   typedef signed short          int16_t;
        !           276: # define  HAVE_INT16_T          1
        !           277: #endif
        !           278: #ifndef HAVE_UINT16_T
        !           279:   typedef unsigned short        uint16_t;
        !           280: # define  HAVE_UINT16_T         1
        !           281: #endif
        !           282: 
        !           283: #ifndef HAVE_INT32_T
        !           284: # if SIZEOF_INT ==              4
        !           285:     typedef signed int          int32_t;
        !           286: # elif SIZEOF_LONG ==           4
        !           287:     typedef signed long         int32_t;
        !           288: # endif
        !           289: # define  HAVE_INT32_T          1
        !           290: #endif
        !           291: 
        !           292: #ifndef HAVE_UINT32_T
        !           293: # if SIZEOF_INT ==              4
        !           294:     typedef unsigned int        uint32_t;
        !           295: # elif SIZEOF_LONG ==           4
        !           296:     typedef unsigned long       uint32_t;
        !           297: # else
        !           298: #   error Cannot create a uint32_t type.
        !           299:     Choke Me.
        !           300: # endif
        !           301: # define  HAVE_UINT32_T         1
        !           302: #endif
        !           303: 
        !           304: #ifndef HAVE_INTPTR_T
        !           305: # if SIZEOF_CHARP == SIZEOF_LONG
        !           306:     typedef signed long         intptr_t;
        !           307: # else
        !           308:     typedef signed int          intptr_t;
        !           309: # endif
        !           310: # define  HAVE_INTPTR_T         1
        !           311: #endif
        !           312: 
        !           313: #ifndef HAVE_UINTPTR_T
        !           314: # if SIZEOF_CHARP == SIZEOF_LONG
        !           315:     typedef unsigned long       intptr_t;
        !           316: # else
        !           317:     typedef unsigned int        intptr_t;
        !           318: # endif
        !           319: # define  HAVE_INTPTR_T         1
        !           320: #endif
        !           321: 
        !           322: #ifndef HAVE_UINT_T
        !           323:   typedef unsigned int          uint_t;
        !           324: # define  HAVE_UINT_T           1
        !           325: #endif
        !           326: 
        !           327: #ifndef HAVE_SIZE_T
        !           328:   typedef unsigned int          size_t;
        !           329: # define  HAVE_SIZE_T           1
        !           330: #endif
        !           331: #ifndef HAVE_WINT_T
        !           332:   typedef unsigned int          wint_t;
        !           333: # define  HAVE_WINT_T           1
        !           334: #endif
        !           335: #ifndef HAVE_PID_T
        !           336:   typedef signed int            pid_t;
        !           337: # define  HAVE_PID_T            1
        !           338: #endif
        !           339: 
        !           340: /* redefine these for BSD style string libraries */
        !           341: #ifndef HAVE_STRCHR
        !           342: #  define strchr            index
        !           343: #  define strrchr           rindex
        !           344: #endif
        !           345: 
        !           346: #ifdef USE_FOPEN_BINARY
        !           347: #  ifndef FOPEN_BINARY_FLAG
        !           348: #    define FOPEN_BINARY_FLAG   "b"
        !           349: #  endif
        !           350: #  ifndef FOPEN_TEXT_FLAG
        !           351: #    define FOPEN_TEXT_FLAG     "t"
        !           352: #  endif
        !           353: #else
        !           354: #  ifndef FOPEN_BINARY_FLAG
        !           355: #    define FOPEN_BINARY_FLAG
        !           356: #  endif
        !           357: #  ifndef FOPEN_TEXT_FLAG
        !           358: #    define FOPEN_TEXT_FLAG
        !           359: #  endif
        !           360: #endif
        !           361: 
        !           362: #ifndef STR
        !           363: #  define _STR(s) #s
        !           364: #  define STR(s)  _STR(s)
        !           365: #endif
        !           366: 
        !           367: /* ##### Pointer sized word ##### */
        !           368: 
        !           369: /* FIXME:  the MAX stuff in here is broken! */
        !           370: #if SIZEOF_CHARP > SIZEOF_INT
        !           371:    typedef long t_word;
        !           372:    #define WORD_MAX  LONG_MAX
        !           373:    #define WORD_MIN  LONG_MIN
        !           374: #else /* SIZEOF_CHARP <= SIZEOF_INT */
        !           375:    typedef int t_word;
        !           376:    #define WORD_MAX  INT_MAX
        !           377:    #define WORD_MIN  INT_MIN
        !           378: #endif
        !           379: 
        !           380: #endif /* COMPAT_H_GUARD */
        !           381: 
        !           382: /*
        !           383:  * Local Variables:
        !           384:  * mode: C
        !           385:  * c-file-style: "stroustrup"
        !           386:  * indent-tabs-mode: nil
        !           387:  * End:
        !           388:  * end of compat/compat.h */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>