1 /* types.h - some common typedefs
2 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
23 #ifdef HAVE_INTTYPES_H
28 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
29 * we provide some fallback values here */
30 #if !SIZEOF_UNSIGNED_SHORT
31 #undef SIZEOF_UNSIGNED_SHORT
32 #define SIZEOF_UNSIGNED_SHORT 2
34 #if !SIZEOF_UNSIGNED_INT
35 #undef SIZEOF_UNSIGNED_INT
36 #define SIZEOF_UNSIGNED_INT 4
38 #if !SIZEOF_UNSIGNED_LONG
39 #undef SIZEOF_UNSIGNED_LONG
40 #define SIZEOF_UNSIGNED_LONG 4
44 #include <sys/types.h>
47 #ifndef HAVE_BYTE_TYPEDEF
48 #undef byte /* maybe there is a macro with this name */
50 typedef unsigned char byte
;
52 /* Norcroft treats char = unsigned char as legal assignment
53 but char* = unsigned char* as illegal assignment
54 and the same applies to the signed variants as well */
57 #define HAVE_BYTE_TYPEDEF
60 #ifndef HAVE_USHORT_TYPEDEF
61 #undef ushort /* maybe there is a macro with this name */
62 typedef unsigned short ushort
;
63 #define HAVE_USHORT_TYPEDEF
66 #ifndef HAVE_ULONG_TYPEDEF
67 #undef ulong /* maybe there is a macro with this name */
68 typedef unsigned long ulong
;
69 #define HAVE_ULONG_TYPEDEF
72 #ifndef HAVE_U16_TYPEDEF
73 #undef u16 /* maybe there is a macro with this name */
74 #if SIZEOF_UNSIGNED_INT == 2
75 typedef unsigned int u16
;
76 #elif SIZEOF_UNSIGNED_SHORT == 2
77 typedef unsigned short u16
;
79 #error no typedef for u16
81 #define HAVE_U16_TYPEDEF
84 #ifndef HAVE_U32_TYPEDEF
85 #undef u32 /* maybe there is a macro with this name */
86 #if SIZEOF_UNSIGNED_INT == 4
87 typedef unsigned int u32
;
88 #elif SIZEOF_UNSIGNED_LONG == 4
89 typedef unsigned long u32
;
91 #error no typedef for u32
93 #define HAVE_U32_TYPEDEF
97 * Warning: Some systems segfault when this u64 typedef and
98 * the dummy code in cipher/md.c is not available. Examples are
101 #ifndef HAVE_U64_TYPEDEF
102 #undef u64 /* maybe there is a macro with this name */
103 #if SIZEOF_UINT64_T == 8
104 typedef uint64_t u64
;
105 #define U64_C(c) (UINT64_C(c))
106 #define HAVE_U64_TYPEDEF
107 #elif SIZEOF_UNSIGNED_INT == 8
108 typedef unsigned int u64
;
109 #define U64_C(c) (c ## U)
110 #define HAVE_U64_TYPEDEF
111 #elif SIZEOF_UNSIGNED_LONG == 8
112 typedef unsigned long u64
;
113 #define U64_C(c) (c ## UL)
114 #define HAVE_U64_TYPEDEF
115 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
116 typedef unsigned long long u64
;
117 #define U64_C(c) (c ## ULL)
118 #define HAVE_U64_TYPEDEF
127 #ifdef HAVE_U64_TYPEDEF
132 } PROPERLY_ALIGNED_TYPE
;
134 #endif /*G10_TYPES_H*/