]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/dll/detail/system_error.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / dll / detail / system_error.hpp
1 // Copyright 2014 Renato Tegon Forti, Antony Polukhin.
2 // Copyright 2015-2019 Antony Polukhin.
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt
6 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifndef BOOST_DLL_SYSTEM_ERROR_HPP
9 #define BOOST_DLL_SYSTEM_ERROR_HPP
10
11 #include <boost/dll/config.hpp>
12 #include <boost/predef/os.h>
13 #include <boost/throw_exception.hpp>
14
15 #if !BOOST_OS_WINDOWS
16 # include <dlfcn.h>
17 #endif
18
19 #ifdef BOOST_HAS_PRAGMA_ONCE
20 # pragma once
21 #endif
22
23 namespace boost { namespace dll { namespace detail {
24
25 inline void reset_dlerror() BOOST_NOEXCEPT {
26 #if !BOOST_OS_WINDOWS
27 const char* const error_txt = dlerror();
28 (void)error_txt;
29 #endif
30 }
31
32 inline void report_error(const boost::dll::fs::error_code& ec, const char* message) {
33 #if !BOOST_OS_WINDOWS
34 const char* const error_txt = dlerror();
35 if (error_txt) {
36 boost::throw_exception(
37 boost::dll::fs::system_error(
38 ec,
39 message + std::string(" (dlerror system message: ") + error_txt + std::string(")")
40 )
41 );
42 }
43 #endif
44
45 boost::throw_exception(
46 boost::dll::fs::system_error(
47 ec, message
48 )
49 );
50 }
51
52 }}} // boost::dll::detail
53
54 #endif // BOOST_DLL_SYSTEM_ERROR_HPP
55