1 //===------------------------ iostream.cpp --------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "__std_stream"
14 _LIBCPP_BEGIN_NAMESPACE_STD
16 static mbstate_t state_types
[6] = {};
18 _ALIGNAS_TYPE (__stdinbuf
<char> ) static char __cin
[sizeof(__stdinbuf
<char>)];
19 _ALIGNAS_TYPE (__stdoutbuf
<char>) static char __cout
[sizeof(__stdoutbuf
<char>)];
20 _ALIGNAS_TYPE (__stdoutbuf
<char>) static char __cerr
[sizeof(__stdoutbuf
<char>)];
21 _ALIGNAS_TYPE (__stdinbuf
<wchar_t> ) static char __wcin
[sizeof(__stdinbuf
<wchar_t>)];
22 _ALIGNAS_TYPE (__stdoutbuf
<wchar_t>) static char __wcout
[sizeof(__stdoutbuf
<wchar_t>)];
23 _ALIGNAS_TYPE (__stdoutbuf
<wchar_t>) static char __wcerr
[sizeof(__stdoutbuf
<wchar_t>)];
25 _ALIGNAS_TYPE (istream
) _LIBCPP_FUNC_VIS
char cin
[sizeof(istream
)];
26 _ALIGNAS_TYPE (ostream
) _LIBCPP_FUNC_VIS
char cout
[sizeof(ostream
)];
27 _ALIGNAS_TYPE (ostream
) _LIBCPP_FUNC_VIS
char cerr
[sizeof(ostream
)];
28 _ALIGNAS_TYPE (ostream
) _LIBCPP_FUNC_VIS
char clog
[sizeof(ostream
)];
29 _ALIGNAS_TYPE (wistream
) _LIBCPP_FUNC_VIS
char wcin
[sizeof(wistream
)];
30 _ALIGNAS_TYPE (wostream
) _LIBCPP_FUNC_VIS
char wcout
[sizeof(wostream
)];
31 _ALIGNAS_TYPE (wostream
) _LIBCPP_FUNC_VIS
char wcerr
[sizeof(wostream
)];
32 _ALIGNAS_TYPE (wostream
) _LIBCPP_FUNC_VIS
char wclog
[sizeof(wostream
)];
34 ios_base::Init __start_std_streams
;
36 ios_base::Init::Init()
38 istream
* cin_ptr
= ::new(cin
) istream(::new(__cin
) __stdinbuf
<char>(stdin
, state_types
+0) );
39 ostream
* cout_ptr
= ::new(cout
) ostream(::new(__cout
) __stdoutbuf
<char>(stdout
, state_types
+1));
40 ostream
* cerr_ptr
= ::new(cerr
) ostream(::new(__cerr
) __stdoutbuf
<char>(stderr
, state_types
+2));
41 ::new(clog
) ostream(cerr_ptr
->rdbuf());
42 cin_ptr
->tie(cout_ptr
);
43 _VSTD::unitbuf(*cerr_ptr
);
44 cerr_ptr
->tie(cout_ptr
);
46 wistream
* wcin_ptr
= ::new(wcin
) wistream(::new(__wcin
) __stdinbuf
<wchar_t>(stdin
, state_types
+3) );
47 wostream
* wcout_ptr
= ::new(wcout
) wostream(::new(__wcout
) __stdoutbuf
<wchar_t>(stdout
, state_types
+4));
48 wostream
* wcerr_ptr
= ::new(wcerr
) wostream(::new(__wcerr
) __stdoutbuf
<wchar_t>(stderr
, state_types
+5));
49 ::new(wclog
) wostream(wcerr_ptr
->rdbuf());
50 wcin_ptr
->tie(wcout_ptr
);
51 _VSTD::unitbuf(*wcerr_ptr
);
52 wcerr_ptr
->tie(wcout_ptr
);
55 ios_base::Init::~Init()
57 ostream
* cout_ptr
= reinterpret_cast<ostream
*>(cout
);
58 ostream
* clog_ptr
= reinterpret_cast<ostream
*>(clog
);
62 wostream
* wcout_ptr
= reinterpret_cast<wostream
*>(wcout
);
63 wostream
* wclog_ptr
= reinterpret_cast<wostream
*>(wclog
);
68 _LIBCPP_END_NAMESPACE_STD