comparison th_types.h @ 0:728243125263

Import.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 20 Mar 2008 00:15:03 +0000
parents
children 69aed051f84d
comparison
equal deleted inserted replaced
-1:000000000000 0:728243125263
1 /*
2 * Type definations
3 * Programmed and designed by Matti 'ccr' Hamalainen
4 * (C) Copyright 2002-2008 Tecnic Software productions (TNSP)
5 *
6 * Please read file 'COPYING' for information on license and distribution.
7 */
8 /* If your code uses "config.h", you need to #include
9 * it before including this header.
10 */
11 #ifndef _TH_TYPES_H
12 #define _TH_TYPES_H
13
14 #ifdef HAVE_STDINT_H
15 #include <stdint.h>
16 #ifndef HAVE_INT_TYPES
17 #define HAVE_INT_TYPES 1
18 #endif
19 #endif
20
21 #ifdef HAVE_SYS_TYPES_H
22 #include <sys/types.h>
23 #ifndef HAVE_INT_TYPES
24 #define HAVE_INT_TYPES 1
25 #endif
26 #endif
27
28 /* Shorthand types */
29 typedef unsigned long int ulint_t;
30 typedef signed long int lint_t;
31 #ifndef HAVE_UINT_T
32 typedef unsigned int uint_t;
33 #endif
34
35 /* Default assumptions for these types should be ok for most 32bit platforms...
36 * feel free to define TH_TYPE_* if necessary to remedy
37 */
38 #ifdef TH_TYPE_I8
39 typedef unsigned TH_TYPE_I8 uint8_t; /* 8 bits, unsigned */
40 typedef signed TH_TYPE_I8 int8_t; /* 8 bits, signed */
41 #else
42 #ifndef HAVE_INT_TYPES
43 typedef unsigned char uint8_t;
44 typedef signed char int8_t;
45 #endif
46 #endif
47
48
49 #ifdef TH_TYPE_I16
50 typedef unsigned TH_TYPE_I16 uint16_t; /* 16 bits, unsigned == 2 BYTEs */
51 typedef signed TH_TYPE_I16 int16_t; /* 16 bits, signed */
52 #else
53 #ifndef HAVE_INT_TYPES
54 typedef unsigned short int uint16_t;
55 typedef signed short int int16_t;
56 #endif
57 #endif
58
59 #ifdef TH_TYPE_I32
60 typedef unsigned TH_TYPE_I32 uint32_t; /* 32 bits, unsigned == 4 BYTES == 2 WORDs */
61 typedef signed TH_TYPE_I32 int32_t; /* 32 bits, signed */
62 #else
63 #ifndef HAVE_INT_TYPES
64 typedef unsigned int uint32_t;
65 typedef signed int int32_t;
66 #endif
67 #endif
68
69 #ifdef TH_TYPE_I64
70 typedef unsigned TH_TYPE_I64 uint64_t; /* 64 bits, unsigned == 8 BYTES == 2 DWORDs */
71 typedef signed TH_TYPE_I64 int64_t; /* 64 bits, signed */
72 #else
73 #ifndef HAVE_INT_TYPES
74 typedef unsigned long long uint64_t;
75 typedef signed long long int64_t;
76 #endif
77 #endif
78
79
80 /* This is the character type used in all string-related routines of
81 * th_libs. Currently it is set to be equivalent of basetype "char",
82 * but under some platforms it may be necessary to use
83 * "unsigned char" instead.
84 *
85 * Also in future this type may be changed to hold 32-bit UNICODE
86 */
87 typedef char char_t;
88
89
90 /* Define a boolean type
91 */
92 #if ((!defined(FALSE)) && (!defined(TRUE)) && (!defined(BOOL)))
93 typedef enum { FALSE=0, TRUE=1 } BOOL;
94 #endif
95
96 #ifndef BOOL
97 #ifdef bool
98 #define BOOL bool
99 #else
100 #define BOOL int
101 #endif
102 #endif
103
104 #endif /* _TH_TYPES_H */