Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/include/stdio.h

  • Property svn:executable set to *
1/*
2 * Copyright (c) 2000, 2005, 2007, 2009, 2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*-
24 * Copyright (c) 1990, 1993
25 *The Regents of the University of California. All rights reserved.
26 *
27 * This code is derived from software contributed to Berkeley by
28 * Chris Torek.
29 *
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
32 * are met:
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 *This product includes software developed by the University of
41 *California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 *@(#)stdio.h8.5 (Berkeley) 4/29/95
59 */
60
61#ifndef_STDIO_H_
62#define_STDIO_H_
63
64#include <sys/cdefs.h>
65#include <Availability.h>
66
67#include <_types.h>
68#include "saio_types.h"
69#include "platform.h"
70
71
72#ifndef _VA_LIST
73#define _VA_LIST
74/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
75 * __gnuc_va_list and include <stdarg.h> */
76typedef __darwin_va_listva_list;
77#endif
78
79#ifndef_SIZE_T
80#define_SIZE_T
81typedef__darwin_size_tsize_t;
82#endif
83
84#ifndef NULL
85#define NULL __DARWIN_NULL
86#endif /* ! NULL */
87
88typedef __darwin_off_tfpos_t;
89
90#define_FSTDIO/* Define for new stdio with functions. */
91
92/*
93 * NB: to fit things in six character monocase externals, the stdio
94 * code uses the prefix `__s' for stdio objects, typically followed
95 * by a three-character attempt at a mnemonic.
96 */
97
98/* stdio buffers */
99struct __sbuf {
100unsigned char*_base;
101int_size;
102};
103
104/* hold a buncha junk that would grow the ABI */
105struct __sFILEX;
106
107/*
108 * stdio state variables.
109 *
110 * The following always hold:
111 *
112 *if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR),
113 *_lbfsize is -_bf._size, else _lbfsize is 0
114 *if _flags&__SRD, _w is 0
115 *if _flags&__SWR, _r is 0
116 *
117 * This ensures that the getc and putc macros (or inline functions) never
118 * try to write or read from a file that is in `read' or `write' mode.
119 * (Moreover, they can, and do, automatically switch from read mode to
120 * write mode, and back, on "r+" and "w+" files.)
121 *
122 * _lbfsize is used only to make the inline line-buffered output stream
123 * code as compact as possible.
124 *
125 * _ub, _up, and _ur are used when ungetc() pushes back more characters
126 * than fit in the current _bf, or when ungetc() pushes back a character
127 * that does not match the previous one in _bf. When this happens,
128 * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff
129 * _ub._base!=NULL) and _up and _ur save the current values of _p and _r.
130 *
131 * NB: see WARNING above before changing the layout of this structure!
132 */
133typedefstruct __sFILE {
134unsigned char *_p;/* current position in (some) buffer */
135int_r;/* read space left for getc() */
136int_w;/* write space left for putc() */
137short_flags;/* flags, below; this FILE is free if 0 */
138short_file;/* fileno, if Unix descriptor, else -1 */
139struct__sbuf _bf;/* the buffer (at least 1 byte, if !NULL) */
140int_lbfsize;/* 0 or -_bf._size, for inline putc */
141
142/* operations */
143void*_cookie;/* cookie passed to io functions */
144int(*_close)(void *);
145int(*_read) (void *, char *, int);
146fpos_t(*_seek) (void *, fpos_t, int);
147int(*_write)(void *, const char *, int);
148
149/* separate buffer for long sequences of ungetc() */
150struct__sbuf _ub;/* ungetc buffer */
151struct __sFILEX *_extra; /* additions to FILE to not break ABI */
152int_ur;/* saved _r when _r is counting ungetc data */
153
154/* tricks to meet minimum requirements even when malloc() fails */
155unsigned char _ubuf[3];/* guarantee an ungetc() buffer */
156unsigned char _nbuf[1];/* guarantee a getc() buffer */
157
158/* separate buffer for fgetln() when line crosses buffer boundary */
159struct__sbuf _lb;/* buffer for fgetln() */
160
161/* Unix stdio files get aligned to block boundaries on fseek() */
162int_blksize;/* stat.st_blksize (may be != _bf._size) */
163fpos_t_offset;/* current lseek offset (see WARNING) */
164} FILE;
165
166
167
168__BEGIN_DECLS
169extern FILE *__stdinp;
170extern FILE *__stdoutp;
171extern FILE *__stderrp;
172__END_DECLS
173
174#define__SLBF0x0001/* line buffered */
175#define__SNBF0x0002/* unbuffered */
176#define__SRD0x0004/* OK to read */
177#define__SWR0x0008/* OK to write */
178/* RD and WR are never simultaneously asserted */
179#define__SRW0x0010/* open for reading & writing */
180#define__SEOF0x0020/* found EOF */
181#define__SERR0x0040/* found error */
182#define__SMBF0x0080/* _buf is from malloc */
183#define__SAPP0x0100/* fdopen()ed in append mode */
184#define__SSTR0x0200/* this is an sprintf/snprintf string */
185#define__SOPT0x0400/* do fseek() optimisation */
186#define__SNPT0x0800/* do not do fseek() optimisation */
187#define__SOFF0x1000/* set iff _offset is in fact correct */
188#define__SMOD0x2000/* true => fgetln modified _p text */
189#define __SALC 0x4000/* allocate string space dynamically */
190#define __SIGN 0x8000/* ignore this file in _fwalk */
191
192/*
193 * The following three definitions are for ANSI C, which took them
194 * from System V, which brilliantly took internal interface macros and
195 * made them official arguments to setvbuf(), without renaming them.
196 * Hence, these ugly _IOxxx names are *supposed* to appear in user code.
197 *
198 * Although numbered as their counterparts above, the implementation
199 * does not rely on this.
200 */
201#define_IOFBF0/* setvbuf should set fully buffered */
202#define_IOLBF1/* setvbuf should set line buffered */
203#define_IONBF2/* setvbuf should set unbuffered */
204
205#defineBUFSIZ1024/* size of buffer used by setbuf */
206#defineEOF(-1)
207
208/* must be == _POSIX_STREAM_MAX <limits.h> */
209#defineFOPEN_MAX20/* must be <= OPEN_MAX <sys/syslimits.h> */
210#defineFILENAME_MAX1024/* must be <= PATH_MAX <sys/syslimits.h> */
211
212/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
213#ifndef _ANSI_SOURCE
214#defineP_tmpdir"/var/tmp/"
215#endif
216#defineL_tmpnam1024/* XXX must be == PATH_MAX */
217#defineTMP_MAX308915776
218
219#ifndef SEEK_SET
220#defineSEEK_SET0/* set file offset to offset */
221#endif
222#ifndef SEEK_CUR
223#defineSEEK_CUR1/* set file offset to current plus offset */
224#endif
225#ifndef SEEK_END
226#defineSEEK_END2/* set file offset to EOF plus offset */
227#endif
228
229#definestdin__stdinp
230#definestdout__stdoutp
231#definestderr__stderrp
232
233#ifdef _DARWIN_UNLIMITED_STREAMS
234#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2
235#error "_DARWIN_UNLIMITED_STREAMS specified, but -miphoneos-version-min version does not support it."
236#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6
237#error "_DARWIN_UNLIMITED_STREAMS specified, but -mmacosx-version-min version does not support it."
238#endif
239#endif
240
241#define STDIN_FILENO0/* standard input file descriptor */
242#defineSTDOUT_FILENO1/* standard output file descriptor */
243#defineSTDERR_FILENO2/* standard error file descriptor */
244
245/* ANSI-C */
246
247__BEGIN_DECLS
248int fclose(FILE *);
249int feof(FILE *);
250int ferror(FILE *);
251int fflush(FILE *);
252int fgetc(FILE *);
253int fgetpos(FILE * __restrict, fpos_t *);
254char *fgets(char * __restrict, int, FILE *);
255FILE*fopen(const char * __restrict, const char * __restrict) ;
256
257int fprintf(FILE * __restrict, const char * __restrict, ...);
258int fputc(int, FILE *);
259
260int fputs(const char * __restrict, FILE * __restrict);
261
262size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
263
264FILE*freopen(const char * __restrict, const char * __restrict,
265 FILE * __restrict);
266FILE*fdopen(int, const char *);
267
268int fscanf(FILE * __restrict, const char * __restrict, ...) __scanflike(2, 3);
269int fseek(FILE *, long, int);
270int fsetpos(FILE *, const fpos_t *);
271long ftell(FILE *);
272size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict) ;
273
274void puts(const char *);
275int ungetc(int , FILE *);
276int ungetchar(int );
277
278extern FILE *stdin;
279extern FILE *stdout;
280extern FILE *stderr;
281int fseeko(FILE *, off_t, int);
282off_t ftello(FILE *);
283int
284vfprintf(FILE *fp, const char *fmt0, va_list ap);
285__END_DECLS
286
287/* Additional functionality provided by:
288 * POSIX.1-1988
289 */
290
291
292/* Additional functionality provided by:
293 * POSIX.1c-1995,
294 * POSIX.1i-1995,
295 * and the omnibus ISO/IEC 9945-1: 1996
296 */
297
298//#if __DARWIN_C_LEVEL >= 199506L
299
300
301#define__sfeof(p)(((p)->_flags & __SEOF) != 0)
302#define__sferror(p)(((p)->_flags & __SERR) != 0)
303#define__sclearerr(p)((void)((p)->_flags &= ~(__SERR|__SEOF)))
304#define__sfileno(p)((p)->_file)
305
306
307
308
309//#endif /* __DARWIN_C_LEVEL >= 199506L */
310
311
312
313/* Additional functionality provided by:
314 * POSIX.1-2001
315 * ISO C99
316 */
317
318#if __DARWIN_C_LEVEL >= 200112L
319#ifndef_OFF_T
320#define_OFF_T
321typedef__darwin_off_toff_t;
322#endif
323#endif /* __DARWIN_C_LEVEL >= 200112L */
324
325/* Additional functionality provided by:
326 * POSIX.1-2008
327 */
328
329#if __DARWIN_C_LEVEL >= 200809L
330#ifndef _SSIZE_T
331#define _SSIZE_T
332typedef __darwin_ssize_t ssize_t;
333#endif
334
335#endif /* __DARWIN_C_LEVEL >= 200809L */
336
337
338
339
340
341
342
343
344#endif /* _STDIO_H_ */
345

Archive Download this file

Revision: 2154