2 * $Id: endian.h,v 1.7 2001-12-15 12:13:10 srittau 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 typedef unsigned char u_int8_t;
61 typedef unsigned short u_int16_t;
62 typedef unsigned int u_int32_t;
64 #endif /* ultrix || HAVE_32BIT_LONGS || HAVE_64BIT_LONGS */
70 #ifdef HAVE_64BIT_LONGS
71 typedef unsigned long u_int64_t;
72 #else /* HAVE_64BIT_LONGS */
73 /* check for long long support. currently, i assume that if 64-bit
74 * ints exist that their made available via long long */
76 #include <endian.h> /* i think this is here for libc4 */
78 #if defined(HAVE_32BIT_LONGS) && !(defined(BSD4_4) || \
79 defined(NO_LARGE_VOL_SUPPORT))
80 typedef unsigned long long u_int64_t;
81 #endif /* HAVE_32BIT_LONGS || !BSD4_4 || NO_LARGE_VOL_SUPPORT */
83 #endif /* HAVE_64BIT_LONGS */
88 #define LITTLE_ENDIAN 1234
89 #define BIG_ENDIAN 4321
90 #define PDP_ENDIAN 3412
93 #if defined(WORDS_BIGENDIAN) || defined(_BIG_ENDIAN)
94 #define BYTE_ORDER BIG_ENDIAN
96 #define BYTE_ORDER LITTLE_ENDIAN
97 #endif /* WORDS_BIGENDIAN */
100 # if defined( sun ) || defined( ultrix ) || defined( _IBMR2 )
101 #if BYTE_ORDER == BIG_ENDIAN
107 #else /* BYTE_ORDER == BIG_ENDIAN */
108 #if defined( mips ) && defined( KERNEL )
109 #define ntohl(x) nuxi_l(x)
110 #define ntohs(x) nuxi_s(x)
111 #define htonl(x) nuxi_l(x)
112 #define htons(x) nuxi_s(x)
114 #else /* mips && KERNEL */
116 #if !( defined( sun ) && defined( i386 ))
117 unsigned short ntohs(), htons();
118 unsigned int ntohl(), htonl();
119 #endif /* ! ( sun && i386 ) */
121 #endif /* mips && KERNEL */
122 #endif /* BYTE_ORDER == BIGENDIAN*/
123 # endif /* sun ultrix _IBMR2 */
125 #endif /* BYTE_ORDER */
127 #endif /* _ATALK_ENDIAN_H_ */