9
proto stdc note{ Standard-C prototypes ok }end compile{
10
extern int foo(int, int);
16
dll import note{ Microsoft import/export nonsense }end execute{
17
__declspec(dllimport) int foo;
18
main() { return foo == 5 ? 0 : 1; }
20
int* _imp__foo = &bar;
23
xopen stdio note{ Stdio fseek/fflush are X/Open-compliant }end execute{
25
#define Failed(file) (unlink(file),1)
26
main(int argc, char** argv)
28
char file[1024], buf[1024], *f, *t;
32
for(f = argv[0], t = file; (*t = *f++) != 0; )
34
*t++ = '.'; *t++ = 'D'; *t++ = 0;
35
if((fd = creat(file,0666)) < 0)
38
for (i = 0; i < sizeof(buf); ++i)
39
buf[i] = '0' + (i%10);
40
for (i = 0; i < 16; ++i)
41
if (write(fd,buf,sizeof(buf)) != sizeof(buf))
45
if(!(f1 = fopen(file,"r+")) ||
46
(fd = dup(fileno(f1))) < 0 ||
47
!(f2 = fdopen(fd,"r+")) )
50
if(fread(buf, 1, 7, f2) != 7 || ftell(f2) != 7)
53
if(fseek(f1, 1010, 0) < 0 || ftell(f1) != 1010)
56
fflush(f2); /* this should set the seek location to 1010 */
67
/* __STD_C indicates that the language is ANSI-C or C++ */
68
#if !defined(__STD_C) && __STDC__
71
#if !defined(__STD_C) && (__cplusplus || c_plusplus)
74
#if !defined(__STD_C) && _proto_stdc
81
/* extern symbols must be protected against C++ name mangling */
82
#ifndef _BEGIN_EXTERNS_
83
#if __cplusplus || c_plusplus
84
#define _BEGIN_EXTERNS_ extern "C" {
85
#define _END_EXTERNS_ }
87
#define _BEGIN_EXTERNS_
90
#endif /*_BEGIN_EXTERNS_*/
92
/* _ARG_ simplifies function prototyping among flavors of C */
101
/* __INLINE__ is the inline keyword */
102
#if !defined(__INLINE__) && defined(__cplusplus)
103
#define __INLINE__ inline
105
#if !defined(__INLINE__) && defined(_WIN32) && !defined(__GNUC__)
106
#define __INLINE__ __inline
109
/* Void_t is defined so that Void_t* can address any type */
118
/* dynamic linked library external scope handling */
120
#if _dll_import && !defined(__EXPORT__) && _DLL_BLD
121
#define __EXPORT__ __declspec(dllexport)
123
#if _dll_import && !defined(__IMPORT__)
124
#define __IMPORT__ __declspec(dllimport)
126
#if !defined(_astimport)
127
#if defined(__IMPORT__) && _DLL_BLD
128
#define _astimport __IMPORT__
130
#define _astimport extern
132
#endif /*_astimport*/
136
#if !_DLL_BLD && _dll_import
137
#define __EXTERN__(T,obj) extern T obj; T* _imp__ ## obj = &obj
138
#define __DEFINE__(T,obj,val) T obj = val; T* _imp__ ## obj = &obj
140
#define __EXTERN__(T,obj) extern T obj
141
#define __DEFINE__(T,obj,val) T obj = val
151
# include <sys/types.h>
155
# define _typ_size_t 1
159
# define _typ_ssize_t 1
164
tst - -DN=0 - -DN=1 - -DN=2 - -DN=3 - -DN=4 - -DN=5 - -DN=6 - -DN=7 - -DN=8 output{
170
#include <sys/types.h>
174
extern int printf _ARG_((const char*, ...));
178
#define _ast_int8_t long
179
#define _ast_int8_str "long"
182
#define _ast_int8_t long long
183
#define _ast_int8_str "long long"
186
#define _ast_int8_t __int64_t
187
#define _ast_int8_str "__int64_t"
190
#define _ast_int8_t _int64_t
191
#define _ast_int8_str "_int64_t"
194
#define _ast_int8_t int64_t
195
#define _ast_int8_str "int64_t"
198
#define _ast_int8_t __int64
199
#define _ast_int8_str "__int64"
202
#define _ast_int8_t _int64
203
#define _ast_int8_str "_int64"
206
#define _ast_int8_t int64
207
#define _ast_int8_str "int64"
210
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
212
static char i_char = 1;
213
static short i_short = 1;
214
static int i_int = 1;
215
static long i_long = 1;
217
static _ast_int8_t i_long_long = 1;
227
"char", sizeof(char), (char*)&i_char,
228
"short", sizeof(short), (char*)&i_short,
229
"int", sizeof(int), (char*)&i_int,
230
"long", sizeof(long), (char*)&i_long,
232
_ast_int8_str, sizeof(_ast_int8_t), (char*)&i_long_long,
242
"float", sizeof(float),
243
"double", sizeof(double),
244
#ifdef _typ_long_double
245
"long double", sizeof(long double),
249
static int int_size[] = { 1, 2, 4, 8 };
260
if (int_type[elementsof(int_type)-1].size <= 4)
263
for (s = 0; s < elementsof(int_size); s++)
265
for (t = 0; t < elementsof(int_type); t++)
266
if(int_type[t].size >= int_size[s])
268
if (t < elementsof(int_type))
271
printf("#define _ast_int%d_t\t\t%s\n",
272
m, int_type[t].name);
275
if (*int_type[t].swap)
281
printf("#define _ast_intmax_t _ast_int%d_t\n", m);
282
if (m == sizeof(long))
283
printf("#define _ast_intmax_long 1\n");
284
printf("#define _ast_intswap %d\n", w);
286
for (t = 0; t < elementsof(flt_type); t++)
288
for(; t < elementsof(flt_type); t++)
289
if(flt_type[t].size != flt_type[t + 1].size)
291
m = flt_type[t].size;
292
printf("#define _ast_flt%d_t\t\t%s\n",
293
flt_type[t].size, flt_type[t].name);
295
printf("#define _ast_fltmax_t _ast_flt%d_t\n", m);
296
if (m == sizeof(double))
297
printf("#define _ast_fltmax_double 1\n");
302
tst - -DTRY=1 - -DTRY=1 -Dvoid=char - -DTRY=2 - -DTRY=3 - -DTRY=4 output{
303
#define printf ______printf
311
extern int printf _ARG_((const char*, ...));
317
printf("\n#ifndef va_listref\n");
318
printf("#define va_listref(p) (&(p))\t");
319
printf("/* pass va_list to varargs function */\n");
320
printf("#define va_listval(p) (*(p))\t");
321
printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
322
printf("#define va_listarg va_list*\t");
323
printf("/* va_arg() va_list type */\n");
335
printf("\n#ifndef va_listref\n");
336
printf("#define va_listref(p) (p)\t");
337
printf("/* pass va_list to varargs function */\n");
338
printf("#define va_listval(p) (p)\t");
339
printf("/* retrieve va_list from va_arg(ap,va_listarg) */\n");
341
printf("#define va_listarg va_list*\t");
343
printf("#define va_listarg va_list\t");
345
printf("/* va_arg() va_list type */\n");
348
#if defined(_WIN32) || !defined(va_copy)
349
printf("#ifndef va_copy\n");
351
printf("#define va_copy(to,fr) memcpy(to,fr,sizeof(va_list))\t");
352
printf("/* copy va_list fr -> to */\n");
354
printf("#define va_copy(to,fr) ((to)=(fr))\t");
355
printf("/* copy va_list fr -> to */\n");
360
printf("#undef _ast_va_list\n");
361
printf("#ifdef va_start\n");
362
printf("#define _ast_va_list va_list\n");
364
#if TRY == 1 || TRY == 2
365
printf("#define _ast_va_list void*\t");
368
if (sizeof(va_list) == sizeof(long))
369
printf("#define _ast_va_list long\t");
370
else if (sizeof(va_list) == sizeof(short))
371
printf("#define _ast_va_list short\t");
373
printf("#define _ast_va_list int\t");
375
printf("#define _ast_va_list ...\t");
378
printf("/* va_list that avoids #include */\n");
379
printf("#endif\n\n");