/usr/include/xbt/system_error.hpp is in libsimgrid-dev 3.14.159-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /* Copyright (c) 2016. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <cerrno>
#include <system_error>
#ifndef SIMGRID_MC_SYSTEM_ERROR_HPP
#define SIMGRID_MC_SYSTEM_ERROR_HPP
namespace simgrid {
namespace xbt {
/** A `error_category` suitable to be used with `errno`
*
* It is not clear which error we are supposed to generate
* when getting a errno:
*
* * `system_error` clearly cannot be used for this on Windows;
*
* * `generic_error` might not be used for non-standard `errno`.
*
* Let's just define a function which gives us the correct
* category.
*/
inline
const std::error_category& errno_category() noexcept
{
return std::generic_category();
}
/** Create a `error_code` from an `errno` value
*
* This is expected to to whatever is right to create a
* `error_code` from a given `errno` value.
*/
inline
std::error_code errno_code(int errnum)
{
return std::error_code(errnum, errno_category());
}
/** Create an `error_code` from `errno` (and clear it) */
inline
std::error_code errno_code()
{
int errnum = errno;
errno = 0;
return errno_code(errnum);
}
/** Create a `system_error` from an `errno` value
*
* This is expected to to whatever is right to create a
* `system_error` from a given `errno` value.
*/
inline
std::system_error errno_error(int errnum)
{
return std::system_error(errno_code(errnum));
}
inline
std::system_error errno_error(int errnum, const char* what)
{
return std::system_error(errno_code(errnum), what);
}
/** Create a `system_code` from `errno` (and clear it) */
inline
std::system_error errno_error()
{
return std::system_error(errno_code());
}
inline
std::system_error errno_error(const char* what)
{
return std::system_error(errno_code(), what);
}
}
}
#endif
|