1
################################################################
2
## Need to hide certain names such as _doprnt, _doscan
3
################################################################
5
#pragma weak note{ compile system supports symbol transform }end link{
6
# main() { return _xyz(); }
7
# #pragma weak _xyz = __xyz
12
################################################################
13
## To emulate old-style stdio at binary level
14
################################################################
18
main() { printf("#define _siz_fpos_t %d\n", sizeof(fpos_t)); exit(0); }
21
FILE _cnt note{ field FILE.__cnt exists }end compile{
23
main() { return (stdin->__cnt == 0) ? 0 : -1; }
25
FILE _ptr note{ field FILE.__ptr exists }end compile{
27
main() { return (stdin->__ptr == 0) ? 0 : -1; }
29
FILE _file note{ field FILE.__file exists }end compile{
31
main() { return (stdin->__file == 0) ? 0 : -1; }
33
FILE _flag note{ field FILE.__flag exists }end compile{
35
main() { return (stdin->__flag == 0) ? 0 : -1; }
38
FILE cnt note{ field FILE._cnt exists }end compile{
40
main() { return (stdin->_cnt == 0) ? 0 : -1; }
42
FILE ptr note{ field FILE._ptr exists }end compile{
44
main() { return (stdin->_ptr == 0) ? 0 : -1; }
46
FILE file note{ field FILE._file exists }end compile{
48
main() { return (stdin->_file == 0) ? 0 : -1; }
50
FILE flag note{ field FILE._flag exists }end compile{
52
main() { return (stdin->_flag == 0) ? 0 : -1; }
54
FILE flags note{ field FILE._flags exists }end compile{
56
main() { return (stdin->_flags == 0) ? 0 : -1; }
60
#if _FILE__cnt && ! _FILE_cnt
64
#if _FILE__ptr && ! _FILE_ptr
68
#if _FILE__flag && ! _FILE_flag
72
#if _FILE__file && ! _FILE_file
78
############################################################################
79
# To emulate Linux-stdio at binary level
80
############################################################################
81
FILE readptr note{ fields FILE._IO_read_ptr/end exist }end execute{
84
{ if(sizeof(stdin->_IO_read_ptr) != sizeof(char*) ) return 1;
85
if(sizeof(stdin->_IO_read_end) != sizeof(char*) ) return 1;
89
FILE writeptr note{ fields FILE._IO_write_ptr/end exist }end execute{
92
{ if(sizeof(stdin->_IO_write_ptr) != sizeof(char*) ) return 1;
93
if(sizeof(stdin->_IO_write_end) != sizeof(char*) ) return 1;
97
FILE flags note{ field FILE._flags exists }end compile{
100
{ return stdin->_flags == 0 ? 1 : 0;
103
FILE fileno note{ field FILE._fileno exists }end compile{
106
{ return stdin->_fileno == 0 ? 1 : 0;
109
u flow note{ uflow() does bump buffer }end execute{
112
main(int argc, char** argv)
120
sprintf(file,"%s.D",argv[0]);
121
if(!(f = fopen(file,"w+")) )
125
fputs("123456789",f);
127
if(__uflow(f) == EOF)
129
if(*f->_IO_read_ptr == '1')
134
under flow note{ underflow() does not bump buffer }end execute{
137
main(int argc, char** argv)
145
sprintf(file,"%s.D",argv[0]);
146
if(!(f = fopen(file,"w+")) )
150
fputs("123456789",f);
152
if(__underflow(f) == EOF)
154
if(*f->_IO_read_ptr == '1')
160
######################################################################
161
# To emulate BSD-style stdio
162
######################################################################
163
FILE p note{ FILE._p field }end compile{
165
main() { return stdin->_p == 0 ? 0 : 1; }
167
FILE r note{ FILE._r field }end compile{
169
main() { return stdin->_r == 0 ? 0 : 1; }
171
FILE w note{ FILE._w field }end compile{
173
main() { return stdout->_w == 0 ? 0 : 1; }
186
lib clearerr_unlocked
205
# detect microsoft dll declaration of _iob
207
msft iob note{ microsoft's oddity }end compile{
210
_CRTIMP extern FILE * __cdecl __p__iob(void);
211
FILE* foo() { return &(_iob[0]); }
217
dat _iob,__iob stdio.h
218
native iob note{ ok to use stdio's _iob }end compile{
219
#define _doprnt _____doprnt
220
#define _doscan _____doscan
221
#define fclose ____fclose
222
#define fdopen ____fdopen
223
#define fflush ____fflush
224
#define fgetc ____fgetc
225
#define fgets ____fgets
226
#define _filbuf _____filbuf
227
#define _flsbuf _____flsbuf
228
#define _cleanup _____cleanup
229
#define fopen ____fopen
230
#define fprintf ____fprintf
231
#define fputc ____fputc
232
#define fputs ____fputs
233
#define fread ____fread
234
#define freopen ____freopen
235
#define fscanf ____fscanf
236
#define fseek ____fseek
237
#define ftell ____ftell
238
#define fgetpos ____fgetpos
239
#define fsetpos ____fsetpos
240
#define fpurge ____fpurge
241
#define fwrite ____fwrite
242
#define gets ____gets
243
#define getw ____getw
244
#define pclose ____pclose
245
#define popen ____popen
246
#define printf ____printf
247
#define puts ____puts
248
#define putw ____putw
249
#define rewind ____rewind
250
#define scanf ____scanf
251
#define setbuf ____setbuf
252
#define setbuffer ____setbuffer
253
#define setlinebuf ____setlinebuf
254
#define setvbuf ____setvbuf
255
#define sprintf ____sprintf
256
#define sscanf ____sscanf
257
#define tmpfile ____tmpfile
258
#define ungetc ____ungetc
259
#define vfprintf ____vfprintf
260
#define vfscanf ____vfscanf
261
#define vprintf ____vprintf
262
#define vscanf ____vscanf
263
#define vsprintf ____vsprintf
264
#define vsscanf ____vsscanf
265
#define flockfile ____flockfile
266
#define funlockfile ____funlockfile
267
#define ftrylockfile ____ftrylockfile
272
#if defined(_dat_iob) && !defined(IOB)
275
#if defined(_dat__iob) && !defined(IOB)
278
#if defined(_dat___iob) && !defined(IOB)
282
static void* addr() { return((void*)IOB); }
283
int main() { addr(); exit(0); }
382
void funlockfile() {}
383
void ftrylockfile() {}