File: types.h

package info (click to toggle)
bar 1.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 928 kB
  • sloc: ansic: 4,381; sh: 3,334; makefile: 264
file content (120 lines) | stat: -rw-r--r-- 3,104 bytes parent folder | download | duplicates (3)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include "config.h"

/*
 * Types
 */

#ifndef __types_h__
#define __types_h__

#include "headers.h"

/*
 * uint8
 */
#if SIZEOF_UNSIGNED_CHAR == 1
	typedef unsigned char uint8;
# define UINT8_CTYPE(v) ((unsigned int)(unsigned char)(v))
#elif SIZEOF_UNSIGNED_SHORT == 1
	typedef unsigned short uint8;
# define UINT8_CTYPE(v) ((unsigned short)(v))
#elif SIZEOF_UNSIGNED_INT == 1
	typedef unsigned int uint8;
# define UINT8_CTYPE(v) ((unsigned int)(v))
#elif SIZEOF_UNSIGNED_LONG == 1
	typedef unsigned long uint8;
# define UINT8_CTYPE(v) ((unsigned long)(v))
#elif SIZEOF_UNSIGNED_LONG_LONG == 1
	typedef unsigned long long uint8;
# define UINT8_CTYPE(v) ((unsigned long long)(v))
#else
#	error *** ERROR: No 8-bit type found to use as uint8
#endif

#define MAX_UINT8 ((uint8)-1)
#if SIZEOF_SIZE_T == 1
#define MAX_SIZE_T MAX_UINT8
#endif

/*
 * uint16
 */
#if SIZEOF_UNSIGNED_CHAR == 2
	typedef unsigned char uint16;
# define UINT16_CTYPE(v) ((unsigned int)(unsigned char)(v))
#elif SIZEOF_UNSIGNED_SHORT == 2
	typedef unsigned short uint16;
# define UINT16_CTYPE(v) ((unsigned short)(v))
#elif SIZEOF_UNSIGNED_INT == 2
	typedef unsigned int uint16;
# define UINT16_CTYPE(v) ((unsigned int)(v))
#elif SIZEOF_UNSIGNED_LONG == 2
	typedef unsigned long uint16;
# define UINT16_CTYPE(v) ((unsigned long)(v))
#elif SIZEOF_UNSIGNED_LONG_LONG == 2
	typedef unsigned long long uint16;
# define UINT16_CTYPE(v) ((unsigned long long)(v))
#else
#	error *** ERROR: No 16-bit type found to use as uint16
#endif

#define MAX_UINT16 ((uint16)-1)
#if SIZEOF_SIZE_T == 2
#define MAX_SIZE_T MAX_UINT16
#endif

/*
 * uint32
 */
#if SIZEOF_UNSIGNED_CHAR == 4
	typedef unsigned char uint32;
# define UINT32_CTYPE(v) ((unsigned int)(unsigned char)(v))
#elif SIZEOF_UNSIGNED_SHORT == 4
	typedef unsigned short uint32;
# define UINT32_CTYPE(v) ((unsigned short)(v))
#elif SIZEOF_UNSIGNED_INT == 4
	typedef unsigned int uint32;
# define UINT32_CTYPE(v) ((unsigned int)(v))
#elif SIZEOF_UNSIGNED_LONG == 4
	typedef unsigned long uint32;
# define UINT32_CTYPE(v) ((unsigned long)(v))
#elif SIZEOF_UNSIGNED_LONG_LONG == 4
	typedef unsigned long long uint32;
# define UINT32_CTYPE(v) ((unsigned long long)(v))
#else
#	error *** ERROR: No 32-bit type found to use as uint32
#endif

#define MAX_UINT32 ((uint32)-1)
#if SIZEOF_SIZE_T == 4
#define MAX_SIZE_T MAX_UINT32
#endif

/*
 * uint64
 */
#if SIZEOF_UNSIGNED_CHAR == 8
	typedef unsigned char uint64;
# define UINT64_CTYPE(v) ((unsigned int)(unsigned char)(v))
#elif SIZEOF_UNSIGNED_SHORT == 8
	typedef unsigned short uint64;
# define UINT64_CTYPE(v) ((unsigned short)(v))
#elif SIZEOF_UNSIGNED_INT == 8
	typedef unsigned int uint64;
# define UINT64_CTYPE(v) ((unsigned int)(v))
#elif SIZEOF_UNSIGNED_LONG == 8
	typedef unsigned long uint64;
# define UINT64_CTYPE(v) ((unsigned long)(v))
#elif SIZEOF_UNSIGNED_LONG_LONG == 8
	typedef unsigned long long uint64;
# define UINT64_CTYPE(v) ((unsigned long long)(v))
#else
#	error *** ERROR: No 64-bit type found to use as uint64
#endif

#define MAX_UINT64 ((uint64)-1)
#if SIZEOF_SIZE_T == 8
#define MAX_SIZE_T MAX_UINT64
#endif

#endif