12632SN/A/* 22632SN/A * os.h 32632SN/A * 42632SN/A * Sleazy OS-specific defines. 52632SN/A * 62632SN/A * Copyright (c) 2000 Dug Song <dugsong@monkey.org> 72632SN/A * 82632SN/A * $Id: os.h,v 1.10 2004/05/04 03:19:42 dugsong Exp $ 92632SN/A */ 102632SN/A 112632SN/A#ifndef DNET_OS_H 122632SN/A#define DNET_OS_H 132632SN/A 142632SN/A#ifdef _WIN32 152632SN/A# include <windows.h> 162632SN/A# include <winsock2.h> 172632SN/A# include <stdint.h> 182632SN/A/* XXX */ 192632SN/A# undef IP_OPT_LSRR 202632SN/A# undef IP_OPT_TS 212632SN/A# undef IP_OPT_RR 222632SN/A# undef IP_OPT_SSRR 232632SN/A#else 242632SN/A# include <sys/param.h> 252632SN/A# include <sys/types.h> 262632SN/A# include <sys/socket.h> 272632SN/A# include <netinet/in.h> 282632SN/A# include <arpa/inet.h> 292632SN/A# include <netdb.h> 302632SN/A# ifdef __bsdi__ 312632SN/A# include <machine/types.h> 322632SN/A typedef u_int8_t uint8_t; 332632SN/A typedef u_int16_t uint16_t; 342632SN/A typedef u_int32_t uint32_t; 352632SN/A typedef u_int64_t uint64_t; 362632SN/A# else 372632SN/A# include <inttypes.h> 382632SN/A# endif 392632SN/A#endif 402632SN/A 412632SN/A#define DNET_LIL_ENDIAN 1234 422632SN/A#define DNET_BIG_ENDIAN 4321 432632SN/A 442632SN/A/* BSD and IRIX */ 452632SN/A#ifdef BYTE_ORDER 462632SN/A#if BYTE_ORDER == LITTLE_ENDIAN 472632SN/A# define DNET_BYTESEX DNET_LIL_ENDIAN 482632SN/A#elif BYTE_ORDER == BIG_ENDIAN 492632SN/A# define DNET_BYTESEX DNET_BIG_ENDIAN 502632SN/A#endif 512632SN/A#endif 522632SN/A 532632SN/A/* Linux */ 542632SN/A#ifdef __BYTE_ORDER 552632SN/A#if __BYTE_ORDER == __LITTLE_ENDIAN 562632SN/A# define DNET_BYTESEX DNET_LIL_ENDIAN 572632SN/A#elif __BYTE_ORDER == __BIG_ENDIAN 582632SN/A# define DNET_BYTESEX DNET_BIG_ENDIAN 592632SN/A#endif 602632SN/A#endif 612632SN/A 622632SN/A/* Solaris */ 632632SN/A#if defined(_BIT_FIELDS_LTOH) 642632SN/A# define DNET_BYTESEX DNET_LIL_ENDIAN 652632SN/A#elif defined (_BIT_FIELDS_HTOL) 662632SN/A# define DNET_BYTESEX DNET_BIG_ENDIAN 672632SN/A#endif 682632SN/A 692632SN/A/* Nastiness from old BIND code. */ 702632SN/A#ifndef DNET_BYTESEX 712632SN/A# if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \ 722632SN/A defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ 732632SN/A defined(__alpha__) || defined(__alpha) 742632SN/A# define DNET_BYTESEX DNET_LIL_ENDIAN 752632SN/A# elif defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ 762632SN/A defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ 772632SN/A defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ 782632SN/A defined(apollo) || defined(__convex__) || defined(_CRAY) || \ 792632SN/A defined(__hppa) || defined(__hp9000) || \ 802632SN/A defined(__hp9000s300) || defined(__hp9000s700) || defined(__ia64) || \ 812632SN/A defined (BIT_ZERO_ON_LEFT) || defined(m68k) 822632SN/A# define DNET_BYTESEX DNET_BIG_ENDIAN 832632SN/A# else 842632SN/A# error "bytesex unknown" 852632SN/A# endif 862632SN/A#endif 872632SN/A 882632SN/A/* C++ support. */ 892632SN/A#undef __BEGIN_DECLS 902632SN/A#undef __END_DECLS 912632SN/A#ifdef __cplusplus 922632SN/A# define __BEGIN_DECLS extern "C" { 932632SN/A# define __END_DECLS } /* extern "C" */ 942632SN/A#else 952632SN/A# define __BEGIN_DECLS 962632SN/A# define __END_DECLS 972632SN/A#endif 982632SN/A 992632SN/A/* Support for flexible arrays. */ 1002632SN/A#undef __flexarr 10110271Smitch.hayenga@arm.com#if !defined(__clang__) && defined(__GNUC__) && \ 10210271Smitch.hayenga@arm.com ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)) 1032632SN/A/* GCC 2.97 supports C99 flexible array members. */ 1042632SN/A# define __flexarr [] 1052632SN/A#else 1062632SN/A# ifdef __GNUC__ 1072632SN/A# define __flexarr [0] 1082632SN/A# else 1092632SN/A# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 1102632SN/A# define __flexarr [] 1112632SN/A# else 1122632SN/A/* Some other non-C99 compiler. Approximate with [1]. */ 1132632SN/A# define __flexarr [1] 1142632SN/A# endif 1152632SN/A# endif 1162632SN/A#endif 1172632SN/A 1182632SN/A#endif /* DNET_OS_H */ 119