Back to index

glibc  2.9
stdfiles.c
Go to the documentation of this file.
00001 /* Copyright (C) 1993-1997,1999,2000,2002,2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.
00018 
00019    As a special exception, if you link the code in this file with
00020    files compiled with a GNU compiler to produce an executable,
00021    that does not cause the resulting executable to be covered by
00022    the GNU Lesser General Public License.  This exception does not
00023    however invalidate any other reasons why the executable file
00024    might be covered by the GNU Lesser General Public License.
00025    This exception applies to code released by its copyright holders
00026    in files containing the exception.  */
00027 
00028 
00029 /* This file provides definitions of _IO_stdin, _IO_stdout, and _IO_stderr
00030    for C code.  Compare stdstreams.cc.
00031    (The difference is that here the vtable field is set to 0,
00032    so the objects defined are not valid C++ objects.  On the other
00033    hand, we don't need a C++ compiler to build this file.) */
00034 
00035 #include "libioP.h"
00036 
00037 #ifdef _IO_MTSAFE_IO
00038 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
00039 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
00040   static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
00041   static struct _IO_wide_data _IO_wide_data_##FD \
00042     = { ._wide_vtable = &_IO_wfile_jumps }; \
00043   struct _IO_FILE_plus NAME \
00044     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
00045        &_IO_file_jumps};
00046 # else
00047 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
00048   static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
00049   struct _IO_FILE_plus NAME \
00050     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
00051        &_IO_file_jumps};
00052 # endif
00053 #else
00054 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
00055 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
00056   static struct _IO_wide_data _IO_wide_data_##FD \
00057     = { ._wide_vtable = &_IO_wfile_jumps }; \
00058   struct _IO_FILE_plus NAME \
00059     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
00060        &_IO_file_jumps};
00061 # else
00062 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
00063   struct _IO_FILE_plus NAME \
00064     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
00065        &_IO_file_jumps};
00066 # endif
00067 #endif
00068 
00069 DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES);
00070 DEF_STDFILE(_IO_2_1_stdout_, 1, &_IO_2_1_stdin_, _IO_NO_READS);
00071 DEF_STDFILE(_IO_2_1_stderr_, 2, &_IO_2_1_stdout_, _IO_NO_READS+_IO_UNBUFFERED);
00072 
00073 struct _IO_FILE_plus *_IO_list_all = &_IO_2_1_stderr_;
00074 INTVARDEF(_IO_list_all)