summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/strings
diff options
context:
space:
mode:
authorEd Schouten <ed@nuxi.nl>2015-03-26 14:35:46 +0000
committerEd Schouten <ed@nuxi.nl>2015-03-26 14:35:46 +0000
commitf4ac884f2bc299aab6afaf8bb2831f414d819f52 (patch)
treefb22bcd2710486ea7f4222b3cdb05a731834484c /libcxx/test/std/strings
parent4d5142937f0436fed3ae38f96b36ae8bd399ab85 (diff)
downloadbcm5719-llvm-f4ac884f2bc299aab6afaf8bb2831f414d819f52.tar.gz
bcm5719-llvm-f4ac884f2bc299aab6afaf8bb2831f414d819f52.zip
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 llvm-svn: 233275
Diffstat (limited to 'libcxx/test/std/strings')
-rw-r--r--libcxx/test/std/strings/c.strings/cwchar.pass.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
index d0481b70610..c3d868fbc3b 100644
--- a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
+++ b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp
@@ -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
}
OpenPOWER on IntegriCloud