| 1 |
/*
|
| 2 |
* Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu)
|
| 3 |
*
|
| 4 |
* This program is free software; you can redistribute it and/or
|
| 5 |
* modify it under the terms of the GNU General Public License
|
| 6 |
* as published by the Free Software Foundation; either version 2
|
| 7 |
* of the License, or (at your option) any later version.
|
| 8 |
*
|
| 9 |
* This program is distributed in the hope that it will be useful,
|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
* GNU General Public License for more details.
|
| 13 |
*
|
| 14 |
* You should have received a copy of the GNU General Public License
|
| 15 |
* along with this program; if not, write to the Free Software
|
| 16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 17 |
*/
|
| 18 |
#ifndef INCLUDED_UINT_TYPES
|
| 19 |
#define INCLUDED_UINT_TYPES
|
| 20 |
|
| 21 |
#ifdef HAVE_STDINT_H
|
| 22 |
|
| 23 |
# include <stdint.h>
|
| 24 |
typedef uint8_t t_uint8;
|
| 25 |
typedef uint16_t t_uint16;
|
| 26 |
typedef uint32_t t_uint32;
|
| 27 |
typedef uint64_t t_uint64;
|
| 28 |
# define HAVE_UINT64_T
|
| 29 |
|
| 30 |
#else
|
| 31 |
#ifdef HAVE_MODE_ATTR
|
| 32 |
typedef unsigned int t_uint8 MODE_ATTR(__QI__);
|
| 33 |
typedef unsigned int t_uint16 MODE_ATTR(__HI__);
|
| 34 |
typedef unsigned int t_uint32 MODE_ATTR(__SI__);
|
| 35 |
typedef unsigned int t_uint64 MODE_ATTR(__DI__); /* FIXME: I guess DI is always available... Is there a way to check? */
|
| 36 |
# define HAVE_UINT64_T
|
| 37 |
|
| 38 |
# else
|
| 39 |
|
| 40 |
# ifdef HAVE_LIMITS_H
|
| 41 |
# include <limits.h>
|
| 42 |
# endif
|
| 43 |
# ifndef CHAR_BIT
|
| 44 |
# define MY_CHAR_BIT 8 /* well, this is usually true :) */
|
| 45 |
# else
|
| 46 |
# define MY_CHAR_BIT CHAR_BIT
|
| 47 |
# endif
|
| 48 |
|
| 49 |
# if SIZEOF_UNSIGNED_CHAR*MY_CHAR_BIT == 8
|
| 50 |
typedef unsigned char t_uint8;
|
| 51 |
# else
|
| 52 |
# error "Unable to find 8-bit integer type"
|
| 53 |
# endif
|
| 54 |
|
| 55 |
# if SIZEOF_UNSIGNED_SHORT*MY_CHAR_BIT == 16
|
| 56 |
typedef unsigned short t_uint16;
|
| 57 |
# else
|
| 58 |
# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 16
|
| 59 |
typedef unsigned int t_uint16;
|
| 60 |
# else
|
| 61 |
# error "Unable to find 16-bit integer type"
|
| 62 |
# endif
|
| 63 |
# endif
|
| 64 |
|
| 65 |
# if SIZEOF_UNSIGNED_SHORT*MY_CHAR_BIT == 32
|
| 66 |
typedef unsigned short t_uint32;
|
| 67 |
# else
|
| 68 |
# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 32
|
| 69 |
typedef unsigned int t_uint32;
|
| 70 |
# else
|
| 71 |
# if SIZEOF_UNSIGNED_LONG*MY_CHAR_BIT == 32
|
| 72 |
typedef unsigned long t_uint32;
|
| 73 |
# else
|
| 74 |
# error "Unable to find 32-bit integer type"
|
| 75 |
# endif
|
| 76 |
# endif
|
| 77 |
# endif
|
| 78 |
|
| 79 |
# if SIZEOF_UNSIGNED_INT*MY_CHAR_BIT == 64
|
| 80 |
typedef unsigned int t_uint64;
|
| 81 |
# define HAVE_UINT64_T
|
| 82 |
# else
|
| 83 |
# if SIZEOF_UNSIGNED_LONG*MY_CHAR_BIT == 64
|
| 84 |
typedef unsigned long t_uint64;
|
| 85 |
# define HAVE_UINT64_T
|
| 86 |
# else
|
| 87 |
# if SIZEOF_UNSIGNED_LONG_LONG*MY_CHAR_BIT == 64
|
| 88 |
typedef unsigned long long t_uint64;
|
| 89 |
# define HAVE_UINT64_T
|
| 90 |
# endif
|
| 91 |
# endif
|
| 92 |
# endif
|
| 93 |
|
| 94 |
# undef MY_CHAR_BIT
|
| 95 |
|
| 96 |
# endif
|
| 97 |
#endif
|
| 98 |
|
| 99 |
#endif
|