raw
ch1_mpi                 1 /* types.h - some common typedefs
ch1_mpi 2 * Modified by No Such Labs. (C) 2015. See README.
ch1_mpi 3 *
ch1_mpi 4 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
ch1_mpi 5 * SHA256(gnupg-1.4.10.tar.gz):
ch1_mpi 6 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
ch1_mpi 7 * (C) 1994-2005 Free Software Foundation, Inc.
ch1_mpi 8 *
ch1_mpi 9 * This program is free software: you can redistribute it and/or modify
ch1_mpi 10 * it under the terms of the GNU General Public License as published by
ch1_mpi 11 * the Free Software Foundation, either version 3 of the License, or
ch1_mpi 12 * (at your option) any later version.
ch1_mpi 13 *
ch1_mpi 14 * This program is distributed in the hope that it will be useful,
ch1_mpi 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ch1_mpi 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ch1_mpi 17 * GNU General Public License for more details.
ch1_mpi 18 *
ch1_mpi 19 * You should have received a copy of the GNU General Public License
ch1_mpi 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ch1_mpi 21 */
ch1_mpi 22
ch1_mpi 23 #ifndef G10_TYPES_H
ch1_mpi 24 #define G10_TYPES_H
ch1_mpi 25
ch1_mpi 26 #ifdef HAVE_INTTYPES_H
ch1_mpi 27 /* For uint64_t */
ch1_mpi 28 #include <inttypes.h>
ch1_mpi 29 #endif
ch1_mpi 30
ch1_mpi 31 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
ch1_mpi 32 * we provide some fallback values here */
ch1_mpi 33 #if !SIZEOF_UNSIGNED_SHORT
ch1_mpi 34 #undef SIZEOF_UNSIGNED_SHORT
ch1_mpi 35 #define SIZEOF_UNSIGNED_SHORT 2
ch1_mpi 36 #endif
ch1_mpi 37 #if !SIZEOF_UNSIGNED_INT
ch1_mpi 38 #undef SIZEOF_UNSIGNED_INT
ch1_mpi 39 #define SIZEOF_UNSIGNED_INT 4
ch1_mpi 40 #endif
ch1_mpi 41 #if !SIZEOF_UNSIGNED_LONG
ch1_mpi 42 #undef SIZEOF_UNSIGNED_LONG
ch1_mpi 43 #define SIZEOF_UNSIGNED_LONG 4
ch1_mpi 44 #endif
ch1_mpi 45
ch1_mpi 46
ch1_mpi 47 #include <sys/types.h>
ch1_mpi 48
ch1_mpi 49
ch1_mpi 50 #ifndef HAVE_BYTE_TYPEDEF
ch1_mpi 51 #undef byte /* maybe there is a macro with this name */
ch1_mpi 52 typedef unsigned char byte;
ch1_mpi 53 #define HAVE_BYTE_TYPEDEF
ch1_mpi 54 #endif
ch1_mpi 55
ch1_mpi 56 #ifndef HAVE_USHORT_TYPEDEF
ch1_mpi 57 #undef ushort /* maybe there is a macro with this name */
ch1_mpi 58 typedef unsigned short ushort;
ch1_mpi 59 #define HAVE_USHORT_TYPEDEF
ch1_mpi 60 #endif
ch1_mpi 61
ch1_mpi 62 #ifndef HAVE_ULONG_TYPEDEF
ch1_mpi 63 #undef ulong /* maybe there is a macro with this name */
ch1_mpi 64 typedef unsigned long ulong;
ch1_mpi 65 #define HAVE_ULONG_TYPEDEF
ch1_mpi 66 #endif
ch1_mpi 67
ch1_mpi 68 #ifndef HAVE_U16_TYPEDEF
ch1_mpi 69 #undef u16 /* maybe there is a macro with this name */
ch1_mpi 70 #if SIZEOF_UNSIGNED_INT == 2
ch1_mpi 71 typedef unsigned int u16;
ch1_mpi 72 #elif SIZEOF_UNSIGNED_SHORT == 2
ch1_mpi 73 typedef unsigned short u16;
ch1_mpi 74 #else
ch1_mpi 75 #error no typedef for u16
ch1_mpi 76 #endif
ch1_mpi 77 #define HAVE_U16_TYPEDEF
ch1_mpi 78 #endif
ch1_mpi 79
ch1_mpi 80 #ifndef HAVE_U32_TYPEDEF
ch1_mpi 81 #undef u32 /* maybe there is a macro with this name */
ch1_mpi 82 #if SIZEOF_UNSIGNED_INT == 4
ch1_mpi 83 typedef unsigned int u32;
ch1_mpi 84 #elif SIZEOF_UNSIGNED_LONG == 4
ch1_mpi 85 typedef unsigned long u32;
ch1_mpi 86 #else
ch1_mpi 87 #error no typedef for u32
ch1_mpi 88 #endif
ch1_mpi 89 #define HAVE_U32_TYPEDEF
ch1_mpi 90 #endif
ch1_mpi 91
ch1_mpi 92 /****************
ch1_mpi 93 * Warning: Some systems segfault when this u64 typedef and
ch1_mpi 94 * the dummy code in cipher/md.c is not available. Examples are
ch1_mpi 95 * Solaris and IRIX.
ch1_mpi 96 */
ch1_mpi 97 #ifndef HAVE_U64_TYPEDEF
ch1_mpi 98 #undef u64 /* maybe there is a macro with this name */
ch1_mpi 99 #if SIZEOF_UINT64_T == 8
ch1_mpi 100 typedef uint64_t u64;
ch1_mpi 101 #define U64_C(c) (UINT64_C(c))
ch1_mpi 102 #define HAVE_U64_TYPEDEF
ch1_mpi 103 #elif SIZEOF_UNSIGNED_INT == 8
ch1_mpi 104 typedef unsigned int u64;
ch1_mpi 105 #define U64_C(c) (c ## U)
ch1_mpi 106 #define HAVE_U64_TYPEDEF
ch1_mpi 107 #elif SIZEOF_UNSIGNED_LONG == 8
ch1_mpi 108 typedef unsigned long u64;
ch1_mpi 109 #define U64_C(c) (c ## UL)
ch1_mpi 110 #define HAVE_U64_TYPEDEF
ch1_mpi 111 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
ch1_mpi 112 typedef unsigned long long u64;
ch1_mpi 113 #define U64_C(c) (c ## ULL)
ch1_mpi 114 #define HAVE_U64_TYPEDEF
ch1_mpi 115 #endif
ch1_mpi 116 #endif
ch1_mpi 117
ch1_mpi 118 typedef union {
ch1_mpi 119 int a;
ch1_mpi 120 short b;
ch1_mpi 121 char c[1];
ch1_mpi 122 long d;
ch1_mpi 123 #ifdef HAVE_U64_TYPEDEF
ch1_mpi 124 u64 e;
ch1_mpi 125 #endif
ch1_mpi 126 float f;
ch1_mpi 127 double g;
ch1_mpi 128 } PROPERLY_ALIGNED_TYPE;
ch1_mpi 129
ch1_mpi 130 struct string_list {
ch1_mpi 131 struct string_list *next;
ch1_mpi 132 unsigned int flags;
ch1_mpi 133 char d[1];
ch1_mpi 134 };
ch1_mpi 135 typedef struct string_list *STRLIST;
ch1_mpi 136 typedef struct string_list *strlist_t;
ch1_mpi 137
ch1_mpi 138 #endif /*G10_TYPES_H*/