1 /*
2  * Copyright (C) 1999,2000,2001 Uwe Ohse <uwe@ohse.de>
3  *
4  * placed in the public domain.
5  *
6  *
7  * @(#) $Id: typesize.h 1.6 01/09/06 07:28:04+00:00 uwe@fjoras.ohse.de $
8  */
9 #ifndef TYPESIZE_H
10 #define TYPESIZE_H
11 
12 #ifndef HAVE_CONFIG_H
13 #include "auto-typesize.h"
14 #endif
15 
16 /* Note: i'm not very happy about this.
17  * But some compilers define a int16_t, others dont.
18  */
19 
20 #ifndef SIZEOF_SHORT
21 /* no #error, pre ansi compiler tend to warn .. */
22 error SIZEOF_SHORT not defined, did you include the macros in config.h and acconfig.h?
23 #endif
24 
25 /* int16 */
26 #if SIZEOF_SHORT >= 2
27 typedef short uo_int16_t;
28 #else
29 typedef int uo_int16_t;
30 #endif
31 
32 /* uo_int16 */
33 #if SIZEOF_UNSIGNED_SHORT >= 2
34 typedef unsigned short uo_uint16_t;
35 #else
36 typedef unsigned int uo_uint16_t;
37 #endif
38 
39 /* int32 */
40 #if SIZEOF_SHORT >= 4
41 typedef short uo_int32_t;
42 #else
43 # if SIZEOF_INT >= 4
44 typedef int uo_int32_t;
45 # else
46 #  if SIZEOF_LONG >= 4
47 typedef long uo_int32_t;
48 #  else
49 #   if SIZEOF_LONG_LONG >= 4
50 typedef long long uo_int32_t;
51 #   else
52 error no 32bit integer available
53 #   endif
54 #  endif
55 # endif
56 #endif
57 
58 /* uo_int32 */
59 #if SIZEOF_UNSIGNED_SHORT >= 4
60 typedef unsigned short uo_uint32_t;
61 #else
62 # if SIZEOF_UNSIGNED_INT >= 4
63 typedef unsigned int uo_uint32_t;
64 # else
65 #  if SIZEOF_UNSIGNED_LONG >= 4
66 typedef unsigned long uo_uint32_t;
67 #  else
68 #   if SIZEOF_UNSIGNED_LONG_LONG >= 4
69 typedef unsigned long long uo_uint32_t;
70 #   else
71 error no 32bit unsigned integer available
72 #   endif
73 #  endif
74 # endif
75 #endif
76 
77 #ifdef __GNUC__
78 #define TYPESIZE_QUIET __extension__
79 #else
80 #define TYPESIZE_QUIET
81 #endif
82 
83 /* int64 */
84 #define HAVE_INT64
85 #if SIZEOF_INT >= 8
86 typedef int uo_int64_t;
87 #else
88 # if SIZEOF_LONG >= 8
89 typedef long uo_int64_t;
90 # else
91 #  if SIZEOF_LONG_LONG >= 8
92 TYPESIZE_QUIET typedef long long uo_int64_t;
93 #  else
94 #   undef HAVE_INT64
95 #  endif
96 # endif
97 #endif
98 
99 
100 /* uo_uint64 */
101 #define HAVE_UINT64
102 #if SIZEOF_UNSIGNED_INT >= 8
103 typedef unsigned int uo_uint64_t;
104 #else
105 # if SIZEOF_UNSIGNED_LONG >= 8
106 typedef unsigned long uo_uint64_t;
107 # else
108 #  if SIZEOF_UNSIGNED_LONG_LONG >= 8
109 TYPESIZE_QUIET typedef unsigned long long uo_uint64_t;
110 #  else
111 #   undef HAVE_INT64
112 #  endif
113 # endif
114 #endif
115 
116 #endif
117