aboutsummaryrefslogtreecommitdiff
path: root/include/types.h
blob: 3ae418f39d3ed1806297df1f380dd08e4cc86fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @file types.h
* @author Paul Oliver
*
* Declare main typedefs for the Salis library. Salis depends on fixed-width
* unsigned types being available. We use the limits header to define these in
* a C89 compliant way. Also, we typedef respective pointer types and a string
* type to aid in header parsing.
*/

#ifndef SALIS_TYPES_H
#define SALIS_TYPES_H

#include <limits.h>

#define UINT8_MAX 0xff
#define UINT32_MAX 0xffffffff

#if UCHAR_MAX == UINT8_MAX
	typedef unsigned char uint8;
	typedef unsigned char *uint8_p;
#else
	#error "Cannot define uint8/uint8_p types!"
#endif

#if ULONG_MAX == UINT32_MAX
	typedef unsigned long int uint32;
	typedef unsigned long int *uint32_p;
#elif UINT_MAX == UINT32_MAX
	typedef unsigned int uint32;
	typedef unsigned int *uint32_p;
#elif USHRT_MAX == UINT32_MAX
	typedef unsigned short int uint32;
	typedef unsigned short int *uint32_p;
#else
	#error "Cannot define uint32/uint32_p types!"
#endif

typedef int boolean;
typedef const char *string;

#define TRUE 1
#define FALSE 0

#endif