Blame view

3rdparty/boost_1_81_0/boost/process/detail/config.hpp 3.09 KB
0b6a182c   Hu Chunming   添加无鉴权注册和注销
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  // Copyright (c) 2006, 2007 Julio M. Merino Vidal
  // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
  // Copyright (c) 2009 Boris Schaeling
  // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
  // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
  // Copyright (c) 2016 Klemens D. Morgenstern
  //
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  
  /**
   * \file boost/process/config.hpp
   *
   * Defines various macros.
   */
  
  #ifndef BOOST_PROCESS_DETAIL_CONFIG_HPP
  #define BOOST_PROCESS_DETAIL_CONFIG_HPP
  
  #include <boost/config.hpp>
  #include <system_error>
  #include <boost/system/api_config.hpp>
  
  #include <boost/process/exception.hpp>
  
  #if defined(BOOST_POSIX_API)
  #include <errno.h>
  #if defined(__GLIBC__)
  #include <features.h>
  #else
  extern char **environ;
  #endif
  #elif defined(BOOST_WINDOWS_API)
  #include <boost/winapi/get_last_error.hpp>
  #else
  #error "System API not supported by boost.process"
  #endif
  
  namespace boost { namespace process { namespace detail
  {
  
  #if !defined(BOOST_PROCESS_PIPE_SIZE)
  #define BOOST_PROCESS_PIPE_SIZE 1024
  #endif
  
  #if defined(BOOST_POSIX_API)
  namespace posix {namespace extensions {}}
  namespace api = posix;
  
  inline std::error_code get_last_error() noexcept
  {
      return std::error_code(errno, std::system_category());
  }
  
  //copied from linux spec.
  #if (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
  #define BOOST_POSIX_HAS_VFORK 1
  #endif
  
  #if (_POSIX_C_SOURCE >= 199309L)
  #define BOOST_POSIX_HAS_SIGTIMEDWAIT 1
  #endif
  
  #elif defined(BOOST_WINDOWS_API)
  namespace windows {namespace extensions {}}
  namespace api = windows;
  
  inline std::error_code get_last_error() noexcept
  {
      return std::error_code(::boost::winapi::GetLastError(), std::system_category());
  }
  #endif
  
  inline void throw_last_error(const std::string & msg)
  {
      throw process_error(get_last_error(), msg);
  }
  
  inline void throw_last_error(const char * msg)
  {
      throw process_error(get_last_error(), msg);
  }
  
  inline void throw_last_error()
  {
      throw process_error(get_last_error());
  }
  
  inline void throw_error(const std::error_code& ec)
  {
      if (ec)
          throw process_error(ec);
  }
  
  inline void throw_error(const std::error_code& ec, const char* msg)
  {
      if (ec)
          throw process_error(ec, msg);
  }
  
  template<typename Char> constexpr Char null_char();
  template<> constexpr char     null_char<char>     (){return   '\0';}
  template<> constexpr wchar_t  null_char<wchar_t>  (){return  L'\0';}
  
  template<typename Char> constexpr Char equal_sign();
  template<> constexpr char     equal_sign<char>    () {return  '='; }
  template<> constexpr wchar_t  equal_sign<wchar_t> () {return L'='; }
  
  template<typename Char> constexpr Char quote_sign();
  template<> constexpr char     quote_sign<char>    () {return  '"'; }
  template<> constexpr wchar_t  quote_sign<wchar_t> () {return L'"'; }
  
  template<typename Char> constexpr Char space_sign();
  template<> constexpr char     space_sign<char>    () {return  ' '; }
  template<> constexpr wchar_t  space_sign<wchar_t> () {return L' '; }
  
  
  }}}
  #endif