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>
15 #include <sys/machine.h>
20 typedef uint8_t u_int8_t;
21 typedef uint16_t u_int16_t;
22 typedef uint32_t u_int32_t;
23 typedef uint64_t u_int64_t;
26 /* handle sunos and solaris */
29 #include <sys/bitypes.h>
31 /* solaris and sunos don't consistently define u_int*_t. */
32 typedef unsigned char u_int8_t;
33 typedef unsigned short u_int16_t;
34 typedef unsigned int u_int32_t;
38 typedef unsigned long long u_int64_t;
47 /* luckily ultrix is dead. as a result, we know what the sizes of
48 * various types are forever. this makes some assumptions about integer
50 #if defined (ultrix) || defined(HAVE_32BIT_LONGS) || defined(HAVE_64BIT_LONGS)
51 typedef unsigned char u_int8_t;
52 typedef unsigned short u_int16_t;
53 typedef unsigned int u_int32_t;
61 #ifdef HAVE_64BIT_LONGS
62 typedef unsigned long u_int64_t;
64 /* check for long long support. currently, i assume that if 64-bit
65 * ints exist that their made available via long long */
67 #include <endian.h> /* i think this is here for libc4 */
69 #if defined(HAVE_32BIT_LONGS) && !(defined(BSD4_4) || \
70 defined(NO_LARGE_VOL_SUPPORT))
71 typedef unsigned long long u_int64_t;
74 #endif /* HAVE_64BIT_LONGS */
79 #define LITTLE_ENDIAN 1234
80 #define BIG_ENDIAN 4321
81 #define PDP_ENDIAN 3412
84 #if defined(i386) || defined(_LITTLE_ENDIAN)
85 #define BYTE_ORDER LITTLE_ENDIAN
87 #define BYTE_ORDER BIG_ENDIAN
91 #define BYTE_ORDER BIG_ENDIAN
94 #define BYTE_ORDER LITTLE_ENDIAN
96 #error Like, what is your byte order, man?
100 # endif /*BYTE_ORDER*/
103 # if defined( sun ) || defined( ultrix ) || defined( _IBMR2 )
104 #if 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 ))
120 unsigned short ntohs(), htons();
121 unsigned int ntohl(), htonl();
124 #endif /*mips KERNEL*/
125 #endif /*BYTE_ORDER*/
126 # endif /*sun ultrix _IBMR2*/
129 # endif /*_ATALK_ENDIAN_H_*/