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
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
/* 
|| This file is part of Pike. For copyright information see COPYRIGHT. 
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING 
|| for more information. 
|| $Id$ 
*/ 
 
#ifndef GLOBAL_H 
#define GLOBAL_H 
 
#if defined(__WINNT__) && !defined(__NT__) 
#define __NT__ 
#endif 
 
#ifndef _LARGEFILE_SOURCE 
#  define _FILE_OFFSET_BITS 64 
#  define _LARGEFILE_SOURCE 
#  define _LARGEFILE64_SOURCE 1 
#endif 
 
/* HPUX needs these too... */ 
#ifndef __STDC_EXT__ 
#  define __STDC_EXT__ 
#endif /* !__STDC_EXT__ */ 
#ifndef _PROTOTYPES 
#  define _PROTOTYPES 
#endif /* !_PROTOTYPES */ 
 
/* 
 * Some structure forward declarations are needed. 
 */ 
 
/* This is needed for linux */ 
#ifdef MALLOC_REPLACED 
#define NO_FIX_MALLOC 
#endif 
 
#ifndef STRUCT_PROGRAM_DECLARED 
#define STRUCT_PROGRAM_DECLARED 
struct program; 
#endif 
 
struct function; 
#ifndef STRUCT_SVALUE_DECLARED 
#define STRUCT_SVALUE_DECLARED 
struct svalue; 
#endif 
struct sockaddr; 
struct object; 
struct array; 
struct svalue; 
 
#ifndef STRUCT_TIMEVAL_DECLARED 
#define STRUCT_TIMEVAL_DECLARED 
struct timeval; 
#endif 
 
#include "machine.h" 
 
/* 
 * Max number of local variables in a function. 
 * Currently there is no support for more than 256 
 */ 
#define MAX_LOCAL     256 
 
/* 
 * define NO_GC to get rid of garbage collection 
 */ 
#ifndef NO_GC 
#define GC2 
#endif 
 
#if defined(i386) 
#ifndef HANDLES_UNALIGNED_MEMORY_ACCESS 
#define HANDLES_UNALIGNED_MEMORY_ACCESS 
#endif 
#endif 
 
/* AIX requires this to be the first thing in the file.  */ 
#if HAVE_ALLOCA_H 
# include <alloca.h> 
# ifdef __GNUC__ 
#  ifdef alloca 
#   undef alloca 
#  endif 
#  define alloca __builtin_alloca 
# endif  
#else 
# ifdef __GNUC__ 
#  ifdef alloca 
#   undef alloca 
#  endif 
#  define alloca __builtin_alloca 
# else 
#  ifdef _AIX 
 #pragma alloca 
#  else 
#   ifndef alloca /* predefined by HP cc +Olibcalls */ 
void *alloca(); 
#   endif 
#  endif 
# endif 
#endif 
 
#ifdef __NT__ 
/* We are running NT */ 
#define FD_SETSIZE MAX_OPEN_FILEDESCRIPTORS 
#endif 
 
#include <stdio.h> 
 
#ifdef HAVE_STDLIB_H 
#include <stdlib.h> 
#undef HAVE_STDLIB_H 
#endif 
 
#ifdef HAVE_STDDEF_H 
#include <stddef.h> 
#undef HAVE_STDDEF_H 
#endif 
 
#ifdef HAVE_MALLOC_H 
#if !defined(__FreeBSD__) 
/* FreeBSD has <malloc.h>, but it just contains a warning... */ 
#include <malloc.h> 
#endif /* !__FreeBSD__ */ 
#undef HAVE_MALLOC_H 
#endif 
 
#ifdef HAVE_UNISTD_H 
#include <unistd.h> 
#undef HAVE_UNISTD_H 
#endif 
 
#ifdef HAVE_STRING_H 
#include <string.h> 
#undef HAVE_STRING_H 
#endif 
 
#ifdef HAVE_LIMITS_H 
#include <limits.h> 
#undef HAVE_LIMITS_H 
#endif 
 
#ifdef HAVE_SYS_TYPES_H 
#include <sys/types.h> 
#undef HAVE_SYS_TYPES_H 
#endif 
 
#ifdef HAVE_MEMORY_H 
#include <memory.h> 
#undef HAVE_MEMORY_H 
#endif 
 
#ifdef HAVE_WINDOWS_H 
#include <windows.h> 
#undef HAVE_WINDOWS_H 
#endif 
 
 
/* we here define a few types with more defined values */ 
 
