From 63d591b2b87fc33b67d4e3c5521c995e59c68433 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 4 Mar 2019 11:23:25 -0800 Subject: [PATCH] ircd::util::fpe: Add interface to set the except flag. --- include/ircd/util/fpe.h | 4 +++- ircd/util.cc | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/ircd/util/fpe.h b/include/ircd/util/fpe.h index f8e0e2a9a..307dc80f1 100644 --- a/include/ircd/util/fpe.h +++ b/include/ircd/util/fpe.h @@ -18,7 +18,9 @@ namespace ircd::util::fpe string_view reflect_sicode(const int &); string_view reflect(const ushort &flag); string_view reflect(const mutable_buffer &, const ushort &flags); + void throw_errors(const ushort &flags); + std::fexcept_t set(const ushort &flag); } /// Perform a single floating point operation at a time within the scope @@ -26,7 +28,7 @@ namespace ircd::util::fpe /// unit for an error status flag and throw a C++ exception. struct ircd::util::fpe::errors_handle { - fexcept_t theirs; + std::fexcept_t theirs; public: ushort pending() const; diff --git a/ircd/util.cc b/ircd/util.cc index b953c7f03..88d7168f9 100644 --- a/ircd/util.cc +++ b/ircd/util.cc @@ -32,6 +32,14 @@ ircd::util::size(std::ostream &s) #pragma STDC FENV_ACCESS on #endif +std::fexcept_t +ircd::util::fpe::set(const ushort &flags) +{ + std::fexcept_t theirs; + syscall(std::fesetexceptflag, &theirs, flags); + return theirs; +} + void ircd::util::fpe::throw_errors(const ushort &flags) {