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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#ifndef PORT_H
#define PORT_H
#ifdef _WIN32
#include <assert.h>
#include <stdio.h>
#endif
#ifndef NULL
#define NULL 0
#endif /* NULL */
#ifndef _WIN32
#ifdef SABER
#define volatile
#endif
#ifdef _IBMR2
#define _BSD
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE /* Argh! IBM strikes again */
#endif
#ifndef _ALL_SOURCE
#define _ALL_SOURCE /* Argh! IBM strikes again */
#endif
#ifndef _ANSI_C_SOURCE
#define _ANSI_C_SOURCE /* Argh! IBM strikes again */
#endif
#endif
/*
* int32 should be defined as the most economical sized integer capable of
* holding a 32 bit quantity
* int16 should be similarly defined
*/
/* XXX hack */
#ifndef MACHDEP_INCLUDED
#define MACHDEP_INCLUDED
#ifdef vax
typedef int int32;
typedef short int16;
#else
/* Ansi-C promises that these definitions should always work */
typedef long int32;
typedef int int16;
#endif /* vax */
#endif /* MACHDEP_INCLUDED */
#ifndef __STDC__
#ifndef __DATE__
#ifdef CUR_DATE
#define __DATE__ CUR_DATE
#else
#define __DATE__ "unknown-date"
#endif /* CUR_DATE */
#endif /* __DATE__ */
#ifndef __TIME__
#ifdef CUR_TIME
#define __TIME__ CUR_TIME
#else
#define __TIME__ "unknown-time"
#endif /* CUR_TIME */
#endif /* __TIME__ */
#endif /* __STDC__ */
#ifdef sun386
#define PORTAR
#endif
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#undef HUGE
#include <math.h>
#include <signal.h>
#if defined(ultrix) /* { */
#if defined(_SIZE_T_) /* { */
#define ultrix4
#else /* } else { */
#if defined(SIGLOST) /* { */
#define ultrix3
#else /* } else { */
#define ultrix2
#endif /* } */
#endif /* } */
#endif /* } */
#if defined(ultrix3) && defined(mips)
extern double rint();
extern double trunc();
#endif
#if defined(sun) && defined(FD_SETSIZE)
#define sunos4
#else
#define sunos3
#endif
#if defined(sequent) || defined(news800)
#define LACK_SYS5
#endif
#if defined(ultrix3) || defined(sunos4) || defined(_IBMR2)
#define SIGNAL_FN void
#else
/* sequent, ultrix2, 4.3BSD (vax, hp), sunos3 */
#define SIGNAL_FN int
#endif
/* Some systems have 'fixed' certain functions which used to be int */
#if defined(ultrix) || defined(SABER) || defined(hpux) || defined(aiws) || defined(apollo) || defined(__STDC__)
#define VOID_HACK void
#else
#define VOID_HACK int
#endif
/*
* CHARBITS should be defined only if the compiler lacks "unsigned char".
* It should be a mask, e.g. 0377 for an 8-bit machine.
*/
#ifndef CHARBITS
# define UNSCHAR(c) ((unsigned char)(c))
#else
# define UNSCHAR(c) ((c)&CHARBITS)
#endif
#define SIZET int
#ifdef __STDC__
#define CONST const
#define VOIDSTAR void *
#else
#define CONST
#define VOIDSTAR char *
#endif /* __STDC__ */
/* Some machines fail to define some functions in stdio.h */
#if !defined(__STDC__) && !defined(sprite)
extern FILE *popen(), *tmpfile();
extern int pclose();
#ifndef clearerr /* is a macro on many machines, but not all */
extern VOID_HACK clearerr();
#endif /* clearerr */
#ifndef rewind
extern VOID_HACK rewind();
#endif /* rewind */
#endif /* __STDC__ */
/* most machines don't give us a header file for these */
#if defined(__STDC__) || defined(sprite)
#include <stdlib.h>
#else
#ifdef hpux
extern int abort();
extern void free(), exit(), perror();
#else
extern VOID_HACK abort(), free(), exit(), perror();
#endif /* hpux */
extern char *getenv();
#ifdef ultrix4
extern void *malloc(), *realloc(), *calloc();
#else
extern char *malloc(), *realloc(), *calloc();
#endif
#if defined(aiws) || defined(hpux)
extern int sprintf();
#else
extern char *sprintf();
#endif
extern int system();
extern double atof();
extern long atol();
extern int sscanf();
#endif /* __STDC__ */
/* some call it strings.h, some call it string.h; others, also have memory.h */
#if defined(__STDC__) || defined(sprite)
#include <string.h>
#else
/* ANSI C string.h -- 1/11/88 Draft Standard */
#if defined(ultrix4) || defined(hpux)
#include <strings.h>
#else
extern char *strcpy(), *strncpy(), *strcat(), *strncat(), *strerror();
extern char *strpbrk(), *strtok(), *strchr(), *strrchr(), *strstr();
extern int strcoll(), strxfrm(), strncmp(), strlen(), strspn(), strcspn();
extern char *memmove(), *memccpy(), *memchr(), *memcpy(), *memset();
extern int memcmp(), strcmp();
#endif /* ultrix4 */
#endif /* __STDC__ */
#ifdef lint
#undef putc /* correct lint '_flsbuf' bug */
#endif /* lint */
/* a few extras */
#if defined(hpux)
extern VOID_HACK srand();
extern int rand();
#define random() rand()
#define srandom(a) srand(a)
#define bzero(a,b) memset(a, 0, b)
#else
extern VOID_HACK srandom();
extern long random();
#endif
/*
** _std_h is defined in /usr/local/lib/g++-include/std.h
*/
#if ! defined(_std_h)
#if defined(ultrix3) || defined(ultrix4) || defined(hpux)
extern unsigned sleep();
#else
extern VOID_HACK sleep();
#endif
#endif /* _std_h */
/* assertion macro */
#ifndef assert
#if defined(__STDC__) || defined(sprite)
#include <assert.h>
#else
#ifndef NDEBUG
#define assert(ex) {\
if (! (ex)) {\
(void) fprintf(stderr, "Assertion failed: file %s, line %d\n",\
__FILE__, __LINE__);\
(void) fflush(stdout);\
abort();\
}\
}
#else
#define assert(ex) {;}
#endif
#endif
#endif
/* handle the various limits */
#if defined(__STDC__) || defined(POSIX)
#include <limits.h>
#else
#define USHRT_MAX (~ (unsigned short int) 0)
#define UINT_MAX (~ (unsigned int) 0)
#define ULONG_MAX (~ (unsigned long int) 0)
#define SHRT_MAX ((short int) (USHRT_MAX >> 1))
#define INT_MAX ((int) (UINT_MAX >> 1))
#define LONG_MAX ((long int) (ULONG_MAX >> 1))
#endif
#endif
#endif /* PORT_H */
|