2 * $Id: endian.h,v 1.7.12.2 2009-01-10 20:14:29 didg Exp $
4 * Copyright (c) 1990,1991 Regents of The University of Michigan.
5 * All Rights Reserved. See COPYRIGHT.
7 * This file handles both byte ordering and integer sizes.
10 #ifndef _ATALK_ENDIAN_H_
11 #define _ATALK_ENDIAN_H_
15 #endif /* HAVE_CONFIG_H */
17 #include <sys/types.h>
18 #include <netinet/in.h>
21 #include <sys/machine.h>
26 #ifndef __BIT_TYPES_DEFINED__
27 #define __BIT_TYPES_DEFINED__
28 typedef uint8_t u_int8_t;
29 typedef uint16_t u_int16_t;
30 typedef uint32_t u_int32_t;
31 typedef uint64_t u_int64_t;
32 #endif /* ! __BIT_TYPES_DEFINED__ */
35 /* handle sunos and solaris */
38 #include <sys/bitypes.h>
40 /* solaris and sunos don't consistently define u_int*_t. */
41 typedef unsigned char u_int8_t;
42 typedef unsigned short u_int16_t;
43 typedef unsigned int u_int32_t;
47 typedef unsigned long long u_int64_t;
56 /* luckily ultrix is dead. as a result, we know what the sizes of
57 * various types are forever. this makes some assumptions about integer
59 #if defined (ultrix) || defined(HAVE_32BIT_LONGS) || defined(HAVE_64BIT_LONGS)
60 #ifndef __BIT_TYPES_DEFINED__
61 #define __BIT_TYPES_DEFINED__
62 typedef unsigned char u_int8_t;
63 typedef unsigned short u_int16_t;
64 typedef unsigned int u_int32_t;
67 #endif /* ultrix || HAVE_32BIT_LONGS || HAVE_64BIT_LONGS */
73 #ifdef HAVE_64BIT_LONGS
74 typedef unsigned long u_int64_t;
75 #else /* HAVE_64BIT_LONGS */
76 /* check for long long support. currently, i assume that if 64-bit
77 * ints exist that their made available via long long */
79 #include <endian.h> /* i think this is here for libc4 */
81 #if defined(HAVE_32BIT_LONGS) && !(defined(BSD4_4) || \
82 defined(NO_LARGE_VOL_SUPPORT))
83 typedef unsigned long long u_int64_t;
84 #endif /* HAVE_32BIT_LONGS || !BSD4_4 || NO_LARGE_VOL_SUPPORT */
86 #endif /* HAVE_64BIT_LONGS */
91 #define LITTLE_ENDIAN 1234
92 #define BIG_ENDIAN 4321
93 #define PDP_ENDIAN 3412
96 #if defined(WORDS_BIGENDIAN) || defined(_BIG_ENDIAN)
97 #define BYTE_ORDER BIG_ENDIAN
99 #define BYTE_ORDER LITTLE_ENDIAN
100 #endif /* WORDS_BIGENDIAN */
103 # if defined( sun ) || defined( ultrix ) || defined( _IBMR2 )
104 #if BYTE_ORDER == BIG_ENDIAN
110 #else /* BYTE_ORDER == BIG_ENDIAN */
111 #if defined( mips ) && defined( KERNEL )
112 #define ntohl(x) nuxi_l(x)
113 #define ntohs(x) nuxi_s(x)
114 #define htonl(x) nuxi_l(x)
115 #define htons(x) nuxi_s(x)
117 #else /* mips && KERNEL */
119 #if !( defined( sun ) && ( defined( i386 ) || defined(__x86_64) ) )
120 unsigned short ntohs(), htons();
121 unsigned int ntohl(), htonl();
122 #endif /* ! ( sun && i386 ) */
124 #endif /* mips && KERNEL */
125 #endif /* BYTE_ORDER == BIGENDIAN*/
126 # endif /* sun ultrix _IBMR2 */
128 #endif /* BYTE_ORDER */
130 #endif /* _ATALK_ENDIAN_H_ */