-
+ D355F8BB711647E95451CF2D53F8C496013D9C797ACC81560FAE155C5850823C880D647347426A4562DA568A6CDE708FDCCBD1E881568816156C0801C7E47FD7
mpi/include/types.h
(0 . 0)(1 . 142)
2296 /* types.h - some common typedefs
2297 * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
2298 *
2299 * This file is part of GNUPG.
2300 *
2301 * GNUPG is free software; you can redistribute it and/or modify
2302 * it under the terms of the GNU General Public License as published by
2303 * the Free Software Foundation; either version 3 of the License, or
2304 * (at your option) any later version.
2305 *
2306 * GNUPG is distributed in the hope that it will be useful,
2307 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2308 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2309 * GNU General Public License for more details.
2310 *
2311 * You should have received a copy of the GNU General Public License
2312 * along with this program; if not, see <http://www.gnu.org/licenses/>.
2313 */
2314
2315 #ifndef G10_TYPES_H
2316 #define G10_TYPES_H
2317
2318 #ifdef HAVE_INTTYPES_H
2319 /* For uint64_t */
2320 #include <inttypes.h>
2321 #endif
2322
2323 /* The AC_CHECK_SIZEOF() in configure fails for some machines.
2324 * we provide some fallback values here */
2325 #if !SIZEOF_UNSIGNED_SHORT
2326 #undef SIZEOF_UNSIGNED_SHORT
2327 #define SIZEOF_UNSIGNED_SHORT 2
2328 #endif
2329 #if !SIZEOF_UNSIGNED_INT
2330 #undef SIZEOF_UNSIGNED_INT
2331 #define SIZEOF_UNSIGNED_INT 4
2332 #endif
2333 #if !SIZEOF_UNSIGNED_LONG
2334 #undef SIZEOF_UNSIGNED_LONG
2335 #define SIZEOF_UNSIGNED_LONG 4
2336 #endif
2337
2338
2339 #include <sys/types.h>
2340
2341
2342 #ifndef HAVE_BYTE_TYPEDEF
2343 #undef byte /* maybe there is a macro with this name */
2344 #ifndef __riscos__
2345 typedef unsigned char byte;
2346 #else
2347 /* Norcroft treats char = unsigned char as legal assignment
2348 but char* = unsigned char* as illegal assignment
2349 and the same applies to the signed variants as well */
2350 typedef char byte;
2351 #endif
2352 #define HAVE_BYTE_TYPEDEF
2353 #endif
2354
2355 #ifndef HAVE_USHORT_TYPEDEF
2356 #undef ushort /* maybe there is a macro with this name */
2357 typedef unsigned short ushort;
2358 #define HAVE_USHORT_TYPEDEF
2359 #endif
2360
2361 #ifndef HAVE_ULONG_TYPEDEF
2362 #undef ulong /* maybe there is a macro with this name */
2363 typedef unsigned long ulong;
2364 #define HAVE_ULONG_TYPEDEF
2365 #endif
2366
2367 #ifndef HAVE_U16_TYPEDEF
2368 #undef u16 /* maybe there is a macro with this name */
2369 #if SIZEOF_UNSIGNED_INT == 2
2370 typedef unsigned int u16;
2371 #elif SIZEOF_UNSIGNED_SHORT == 2
2372 typedef unsigned short u16;
2373 #else
2374 #error no typedef for u16
2375 #endif
2376 #define HAVE_U16_TYPEDEF
2377 #endif
2378
2379 #ifndef HAVE_U32_TYPEDEF
2380 #undef u32 /* maybe there is a macro with this name */
2381 #if SIZEOF_UNSIGNED_INT == 4
2382 typedef unsigned int u32;
2383 #elif SIZEOF_UNSIGNED_LONG == 4
2384 typedef unsigned long u32;
2385 #else
2386 #error no typedef for u32
2387 #endif
2388 #define HAVE_U32_TYPEDEF
2389 #endif
2390
2391 /****************
2392 * Warning: Some systems segfault when this u64 typedef and
2393 * the dummy code in cipher/md.c is not available. Examples are
2394 * Solaris and IRIX.
2395 */
2396 #ifndef HAVE_U64_TYPEDEF
2397 #undef u64 /* maybe there is a macro with this name */
2398 #if SIZEOF_UINT64_T == 8
2399 typedef uint64_t u64;
2400 #define U64_C(c) (UINT64_C(c))
2401 #define HAVE_U64_TYPEDEF
2402 #elif SIZEOF_UNSIGNED_INT == 8
2403 typedef unsigned int u64;
2404 #define U64_C(c) (c ## U)
2405 #define HAVE_U64_TYPEDEF
2406 #elif SIZEOF_UNSIGNED_LONG == 8
2407 typedef unsigned long u64;
2408 #define U64_C(c) (c ## UL)
2409 #define HAVE_U64_TYPEDEF
2410 #elif SIZEOF_UNSIGNED_LONG_LONG == 8
2411 typedef unsigned long long u64;
2412 #define U64_C(c) (c ## ULL)
2413 #define HAVE_U64_TYPEDEF
2414 #endif
2415 #endif
2416
2417 typedef union {
2418 int a;
2419 short b;
2420 char c[1];
2421 long d;
2422 #ifdef HAVE_U64_TYPEDEF
2423 u64 e;
2424 #endif
2425 float f;
2426 double g;
2427 } PROPERLY_ALIGNED_TYPE;
2428
2429 struct string_list {
2430 struct string_list *next;
2431 unsigned int flags;
2432 char d[1];
2433 };
2434 typedef struct string_list *STRLIST;
2435 typedef struct string_list *strlist_t;
2436
2437 #endif /*G10_TYPES_H*/