Mercurial > hg > nnchat
diff th_types.h @ 0:728243125263
Import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 20 Mar 2008 00:15:03 +0000 |
parents | |
children | 69aed051f84d |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/th_types.h Thu Mar 20 00:15:03 2008 +0000 @@ -0,0 +1,104 @@ +/* + * Type definations + * Programmed and designed by Matti 'ccr' Hamalainen + * (C) Copyright 2002-2008 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 +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 */ +#else +#ifndef HAVE_INT_TYPES +typedef unsigned char uint8_t; +typedef signed char int8_t; +#endif +#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 */ +#else +#ifndef HAVE_INT_TYPES +typedef unsigned short int uint16_t; +typedef signed short int int16_t; +#endif +#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 */ +#else +#ifndef HAVE_INT_TYPES +typedef unsigned int uint32_t; +typedef signed int int32_t; +#endif +#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 */ +#else +#ifndef HAVE_INT_TYPES +typedef unsigned long long uint64_t; +typedef signed long long int64_t; +#endif +#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 */