1 /* types.h - define some extra types
2 * Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify it
7 * under the terms of either
9 * - the GNU Lesser General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at
11 * your option) any later version.
15 * - the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * or both in parallel, as here.
21 * GnuPG is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * General Public License for more details.
26 * You should have received a copies of the GNU General Public License
27 * and the GNU Lesser General Public License along with this program;
28 * if not, see <https://www.gnu.org/licenses/>.
31 #ifndef GNUPG_COMMON_TYPES_H
32 #define GNUPG_COMMON_TYPES_H
34 #ifdef HAVE_INTTYPES_H
35 # include <inttypes.h>
38 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
39 * we provide some fallback values here */
40 #if !SIZEOF_UNSIGNED_SHORT
41 # undef SIZEOF_UNSIGNED_SHORT
42 # define SIZEOF_UNSIGNED_SHORT 2
44 #if !SIZEOF_UNSIGNED_INT
45 # undef SIZEOF_UNSIGNED_INT
46 # define SIZEOF_UNSIGNED_INT 4
48 #if !SIZEOF_UNSIGNED_LONG
49 # undef SIZEOF_UNSIGNED_LONG
50 # define SIZEOF_UNSIGNED_LONG 4
54 #include <sys/types.h>
57 /* We use byte as an abbreviation for unsigned char. On some
58 platforms this needs special treatment:
61 Norcroft C treats char = unsigned char as legal assignment
62 but char* = unsigned char* as illegal assignment
63 and the same applies to the signed variants as well. Thus we use
64 char which is anyway unsigned.
67 Windows typedefs byte in the RPC headers but we need to avoid a
68 warning about a double definition.
70 #ifndef HAVE_BYTE_TYPEDEF
71 # undef byte /* There might be a macro with this name. */
74 # elif !(defined(_WIN32) && defined(cbNDRContext))
75 typedef unsigned char byte;
77 # define HAVE_BYTE_TYPEDEF
78 #endif /*!HAVE_BYTE_TYPEDEF*/
80 #ifndef HAVE_USHORT_TYPEDEF
81 # undef ushort /* There might be a macro with this name. */
82 typedef unsigned short ushort;
83 # define HAVE_USHORT_TYPEDEF
86 #ifndef HAVE_ULONG_TYPEDEF
87 # undef ulong /* There might be a macro with this name. */
88 typedef unsigned long ulong;
89 # define HAVE_ULONG_TYPEDEF
92 #ifndef HAVE_U16_TYPEDEF
93 # undef u16 /* There might be a macro with this name. */
94 # if SIZEOF_UNSIGNED_INT == 2
95 typedef unsigned int u16;
96 # elif SIZEOF_UNSIGNED_SHORT == 2
97 typedef unsigned short u16;
99 # error no typedef for u16
101 # define HAVE_U16_TYPEDEF
104 #ifndef HAVE_U32_TYPEDEF
105 # undef u32 /* There might be a macro with this name. */
106 # if SIZEOF_UNSIGNED_INT == 4
107 typedef unsigned int u32;
108 # elif SIZEOF_UNSIGNED_LONG == 4
109 typedef unsigned long u32;
111 # error no typedef for u32
113 # define HAVE_U32_TYPEDEF
116 #endif /*GNUPG_COMMON_TYPES_H*/