#if SIZEOF_LONG >= 8 
#define INT64 long 
#define SIZEOF_INT64 SIZEOF_LONG 
#elif SIZEOF___INT64 - 0 >= 8 
#define INT64 __int64 
#define SIZEOF_INT64 SIZEOF___INT64 
#elif SIZEOF_LONG_LONG - 0 >= 8 
#define INT64 long long 
#define SIZEOF_INT64 SIZEOF_LONG_LONG 
#endif 
 
#if SIZEOF_SHORT >= 4 
#define INT32 short 
#else 
#if SIZEOF_INT >= 4 
#define INT32 int 
#else 
#define INT32 long 
#endif 
#endif 
 
#define MAX_INT32 2147483647 
#define MIN_INT32 (-2147483647-1) 
 
#if defined (WITH_SHORT_INT) 
 
#define MAX_INT_TYPE  SHRT_MAX 
#define MIN_INT_TYPE        SHRT_MIN 
#define PRINTPIKEINT        "h" 
 
#elif defined (WITH_INT_INT) 
 
#define MAX_INT_TYPE  INT_MAX 
#define MIN_INT_TYPE        INT_MIN 
#define PRINTPIKEINT        "" 
 
#elif defined (WITH_LONG_INT) 
 
#define MAX_INT_TYPE  LONG_MAX 
#define MIN_INT_TYPE        LONG_MIN 
#define PRINTPIKEINT        "l" 
 
#elif defined (WITH_LONG_LONG_INT) 
 
#ifdef LLONG_MAX 
#define MAX_INT_TYPE        LLONG_MAX 
#define MIN_INT_TYPE        LLONG_MIN 
#else 
#define MAX_INT_TYPE        LONG_LONG_MAX 
#define MIN_INT_TYPE        LONG_LONG_MIN 
#endif 
#define PRINTPIKEINT        "ll" 
 
#endif 
 
#if SIZEOF_INT_TYPE - 0 == 0 
#error Unsupported type chosen for native pike integers. 
#endif 
 
#if defined (WITH_LONG_DOUBLE_PRECISION_SVALUE) 
#define PRINTPIKEFLOAT      "L" 
#elif defined (WITH_DOUBLE_PRECISION_SVALUE) 
#define PRINTPIKEFLOAT      "" 
#else 
#define PRINTPIKEFLOAT      "" 
#endif 
 
#if SIZEOF_FLOAT_TYPE - 0 == 0 
#error Unsupported type chosen for pike floats. 
#endif 
 
#define INT16 short 
#define INT8 char 
 
#ifdef INT64 
#define LONGEST INT64 
#define SIZEOF_LONGEST SIZEOF_INT64 
#else 
#define LONGEST INT32 
#define SIZEOF_LONGEST 4 
#endif 
 
#define SIZE_T unsigned INT32 
 
#define TYPE_T unsigned INT8 
#define TYPE_FIELD unsigned INT16 
 
#define B1_T char 
 
#if SIZEOF_SHORT == 2 
#define B2_T short 
#elif SIZEOF_INT == 2 
#define B2_T int 
#endif 
 
#if SIZEOF_SHORT == 4 
#define B4_T short 
#elif SIZEOF_INT == 4 
#define B4_T int 
#elif SIZEOF_LONG == 4 
#define B4_T long 
#endif 
 
#if SIZEOF_INT == 8 
#define B8_T int 
#elif SIZEOF_LONG == 8 
#define B8_T long 
#elif (SIZEOF_LONG_LONG - 0) == 8 
#define B8_T long long 
#elif (SIZEOF___INT64 - 0) == 8 
#define B8_T __int64 
#elif SIZEOF_CHAR_P == 8 
#define B8_T char * 
#elif defined(B4_T) 
struct b8_t_s { B4_T x,y; }; 
#define B8_T struct b8_t_s 
#endif 
 
#if defined(B8_T) 
struct b16_t_s { B8_T x,y; }; 
#define B16_T struct b16_t_s 
#endif 
 
typedef unsigned char p_wchar0; 
typedef unsigned INT16 p_wchar1; 
typedef unsigned INT32 p_wchar2; 
 
typedef struct p_wchar_p 
{ 
  p_wchar0 *ptr; 
  int shift; 
} PCHARP; 
 
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 
#define RCSID(X) \ 
 static char *rcsid __attribute__ ((unused)) =X 
