ZEDA  1.6.18
zeda_defs.h
Go to the documentation of this file.
1 /* ZEDA - Elementary Data and Algorithms
2  * Copyright (C) 1998 Tomomichi Sugihara (Zhidao)
3  */
9 #ifndef __ZEDA_DEFS_H__
10 #define __ZEDA_DEFS_H__
11 
12 /* to tell C++ compiler that types and declarations are in Language C */
13 #ifdef __cplusplus
14 # ifdef __BEGIN_DECLS
15 # undef __BEGIN_DECLS
16 # endif
17 # define __BEGIN_DECLS extern "C"{
18 # ifdef __END_DECLS
19 # undef __END_DECLS
20 # endif
21 # define __END_DECLS }
22 #else /* nothing done for C compiler */
23 # ifdef __BEGIN_DECLS
24 # undef __BEGIN_DECLS
25 # endif
26 # define __BEGIN_DECLS
27 # ifdef __END_DECLS
28 # undef __END_DECLS
29 # endif
30 # define __END_DECLS
31 #endif
32 
33 #ifndef __KERNEL__
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #endif /* __KERNEL__ */
38 
39 #include <time.h>
40 
41 #include <zeda/zeda_compat.h>
42 
44 
45 /* ********************************************************** */
46 /* basic type & macro definitions
47  * ********************************************************** */
48 
55 #ifndef BUFSIZ
56 #define BUFSIZ 512
57 #endif /* BUFSIZ */
58 
59 #if __STDC_VERSION__ < 199901L
60 /* size-fixed integer family */
61 /* might be already defined in stdint.h or sys/types.h conforming to C99 */
62 typedef unsigned char uint8_t;
63 typedef unsigned short int uint16_t;
64 typedef unsigned int uint32_t;
65 #ifdef __LP64__
66 typedef unsigned long int uint64_t;
67 #else
68 typedef unsigned long long int uint64_t;
69 #endif /* __LP64__ */
70 typedef signed char int8_t;
71 typedef short int int16_t;
72 typedef int int32_t;
73 #ifdef __LP64__
74 typedef long int int64_t;
75 #else
76 typedef long long int int64_t;
77 #endif /* __LP64__ */
78 #else
79 #include <stdint.h>
80 #endif /* __STDC_VERSION__ */
81 
82 #define INT_BIT ( sizeof(int) << 3 )
83 
84 #ifndef INT_MAX
85 #define INT_MAX ( ( ( ( 1 << ( ( INT_BIT >> 1 ) - 1 ) ) - 1 ) << ( INT_BIT >> 1 ) ) | ( ( 1 << ( INT_BIT >> 1 ) ) - 1 ) )
86 #endif
87 
88 #ifndef UINT_MAX
89 #define UINT_MAX ( (uint)( ( ( ( 1 << ( INT_BIT >> 1 ) ) - 1 ) << ( INT_BIT >> 1 ) ) | ( ( 1 << ( INT_BIT >> 1 ) ) - 1 ) ) )
90 #endif
91 
92 typedef int8_t byte;
93 typedef int16_t word;
94 typedef int32_t dword;
96 typedef uint8_t ubyte;
97 typedef uint16_t uword;
98 typedef uint32_t udword;
100 #if !defined( _NETBSD_SOURCE )
101 /* NetBSD already defines uint and ulong in sys/types.h */
102 #if !defined( __USE_GNU ) && !defined( __USE_MISC ) && !defined( __KERNEL__ )
103 /* GNU C already defines uint and ulong in sys/types.h */
104 typedef unsigned int uint;
105 typedef unsigned long ulong;
106 #endif
107 #endif
108 
109 #ifndef __cplusplus
110 
111 typedef ubyte bool;
113 enum{
114  false = 0, true = 1
115 };
116 #endif /* __cplusplus */
117 
119 #define zBoolStr(b) ( (b) ? "true" : "false" )
120 
122 
123 #endif /* __ZEDA_DEFS_H__ */
signed char int8_t
Definition: zeda_defs.h:70
int8_t byte
Definition: zeda_defs.h:92
int16_t word
Definition: zeda_defs.h:93
for OS compatibility.
int int32_t
Definition: zeda_defs.h:72
ubyte bool
boolean type (for Language C).
Definition: zeda_defs.h:111
uint32_t udword
Definition: zeda_defs.h:98
#define __END_DECLS
Definition: zeda_defs.h:30
short int int16_t
Definition: zeda_defs.h:71
unsigned int uint
Definition: zeda_defs.h:104
int32_t dword
Definition: zeda_defs.h:94
unsigned long long int uint64_t
Definition: zeda_defs.h:68
uint8_t ubyte
Definition: zeda_defs.h:96
uint16_t uword
Definition: zeda_defs.h:97
unsigned short int uint16_t
Definition: zeda_defs.h:63
unsigned int uint32_t
Definition: zeda_defs.h:64
#define __BEGIN_DECLS
Definition: zeda_defs.h:26
unsigned long ulong
Definition: zeda_defs.h:105
unsigned char uint8_t
Definition: zeda_defs.h:62
long long int int64_t
Definition: zeda_defs.h:76