-
+ D355F8BB711647E95451CF2D53F8C496013D9C797ACC81560FAE155C5850823C880D647347426A4562DA568A6CDE708FDCCBD1E881568816156C0801C7E47FD7
mpi/include/types.h
(0 . 0)(1 . 142)
2192 /* types.h - some common typedefs
2193 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2194 *
2195 * This file is part of GNUPG.
2196 *
2197 * GNUPG is free software; you can redistribute it and/or modify
2198 * it under the terms of the GNU General Public License as published by
2199 * the Free Software Foundation; either version 3 of the License, or
2200 * (at your option) any later version.
2201 *
2202 * GNUPG is distributed in the hope that it will be useful,
2203 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2204 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2205 * GNU General Public License for more details.
2206 *
2207 * You should have received a copy of the GNU General Public License
2208 * along with this program; if not, see <http://www.gnu.org/licenses/>.
2209 */
2210
2211 #ifndef G10_TYPES_H
2212 #define G10_TYPES_H
2213
2214 #ifdef HAVE_INTTYPES_H
2215 /* For uint64_t */
2216 #include <inttypes.h>
2217 #endif
2218
2219 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
2220 * we provide some fallback values here */
2221 #if !SIZEOF_UNSIGNED_SHORT
2222 #undef SIZEOF_UNSIGNED_SHORT
2223 #define SIZEOF_UNSIGNED_SHORT 2
2224 #endif
2225 #if !SIZEOF_UNSIGNED_INT
2226 #undef SIZEOF_UNSIGNED_INT
2227 #define SIZEOF_UNSIGNED_INT 4
2228 #endif
2229 #if !SIZEOF_UNSIGNED_LONG
2230 #undef SIZEOF_UNSIGNED_LONG
2231 #define SIZEOF_UNSIGNED_LONG 4
2232 #endif
2233
2234
2235 #include <sys/types.h>
2236
2237
2238 #ifndef HAVE_BYTE_TYPEDEF
2239 #undef byte /* maybe there is a macro with this name */
2240 #ifndef __riscos__
2241 typedef unsigned char byte;
2242 #else
2243 /* Norcroft treats char = unsigned char as legal assignment
2244 but char* = unsigned char* as illegal assignment
2245 and the same applies to the signed variants as well */
2246 typedef char byte;
2247 #endif
2248 #define HAVE_BYTE_TYPEDEF
2249 #endif
2250
2251 #ifndef HAVE_USHORT_TYPEDEF
2252 #undef ushort /* maybe there is a macro with this name */
2253 typedef unsigned short ushort;
2254 #define HAVE_USHORT_TYPEDEF
2255 #endif
2256
2257 #ifndef HAVE_ULONG_TYPEDEF
2258 #undef ulong /* maybe there is a macro with this name */
2259 typedef unsigned long ulong;
2260 #define HAVE_ULONG_TYPEDEF
2261 #endif
2262
2263 #ifndef HAVE_U16_TYPEDEF
2264 #undef u16 /* maybe there is a macro with this name */
2265 #if SIZEOF_UNSIGNED_INT == 2
2266 typedef unsigned int u16;
2267 #elif SIZEOF_UNSIGNED_SHORT == 2
2268 typedef unsigned short u16;
2269 #else
2270 #error no typedef for u16
2271 #endif
2272 #define HAVE_U16_TYPEDEF
2273 #endif
2274
2275 #ifndef HAVE_U32_TYPEDEF
2276 #undef u32 /* maybe there is a macro with this name */
2277 #if SIZEOF_UNSIGNED_INT == 4
2278 typedef unsigned int u32;
2279 #elif SIZEOF_UNSIGNED_LONG == 4
2280 typedef unsigned long u32;
2281 #else
2282 #error no typedef for u32
2283 #endif
2284 #define HAVE_U32_TYPEDEF
2285 #endif
2286
2287 /****************
2288 * Warning: Some systems segfault when this u64 typedef and
2289 * the dummy code in cipher/md.c is not available. Examples are
2290 * Solaris and IRIX.
2291 */
2292 #ifndef HAVE_U64_TYPEDEF
2293 #undef u64 /* maybe there is a macro with this name */
2294 #if SIZEOF_UINT64_T == 8
2295 typedef uint64_t u64;
2296 #define U64_C(c) (UINT64_C(c))
2297 #define HAVE_U64_TYPEDEF
2298 #elif SIZEOF_UNSIGNED_INT == 8
2299 typedef unsigned int u64;
2300 #define U64_C(c) (c ## U)
2301 #define HAVE_U64_TYPEDEF
2302 #elif SIZEOF_UNSIGNED_LONG == 8
2303 typedef unsigned long u64;
2304 #define U64_C(c) (c ## UL)
2305 #define HAVE_U64_TYPEDEF
2306 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
2307 typedef unsigned long long u64;
2308 #define U64_C(c) (c ## ULL)
2309 #define HAVE_U64_TYPEDEF
2310 #endif
2311 #endif
2312
2313 typedef union {
2314 int a;
2315 short b;
2316 char c[1];
2317 long d;
2318 #ifdef HAVE_U64_TYPEDEF
2319 u64 e;
2320 #endif
2321 float f;
2322 double g;
2323 } PROPERLY_ALIGNED_TYPE;
2324
2325 struct string_list {
2326 struct string_list *next;
2327 unsigned int flags;
2328 char d[1];
2329 };
2330 typedef struct string_list *STRLIST;
2331 typedef struct string_list *strlist_t;
2332
2333 #endif /*G10_TYPES_H*/