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 2 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #ifdef HAVE_INTTYPES_H
30 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
31 * we provide some fallback values here */
32 #if !SIZEOF_UNSIGNED_SHORT
33 #undef SIZEOF_UNSIGNED_SHORT
34 #define SIZEOF_UNSIGNED_SHORT 2
36 #if !SIZEOF_UNSIGNED_INT
37 #undef SIZEOF_UNSIGNED_INT
38 #define SIZEOF_UNSIGNED_INT 4
40 #if !SIZEOF_UNSIGNED_LONG
41 #undef SIZEOF_UNSIGNED_LONG
42 #define SIZEOF_UNSIGNED_LONG 4
46 #include <sys/types.h>
49 #ifndef HAVE_BYTE_TYPEDEF
50 #undef byte /* maybe there is a macro with this name */
52 typedef unsigned char byte
;
54 /* Norcroft treats char = unsigned char as legal assignment
55 but char* = unsigned char* as illegal assignment
56 and the same applies to the signed variants as well */
59 #define HAVE_BYTE_TYPEDEF
62 #ifndef HAVE_USHORT_TYPEDEF
63 #undef ushort /* maybe there is a macro with this name */
64 typedef unsigned short ushort
;
65 #define HAVE_USHORT_TYPEDEF
68 #ifndef HAVE_ULONG_TYPEDEF
69 #undef ulong /* maybe there is a macro with this name */
70 typedef unsigned long ulong
;
71 #define HAVE_ULONG_TYPEDEF
74 #ifndef HAVE_U16_TYPEDEF
75 #undef u16 /* maybe there is a macro with this name */
76 #if SIZEOF_UNSIGNED_INT == 2
77 typedef unsigned int u16
;
78 #elif SIZEOF_UNSIGNED_SHORT == 2
79 typedef unsigned short u16
;
81 #error no typedef for u16
83 #define HAVE_U16_TYPEDEF
86 #ifndef HAVE_U32_TYPEDEF
87 #undef u32 /* maybe there is a macro with this name */
88 #if SIZEOF_UNSIGNED_INT == 4
89 typedef unsigned int u32
;
90 #elif SIZEOF_UNSIGNED_LONG == 4
91 typedef unsigned long u32
;
93 #error no typedef for u32
95 #define HAVE_U32_TYPEDEF
99 * Warning: Some systems segfault when this u64 typedef and
100 * the dummy code in cipher/md.c is not available. Examples are
103 #ifndef HAVE_U64_TYPEDEF
104 #undef u64 /* maybe there is a macro with this name */
105 #if SIZEOF_UINT64_T == 8
106 typedef uint64_t u64
;
107 #define U64_C(c) (UINT64_C(c))
108 #define HAVE_U64_TYPEDEF
109 #elif SIZEOF_UNSIGNED_INT == 8
110 typedef unsigned int u64
;
111 #define U64_C(c) (c ## U)
112 #define HAVE_U64_TYPEDEF
113 #elif SIZEOF_UNSIGNED_LONG == 8
114 typedef unsigned long u64
;
115 #define U64_C(c) (c ## UL)
116 #define HAVE_U64_TYPEDEF
117 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
118 typedef unsigned long long u64
;
119 #define U64_C(c) (c ## ULL)
120 #define HAVE_U64_TYPEDEF
129 #ifdef HAVE_U64_TYPEDEF
134 } PROPERLY_ALIGNED_TYPE
;
136 #endif /*G10_TYPES_H*/