9
mac SF_CLOSE sys/socket.h
10
mac SF_APPEND sys/stat.h
12
proto stdc note{ Standard-C prototypes ok }end compile{
13
extern int foo(int, int);
19
dll import note{ Microsoft import/export nonsense }end execute{
20
__declspec(dllimport) int foo;
21
main() { return foo == 5 ? 0 : 1; }
23
int* _imp__foo = &bar;
26
xopen stdio note{ Stdio fseek/fflush are X/Open-compliant }end execute{
28
#define Failed(file) (unlink(file),1)
29
main(int argc, char** argv)
31
char file[1024], buf[1024], *f, *t;
35
for(f = argv[0], t = file; (*t = *f++) != 0; )
37
*t++ = '.'; *t++ = 'D'; *t++ = 0;
38
if((fd = creat(file,0666)) < 0)
41
for (i = 0; i < sizeof(buf); ++i)
42
buf[i] = '0' + (i%10);
43
for (i = 0; i < 16; ++i)
44
if (write(fd,buf,sizeof(buf)) != sizeof(buf))
48
if(!(f1 = fopen(file,"r+")) ||
49
(fd = dup(fileno(f1))) < 0 ||
50
!(f2 = fdopen(fd,"r+")) )
53
if(fread(buf, 1, 7, f2) != 7 || ftell(f2) != 7)
56
if(fseek(f1, 1010, 0) < 0 || ftell(f1) != 1010)
59
fflush(f2); /* this should set the seek location to 1010 */
70
/* __STD_C indicates that the language is ANSI-C or C++ */
71
#if !defined(__STD_C) && __STDC__
74
#if !defined(__STD_C) && (__cplusplus || c_plusplus)
77
#if !defined(__STD_C) && _proto_stdc
84
/* extern symbols must be protected against C++ name mangling */
85
#ifndef _BEGIN_EXTERNS_
86
#if __cplusplus || c_plusplus
87
#define _BEGIN_EXTERNS_ extern "C" {
88
#define _END_EXTERNS_ }
90
#define _BEGIN_EXTERNS_
93
#endif /*_BEGIN_EXTERNS_*/
95
/* _ARG_ simplifies function prototyping among flavors of C */
104
/* __INLINE__ is the inline keyword */
105
#if !defined(__INLINE__) && defined(__cplusplus)
106
#define __INLINE__ inline
108
#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
109
#define __INLINE__ __inline
112
/* Void_t is defined so that Void_t* can address any type */
121
/* dynamic linked library external scope handling */
123
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
124
#define __EXPORT__ __declspec(dllexport)
126
#if _dll_import && !defined(__IMPORT__)
127
#define __IMPORT__ __declspec(dllimport)
129
#if !defined(_astimport)
130
#if defined(__IMPORT__) && _DLL_BLD
131
#define _astimport __IMPORT__
133
#define _astimport extern
135
#endif /*_astimport*/
139
#if !_DLL_BLD && _dll_import
140
#define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
141
#define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
143
#define __EXTERN__(T,obj) extern T obj
144
#define __DEFINE__(T,obj,val) T obj = val
154
# include <sys/types.h>
158
# define _typ_size_t 1
162
# define _typ_ssize_t 1
167
tst - -DN=0 - -DN=1 - -DN=2 - -DN=3 - -DN=4 - -DN=5 - -DN=6 - -DN=7 - -DN=8 output{
173
#include <sys/types.h>
177
extern int printf _ARG_((const char*, ...));
181
#define _ast_int8_t long
182
#define _ast_int8_str "long"
185
#define _ast_int8_t long long
186
#define _ast_int8_str "long long"
189
#define _ast_int8_t __int64_t
190
#define _ast_int8_str "__int64_t"
193
#define _ast_int8_t _int64_t
194
#define _ast_int8_str "_int64_t"
197
#define _ast_int8_t int64_t
198
#define _ast_int8_str "int64_t"
201
#define _ast_int8_t __int64
202
#define _ast_int8_str "__int64"
205
#define _ast_int8_t _int64
206
#define _ast_int8_str "_int64"
209
#define _ast_int8_t int64
210
#define _ast_int8_str "int64"
213
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
215
static char i_char = 1;
216
static short i_short = 1;
217
static int i_int = 1;
218
static long i_long = 1;
220
static _ast_int8_t i_long_long = 1;
230
"char", sizeof(char), (char*)&i_char,
231
"short", sizeof(short), (char*)&i_short,
232
"int", sizeof(int), (char*)&i_int,
233
"long", sizeof(long), (char*)&i_long,
235
_ast_int8_str, sizeof(_ast_int8_t), (char*)&i_long_long,
245
"float", sizeof(float),
246
"double", sizeof(double),
247
#ifdef _typ_long_double
248
"long double", sizeof(long double),
252
static int int_size[] = { 1, 2, 4, 8 };
263
if (int_type[elementsof(int_type)-1].size <= 4)
266
for (s = 0; s < elementsof(int_size); s++)
268
for (t = 0; t < elementsof(int_type); t++)
269
if(int_type[t].size >= int_size[s])
271
if (t < elementsof(int_type))
274
printf("#define _ast_int%d_t\t\t%s\n",
275
m, int_type[t].name);
278
if (*int_type[t].swap)
284
printf("#define _ast_intmax_t _ast_int%d_t\n", m);
285
if (m == sizeof(long))
286
printf("#define _ast_intmax_long 1\n");
287
printf("#define _ast_intswap %d\n", w);
289
for (t = 0; t < elementsof(flt_type); t++)
291
for(; t < elementsof(flt_type); t++)
292
if(flt_type[t].size != flt_type[t + 1].size)
294
m = flt_type[t].size;
295
printf("#define _ast_flt%d_t\t\t%s\n",
296
flt_type[t].size, flt_type[t].name);
298
printf("#define _ast_fltmax_t _ast_flt%d_t\n", m);
299
if (m == sizeof(double))
300
printf("#define _ast_fltmax_double 1\n");
305
tst - -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{
306
#define printf ______printf
314
extern int printf _ARG_((const char*, ...));
320
printf("\n#ifndef va_listref\n");
321
printf("#define va_listref(p) (&(p))\t");
322
printf("/* pass va_list to varargs function */\n");
323
printf("#define va_listval(p) (*(p))\t");
324
printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
325
printf("#define va_listarg va_list*\t");
326
printf("/* va_arg() va_list type */\n");
338
printf("\n#ifndef va_listref\n");
339
printf("#define va_listref(p) (p)\t");
340
printf("/* pass va_list to varargs function */\n");
341
printf("#define va_listval(p) (p)\t");
342
printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
344
printf("#define va_listarg va_list*\t");
346
printf("#define va_listarg va_list\t");
348
printf("/* va_arg() va_list type */\n");
351
#if defined(_WIN32) || !defined(va_copy)
353
printf("#define va_copy(to,fr) memcpy(to,fr,sizeof(va_list))\t");
354
printf("/* copy va_list fr -> to */\n");
356
printf("#define va_copy(to,fr) ((to)=(fr))\t");
357
printf("/* copy va_list fr -> to */\n");
361
printf("#undef _ast_va_list\n");
362
printf("#ifdef va_start\n");
363
printf("#define _ast_va_list va_list\n");
365
#if TRY == 1 || TRY == 2
366
printf("#define _ast_va_list void*\t");
369
if (sizeof(va_list) == sizeof(long))
370
printf("#define _ast_va_list long\t");
371
else if (sizeof(va_list) == sizeof(short))
372
printf("#define _ast_va_list short\t");
374
printf("#define _ast_va_list int\t");
376
printf("#define _ast_va_list ...\t");
379
printf("/* va_list that avoids #include */\n");
380
printf("#endif\n\n");