Update.
[glibc.git] / libio / stdfiles.c
blob02f7deaffceb6e945e031821ebd7a6dcd0205b84
1 /* Copyright (C) 1993-1997,1999,2000,2002,2003 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. */
29 /* This file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr
30 for C code. Compare stdstreams.cc.
31 (The difference is that here the vtable field is set to 0,
32 so the objects defined are not valid C++ objects. On the other
33 hand, we don't need a C++ compiler to build this file.) */
35 #include "libioP.h"
37 #ifdef _IO_MTSAFE_IO
38 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
39 # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
40 static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
41 static struct _IO_wide_data _IO_wide_data_##FD \
42 = { ._wide_vtable = &_IO_wfile_jumps }; \
43 struct _IO_FILE_plus NAME \
44 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
45 &_IO_file_jumps};
46 # else
47 # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
48 static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
49 struct _IO_FILE_plus NAME \
50 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
51 &_IO_file_jumps};
52 # endif
53 #else
54 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
55 # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
56 static struct _IO_wide_data _IO_wide_data_##FD \
57 = { ._wide_vtable = &_IO_wfile_jumps }; \
58 struct _IO_FILE_plus NAME \
59 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
60 &_IO_file_jumps};
61 # else
62 # define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
63 struct _IO_FILE_plus NAME \
64 = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
65 &_IO_file_jumps};
66 # endif
67 #endif
69 DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES);
70 DEF_STDFILE(_IO_2_1_stdout_, 1, &_IO_2_1_stdin_, _IO_NO_READS);
71 DEF_STDFILE(_IO_2_1_stderr_, 2, &_IO_2_1_stdout_, _IO_NO_READS+_IO_UNBUFFERED);
73 struct _IO_FILE_plus *_IO_list_all = &_IO_2_1_stderr_;
74 INTVARDEF(_IO_list_all)