9#include "../microfmt.hpp"
13#ifndef MICROFMT_USE_SYSTEM_ERROR
14#define MICROFMT_USE_SYSTEM_ERROR 0
16#if MICROFMT_USE_SYSTEM_ERROR
18#include <system_error>
28#if defined(RELOCO_KERNEL)
35RELOCO_BEGIN_UNSAFE_CODE
37#if MICROFMT_USE_SYSTEM_ERROR
38 std::error_code ec(value, std::system_category());
39 std::string msg = ec.message();
43 out.write(
"Unknown error");
50 if (strerror_s(buf,
sizeof(buf), value) != 0) {
51 std::strncpy(buf,
"Unknown error",
sizeof(buf));
53#elif defined(__APPLE__) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L && !defined(_GNU_SOURCE))
54 if (strerror_r(value, buf,
sizeof(buf)) != 0) {
55 std::strncpy(buf,
"Unknown error",
sizeof(buf));
57#elif defined(_GNU_SOURCE) || defined(__GLIBC__)
58 RELOCO_BEGIN_UNSAFE_BUFFER_USAGE;
59 const char *err_msg = strerror_r(value, buf,
sizeof(buf));
60 RELOCO_END_UNSAFE_BUFFER_USAGE;
61 if (err_msg !=
nullptr) {
66 if (
const char *msg = std::strerror(value)) {
75 out.write(
"Unknown error");
103 int_fmt.format(e.value, out);
Definition microfmt.hpp:881
#define MICROFMT_API_CLASS
Definition compat.hpp:181
RELOCO_BEGIN_UNSAFE_CODE void write_errno_string(const sink &out, int value) noexcept
Definition errno.hpp:36
posix_errno current_errno() noexcept
Definition errno.hpp:90
constexpr posix_errno format_errno(int val) noexcept
Definition errno.hpp:88
reloco::sink sink
Type-erased, zero-allocation output sink.
Definition microfmt.hpp:46
RELOCO_END_UNSAFE_CODE
Definition remote_object.hpp:132