Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

os.h

Go to the documentation of this file.
00001 /*
00002  * os.h
00003  *
00004  * Sleazy OS-specific defines.
00005  *
00006  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
00007  *
00008  * $Id: os.h,v 1.12 2005/02/15 05:31:00 dugsong Exp $
00009  */
00010 
00011 #ifndef DNET_OS_H
00012 #define DNET_OS_H
00013 
00014 #ifdef _WIN32
00015 # include <winsock2.h>
00016 # include <windows.h>
00017 /* XXX */
00018 # undef IP_OPT_LSRR
00019 # undef IP_OPT_TS
00020 # undef IP_OPT_RR
00021 # undef IP_OPT_SSRR
00022   typedef u_char        uint8_t;
00023   typedef u_short       uint16_t;
00024   typedef u_int         uint32_t;
00025 # ifndef __CYGWIN__
00026   typedef long          ssize_t;
00027 # endif
00028 #else
00029 # include <sys/param.h>
00030 # include <sys/types.h>
00031 # include <sys/socket.h>
00032 # include <netinet/in.h>
00033 # include <arpa/inet.h>
00034 # include <netdb.h>
00035 # ifdef __bsdi__
00036 #  include <machine/types.h>
00037    typedef u_int8_t     uint8_t;
00038    typedef u_int16_t    uint16_t;
00039    typedef u_int32_t    uint32_t;
00040    typedef u_int64_t    uint64_t;
00041 # else
00042 #  include <inttypes.h>
00043 # endif
00044 #endif
00045 
00046 #define DNET_LIL_ENDIAN         1234
00047 #define DNET_BIG_ENDIAN         4321
00048 
00049 /* BSD and IRIX */
00050 #ifdef BYTE_ORDER
00051 #if BYTE_ORDER == LITTLE_ENDIAN
00052 # define DNET_BYTESEX           DNET_LIL_ENDIAN
00053 #elif BYTE_ORDER == BIG_ENDIAN
00054 # define DNET_BYTESEX           DNET_BIG_ENDIAN
00055 #endif
00056 #endif
00057 
00058 /* Linux */
00059 #ifdef __BYTE_ORDER
00060 #if __BYTE_ORDER == __LITTLE_ENDIAN
00061 # define DNET_BYTESEX           DNET_LIL_ENDIAN
00062 #elif __BYTE_ORDER == __BIG_ENDIAN
00063 # define DNET_BYTESEX           DNET_BIG_ENDIAN
00064 #endif
00065 #endif
00066 
00067 /* Solaris */
00068 #if defined(_BIT_FIELDS_LTOH)
00069 # define DNET_BYTESEX           DNET_LIL_ENDIAN
00070 #elif defined (_BIT_FIELDS_HTOL)
00071 # define DNET_BYTESEX           DNET_BIG_ENDIAN
00072 #endif
00073 
00074 /* Win32 - XXX */
00075 #ifdef _WIN32
00076 # define DNET_BYTESEX           DNET_LIL_ENDIAN
00077 #endif
00078 
00079 /* Nastiness from old BIND code. */
00080 #ifndef DNET_BYTESEX
00081 # if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
00082     defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
00083     defined(__alpha__) || defined(__alpha)
00084 #  define DNET_BYTESEX          DNET_LIL_ENDIAN
00085 # elif defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
00086     defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
00087     defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
00088     defined(apollo) || defined(__convex__) || defined(_CRAY) || \
00089     defined(__hppa) || defined(__hp9000) || \
00090     defined(__hp9000s300) || defined(__hp9000s700) || defined(__ia64) || \
00091     defined (BIT_ZERO_ON_LEFT) || defined(m68k)
00092 #  define DNET_BYTESEX          DNET_BIG_ENDIAN
00093 # else
00094 #  error "bytesex unknown"
00095 # endif
00096 #endif
00097 
00098 /* C++ support. */
00099 #undef __BEGIN_DECLS
00100 #undef __END_DECLS
00101 #ifdef __cplusplus
00102 # define __BEGIN_DECLS  extern "C" {
00103 # define __END_DECLS    } /* extern "C" */
00104 #else
00105 # define __BEGIN_DECLS
00106 # define __END_DECLS
00107 #endif
00108 
00109 /* Support for flexible arrays. */
00110 #undef __flexarr
00111 #if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97))
00112 /* GCC 2.97 supports C99 flexible array members.  */
00113 # define __flexarr      []
00114 #else
00115 # ifdef __GNUC__
00116 #  define __flexarr     [0]
00117 # else
00118 #  if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00119 #   define __flexarr    []
00120 #  elif defined(_WIN32)
00121 /* MS VC++ */
00122 #   define __flexarr    []
00123 #  else
00124 /* Some other non-C99 compiler. Approximate with [1]. */
00125 #   define __flexarr    [1]
00126 #  endif
00127 # endif
00128 #endif
00129 
00130 #endif /* DNET_OS_H */

Generated on Sun May 14 14:51:10 2006 by  doxygen 1.4.2