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