]> git.proxmox.com Git - grub2.git/blob - grub-core/lib/libgcrypt-grub/src/types.h
Import grub2_2.02+dfsg1.orig.tar.xz
[grub2.git] / grub-core / lib / libgcrypt-grub / src / types.h
1 /* types.h - some common typedefs
2 * Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
3 *
4 * This file is part of Libgcrypt.
5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser general Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * Libgcrypt 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 Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License 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 GCRYPT_TYPES_H
22 #define GCRYPT_TYPES_H
23
24
25 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
26 * we provide some fallback values here */
27 #if !SIZEOF_UNSIGNED_SHORT
28 #undef SIZEOF_UNSIGNED_SHORT
29 #define SIZEOF_UNSIGNED_SHORT 2
30 #endif
31 #if !SIZEOF_UNSIGNED_INT
32 #undef SIZEOF_UNSIGNED_INT
33 #define SIZEOF_UNSIGNED_INT 4
34 #endif
35 #if !SIZEOF_UNSIGNED_LONG
36 #undef SIZEOF_UNSIGNED_LONG
37 #define SIZEOF_UNSIGNED_LONG 4
38 #endif
39
40
41 #include <sys/types.h>
42
43
44 #ifndef HAVE_BYTE_TYPEDEF
45 #undef byte /* maybe there is a macro with this name */
46 /* Windows typedefs byte in the rpc headers. Avoid warning about
47 double definition. */
48 #if !(defined(_WIN32) && defined(cbNDRContext))
49 typedef unsigned char byte;
50 #endif
51 #define HAVE_BYTE_TYPEDEF
52 #endif
53
54 #ifndef HAVE_USHORT_TYPEDEF
55 #undef ushort /* maybe there is a macro with this name */
56 typedef unsigned short ushort;
57 #define HAVE_USHORT_TYPEDEF
58 #endif
59
60 #ifndef HAVE_ULONG_TYPEDEF
61 #undef ulong /* maybe there is a macro with this name */
62 typedef unsigned long ulong;
63 #define HAVE_ULONG_TYPEDEF
64 #endif
65
66 #ifndef HAVE_U16_TYPEDEF
67 #undef u16 /* maybe there is a macro with this name */
68 #if SIZEOF_UNSIGNED_INT == 2
69 typedef unsigned int u16;
70 #elif SIZEOF_UNSIGNED_SHORT == 2
71 typedef unsigned short u16;
72 #else
73 #error no typedef for u16
74 #endif
75 #define HAVE_U16_TYPEDEF
76 #endif
77
78 #ifndef HAVE_U32_TYPEDEF
79 #undef u32 /* maybe there is a macro with this name */
80 #if SIZEOF_UNSIGNED_INT == 4
81 typedef unsigned int u32;
82 #elif SIZEOF_UNSIGNED_LONG == 4
83 typedef unsigned long u32;
84 #else
85 #error no typedef for u32
86 #endif
87 #define HAVE_U32_TYPEDEF
88 #endif
89
90 /****************
91 * Warning: Some systems segfault when this u64 typedef and
92 * the dummy code in cipher/md.c is not available. Examples are
93 * Solaris and IRIX.
94 */
95 #ifndef HAVE_U64_TYPEDEF
96 #undef u64 /* maybe there is a macro with this name */
97 #if SIZEOF_UNSIGNED_INT == 8
98 typedef unsigned int u64;
99 #define U64_C(c) (c ## U)
100 #define HAVE_U64_TYPEDEF
101 #elif SIZEOF_UNSIGNED_LONG == 8
102 typedef unsigned long u64;
103 #define U64_C(c) (c ## UL)
104 #define HAVE_U64_TYPEDEF
105 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
106 typedef unsigned long long u64;
107 #define U64_C(c) (c ## ULL)
108 #define HAVE_U64_TYPEDEF
109 #elif SIZEOF_UINT64_T == 8
110 typedef uint64_t u64;
111 #define U64_C(c) (UINT64_C(c))
112 #define HAVE_U64_TYPEDEF
113 #endif
114 #endif
115
116 typedef union {
117 int a;
118 short b;
119 char c[1];
120 long d;
121 #ifdef HAVE_U64_TYPEDEF
122 u64 e;
123 #endif
124
125
126 } PROPERLY_ALIGNED_TYPE;
127
128 #endif /*GCRYPT_TYPES_H*/