]> git.sur5r.net Git - openldap/blob - include/ac/bytes.h
b4b674a04dde5de0c8ccc73fb3acd29ee7b06b95
[openldap] / include / ac / bytes.h
1 /* Generic bytes.h */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11
12 #ifndef _AC_BYTES_H
13 #define _AC_BYTES_H
14
15 #if defined( LDAP_INT4_TYPE ) && defined( LDAP_INT2_TYPE )
16         /* cross compilers should define LDAP_INT{2,4}_TYPE in CPPFLAS */
17         typedef LDAP_INT4_TYPE LDAP_INT4;
18         typedef signed LDAP_INT4_TYPE LDAP_SINT4;
19         typedef unsigned LDAP_INT4_TYPE LDAP_UINT4;
20
21         typedef LDAP_INT2_TYPE LDAP_INT2;
22         typedef signed LDAP_INT2_TYPE LDAP_SINT2;
23         typedef unsigned LDAP_INT2_TYPE LDAP_UINT2;
24
25 #else
26         /* use autoconf defines to provide sized typedefs */
27 #       if SIZEOF_LONG == 4
28                 typedef long LDAP_INT4;
29                 typedef signed long LDAP_SINT4;
30                 typedef unsigned long LDAP_UINT4;
31 #       elif SIZEOF_INT == 4
32                 typedef int LDAP_INT4;
33                 typedef signed int LDAP_SINT4;
34                 typedef unsigned int LDAP_UINT4;
35
36 #       elif SIZEOF_SHORT == 4
37                 typedef short LDAP_INT4;
38                 typedef signed short LDAP_SINT4;
39                 typedef unsigned short LDAP_UINT4;
40
41 #       else
42 #               error "No 4 byte integer type!"
43 #       endif
44
45 #       if SIZEOF_SHORT == 2
46                 typedef short LDAP_INT2;
47                 typedef signed short LDAP_SINT2;
48                 typedef unsigned short LDAP_UINT2;
49
50 #       elif SIZEOF_INT == 2
51                 typedef int LDAP_INT2;
52                 typedef signed int LDAP_SINT2;
53                 typedef unsigned int LDAP_UINT2;
54
55 #       elif SIZEOF_LONG == 2
56                 typedef long LDAP_INT2;
57                 typedef signed long LDAP_SINT2;
58                 typedef unsigned long LDAP_UINT2;
59
60 #       else
61 /* not in use, no error */
62 /* #            error "No 2 byte integer type!" */
63 #       endif
64 #endif
65     
66 #ifndef BYTE_ORDER
67 /* cross compilers should define BYTE_ORDER in CPPFLAGS */
68
69 /*
70  * Definitions for byte order, according to byte significance from low
71  * address to high.
72  */
73 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
74 #define BIG_ENDIAN  4321        /* MSB first: 68000, ibm, net */
75 #define PDP_ENDIAN  3412        /* LSB first in word, MSW first in long */
76
77 /* assume autoconf's AC_C_BIGENDIAN has been ran */
78 /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
79 #       ifdef WORDS_BIGENDIAN
80 #               define BYTE_ORDER  BIG_ENDIAN
81 #       else
82 #               define BYTE_ORDER  LITTLE_ENDIAN
83 #       endif
84
85 #endif /* BYTE_ORDER */
86
87 #endif /* _AC_BYTES_H */