]> git.sur5r.net Git - openldap/blob - include/ac/bytes.h
5d479442c5a64ae1f98cfd1a86d05adf3b854972
[openldap] / include / ac / bytes.h
1 /* Generic bytes.h */
2
3 #ifndef _AC_BYTES_H
4 #define _AC_BYTES_H
5
6 #if defined( LDAP_INT4_TYPE ) && defined( LDAP_INT2_TYPE )
7         /* cross compilers should define LDAP_INT{2,4}_TYPE in CPPFLAS */
8         typedef LDAP_INT4_TYPE LDAP_INT4;
9         typedef signed LDAP_INT4_TYPE LDAP_SINT4;
10         typedef unsigned LDAP_INT4_TYPE LDAP_UINT4;
11
12         typedef LDAP_INT2_TYPE LDAP_INT2;
13         typedef signed LDAP_INT2_TYPE LDAP_SINT2;
14         typedef unsigned LDAP_INT2_TYPE LDAP_UINT2;
15
16 #else
17         /* use autoconf defines to provide sized typedefs */
18 #       if SIZEOF_LONG == 4
19                 typedef long LDAP_INT4;
20                 typedef signed long LDAP_SINT4;
21                 typedef unsigned long LDAP_UINT4;
22 #       elif SIZEOF_INT == 4
23                 typedef int LDAP_INT4;
24                 typedef signed int LDAP_SINT4;
25                 typedef unsigned int LDAP_UINT4;
26
27 #       endif
28
29 #       if SIZEOF_SHORT == 2
30                 typedef short LDAP_INT2;
31                 typedef signed short LDAP_SINT2;
32                 typedef unsigned short LDAP_UINT2;
33 #       elif SIZEOF_INT == 2
34                 typedef int LDAP_INT2;
35                 typedef signed int LDAP_SINT2;
36                 typedef unsigned int LDAP_UINT2;
37 #       endif
38 #endif
39     
40 #ifndef BYTE_ORDER
41 /* cross compilers should define BYTE_ORDER in CPPFLAGS */
42
43 /*
44  * Definitions for byte order, according to byte significance from low
45  * address to high.
46  */
47 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
48 #define BIG_ENDIAN  4321        /* MSB first: 68000, ibm, net */
49 #define PDP_ENDIAN  3412        /* LSB first in word, MSW first in long */
50
51 /* assume autoconf's AC_C_BIGENDIAN has been ran */
52 /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
53 #       ifdef WORDS_BIGENDIAN
54 #               define BYTE_ORDER  BIG_ENDIAN
55 #       else
56 #               define BYTE_ORDER  LITTLE_ENDIAN
57 #       endif
58
59 #endif /* BYTE_ORDER */
60
61 #endif /* _AC_BYTES_H */