import less(1)
[unleashed/tickless.git] / usr / src / lib / libc / port / stdio / data.c
blobf6a32f243aa69af3c3998b43ccbe392b82b2a4a1
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
32 * Use is subject to license terms.
35 #pragma weak __iob = _iob
37 #include "lint.h"
38 #include "mbstatet.h"
39 #include "mtlib.h"
40 #include "file64.h"
41 #include <stdio.h>
42 #include <thread.h>
43 #include <synch.h>
44 #include "stdiom.h"
45 #include <wchar.h>
48 * Ptrs to start of preallocated buffers for stdin, stdout.
49 * Some slop is allowed at the end of the buffers in case an upset in
50 * the synchronization of _cnt and _ptr (caused by an interrupt or other
51 * signal) is not immediately detected.
54 Uchar _sibuf[BUFSIZ + _SMBFSZ], _sobuf[BUFSIZ + _SMBFSZ];
55 Uchar _smbuf[_NFILE + 1][_SMBFSZ] = {0}; /* shared library compatibility */
58 #define DEFAULTMBSTATE \
59 { 0 }
61 #ifdef _LP64
63 #if _NFILE != 20
64 #error "_iob[] initialization impossible"
65 #endif
67 FILE _iob[_NFILE] = {
68 { NULL, NULL, NULL, 0, 0, _IOREAD, RECURSIVEMUTEX, DEFAULTMBSTATE },
69 { NULL, NULL, NULL, 0, 1, _IOWRT, RECURSIVEMUTEX, DEFAULTMBSTATE },
70 { NULL, NULL, NULL, 0, 2, _IOWRT|_IONBF, RECURSIVEMUTEX,
71 DEFAULTMBSTATE },
72 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
73 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
74 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
75 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
76 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
77 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
78 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
79 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
80 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
81 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
82 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
83 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
84 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
85 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
86 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
87 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE },
88 { NULL, NULL, NULL, 0, 0, 0, RECURSIVEMUTEX, DEFAULTMBSTATE }
91 #else
93 #if _NFILE != 20 && _NFILE != 60
94 #error "_iob[] initialization impossible"
95 #endif
98 * FILEs not in _iob will never reference this table, so we only need _NFILE
99 * entries.
101 struct xFILEdata _xftab[_NFILE] = {
102 XFILEINITIALIZER, XFILEINITIALIZER,
103 { 0, _smbuf[2] + _SBFSIZ, RECURSIVEMUTEX, DEFAULTMBSTATE }, /* stderr */
104 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
105 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
106 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
107 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
108 #if _NFILE == 60
109 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
110 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
111 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
112 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
113 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
114 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
115 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
116 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
117 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
118 XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER, XFILEINITIALIZER,
119 #endif
120 XFILEINITIALIZER };
123 * Ptrs to end of read/write buffers for first _NFILE devices.
124 * There is an extra bufend pointer which corresponds to the dummy
125 * file number _NFILE, which is used by sscanf and sprintf.
126 * Our implementation makes sure it never references _realbufend/_reallock/
127 * etc for *sscanf() and *sprintf(); such use of a shared item would not be
128 * thread safe.
130 Uchar *_bufendtab[_NFILE+1] = { NULL, NULL, _smbuf[2] + _SBFSIZ, };
132 FILE _iob[_NFILE] = {
133 { 0, NULL, NULL, _IOREAD, 0 },
134 { 0, NULL, NULL, _IOWRT, 1 },
135 { 0, NULL, NULL, _IOWRT|_IONBF, 2 },
139 * Ptr to end of io control blocks
141 FILE *_lastbuf = &_iob[_NFILE];
143 #endif /* _LP64 */
146 * Standard in/out/err
148 * For now, they are pointers into _iob[] for backwards compatibility.
150 FILE *__stdinp = &_iob[0];
151 FILE *__stdoutp = &_iob[1];
152 FILE *__stderrp = &_iob[2];