#elif __GNUC__ == 2 
#define RCSID(X) \ 
 static char *rcsid = X; \ 
 static void *use_rcsid=(&use_rcsid, (void *)&rcsid) 
#else 
#define RCSID(X) \ 
 static char *rcsid = X 
#endif 
 
#ifdef PIKE_DEBUG 
#define DO_IF_DEBUG(X) X 
#else 
#define DO_IF_DEBUG(X) 
#define NDEBUG 
#endif 
 
#ifdef INTERNAL_PROFILING 
#define DO_IF_INTERNAL_PROFILING(X) X 
#else 
#define DO_IF_INTERNAL_PROFILING(X) 
#endif 
 
#if defined(__GNUC__) && !defined(PIKE_DEBUG) && !defined(lint) 
#define INLINE inline 
#else 
#define INLINE 
#endif 
 
/* PMOD_EXPORT exports a function / variable vfsh.  
 * Putting PMOD_PROTO in front of a prototype does nothing. 
 */ 
#ifndef PMOD_EXPORT 
#if defined(__NT__) && !defined(DYNAMIC_MODULE) 
/* #define PMOD_EXPORT __declspec(dllexport) */ 
#define PMOD_EXPORT 
#else 
#define PMOD_EXPORT 
#endif 
#endif 
 
 
/* PMOD_PROTO is essentially the same as PMOD_EXPORT, but 
 * it exports the identifier even if it only a prototype. 
 */ 
#ifndef PMOD_PROTO 
#define PMOD_PROTO 
#endif 
 
#if defined(PURIFY) || defined(__CHECKER__) ||                                \ 
  defined(DEBUG_MALLOC) || defined(USE_VALGRIND) 
#define DO_PIKE_CLEANUP 
#endif 
 
#ifdef PIKE_SECURITY 
#define DO_IF_SECURITY(X) X 
#else 
#define DO_IF_SECURITY(X) 
#endif 
 
/* Used by the AutoBuild system to mark known warnings. */ 
#define DO_NOT_WARN(X)        (X) 
 
/* Some functions/macros used to avoid loss of precision warnings. */ 
#ifdef __ECL 
static inline long PTRDIFF_T_TO_LONG(ptrdiff_t x) 
{ 
  return DO_NOT_WARN((long)x); 
} 
#else /* !__ECL */ 
#define PTRDIFF_T_TO_LONG(x)       ((long)(x)) 
#endif /* __ECL */ 
 
#include "port.h" 
#include "dmalloc.h" 
#include "pike_cpulib.h" 
 
#ifdef BUFSIZ 
#define PROT_STDIO(x) PROT(x) 
#else 
#define PROT_STDIO(x) () 
#endif 
 
#ifdef __STDC__ 
#define PROT(x) x 
#else 
#define PROT(x) () 
#endif 
 
#ifdef MALLOC_DECL_MISSING 
char *malloc PROT((int)); 
char *realloc PROT((char *,int)); 
void free PROT((char *)); 
char *calloc PROT((int,int)); 
#endif 
 
#ifdef GETPEERNAME_DECL_MISSING 
int getpeername PROT((int, struct sockaddr *, int *)); 
#endif 
 
#ifdef GETHOSTNAME_DECL_MISSING 
void gethostname PROT((char *,int)); 
#endif 
 
#ifdef POPEN_DECL_MISSING 
FILE *popen PROT((char *,char *)); 
#endif 
 
#ifdef GETENV_DECL_MISSING 
char *getenv PROT((char *)); 
#endif 
 
#ifdef USE_CRYPT_C 
char *crypt(char *, char *); 
#endif /* USE_CRYPT_C */ 
 
/* If this define is present, error() has been renamed to Pike_error() and 
 * error.h has been renamed to pike_error.h 
 * Expect to see other similar defines in the future. -Hubbe 
 */ 
#define Pike_error_present 
 
/* Compatibility... */ 
#define USE_PIKE_TYPE 2 
 
#ifdef PIKE_RUN_UNLOCKED 
#define DO_IF_RUN_UNLOCKED(X) X 
#else 
#define DO_IF_RUN_UNLOCKED(X) 
#endif 
 
/* Used in more than one place, better put it here */ 
 
#if defined(PROFILING) && defined(HAVE_GETHRTIME) 
#define DO_IF_PROFILING(X) X 
#else 
#define DO_IF_PROFILING(X) 
#endif 
 
 
 
#endif