[libcxx] r233275 - Make the presence of stdin and stdout optional.
Ed Schouten
ed at nuxi.nl
Thu Mar 26 07:35:46 PDT 2015
Author: ed
Date: Thu Mar 26 09:35:46 2015
New Revision: 233275
URL: http://llvm.org/viewvc/llvm-project?rev=233275&view=rev
Log:
Make the presence of stdin and stdout optional.
The idea behind Nuxi CloudABI is that it is targeted at (but not limited to)
running networked services in a sandboxed environment. The model behind stdin,
stdout and stderr is strongly focused on interactive tools in a command shell.
CloudABI does not support the notion of stdin and stdout, as 'standard
input/output' does not apply to services. The concept of stderr does makes
sense though, as services do need some mechanism to log error messages in a
uniform way.
This patch extends libc++ in such a way that std::cin and std::cout and the
associated <cstdio>/<cwchar> functions can be disabled through the flags
_LIBCPP_HAS_NO_STDIN and _LIBCPP_HAS_NO_STDOUT, respectively. At the same time
it attempts to clean up src/iostream.cpp a bit. Instead of using a single array
of mbstate_t objects and hardcoding the array indices, it creates separate
objects that declared next to the iostream objects and their buffers. The code
is also restructured by interleaving the construction and setup of c* and wc*
objects. That way it is more obvious that this is done identically.
The c* and wc* objects already have separate unit tests. Make use of this fact
by adding XFAILs in case libcpp-has-no-std* is set. That way the tests work in
both directions. If stdin or stdout is disabled, these tests will therefore
test for the absence of c* and wc*.
Differential Revision: http://reviews.llvm.org/D8340
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/__config
libcxx/trunk/include/cstdio
libcxx/trunk/include/cwchar
libcxx/trunk/include/iostream
libcxx/trunk/src/iostream.cpp
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.site.cfg.in
libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp
Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Mar 26 09:35:46 2015
@@ -55,6 +55,8 @@ option(LIBCXX_ENABLE_WERROR "Fail and st
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
+option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
+option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF)
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
@@ -259,6 +261,16 @@ if (NOT LIBCXX_ENABLE_GLOBAL_FILESYSTEM_
add_definitions(-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
endif()
+# LIBCXX_ENABLE_STDIN configuration
+if (NOT LIBCXX_ENABLE_STDIN)
+ add_definitions(-D_LIBCPP_HAS_NO_STDIN)
+endif()
+
+# LIBCXX_ENABLE_STDOUT configuration
+if (NOT LIBCXX_ENABLE_STDOUT)
+ add_definitions(-D_LIBCPP_HAS_NO_STDOUT)
+endif()
+
# LIBCXX_ENABLE_THREADS configuration
if (NOT LIBCXX_ENABLE_THREADS)
add_definitions(-D_LIBCPP_HAS_NO_THREADS)
Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Mar 26 09:35:46 2015
@@ -740,6 +740,13 @@ extern "C" void __sanitizer_annotate_con
#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
#endif
+// CloudABI is intended for running networked services. Processes do not
+// have standard input and output channels.
+#ifdef __CloudABI__
+#define _LIBCPP_HAS_NO_STDIN
+#define _LIBCPP_HAS_NO_STDOUT
+#endif
+
#if defined(__ANDROID__) || defined(__CloudABI__)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif
Modified: libcxx/trunk/include/cstdio
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/cstdio Thu Mar 26 09:35:46 2015
@@ -144,34 +144,20 @@ using ::FILE;
using ::fpos_t;
using ::size_t;
-#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
-using ::remove;
-using ::rename;
-using ::tmpfile;
-using ::tmpnam;
-#endif
using ::fclose;
using ::fflush;
-#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
-using ::fopen;
-using ::freopen;
-#endif
using ::setbuf;
using ::setvbuf;
using ::fprintf;
using ::fscanf;
-using ::printf;
-using ::scanf;
using ::snprintf;
using ::sprintf;
using ::sscanf;
#ifndef _LIBCPP_MSVCRT
using ::vfprintf;
using ::vfscanf;
-using ::vscanf;
using ::vsscanf;
#endif // _LIBCPP_MSVCRT
-using ::vprintf;
using ::vsnprintf;
using ::vsprintf;
using ::fgetc;
@@ -179,13 +165,7 @@ using ::fgets;
using ::fputc;
using ::fputs;
using ::getc;
-using ::getchar;
-#if _LIBCPP_STD_VER <= 11
-using ::gets;
-#endif
using ::putc;
-using ::putchar;
-using ::puts;
using ::ungetc;
using ::fread;
using ::fwrite;
@@ -199,6 +179,31 @@ using ::feof;
using ::ferror;
using ::perror;
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+using ::fopen;
+using ::freopen;
+using ::remove;
+using ::rename;
+using ::tmpfile;
+using ::tmpnam;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+using ::getchar;
+#if _LIBCPP_STD_VER <= 11
+using ::gets;
+#endif
+using ::scanf;
+using ::vscanf;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+using ::printf;
+using ::putchar;
+using ::puts;
+using ::vprintf;
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDIO
Modified: libcxx/trunk/include/cwchar
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cwchar?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/include/cwchar (original)
+++ libcxx/trunk/include/cwchar Thu Mar 26 09:35:46 2015
@@ -126,24 +126,18 @@ using ::fwscanf;
using ::swprintf;
using ::vfwprintf;
using ::vswprintf;
-using ::vwprintf;
#ifndef _LIBCPP_MSVCRT
using ::swscanf;
using ::vfwscanf;
using ::vswscanf;
-using ::vwscanf;
#endif // _LIBCPP_MSVCRT
-using ::wprintf;
-using ::wscanf;
using ::fgetwc;
using ::fgetws;
using ::fputwc;
using ::fputws;
using ::fwide;
using ::getwc;
-using ::getwchar;
using ::putwc;
-using ::putwchar;
using ::ungetwc;
using ::wcstod;
#ifndef _LIBCPP_MSVCRT
@@ -212,6 +206,20 @@ using ::wcrtomb;
using ::mbsrtowcs;
using ::wcsrtombs;
+#ifndef _LIBCPP_HAS_NO_STDIN
+using ::getwchar;
+#ifndef _LIBCPP_MSVCRT
+using ::vwscanf;
+#endif // _LIBCPP_MSVCRT
+using ::wscanf;
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+using ::putwchar;
+using ::vwprintf;
+using ::wprintf;
+#endif
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CWCHAR
Modified: libcxx/trunk/include/iostream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iostream?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/include/iostream (original)
+++ libcxx/trunk/include/iostream Thu Mar 26 09:35:46 2015
@@ -46,13 +46,17 @@ extern wostream wclog;
_LIBCPP_BEGIN_NAMESPACE_STD
+#ifndef _LIBCPP_HAS_NO_STDIN
extern _LIBCPP_FUNC_VIS istream cin;
-extern _LIBCPP_FUNC_VIS ostream cout;
-extern _LIBCPP_FUNC_VIS ostream cerr;
-extern _LIBCPP_FUNC_VIS ostream clog;
extern _LIBCPP_FUNC_VIS wistream wcin;
+#endif
+#ifndef _LIBCPP_HAS_NO_STDOUT
+extern _LIBCPP_FUNC_VIS ostream cout;
extern _LIBCPP_FUNC_VIS wostream wcout;
+#endif
+extern _LIBCPP_FUNC_VIS ostream cerr;
extern _LIBCPP_FUNC_VIS wostream wcerr;
+extern _LIBCPP_FUNC_VIS ostream clog;
extern _LIBCPP_FUNC_VIS wostream wclog;
_LIBCPP_END_NAMESPACE_STD
Modified: libcxx/trunk/src/iostream.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/iostream.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/src/iostream.cpp (original)
+++ libcxx/trunk/src/iostream.cpp Thu Mar 26 09:35:46 2015
@@ -13,19 +13,23 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#ifndef _LIBCPP_HAS_NO_STDIN
_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
static mbstate_t mb_cin;
_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)];
_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wchar_t>)];
static mbstate_t mb_wcin;
+#endif
+#ifndef _LIBCPP_HAS_NO_STDOUT
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
static mbstate_t mb_cout;
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)];
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
static mbstate_t mb_wcout;
+#endif
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
@@ -41,29 +45,39 @@ ios_base::Init __start_std_streams;
ios_base::Init::Init()
{
+#ifndef _LIBCPP_HAS_NO_STDIN
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin));
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin));
+#endif
+#ifndef _LIBCPP_HAS_NO_STDOUT
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
+#endif
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
::new(clog) ostream(cerr_ptr->rdbuf());
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
::new(wclog) wostream(wcerr_ptr->rdbuf());
+#if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT)
cin_ptr->tie(cout_ptr);
wcin_ptr->tie(wcout_ptr);
+#endif
_VSTD::unitbuf(*cerr_ptr);
_VSTD::unitbuf(*wcerr_ptr);
+#ifndef _LIBCPP_HAS_NO_STDOUT
cerr_ptr->tie(cout_ptr);
wcerr_ptr->tie(wcout_ptr);
+#endif
}
ios_base::Init::~Init()
{
+#ifndef _LIBCPP_HAS_NO_STDOUT
ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
cout_ptr->flush();
wcout_ptr->flush();
+#endif
ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
Modified: libcxx/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Thu Mar 26 09:35:46 2015
@@ -43,6 +43,8 @@ if (LIT_EXECUTABLE)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE)
+ pythonize_bool(LIBCXX_ENABLE_STDIN)
+ pythonize_bool(LIBCXX_ENABLE_STDOUT)
pythonize_bool(LIBCXX_ENABLE_THREADS)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
# The tests shouldn't link to any ABI library when it has been linked into
Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Thu Mar 26 09:35:46 2015
@@ -349,6 +349,8 @@ class Configuration(object):
self.configure_compile_flags_exceptions()
self.configure_compile_flags_rtti()
self.configure_compile_flags_no_global_filesystem_namespace()
+ self.configure_compile_flags_no_stdin()
+ self.configure_compile_flags_no_stdout()
enable_32bit = self.get_lit_bool('enable_32bit', False)
if enable_32bit:
self.cxx.flags += ['-m32']
@@ -406,6 +408,18 @@ class Configuration(object):
self.cxx.compile_flags += [
'-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE']
+ def configure_compile_flags_no_stdin(self):
+ enable_stdin = self.get_lit_bool('enable_stdin', True)
+ if not enable_stdin:
+ self.config.available_features.add('libcpp-has-no-stdin')
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDIN']
+
+ def configure_compile_flags_no_stdout(self):
+ enable_stdout = self.get_lit_bool('enable_stdout', True)
+ if not enable_stdout:
+ self.config.available_features.add('libcpp-has-no-stdout')
+ self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDOUT']
+
def configure_compile_flags_no_threads(self):
self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS']
self.config.available_features.add('libcpp-has-no-threads')
Modified: libcxx/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Thu Mar 26 09:35:46 2015
@@ -9,6 +9,8 @@ config.enable_rtti = "@LIBC
config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
config.enable_32bit = "@LIBCXX_BUILD_32_BITS@"
config.enable_global_filesystem_namespace = "@LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE@"
+config.enable_stdin = "@LIBCXX_ENABLE_STDIN@"
+config.enable_stdout = "@LIBCXX_ENABLE_STDOUT@"
config.enable_threads = "@LIBCXX_ENABLE_THREADS@"
config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
Modified: libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/file.streams/c.files/cstdio.pass.cpp Thu Mar 26 09:35:46 2015
@@ -88,31 +88,17 @@ int main()
std::size_t s = 0;
char* cp = 0;
std::va_list va;
-#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
- static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
- static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
- static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
- static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
-#endif
static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), "");
-#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
- static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
- static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
-#endif
static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), "");
static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(std::fprintf(fp," ")), int>::value), "");
static_assert((std::is_same<decltype(std::fscanf(fp,"")), int>::value), "");
- static_assert((std::is_same<decltype(std::printf(" ")), int>::value), "");
- static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
static_assert((std::is_same<decltype(std::snprintf(cp,0," ")), int>::value), "");
static_assert((std::is_same<decltype(std::sprintf(cp," ")), int>::value), "");
static_assert((std::is_same<decltype(std::sscanf("","")), int>::value), "");
static_assert((std::is_same<decltype(std::vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vfscanf(fp,"",va)), int>::value), "");
- static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), "");
- static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsnprintf(cp,0," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsprintf(cp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsscanf("","",va)), int>::value), "");
@@ -121,13 +107,7 @@ int main()
static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), "");
static_assert((std::is_same<decltype(std::getc(fp)), int>::value), "");
- static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
-#if _LIBCPP_STD_VER <= 11
- static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
-#endif
static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), "");
- static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
- static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), "");
static_assert((std::is_same<decltype(std::fwrite((const void*)0,0,0,fp)), std::size_t>::value), "");
@@ -140,4 +120,29 @@ int main()
static_assert((std::is_same<decltype(std::feof(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::perror("")), void>::value), "");
+
+#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
+ static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
+ static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
+ static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+ static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
+#if _LIBCPP_STD_VER <= 11
+ static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
+#endif
+ static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vscanf("",va)), int>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+ static_assert((std::is_same<decltype(std::printf(" ")), int>::value), "");
+ static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
+ static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
+ static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), "");
+#endif
}
Modified: libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp Thu Mar 26 09:35:46 2015
@@ -19,7 +19,11 @@ int main()
#if 0
std::cerr << "Hello World!\n";
#else
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::cerr.tie() == NULL);
+#else
assert(std::cerr.tie() == &std::cout);
+#endif
assert(std::cerr.flags() & std::ios_base::unitbuf);
#endif // 0
}
Modified: libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp Thu Mar 26 09:35:46 2015
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-has-no-stdin
+
// <iostream>
// istream cin;
@@ -23,6 +25,10 @@ int main()
std::cin >> i;
std::cout << "The number is : " << i << '\n';
#else // 0
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::cin.tie() == NULL);
+#else
assert(std::cin.tie() == &std::cout);
#endif
+#endif
}
Modified: libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp Thu Mar 26 09:35:46 2015
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-has-no-stdout
+
// <iostream>
// istream cout;
Modified: libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp Thu Mar 26 09:35:46 2015
@@ -19,7 +19,11 @@ int main()
#if 0
std::wcerr << L"Hello World!\n";
#else
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::wcerr.tie() == NULL);
+#else
assert(std::wcerr.tie() == &std::wcout);
+#endif
assert(std::wcerr.flags() & std::ios_base::unitbuf);
#endif // 0
}
Modified: libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp Thu Mar 26 09:35:46 2015
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-has-no-stdin
+
// <iostream>
// istream wcin;
@@ -23,6 +25,10 @@ int main()
std::wcin >> i;
std::wcout << L"The number is : " << i << L'\n';
#else // 0
+#ifdef _LIBCPP_HAS_NO_STDOUT
+ assert(std::wcin.tie() == NULL);
+#else
assert(std::wcin.tie() == &std::wcout);
#endif
+#endif
}
Modified: libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp (original)
+++ libcxx/trunk/test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp Thu Mar 26 09:35:46 2015
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-has-no-stdout
+
// <iostream>
// istream wcout;
Modified: libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp?rev=233275&r1=233274&r2=233275&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/c.strings/cwchar.pass.cpp Thu Mar 26 09:35:46 2015
@@ -50,19 +50,13 @@ int main()
static_assert((std::is_same<decltype(std::vfwscanf(fp, L"", va)), int>::value), "");
static_assert((std::is_same<decltype(std::vswprintf(ws, s, L"", va)), int>::value), "");
static_assert((std::is_same<decltype(std::vswscanf(L"", L"", va)), int>::value), "");
- static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
- static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
- static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
- static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
static_assert((std::is_same<decltype(std::fgetwc(fp)), std::wint_t>::value), "");
static_assert((std::is_same<decltype(std::fgetws(ws, 0, fp)), wchar_t*>::value), "");
static_assert((std::is_same<decltype(std::fputwc(L' ', fp)), std::wint_t>::value), "");
static_assert((std::is_same<decltype(std::fputws(L"", fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fwide(fp, 0)), int>::value), "");
static_assert((std::is_same<decltype(std::getwc(fp)), std::wint_t>::value), "");
- static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
static_assert((std::is_same<decltype(std::putwc(L' ', fp)), std::wint_t>::value), "");
- static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
static_assert((std::is_same<decltype(std::ungetwc(L' ', fp)), std::wint_t>::value), "");
static_assert((std::is_same<decltype(std::wcstod(L"", (wchar_t**)0)), double>::value), "");
static_assert((std::is_same<decltype(std::wcstof(L"", (wchar_t**)0)), float>::value), "");
@@ -106,4 +100,16 @@ int main()
static_assert((std::is_same<decltype(std::wcrtomb(ns, L' ', &mb)), std::size_t>::value), "");
static_assert((std::is_same<decltype(std::mbsrtowcs(ws, (const char**)0, s, &mb)), std::size_t>::value), "");
static_assert((std::is_same<decltype(std::wcsrtombs(ns, (const wchar_t**)0, s, &mb)), std::size_t>::value), "");
+
+#ifndef _LIBCPP_HAS_NO_STDIN
+ static_assert((std::is_same<decltype(std::getwchar()), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::vwscanf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wscanf(L"")), int>::value), "");
+#endif
+
+#ifndef _LIBCPP_HAS_NO_STDOUT
+ static_assert((std::is_same<decltype(std::putwchar(L' ')), std::wint_t>::value), "");
+ static_assert((std::is_same<decltype(std::vwprintf(L"", va)), int>::value), "");
+ static_assert((std::is_same<decltype(std::wprintf(L"")), int>::value), "");
+#endif
}
More information about the cfe-commits
mailing list