xref: /netbsd-src/external/bsd/openldap/dist/include/ac/bytes.h (revision 466a16a118933bd295a8a104f095714fadf9cf68)
1 /* Generic bytes.h */
2 /* $OpenLDAP: pkg/ldap/include/ac/bytes.h,v 1.20.2.3 2008/02/11 23:26:40 kurt Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2008 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 
17 #ifndef _AC_BYTES_H
18 #define _AC_BYTES_H
19 
20 /* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */
21 
22 #if !defined( AC_INT4_TYPE )
23 	/* use autoconf defines to provide sized typedefs */
24 #	if SIZEOF_LONG == 4
25 #		define AC_INT4_TYPE long
26 #	elif SIZEOF_INT == 4
27 #		define AC_INT4_TYPE int
28 #	elif SIZEOF_SHORT == 4
29 #		define AC_INT4_TYPE short
30 #	else
31 #	error "AC_INT4_TYPE?"
32 #	endif
33 #endif
34 
35 typedef AC_INT4_TYPE ac_int4;
36 typedef signed AC_INT4_TYPE ac_sint4;
37 typedef unsigned AC_INT4_TYPE ac_uint4;
38 
39 #if !defined( AC_INT2_TYPE )
40 #	if SIZEOF_SHORT == 2
41 #		define AC_INT2_TYPE short
42 #	elif SIZEOF_INT == 2
43 #		define AC_INT2_TYPE int
44 #	elif SIZEOF_LONG == 2
45 #		define AC_INT2_TYPE long
46 #	else
47 #	error "AC_INT2_TYPE?"
48 #	endif
49 #endif
50 
51 #if defined( AC_INT2_TYPE )
52 typedef AC_INT2_TYPE ac_int2;
53 typedef signed AC_INT2_TYPE ac_sint2;
54 typedef unsigned AC_INT2_TYPE ac_uint2;
55 #endif
56 
57 #ifndef BYTE_ORDER
58 /* cross compilers should define BYTE_ORDER in CPPFLAGS */
59 
60 /*
61  * Definitions for byte order, according to byte significance from low
62  * address to high.
63  */
64 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
65 #define BIG_ENDIAN  4321        /* MSB first: 68000, ibm, net */
66 #define PDP_ENDIAN  3412        /* LSB first in word, MSW first in long */
67 
68 /* assume autoconf's AC_C_BIGENDIAN has been ran */
69 /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
70 #	ifdef WORDS_BIGENDIAN
71 #		define BYTE_ORDER  BIG_ENDIAN
72 #	else
73 #		define BYTE_ORDER  LITTLE_ENDIAN
74 #	endif
75 
76 #endif /* BYTE_ORDER */
77 
78 #endif /* _AC_BYTES_H */
79