Skip to content

Commit

Permalink
Use char returning strerror_r on Android.
Browse files Browse the repository at this point in the history
  • Loading branch information
ned14 committed Dec 12, 2024
1 parent c9d092c commit 872b343
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/status-code/posix_code.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace detail
{
namespace avoid_string_include
{
#if defined(__GLIBC__) && !defined(__UCLIBC__)
#if(defined(__ANDROID__) || defined(__GLIBC__)) && !defined(__UCLIBC__)
// This returns int for non-glibc strerror_r, but glibc's is particularly weird so we retain it
extern "C" char *strerror_r(int errnum, char *buf, size_t buflen);
#else
Expand Down Expand Up @@ -135,15 +135,15 @@ class _posix_code_domain : public status_code_domain
}

protected:
virtual bool _do_failure(const status_code<void> &code) const noexcept override // NOLINT
virtual bool _do_failure(const status_code<void> &code) const noexcept override // NOLINT
{
assert(code.domain() == *this); // NOLINT
return static_cast<const posix_code &>(code).value() != 0; // NOLINT
assert(code.domain() == *this); // NOLINT
return static_cast<const posix_code &>(code).value() != 0; // NOLINT
}
virtual bool _do_equivalent(const status_code<void> &code1, const status_code<void> &code2) const noexcept override // NOLINT
{
assert(code1.domain() == *this); // NOLINT
const auto &c1 = static_cast<const posix_code &>(code1); // NOLINT
assert(code1.domain() == *this); // NOLINT
const auto &c1 = static_cast<const posix_code &>(code1); // NOLINT
if(code2.domain() == *this)
{
const auto &c2 = static_cast<const posix_code &>(code2); // NOLINT
Expand All @@ -161,21 +161,21 @@ class _posix_code_domain : public status_code_domain
}
virtual generic_code _generic_code(const status_code<void> &code) const noexcept override // NOLINT
{
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
return generic_code(static_cast<errc>(c.value()));
}
virtual string_ref _do_message(const status_code<void> &code) const noexcept override // NOLINT
{
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
return _make_string_ref(c.value());
}
#if defined(_CPPUNWIND) || defined(__EXCEPTIONS) || defined(STANDARDESE_IS_IN_THE_HOUSE)
SYSTEM_ERROR2_NORETURN virtual void _do_throw_exception(const status_code<void> &code) const override // NOLINT
{
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
assert(code.domain() == *this); // NOLINT
const auto &c = static_cast<const posix_code &>(code); // NOLINT
throw status_error<_posix_code_domain>(c);
}
#endif
Expand Down

0 comments on commit 872b343

Please sign in to comment.