Fix range error handling in sgetspent.
[glibc.git] / libio / oldstdfiles.c
blob642d59dd05b64003ba4660c9d2df0afa37e47da5
1 /* Copyright (C) 1993,94,96,97,99,2000,2002,2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA.
19 As a special exception, if you link the code in this file with
20 files compiled with a GNU compiler to produce an executable,
21 that does not cause the resulting executable to be covered by
22 the GNU Lesser General Public License. This exception does not
23 however invalidate any other reasons why the executable file
24 might be covered by the GNU Lesser General Public License.
25 This exception applies to code released by its copyright holders
26 in files containing the exception. */
28 #include <shlib-compat.h>
29 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
31 /* This file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr
32 for C code. Compare stdstreams.cc.
33 (The difference is that here the vtable field is set to 0,
34 so the objects defined are not valid C++ objects. On the other
35 hand, we don't need a C++ compiler to build this file.) */
37 #define _IO_USE_OLD_IO_FILE
38 #include "libioP.h"
40 #ifdef _IO_MTSAFE_IO
41 #define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
42 static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
43 struct _IO_FILE_plus NAME \
44 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), &_IO_old_file_jumps};
45 #else
46 #define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
47 struct _IO_FILE_plus NAME \
48 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), &_IO_old_file_jumps};
49 #endif
51 DEF_STDFILE(_IO_stdin_, 0, 0, _IO_NO_WRITES);
52 DEF_STDFILE(_IO_stdout_, 1, &_IO_stdin_, _IO_NO_READS);
53 DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_, _IO_NO_READS+_IO_UNBUFFERED);
55 #if defined __GNUC__ && __GNUC__ >= 2
57 #include <stdio.h>
59 extern const int _IO_stdin_used;
60 weak_extern (_IO_stdin_used);
62 #undef stdin
63 #undef stdout
64 #undef stderr
66 extern FILE *stdin;
67 extern FILE *stdout;
68 extern FILE *stderr;
70 static void _IO_check_libio (void) __THROW __attribute__ ((constructor));
72 /* This function determines which shared C library the application
73 was linked against. We then set up the stdin/stdout/stderr and
74 _IO_list_all accordingly. */
76 static void
77 _IO_check_libio ()
79 if (&_IO_stdin_used == NULL)
81 /* We are using the old one. */
82 _IO_stdin = stdin = (_IO_FILE *) &_IO_stdin_;
83 _IO_stdout = stdout = (_IO_FILE *) &_IO_stdout_;
84 _IO_stderr = stderr = (_IO_FILE *) &_IO_stderr_;
85 INTUSE(_IO_list_all) = &_IO_stderr_;
86 _IO_stdin->_vtable_offset = _IO_stdout->_vtable_offset =
87 _IO_stderr->_vtable_offset = stdin->_vtable_offset =
88 stdout->_vtable_offset = stderr->_vtable_offset =
89 ((int) sizeof (struct _IO_FILE)
90 - (int) sizeof (struct _IO_FILE_complete));
94 #endif
96 #endif