-
Notifications
You must be signed in to change notification settings - Fork 3
/
morelimits.h
186 lines (150 loc) · 4.66 KB
/
morelimits.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* copyright 2002-2004 Bryce "Zooko" Wilcox-O'Hearn
* mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software to deal in this software without restriction (including the
* rights to use, modify, distribute, sublicense, and/or sell copies) provided
* that the above copyright notice and this permission notice is included in
* all copies or substantial portions of this software. THIS SOFTWARE IS
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
*/
#ifndef __INCL_morelimits_h
#define __INCL_morelimits_h
#include "morelimitsimp.h" /* implementation stuff that you needn't see in order to use the library */
#include <stddef.h>
#include <limits.h>
static char const* const morelimits_h_cvsid = "$Id: morelimits.h,v 1.11 2004/05/07 15:58:59 zooko Exp $";
static int const morelimits_vermaj = 0;
static int const morelimits_vermin = 9;
static int const morelimits_vermicro = 2;
static char const* const morelimits_vernum = "0.9.2";
/*
* The following are not defined in the standard C library's "limits.h", but are sometimes defined in other headers.
*/
#define Z_SIZE_T_MAX Z_MAX(size_t)
#define Z_SIZE_T_MIN Z_MIN(size_t)
#ifndef SIZE_T_MAX
#define SIZE_T_MAX Z_SIZE_T_MAX
#endif
#ifndef SIZE_T_MIN
#define SIZE_T_MIN Z_SIZE_T_MIN
#endif
#ifndef SIZE_MAX
#define SIZE_MAX Z_SIZE_T_MAX
#endif
#ifndef SIZE_MIN
#define SIZE_MIN Z_SIZE_T_MIN
#endif
#define Z_TIME_T_MAX Z_MAX(time_t)
#define Z_TIME_T_MIN Z_MIN(time_t)
#ifndef TIME_T_MAX
#define TIME_T_MAX Z_TIME_T_MAX
#endif
#ifndef TIME_T_MIN
#define TIME_T_MIN Z_TIME_T_MIN
#endif
/**
* The following is useful only if you are storing numbers in storage space of
* type void*, and you want to be sure your numbers aren't too big. ANSI C does
* not guarantee that you can do this.
*/
#define Z_MAX_VOIDP Z_MAX_UNSIGNED_BITS(sizeof(void*) * CHAR_BIT)
/*
* The C standard does not offer integers of an exact width, so if you rely on
* an integer to be of a specific width your code may not port to all C
* platforms. The following are intended only for reading and writing integers
* of fixed width from streams of data.
*/
#define Z_UINT8_MAX ((unsigned short)Z_MAX_UNSIGNED_BITS(8))
#define Z_UINT16_MAX ((unsigned short)Z_MAX_UNSIGNED_BITS(16))
#define Z_UINT32_MAX ((unsigned long)Z_MAX_UNSIGNED_BITS(32))
#define Z_UINT64_MAX ((unsigned long long)Z_MAX_UNSIGNED_BITS(64))
/*
* The following are not defined in the standard C library's "limits.h",
* presumably because you could just write "0" instead.
*/
#define ULONG_MIN Z_MIN(unsigned long)
#define UINT_MIN Z_MIN(unsigned int)
#define USHRT_MIN Z_MIN(unsigned short)
#define UCHAR_MIN Z_MIN(unsigned char)
#define ULLONG_MIN Z_MIN(unsigned long long)
/*
* All of the following should be defined in the standard C library's "limits.h"
* header. They are included here because some limits.h's lack some of them
* (the long long ones), and in order to check that my Z_MAX and Z_MIN macros
* and your system's <limits.h> agree! (test.c tests this.)
*/
#define Z_ULLONG_MAX Z_MAX(unsigned long long)
#define Z_ULONG_MAX Z_MAX(unsigned long)
#define Z_UINT_MAX Z_MAX(unsigned int)
#define Z_USHRT_MAX Z_MAX(unsigned short)
#define Z_UCHAR_MAX Z_MAX(unsigned char)
#define Z_BYTE_MAX Z_MAX(unsigned char)
#define Z_LLONG_MAX Z_MAX(long long)
#define Z_LONG_MAX Z_MAX(long)
#define Z_INT_MAX Z_MAX(int)
#define Z_SHRT_MAX Z_MAX(short)
#define Z_CHAR_MAX Z_MAX(char)
#define Z_LLONG_MIN Z_MIN(long long)
#define Z_LONG_MIN Z_MIN(long)
#define Z_INT_MIN Z_MIN(int)
#define Z_SHRT_MIN Z_MIN(short)
#define Z_CHAR_MIN Z_MIN(char)
#define Z_SCHAR_MAX Z_MAX(signed char)
#define Z_SCHAR_MIN Z_MIN(signed char)
#ifndef ULLONG_MAX
#define ULLONG_MAX Z_ULLONG_MAX
#endif
#ifndef ULONG_MAX
#define ULONG_MAX Z_ULONG_MAX
#endif
#ifndef UINT_MAX
#define UINT_MAX Z_UINT_MAX
#endif
#ifndef USHRT_MAX
#define USHRT_MAX Z_USHRT_MAX
#endif
#ifndef USHRT_MAX
#define USHRT_MAX Z_USHRT_MAX
#endif
#ifndef UCHAR_MAX
#define UCHAR_MAX Z_UCHAR_MAX
#endif
#ifndef LLONG_MAX
#define LLONG_MAX Z_LLONG_MAX
#endif
#ifndef LONG_MAX
#define LONG_MAX Z_LONG_MAX
#endif
#ifndef INT_MAX
#define INT_MAX Z_INT_MAX
#endif
#ifndef SHRT_MAX
#define SHRT_MAX Z_SHRT_MAX
#endif
#ifndef CHAR_MAX
#define CHAR_MAX Z_CHAR_MAX
#endif
#ifndef LLONG_MIN
#define LLONG_MIN Z_LLONG_MIN
#endif
#ifndef LONG_MIN
#define LONG_MIN Z_LONG_MIN
#endif
#ifndef INT_MIN
#define INT_MIN Z_INT_MIN
#endif
#ifndef SHRT_MIN
#define SHRT_MIN Z_SHRT_MIN
#endif
#ifndef CHAR_MIN
#define CHAR_MIN Z_CHAR_MIN
#endif
#ifndef SCHAR_MAX
#define SCHAR_MAX Z_SCHAR_MAX
#endif
#ifndef SCHAR_MIN
#define SCHAR_MIN Z_SCHAR_MIN
#endif
#endif /* #ifndef __INCL_morelimits_h */