]>
Commit | Line | Data |
---|---|---|
69793602 CP |
1 | /* types.h - some common typedefs |
2 | * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
3 | * | |
4 | * This file is part of GNUPG. | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
19 | */ | |
20 | ||
21 | #ifndef G10_TYPES_H | |
22 | #define G10_TYPES_H | |
23 | ||
24 | #ifdef HAVE_INTTYPES_H | |
25 | /* For uint64_t */ | |
26 | #include <inttypes.h> | |
27 | #endif | |
28 | ||
29 | /* The AC_CHECK_SIZEOF() in configure fails for some machines. | |
30 | * we provide some fallback values here */ | |
31 | #if !SIZEOF_UNSIGNED_SHORT | |
32 | #undef SIZEOF_UNSIGNED_SHORT | |
33 | #define SIZEOF_UNSIGNED_SHORT 2 | |
34 | #endif | |
35 | #if !SIZEOF_UNSIGNED_INT | |
36 | #undef SIZEOF_UNSIGNED_INT | |
37 | #define SIZEOF_UNSIGNED_INT 4 | |
38 | #endif | |
39 | #if !SIZEOF_UNSIGNED_LONG | |
40 | #undef SIZEOF_UNSIGNED_LONG | |
41 | #define SIZEOF_UNSIGNED_LONG 4 | |
42 | #endif | |
43 | ||
44 | ||
45 | #include <sys/types.h> | |
46 | ||
47 | #ifndef HAVE_BYTE_TYPEDEF | |
48 | #undef byte /* maybe there is a macro with this name */ | |
49 | #ifndef __riscos__ | |
50 | typedef unsigned char byte; | |
51 | #else | |
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 */ | |
55 | typedef char byte; | |
56 | #endif | |
57 | #define HAVE_BYTE_TYPEDEF | |
58 | #endif | |
59 | ||
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 | |
64 | #endif | |
65 | ||
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 | |
70 | #endif | |
71 | ||
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; | |
78 | #else | |
79 | #error no typedef for u16 | |
80 | #endif | |
81 | #define HAVE_U16_TYPEDEF | |
82 | #endif | |
83 | ||
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; | |
90 | #else | |
91 | #error no typedef for u32 | |
92 | #endif | |
93 | #define HAVE_U32_TYPEDEF | |
94 | #endif | |
95 | ||
96 | /**************** | |
97 | * Warning: Some systems segfault when this u64 typedef and | |
98 | * the dummy code in cipher/md.c is not available. Examples are | |
99 | * Solaris and IRIX. | |
100 | */ | |
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 | |
119 | #endif | |
120 | #endif | |
121 | ||
122 | typedef union { | |
123 | int a; | |
124 | short b; | |
125 | char c[1]; | |
126 | long d; | |
127 | #ifdef HAVE_U64_TYPEDEF | |
128 | u64 e; | |
129 | #endif | |
130 | float f; | |
131 | double g; | |
132 | } PROPERLY_ALIGNED_TYPE; | |
133 | ||
134 | typedef struct string_list { | |
135 | struct string_list *next; | |
136 | unsigned int flags; | |
137 | char d[1]; | |
138 | } *STRLIST; | |
139 | ||
140 | #endif /*G10_TYPES_H*/ |