1/*- 2 * Copyright (c) 2010 by Peter Jeremy <peterjeremy@acm.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 23 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * $FreeBSD$ 26 */ 27 28/*---------------------------------------------------------------------------- 29| One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. 30*----------------------------------------------------------------------------*/ 31#define BIGENDIAN 32 33/*---------------------------------------------------------------------------- 34| The macro `BITS64' can be defined to indicate that 64-bit integer types are 35| supported by the compiler. 36*----------------------------------------------------------------------------*/ 37#define BITS64 38 39/*---------------------------------------------------------------------------- 40| Each of the following `typedef's defines the most convenient type that holds 41| integers of at least as many bits as specified. For example, `uint8' should 42| be the most convenient type that can hold unsigned integers of as many as 43| 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 44| implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 45| to the same as `int'. 46*----------------------------------------------------------------------------*/ 47typedef int flag; 48typedef int uint8; 49typedef int int8; 50typedef int uint16; 51typedef int int16; 52typedef unsigned int uint32; 53typedef signed int int32; 54#ifdef BITS64 55typedef unsigned long int uint64; 56typedef signed long int int64; 57#endif 58 59/*---------------------------------------------------------------------------- 60| Each of the following `typedef's defines a type that holds integers 61| of _exactly_ the number of bits specified. For instance, for most 62| implementation of C, `bits16' and `sbits16' should be `typedef'ed to 63| `unsigned short int' and `signed short int' (or `short int'), respectively. 64*----------------------------------------------------------------------------*/ 65typedef unsigned char bits8; 66typedef signed char sbits8; 67typedef unsigned short int bits16; 68typedef signed short int sbits16; 69typedef unsigned int bits32; 70typedef signed int sbits32; 71#ifdef BITS64 72typedef unsigned long int bits64; 73typedef signed long int sbits64; 74#endif 75 76#ifdef BITS64 77/*---------------------------------------------------------------------------- 78| The `LIT64' macro takes as its argument a textual integer literal and 79| if necessary ``marks'' the literal as having a 64-bit integer type. 80| For example, the GNU C Compiler (`gcc') requires that 64-bit literals be 81| appended with the letters `LL' standing for `long long', which is `gcc's 82| name for the 64-bit integer type. Some compilers may allow `LIT64' to be 83| defined as the identity macro: `#define LIT64( a ) a'. 84*----------------------------------------------------------------------------*/ 85#define LIT64( a ) a##L 86#endif 87 88/*---------------------------------------------------------------------------- 89| The macro `INLINE' can be used before functions that should be inlined. If 90| a compiler does not support explicit inlining, this macro should be defined 91| to be `static'. 92*----------------------------------------------------------------------------*/ 93#define INLINE extern inline 94