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