[PATCH] Make the presence of stdin and stdout optional

Ed Schouten ed at nuxi.nl
Sat Mar 14 05:08:12 PDT 2015


Hi jroelofs, mclow.lists,

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*.

My promise is that this will be the last intrusive patch to add support for CloudABI. ;-)

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8340

Files:
  CMakeLists.txt
  include/__config
  include/cstdio
  include/cwchar
  include/iostream
  src/iostream.cpp
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in
  test/std/input.output/file.streams/c.files/cstdio.pass.cpp
  test/std/input.output/iostream.objects/narrow.stream.objects/cerr.pass.cpp
  test/std/input.output/iostream.objects/narrow.stream.objects/cin.pass.cpp
  test/std/input.output/iostream.objects/narrow.stream.objects/cout.pass.cpp
  test/std/input.output/iostream.objects/wide.stream.objects/wcerr.pass.cpp
  test/std/input.output/iostream.objects/wide.stream.objects/wcin.pass.cpp
  test/std/input.output/iostream.objects/wide.stream.objects/wcout.pass.cpp
  test/std/strings/c.strings/cwchar.pass.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8340.21983.patch
Type: text/x-patch
Size: 24063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150314/c6bd9b4d/attachment.bin>


More information about the cfe-commits mailing list