2 * Copyright (c) 1990,1991 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
5 * This file handles both byte ordering and integer sizes.
8 # ifndef _ATALK_ENDIAN_H_
9 #define _ATALK_ENDIAN_H_
11 #include <sys/types.h>
12 #include <netinet/in.h>
19 #include <sys/machine.h>
24 typedef uint8_t u_int8_t;
25 typedef uint16_t u_int16_t;
26 typedef uint32_t u_int32_t;
27 typedef uint64_t u_int64_t;
30 /* handle sunos and solaris */
33 #include <sys/bitypes.h>
35 /* solaris and sunos don't consistently define u_int*_t. */
36 typedef unsigned char u_int8_t;
37 typedef unsigned short u_int16_t;
38 typedef unsigned int u_int32_t;
42 typedef unsigned long long u_int64_t;
51 /* luckily ultrix is dead. as a result, we know what the sizes of
52 * various types are forever. this makes some assumptions about integer
54 #if defined (ultrix) || defined(HAVE_32BIT_LONGS) || defined(HAVE_64BIT_LONGS)
55 typedef unsigned char u_int8_t;
56 typedef unsigned short u_int16_t;
57 typedef unsigned int u_int32_t;
65 #ifdef HAVE_64BIT_LONGS
66 typedef unsigned long u_int64_t;
68 /* check for long long support. currently, i assume that if 64-bit
69 * ints exist that their made available via long long */
71 #include <endian.h> /* i think this is here for libc4 */
73 #if defined(HAVE_32BIT_LONGS) && !(defined(BSD4_4) || \
74 defined(NO_LARGE_VOL_SUPPORT))
75 typedef unsigned long long u_int64_t;
78 #endif /* HAVE_64BIT_LONGS */
83 #define LITTLE_ENDIAN 1234
84 #define BIG_ENDIAN 4321
85 #define PDP_ENDIAN 3412
88 #if defined(i386) || defined(_LITTLE_ENDIAN)
89 #define BYTE_ORDER LITTLE_ENDIAN
91 #define BYTE_ORDER BIG_ENDIAN
94 #if defined(MIPSEB) || defined(__hppa)
95 #define BYTE_ORDER BIG_ENDIAN
98 #define BYTE_ORDER LITTLE_ENDIAN
100 #error Like, what is your byte order, man?
104 # endif /*BYTE_ORDER*/
107 # if defined( sun ) || defined( ultrix ) || defined( _IBMR2 )
108 #if BYTE_ORDER == BIG_ENDIAN
115 #if defined( mips ) && defined( KERNEL )
116 #define ntohl(x) nuxi_l(x)
117 #define ntohs(x) nuxi_s(x)
118 #define htonl(x) nuxi_l(x)
119 #define htons(x) nuxi_s(x)
121 #else /*mips KERNEL*/
123 #if !( defined( sun ) && defined( i386 ))
124 unsigned short ntohs(), htons();
125 unsigned int ntohl(), htonl();
128 #endif /*mips KERNEL*/
129 #endif /*BYTE_ORDER*/
130 # endif /*sun ultrix _IBMR2*/
133 # endif /*_ATALK_ENDIAN_H_*/