forked from qca/open-plc-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.h
143 lines (113 loc) · 3.26 KB
/
types.h
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*====================================================================*
*
* types.h - custom data type definitions and declarations;
*
* this file is a subset of the original that includes only those
* definitions and declaration needed for toolkit programs;
*
* Motley Tools by Charles Maier <[email protected]>;
* Copyright 2001-2006 by Charles Maier Associates;
* Licensed under the Internet Software Consortium License;
*
* Contributor(s):
*
* Werner Henze <[email protected]>
*
*--------------------------------------------------------------------*/
#ifndef TYPES_HEADER
#define TYPES_HEADER
/*====================================================================*
* system header files;
*--------------------------------------------------------------------*/
#include <stdint.h>
/*====================================================================*
* constants;
*--------------------------------------------------------------------*/
#if defined (_WIN64)
#define SIZE_T_SPEC "%I64d"
#define OFF_T_SPEC "%ld"
#elif defined (WIN32)
#define SIZE_T_SPEC "%d"
#define OFF_T_SPEC "%ld"
#elif defined (__APPLE__)
#define SIZE_T_SPEC "%zu"
#define OFF_T_SPEC "%lld"
#elif defined (__OpenBSD__)
#define SIZE_T_SPEC "%zu"
#define OFF_T_SPEC "%lld"
#elif defined (__linux__)
#define SIZE_T_SPEC "%zu"
#define OFF_T_SPEC "%ld"
#else
error "Unknown environment."
#endif
/*====================================================================*
* macros;
*--------------------------------------------------------------------*/
#define MONIKER(x) #x
#define LITERAL(x) MONIKER(x)
#define SIZEOF(array) (sizeof(array)/sizeof(array[0]))
/*====================================================================*
* new POSIX types;
*--------------------------------------------------------------------*/
typedef signed errno_t;
typedef signed signo_t;
typedef unsigned char byte;
/*====================================================================*
* define C++ style true and false for use in standard C programs;
*--------------------------------------------------------------------*/
#ifndef __cplusplus
typedef enum
{
false,
true
}
bool;
#endif
/*====================================================================*
* cope with structure packing vagaries;
*--------------------------------------------------------------------*/
#ifndef __packed
#ifdef __GNUC__
#define __packed __attribute__ ((packed))
#else
#define __packed
#endif
#endif
/*====================================================================*
* define flagword (bitmap) variable type for clarity;
*--------------------------------------------------------------------*/
typedef signed file_t;
typedef signed sock_t;
typedef signed code_t;
typedef unsigned char byte_t;
typedef unsigned type_t;
typedef unsigned flag_t;
typedef struct _file_
{
file_t file;
char const *name;
}
file;
typedef struct _term_
{
char const * term;
char const * text;
}
TERM;
typedef struct _type_
{
type_t type;
char const * name;
}
TYPE;
typedef struct _code_
{
code_t code;
char const * name;
}
CODE;
/*====================================================================*
* end definitions and declarations;
*--------------------------------------------------------------------*/
#endif