bytes.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Generic bytes.h */
  2. /* $OpenLDAP$ */
  3. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  4. *
  5. * Copyright 1998-2022 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. #ifndef _AC_BYTES_H
  17. #define _AC_BYTES_H
  18. /* cross compilers should define both AC_INT{2,4}_TYPE in CPPFLAGS */
  19. #if !defined( AC_INT4_TYPE )
  20. /* use autoconf defines to provide sized typedefs */
  21. # if SIZEOF_LONG == 4
  22. # define AC_INT4_TYPE long
  23. # elif SIZEOF_INT == 4
  24. # define AC_INT4_TYPE int
  25. # elif SIZEOF_SHORT == 4
  26. # define AC_INT4_TYPE short
  27. # else
  28. # error "AC_INT4_TYPE?"
  29. # endif
  30. #endif
  31. typedef AC_INT4_TYPE ac_int4;
  32. typedef signed AC_INT4_TYPE ac_sint4;
  33. typedef unsigned AC_INT4_TYPE ac_uint4;
  34. #if !defined( AC_INT2_TYPE )
  35. # if SIZEOF_SHORT == 2
  36. # define AC_INT2_TYPE short
  37. # elif SIZEOF_INT == 2
  38. # define AC_INT2_TYPE int
  39. # elif SIZEOF_LONG == 2
  40. # define AC_INT2_TYPE long
  41. # else
  42. # error "AC_INT2_TYPE?"
  43. # endif
  44. #endif
  45. #if defined( AC_INT2_TYPE )
  46. typedef AC_INT2_TYPE ac_int2;
  47. typedef signed AC_INT2_TYPE ac_sint2;
  48. typedef unsigned AC_INT2_TYPE ac_uint2;
  49. #endif
  50. #ifndef BYTE_ORDER
  51. /* cross compilers should define BYTE_ORDER in CPPFLAGS */
  52. /*
  53. * Definitions for byte order, according to byte significance from low
  54. * address to high.
  55. */
  56. #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
  57. #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
  58. #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */
  59. /* assume autoconf's AC_C_BIGENDIAN has been ran */
  60. /* if it hasn't, we assume (maybe falsely) the order is LITTLE ENDIAN */
  61. # ifdef WORDS_BIGENDIAN
  62. # define BYTE_ORDER BIG_ENDIAN
  63. # else
  64. # define BYTE_ORDER LITTLE_ENDIAN
  65. # endif
  66. #endif /* BYTE_ORDER */
  67. #endif /* _AC_BYTES_H */