Fix debian bug#543530
[gnupg.git] / jnlib / types.h
blob62fa0470d8e8b04aed18b70aebde036579a60014
1 /* types.h - define some extra types
2 * Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
4 * This file is part of JNLIB.
6 * JNLIB is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * JNLIB is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBJNLIB_TYPES_H
21 #define LIBJNLIB_TYPES_H
23 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
24 * we provide some fallback values here */
25 #if !SIZEOF_UNSIGNED_SHORT
26 # undef SIZEOF_UNSIGNED_SHORT
27 # define SIZEOF_UNSIGNED_SHORT 2
28 #endif
29 #if !SIZEOF_UNSIGNED_INT
30 # undef SIZEOF_UNSIGNED_INT
31 # define SIZEOF_UNSIGNED_INT 4
32 #endif
33 #if !SIZEOF_UNSIGNED_LONG
34 # undef SIZEOF_UNSIGNED_LONG
35 # define SIZEOF_UNSIGNED_LONG 4
36 #endif
39 #include <sys/types.h>
42 #ifndef HAVE_BYTE_TYPEDEF
43 # undef byte /* There might be a macro with this name. */
44 /* Windows typedefs byte in the rpc headers. Avoid warning about
45 double definition. */
46 #if !(defined(_WIN32) && defined(cbNDRContext))
47 typedef unsigned char byte;
48 #endif
49 # define HAVE_BYTE_TYPEDEF
50 #endif
52 #ifndef HAVE_USHORT_TYPEDEF
53 # undef ushort /* There might be a macro with this name. */
54 typedef unsigned short ushort;
55 # define HAVE_USHORT_TYPEDEF
56 #endif
58 #ifndef HAVE_ULONG_TYPEDEF
59 # undef ulong /* There might be a macro with this name. */
60 typedef unsigned long ulong;
61 # define HAVE_ULONG_TYPEDEF
62 #endif
64 #ifndef HAVE_U16_TYPEDEF
65 # undef u16 /* There might be a macro with this name. */
66 # if SIZEOF_UNSIGNED_INT == 2
67 typedef unsigned int u16;
68 # elif SIZEOF_UNSIGNED_SHORT == 2
69 typedef unsigned short u16;
70 # else
71 # error no typedef for u16
72 # endif
73 # define HAVE_U16_TYPEDEF
74 #endif
76 #ifndef HAVE_U32_TYPEDEF
77 # undef u32 /* There might be a macro with this name. */
78 # if SIZEOF_UNSIGNED_INT == 4
79 typedef unsigned int u32;
80 # elif SIZEOF_UNSIGNED_LONG == 4
81 typedef unsigned long u32;
82 # else
83 # error no typedef for u32
84 # endif
85 # define HAVE_U32_TYPEDEF
86 #endif
88 #ifndef HAVE_U64_TYPEDEF
89 # undef u64 /* There might be a macro with this name. */
90 # if SIZEOF_UNSIGNED_INT == 8
91 typedef unsigned int u64;
92 # define HAVE_U64_TYPEDEF
93 # elif SIZEOF_UNSIGNED_LONG == 8
94 typedef unsigned long u64;
95 # define HAVE_U64_TYPEDEF
96 # elif __GNUC__ >= 2 || defined(__SUNPRO_C)
97 typedef unsigned long long u64;
98 # define HAVE_U64_TYPEDEF
99 # endif
100 #endif
103 /* Some GCC attributes. Note that we use also define some in
104 mischelp.h, but this header and types.h are not always included.
105 Should eventually be put into one file (e.g. nlib-common.h). */
106 #if __GNUC__ >= 4
107 # define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a)))
108 #else
109 # define GNUPG_GCC_A_SENTINEL(a)
110 #endif
114 #endif /*LIBJNLIB_TYPES_H*/