Loading...
Searching...
No Matches
gpr::rgmin_abi Namespace Reference

Classes

struct  Stamp
 Header and library identities as plain numbers. More...

Functions

std::string describe (const Stamp &stamp)
std::string mismatch (const Stamp &header, const Stamp &library, bool library_accepts)
Stamp headerStamp () noexcept
Stamp libraryStamp ()
std::string linkedLibraryMismatch ()
 The mismatch message for the linked library; empty when compatible.
void requireCompatibleLibrary ()

Function Documentation

◆ describe()

std::string gpr::rgmin_abi::describe ( const Stamp & stamp)
inlinenodiscard

Definition at line 41 of file RgminAbi.h.

42{
43 std::ostringstream out;
44 out << stamp.major << '.' << stamp.minor << " layout " << stamp.layout;
45 return out.str();
46}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ headerStamp()

Stamp gpr::rgmin_abi::headerStamp ( )
inlinenodiscardnoexcept

Definition at line 65 of file RgminAbi.h.

66{
67 return {RGMIN_ABI_VERSION_MAJOR, RGMIN_ABI_VERSION_MINOR,
68 RGMIN_ABI_LAYOUT_REVISION};
69}

◆ libraryStamp()

Stamp gpr::rgmin_abi::libraryStamp ( )
inlinenodiscard

Definition at line 71 of file RgminAbi.h.

72{
73 const rgmin_abi_stamp_t stamp = rgmin_abi_stamp();
74 return {stamp.abi_major, stamp.abi_minor, stamp.layout_revision};
75}

◆ linkedLibraryMismatch()

std::string gpr::rgmin_abi::linkedLibraryMismatch ( )
inlinenodiscard

The mismatch message for the linked library; empty when compatible.

Definition at line 78 of file RgminAbi.h.

79{
80 const Stamp header = headerStamp();
81 const rgmin_abi_stamp_t compiled{static_cast<uint16_t>(header.major),
82 static_cast<uint16_t>(header.minor),
83 static_cast<uint16_t>(header.layout)};
84 return mismatch(header, libraryStamp(),
85 rgmin_abi_compatible(&compiled) != 0);
86}
Stamp libraryStamp()
Definition RgminAbi.h:71
Stamp headerStamp() noexcept
Definition RgminAbi.h:65
std::string mismatch(const Stamp &header, const Stamp &library, bool library_accepts)
Definition RgminAbi.h:52
Header and library identities as plain numbers.
Definition RgminAbi.h:35

◆ mismatch()

std::string gpr::rgmin_abi::mismatch ( const Stamp & header,
const Stamp & library,
bool library_accepts )
inlinenodiscard

Empty when the library accepts the header's stamp and agrees with it on major and layout revision; otherwise a message naming both stamps. library_accepts is the result of rgmin_abi_compatible on the header's stamp.

Definition at line 52 of file RgminAbi.h.

55{
56 if (library_accepts && header.major == library.major &&
57 header.layout == library.layout)
58 return {};
59 return "rgmin ABI mismatch: gpridge was built against rgmin.h " +
60 describe(header) + " and the loaded rgmin library reports " +
61 describe(library) +
62 (library_accepts ? "" : " and rejects the header's stamp");
63}
std::string describe(const Stamp &stamp)
Definition RgminAbi.h:41

◆ requireCompatibleLibrary()

void gpr::rgmin_abi::requireCompatibleLibrary ( )
inline

Checks the linked library once, before the first rgmin call. Throws std::runtime_error on a mismatch; there is no fallback.

Definition at line 90 of file RgminAbi.h.

91{
92 static std::once_flag checked;
93 static std::string failure;
94 std::call_once(checked, [] { failure = linkedLibraryMismatch(); });
95 if (!failure.empty()) throw std::runtime_error(failure);
96}
std::string linkedLibraryMismatch()
The mismatch message for the linked library; empty when compatible.
Definition RgminAbi.h:78