Back to index

openldap  2.4.31
bytes.h
Go to the documentation of this file.
00001 /* Generic bytes.h */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifndef _AC_BYTES_H
00018 #define _AC_BYTES_H
00019 
00020 /* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */
00021 
00022 #if !defined( AC_INT4_TYPE )
00023        /* use autoconf defines to provide sized typedefs */
00024 #      if SIZEOF_LONG == 4
00025 #             define AC_INT4_TYPE long
00026 #      elif SIZEOF_INT == 4
00027 #             define AC_INT4_TYPE int
00028 #      elif SIZEOF_SHORT == 4
00029 #             define AC_INT4_TYPE short
00030 #      else
00031 #      error "AC_INT4_TYPE?"
00032 #      endif
00033 #endif
00034 
00035 typedef AC_INT4_TYPE ac_int4;
00036 typedef signed AC_INT4_TYPE ac_sint4;
00037 typedef unsigned AC_INT4_TYPE ac_uint4;
00038 
00039 #if !defined( AC_INT2_TYPE )
00040 #      if SIZEOF_SHORT == 2
00041 #             define AC_INT2_TYPE short
00042 #      elif SIZEOF_INT == 2
00043 #             define AC_INT2_TYPE int
00044 #      elif SIZEOF_LONG == 2
00045 #             define AC_INT2_TYPE long
00046 #      else
00047 #      error "AC_INT2_TYPE?"
00048 #      endif
00049 #endif
00050  
00051 #if defined( AC_INT2_TYPE )
00052 typedef AC_INT2_TYPE ac_int2;
00053 typedef signed AC_INT2_TYPE ac_sint2;
00054 typedef unsigned AC_INT2_TYPE ac_uint2;
00055 #endif
00056 
00057 #ifndef BYTE_ORDER
00058 /* cross compilers should define BYTE_ORDER in CPPFLAGS */
00059 
00060 /*
00061  * Definitions for byte order, according to byte significance from low
00062  * address to high.
00063  */
00064 #define LITTLE_ENDIAN   1234    /* LSB first: i386, vax */
00065 #define BIG_ENDIAN  4321        /* MSB first: 68000, ibm, net */
00066 #define PDP_ENDIAN  3412        /* LSB first in word, MSW first in long */
00067 
00068 /* assume autoconf's AC_C_BIGENDIAN has been ran */
00069 /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
00070 #      ifdef WORDS_BIGENDIAN
00071 #             define BYTE_ORDER  BIG_ENDIAN
00072 #      else
00073 #             define BYTE_ORDER  LITTLE_ENDIAN
00074 #      endif
00075 
00076 #endif /* BYTE_ORDER */
00077 
00078 #endif /* _AC_BYTES_H */