Blame include/types.h

Packit 762fc5
/* types.h - some common typedefs
Packit 762fc5
 *	Copyright (C) 1998 Free Software Foundation, Inc.
Packit 762fc5
 *
Packit 762fc5
 * This file was part of GNUPG.
Packit 762fc5
 * $Header$
Packit 762fc5
 *
Packit 762fc5
 * GNUPG is free software; you can redistribute it and/or modify
Packit 762fc5
 * it under the terms of the GNU General Public License as published by
Packit 762fc5
 * the Free Software Foundation; either version 2 of the License, or
Packit 762fc5
 * (at your option) any later version.
Packit 762fc5
 *
Packit 762fc5
 * GNUPG is distributed in the hope that it will be useful,
Packit 762fc5
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 762fc5
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 762fc5
 * GNU General Public License for more details.
Packit 762fc5
 *
Packit 762fc5
 * You should have received a copy of the GNU General Public License
Packit 762fc5
 * along with this program; if not, write to the Free Software
Packit 762fc5
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Packit 762fc5
 */
Packit 762fc5
Packit 762fc5
#ifndef _TYPES_H_INCLUDED
Packit 762fc5
#define _TYPES_H_INCLUDED
Packit 762fc5
Packit 762fc5
/* The AC_CHECK_SIZEOF() in configure fails for some machines.
Packit 762fc5
 * we provide some fallback values here */
Packit 762fc5
#if !SIZEOF_UNSIGNED_SHORT
Packit 762fc5
#  undef SIZEOF_UNSIGNED_SHORT
Packit 762fc5
#  define SIZEOF_UNSIGNED_SHORT 2
Packit 762fc5
#endif
Packit 762fc5
#if !SIZEOF_UNSIGNED_INT
Packit 762fc5
#  undef SIZEOF_UNSIGNED_INT
Packit 762fc5
#  define SIZEOF_UNSIGNED_INT 4
Packit 762fc5
#endif
Packit 762fc5
#if !SIZEOF_UNSIGNED_LONG
Packit 762fc5
#  undef SIZEOF_UNSIGNED_LONG
Packit 762fc5
#  define SIZEOF_UNSIGNED_LONG 4
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#include <sys/types.h>
Packit 762fc5
Packit 762fc5
#ifndef HAVE_BYTE
Packit 762fc5
#  undef byte	    /* maybe there is a macro with this name */
Packit 762fc5
  typedef unsigned char byte;
Packit 762fc5
#  define HAVE_BYTE
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#ifndef HAVE_USHORT
Packit 762fc5
#  undef ushort     /* maybe there is a macro with this name */
Packit 762fc5
  typedef unsigned short ushort;
Packit 762fc5
#  define HAVE_USHORT
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#ifndef HAVE_ULONG
Packit 762fc5
#  undef ulong	    /* maybe there is a macro with this name */
Packit 762fc5
  typedef unsigned long ulong;
Packit 762fc5
#  define HAVE_ULONG
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#ifndef HAVE_U16
Packit 762fc5
#  undef u16	    /* maybe there is a macro with this name */
Packit 762fc5
#  if SIZEOF_UNSIGNED_INT == 2
Packit 762fc5
    typedef unsigned int   u16;
Packit 762fc5
#  elif SIZEOF_UNSIGNED_SHORT == 2
Packit 762fc5
    typedef unsigned short u16;
Packit 762fc5
#  else
Packit 762fc5
#    error no typedef for u16
Packit 762fc5
#  endif
Packit 762fc5
#  define HAVE_U16
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#ifndef HAVE_U32
Packit 762fc5
#  undef u32	    /* maybe there is a macro with this name */
Packit 762fc5
#  if SIZEOF_UNSIGNED_INT == 4
Packit 762fc5
    typedef unsigned int u32;
Packit 762fc5
#  elif SIZEOF_UNSIGNED_LONG == 4
Packit 762fc5
    typedef unsigned long u32;
Packit 762fc5
#  else
Packit 762fc5
#    error no typedef for u32
Packit 762fc5
#  endif
Packit 762fc5
#  define HAVE_U32
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
#ifndef HAVE_U64
Packit 762fc5
#  undef u64	    /* maybe there is a macro with this name */
Packit 762fc5
#  if SIZEOF_UNSIGNED_INT == 8
Packit 762fc5
    typedef unsigned int u64;
Packit 762fc5
#    define HAVE_U64
Packit 762fc5
#  elif SIZEOF_UNSIGNED_LONG == 8
Packit 762fc5
    typedef unsigned long u64;
Packit 762fc5
#    define HAVE_U64
Packit 762fc5
#  elif __GNUC__ >= 2 || defined(__SUNPRO_C) || defined(_AIX) && defined(_LONGLONG)
Packit 762fc5
    typedef unsigned long long u64;
Packit 762fc5
#    define HAVE_U64
Packit 762fc5
#  endif
Packit 762fc5
#endif
Packit 762fc5
Packit 762fc5
typedef union {
Packit 762fc5
    int a;
Packit 762fc5
    short b;
Packit 762fc5
    char c[1];
Packit 762fc5
    long d;
Packit 762fc5
#  ifdef HAVE_U64
Packit 762fc5
    u64 e;
Packit 762fc5
#  endif
Packit 762fc5
    float f;
Packit 762fc5
    double g;
Packit 762fc5
} PROPERLY_ALIGNED_TYPE;
Packit 762fc5
Packit 762fc5
typedef struct string_list {
Packit 762fc5
    struct string_list *next;
Packit 762fc5
    unsigned int flags;
Packit 762fc5
    char d[1];
Packit 762fc5
} *STRLIST;
Packit 762fc5
Packit 762fc5
Packit 762fc5
#endif /*_INCLUDED_TYPES_H*/