view th_types.h @ 149:6a0e9980b76b

Mostly cosmetic changes.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 07 Jan 2015 17:04:31 +0200
parents 51eec969b07a
children 9bc7f60f3013
line wrap: on
line source

/*
 * Type definations
 * Programmed and designed by Matti 'ccr' Hamalainen
 * (C) Copyright 2002-2015 Tecnic Software productions (TNSP)
 *
 * Please read file 'COPYING' for information on license and distribution.
 */
/* If your code uses "config.h", you need to #include
 * it before including this header.
 */
#ifndef _TH_TYPES_H
#define _TH_TYPES_H

#ifdef HAVE_STDINT_H
#include <stdint.h>
#ifndef HAVE_INT_TYPES
#define HAVE_INT_TYPES 1
#endif
#endif

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#ifndef HAVE_INT_TYPES
#define HAVE_INT_TYPES 1
#endif
#endif

// Shorthand types
typedef unsigned long int ulint_t;
typedef signed long int lint_t;
#ifndef HAVE_UINT_T // BOOST defines uint_t at least
typedef unsigned int uint_t;
#endif

/* Default assumptions for these types should be ok for most 32bit platforms...
 * feel free to define TH_TYPE_* if necessary to remedy
 */
#ifdef TH_TYPE_I8
typedef unsigned TH_TYPE_I8 uint8_t;    // 8 bits, unsigned
typedef signed TH_TYPE_I8 int8_t;    // 8 bits, signed
#elif !defined(HAVE_INT_TYPES)
typedef unsigned char uint8_t;
typedef signed char int8_t;
#endif


#ifdef TH_TYPE_I16
typedef unsigned TH_TYPE_I16 uint16_t;    // 16 bits, unsigned == 2 BYTEs
typedef signed TH_TYPE_I16 int16_t;    // 16 bits, signed
#elif !defined(HAVE_INT_TYPES)
typedef unsigned short int uint16_t;
typedef signed short int int16_t;
#endif

#ifdef TH_TYPE_I32
typedef unsigned TH_TYPE_I32 uint32_t;    // 32 bits, unsigned == 4 BYTES == 2 WORDs
typedef signed TH_TYPE_I32 int32_t;    // 32 bits, signed
#elif !defined(HAVE_INT_TYPES)
typedef unsigned int uint32_t;
typedef signed int int32_t;
#endif

#ifdef TH_TYPE_I64
typedef unsigned TH_TYPE_I64 uint64_t;    // 64 bits, unsigned == 8 BYTES == 2 DWORDs
typedef signed TH_TYPE_I64 int64_t;    // 64 bits, signed
#elif !defined(HAVE_INT_TYPES)
typedef unsigned long long uint64_t;
typedef signed long long int64_t;
#endif


/* This is the character type used in all string-related routines of
 * th_libs. Currently it is set to be equivalent of basetype "char",
 * but under some platforms it may be necessary to use
 * "unsigned char" instead.
 *
 * Also in future this type may be changed to hold 32-bit UNICODE
 */
typedef char char_t;


/* Define a boolean type
 */
#if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
typedef enum { FALSE = 0, TRUE = 1 } BOOL;
#endif

#ifndef BOOL
#ifdef bool
#define BOOL bool
#else
#define BOOL int
#endif
#endif

#endif // _TH_TYPES_H