filename | test/include/stdio.h |
changeset | 185:6755a04c447f |
author | nkeynes |
date | Tue Feb 13 08:34:27 2007 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Add tests for FLOAT and FTRC Comment out user-mode exception test (broken) |
file | annotate | diff | log | raw |
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +00001.2 +++ b/test/include/stdio.h Tue Feb 13 08:34:27 2007 +00001.3 @@ -0,0 +1,313 @@1.4 +/*1.5 + * Copyright (c) 1990 The Regents of the University of California.1.6 + * All rights reserved.1.7 + *1.8 + * Redistribution and use in source and binary forms are permitted1.9 + * provided that the above copyright notice and this paragraph are1.10 + * duplicated in all such forms and that any documentation,1.11 + * advertising materials, and other materials related to such1.12 + * distribution and use acknowledge that the software was developed1.13 + * by the University of California, Berkeley. The name of the1.14 + * University may not be used to endorse or promote products derived1.15 + * from this software without specific prior written permission.1.16 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR1.17 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED1.18 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.1.19 + *1.20 + * @(#)stdio.h 5.3 (Berkeley) 3/15/861.21 + */1.22 +1.23 +/*1.24 + * NB: to fit things in six character monocase externals, the1.25 + * stdio code uses the prefix `__s' for stdio objects, typically1.26 + * followed by a three-character attempt at a mnemonic.1.27 + */1.28 +1.29 +#ifndef _STDIO_H_1.30 +#ifdef __cplusplus1.31 +extern "C" {1.32 +#endif1.33 +#define _STDIO_H_1.34 +1.35 +#include "_ansi.h"1.36 +1.37 +#define _FSTDIO /* ``function stdio'' */1.38 +1.39 +#define __need_size_t1.40 +#include <stddef.h>1.41 +1.42 +#define __need___va_list1.43 +#include <stdarg.h>1.44 +1.45 +/*1.46 + * <sys/reent.h> defines __sFILE, _fpos_t.1.47 + * They must be defined there because struct _reent needs them (and we don't1.48 + * want reent.h to include this file.1.49 + */1.50 +1.51 +#include <sys/reent.h>1.52 +1.53 +typedef _fpos_t fpos_t;1.54 +1.55 +typedef struct __sFILE FILE;1.56 +1.57 +#define __SLBF 0x0001 /* line buffered */1.58 +#define __SNBF 0x0002 /* unbuffered */1.59 +#define __SRD 0x0004 /* OK to read */1.60 +#define __SWR 0x0008 /* OK to write */1.61 + /* RD and WR are never simultaneously asserted */1.62 +#define __SRW 0x0010 /* open for reading & writing */1.63 +#define __SEOF 0x0020 /* found EOF */1.64 +#define __SERR 0x0040 /* found error */1.65 +#define __SMBF 0x0080 /* _buf is from malloc */1.66 +#define __SAPP 0x0100 /* fdopen()ed in append mode - so must write to end */1.67 +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */1.68 +#define __SOPT 0x0400 /* do fseek() optimisation */1.69 +#define __SNPT 0x0800 /* do not do fseek() optimisation */1.70 +#define __SOFF 0x1000 /* set iff _offset is in fact correct */1.71 +#define __SMOD 0x2000 /* true => fgetline modified _p text */1.72 +1.73 +/*1.74 + * The following three definitions are for ANSI C, which took them1.75 + * from System V, which stupidly took internal interface macros and1.76 + * made them official arguments to setvbuf(), without renaming them.1.77 + * Hence, these ugly _IOxxx names are *supposed* to appear in user code.1.78 + *1.79 + * Although these happen to match their counterparts above, the1.80 + * implementation does not rely on that (so these could be renumbered).1.81 + */1.82 +#define _IOFBF 0 /* setvbuf should set fully buffered */1.83 +#define _IOLBF 1 /* setvbuf should set line buffered */1.84 +#define _IONBF 2 /* setvbuf should set unbuffered */1.85 +1.86 +#ifndef NULL1.87 +#define NULL 01.88 +#endif1.89 +1.90 +#define BUFSIZ 10241.91 +#define EOF (-1)1.92 +1.93 +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */1.94 +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */1.95 +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */1.96 +#ifndef __STRICT_ANSI__1.97 +#define P_tmpdir "/tmp"1.98 +#endif1.99 +1.100 +#ifndef SEEK_SET1.101 +#define SEEK_SET 0 /* set file offset to offset */1.102 +#endif1.103 +#ifndef SEEK_CUR1.104 +#define SEEK_CUR 1 /* set file offset to current plus offset */1.105 +#endif1.106 +#ifndef SEEK_END1.107 +#define SEEK_END 2 /* set file offset to EOF plus offset */1.108 +#endif1.109 +1.110 +#define TMP_MAX 261.111 +1.112 +#define stdin (_impure_ptr->_stdin)1.113 +#define stdout (_impure_ptr->_stdout)1.114 +#define stderr (_impure_ptr->_stderr)1.115 +1.116 +#define _stdin_r(x) ((x)->_stdin)1.117 +#define _stdout_r(x) ((x)->_stdout)1.118 +#define _stderr_r(x) ((x)->_stderr)1.119 +1.120 +/*1.121 + * Functions defined in ANSI C standard.1.122 + */1.123 +1.124 +#ifdef __GNUC__1.125 +#define __VALIST __gnuc_va_list1.126 +#else1.127 +#define __VALIST char*1.128 +#endif1.129 +1.130 +#ifndef _REENT_ONLY1.131 +int _EXFUN(remove, (const char *));1.132 +int _EXFUN(rename, (const char *, const char *));1.133 +#endif1.134 +char * _EXFUN(tempnam, (const char *, const char *));1.135 +FILE * _EXFUN(tmpfile, (void));1.136 +char * _EXFUN(tmpnam, (char *));1.137 +int _EXFUN(fclose, (FILE *));1.138 +int _EXFUN(fflush, (FILE *));1.139 +FILE * _EXFUN(freopen, (const char *, const char *, FILE *));1.140 +void _EXFUN(setbuf, (FILE *, char *));1.141 +int _EXFUN(setvbuf, (FILE *, char *, int, size_t));1.142 +int _EXFUN(fprintf, (FILE *, const char *, ...));1.143 +int _EXFUN(fscanf, (FILE *, const char *, ...));1.144 +int _EXFUN(printf, (const char *, ...));1.145 +int _EXFUN(scanf, (const char *, ...));1.146 +int _EXFUN(sscanf, (const char *, const char *, ...));1.147 +int _EXFUN(vfprintf, (FILE *, const char *, __VALIST));1.148 +int _EXFUN(vprintf, (const char *, __VALIST));1.149 +int _EXFUN(vsprintf, (char *, const char *, __VALIST));1.150 +int _EXFUN(vsnprintf, (char *, size_t, const char *, __VALIST));1.151 +int _EXFUN(fgetc, (FILE *));1.152 +char * _EXFUN(fgets, (char *, int, FILE *));1.153 +int _EXFUN(fputc, (int, FILE *));1.154 +int _EXFUN(fputs, (const char *, FILE *));1.155 +int _EXFUN(getc, (FILE *));1.156 +int _EXFUN(getchar, (void));1.157 +char * _EXFUN(gets, (char *));1.158 +int _EXFUN(putc, (int, FILE *));1.159 +int _EXFUN(putchar, (int));1.160 +int _EXFUN(puts, (const char *));1.161 +int _EXFUN(ungetc, (int, FILE *));1.162 +size_t _EXFUN(fread, (_PTR, size_t _size, size_t _n, FILE *));1.163 +size_t _EXFUN(fwrite, (const _PTR , size_t _size, size_t _n, FILE *));1.164 +int _EXFUN(fgetpos, (FILE *, fpos_t *));1.165 +int _EXFUN(fseek, (FILE *, long, int));1.166 +int _EXFUN(fsetpos, (FILE *, const fpos_t *));1.167 +long _EXFUN(ftell, ( FILE *));1.168 +void _EXFUN(rewind, (FILE *));1.169 +void _EXFUN(clearerr, (FILE *));1.170 +int _EXFUN(feof, (FILE *));1.171 +int _EXFUN(ferror, (FILE *));1.172 +void _EXFUN(perror, (const char *));1.173 +#ifndef _REENT_ONLY1.174 +FILE * _EXFUN(fopen, (const char *_name, const char *_type));1.175 +int _EXFUN(sprintf, (char *, const char *, ...));1.176 +int _EXFUN(snprintf, (char *, size_t, const char *, ...));1.177 +#endif1.178 +#ifndef __STRICT_ANSI__1.179 +int _EXFUN(vfiprintf, (FILE *, const char *, __VALIST));1.180 +int _EXFUN(iprintf, (const char *, ...));1.181 +int _EXFUN(fiprintf, (FILE *, const char *, ...));1.182 +int _EXFUN(siprintf, (char *, const char *, ...));1.183 +#endif1.184 +1.185 +/*1.186 + * Routines in POSIX 1003.1.1.187 + */1.188 +1.189 +#ifndef __STRICT_ANSI__1.190 +#ifndef _REENT_ONLY1.191 +FILE * _EXFUN(fdopen, (int, const char *));1.192 +#endif1.193 +int _EXFUN(fileno, (FILE *));1.194 +int _EXFUN(getw, (FILE *));1.195 +int _EXFUN(pclose, (FILE *));1.196 +FILE * _EXFUN(popen, (const char *, const char *));1.197 +int _EXFUN(putw, (int, FILE *));1.198 +void _EXFUN(setbuffer, (FILE *, char *, int));1.199 +int _EXFUN(setlinebuf, (FILE *));1.200 +#endif1.201 +1.202 +/*1.203 + * Recursive versions of the above.1.204 + */1.205 +1.206 +FILE * _EXFUN(_fdopen_r, (struct _reent *, int, const char *));1.207 +FILE * _EXFUN(_fopen_r, (struct _reent *, const char *, const char *));1.208 +int _EXFUN(_getchar_r, (struct _reent *));1.209 +char * _EXFUN(_gets_r, (struct _reent *, char *));1.210 +int _EXFUN(_iprintf_r, (struct _reent *, const char *, ...));1.211 +int _EXFUN(_mkstemp_r, (struct _reent *, char *));1.212 +char * _EXFUN(_mktemp_r, (struct _reent *, char *));1.213 +void _EXFUN(_perror_r, (struct _reent *, const char *));1.214 +int _EXFUN(_printf_r, (struct _reent *, const char *, ...));1.215 +int _EXFUN(_putchar_r, (struct _reent *, int));1.216 +int _EXFUN(_puts_r, (struct _reent *, const char *));1.217 +int _EXFUN(_remove_r, (struct _reent *, const char *));1.218 +int _EXFUN(_rename_r, (struct _reent *,1.219 + const char *_old, const char *_new));1.220 +int _EXFUN(_scanf_r, (struct _reent *, const char *, ...));1.221 +int _EXFUN(_sprintf_r, (struct _reent *, char *, const char *, ...));1.222 +int _EXFUN(_snprintf_r, (struct _reent *, char *, size_t, const char *, ...));1.223 +char * _EXFUN(_tempnam_r, (struct _reent *, const char *, const char *));1.224 +FILE * _EXFUN(_tmpfile_r, (struct _reent *));1.225 +char * _EXFUN(_tmpnam_r, (struct _reent *, char *));1.226 +int _EXFUN(_vfprintf_r, (struct _reent *, FILE *, const char *, __VALIST));1.227 +int _EXFUN(_vprintf_r, (struct _reent *, const char *, __VALIST));1.228 +int _EXFUN(_vsprintf_r, (struct _reent *, char *, const char *, __VALIST));1.229 +int _EXFUN(_vsnprintf_r, (struct _reent *, char *, size_t, const char *, __VALIST));1.230 +1.231 +/*1.232 + * Routines internal to the implementation.1.233 + */1.234 +1.235 +int _EXFUN(__srget, (FILE *));1.236 +int _EXFUN(__swbuf, (int, FILE *));1.237 +1.238 +/*1.239 + * Stdio function-access interface.1.240 + */1.241 +1.242 +#ifndef __STRICT_ANSI__1.243 +FILE *_EXFUN(funopen,(const _PTR _cookie,1.244 + int (*readfn)(_PTR _cookie, char *_buf, int _n),1.245 + int (*writefn)(_PTR _cookie, const char *_buf, int _n),1.246 + fpos_t (*seekfn)(_PTR _cookie, fpos_t _off, int _whence),1.247 + int (*closefn)(_PTR _cookie)));1.248 +1.249 +#define fropen(cookie, fn) funopen(cookie, fn, (int (*)())0, (fpos_t (*)())0, (int (*)())0)1.250 +#define fwopen(cookie, fn) funopen(cookie, (int (*)())0, fn, (fpos_t (*)())0, (int (*)())0)1.251 +#endif1.252 +1.253 +/*1.254 + * The __sfoo macros are here so that we can1.255 + * define function versions in the C library.1.256 + */1.257 +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++))1.258 +#ifdef _never /* __GNUC__ */1.259 +/* If this inline is actually used, then systems using coff debugging1.260 + info get hopelessly confused. 21sept93 rich@cygnus.com. */1.261 +static __inline int __sputc(int _c, FILE *_p) {1.262 + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))1.263 + return (*_p->_p++ = _c);1.264 + else1.265 + return (__swbuf(_c, _p));1.266 +}1.267 +#else1.268 +/*1.269 + * This has been tuned to generate reasonable code on the vax using pcc1.270 + */1.271 +#define __sputc(c, p) \1.272 + (--(p)->_w < 0 ? \1.273 + (p)->_w >= (p)->_lbfsize ? \1.274 + (*(p)->_p = (c)), *(p)->_p != '\n' ? \1.275 + (int)*(p)->_p++ : \1.276 + __swbuf('\n', p) : \1.277 + __swbuf((int)(c), p) : \1.278 + (*(p)->_p = (c), (int)*(p)->_p++))1.279 +#endif1.280 +1.281 +#define __sfeof(p) (((p)->_flags & __SEOF) != 0)1.282 +#define __sferror(p) (((p)->_flags & __SERR) != 0)1.283 +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF)))1.284 +#define __sfileno(p) ((p)->_file)1.285 +1.286 +#define feof(p) __sfeof(p)1.287 +#define ferror(p) __sferror(p)1.288 +#define clearerr(p) __sclearerr(p)1.289 +1.290 +#if 0 /*ndef __STRICT_ANSI__ - FIXME: must initialize stdio first, use fn */1.291 +#define fileno(p) __sfileno(p)1.292 +#endif1.293 +1.294 +#ifndef lint1.295 +#define getc(fp) __sgetc(fp)1.296 +#define putc(x, fp) __sputc(x, fp)1.297 +#endif /* lint */1.298 +1.299 +#define getchar() getc(stdin)1.300 +#define putchar(x) putc(x, stdout)1.301 +1.302 +#ifndef __STRICT_ANSI__1.303 +/* fast always-buffered version, true iff error */1.304 +#define fast_putc(x,p) (--(p)->_w < 0 ? \1.305 + __swbuf((int)(x), p) == EOF : (*(p)->_p = (x), (p)->_p++, 0))1.306 +1.307 +#define L_cuserid 9 /* posix says it goes in stdio.h :( */1.308 +#ifdef __CYGWIN32__1.309 +#define L_ctermid 161.310 +#endif1.311 +#endif1.312 +1.313 +#ifdef __cplusplus1.314 +}1.315 +#endif1.316 +#endif /* _STDIO_H_ */
.