mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::magic: Relax the linked version check.
This commit is contained in:
parent
b9822a8c6c
commit
dbbc22d98a
1 changed files with 14 additions and 10 deletions
|
@ -22,10 +22,14 @@ namespace ircd::magic
|
||||||
static void set_flags(const magic_t &, const int &flags);
|
static void set_flags(const magic_t &, const int &flags);
|
||||||
static string_view call(const magic_t &, const int &flags, const mutable_buffer &, const std::function<const char *()> &);
|
static string_view call(const magic_t &, const int &flags, const mutable_buffer &, const std::function<const char *()> &);
|
||||||
static string_view call(const magic_t &, const int &flags, const mutable_buffer &, const const_buffer &);
|
static string_view call(const magic_t &, const int &flags, const mutable_buffer &, const const_buffer &);
|
||||||
|
|
||||||
|
static void version_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::magic::init::init()
|
ircd::magic::init::init()
|
||||||
{
|
{
|
||||||
|
version_check();
|
||||||
|
|
||||||
if(unlikely(!(cookie = ::magic_open(flags))))
|
if(unlikely(!(cookie = ::magic_open(flags))))
|
||||||
throw error{"magic_open() failed"};
|
throw error{"magic_open() failed"};
|
||||||
|
|
||||||
|
@ -160,16 +164,16 @@ ircd::magic::version()
|
||||||
return ::magic_version();
|
return ::magic_version();
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((constructor))
|
void
|
||||||
static void
|
ircd::magic::version_check()
|
||||||
ircd_magic_version_check()
|
|
||||||
{
|
{
|
||||||
if(unlikely(MAGIC_VERSION != ircd::magic::version()))
|
if(likely(MAGIC_VERSION == version()))
|
||||||
{
|
return;
|
||||||
fprintf(stderr, "FATAL: linked libmagic version %d != compiled magic.h version %d.\n",
|
|
||||||
ircd::magic::version(),
|
|
||||||
MAGIC_VERSION);
|
|
||||||
|
|
||||||
std::terminate();
|
log::warning
|
||||||
}
|
{
|
||||||
|
"Linked libmagic version %d is not the compiled magic.h version %d.\n",
|
||||||
|
version(),
|
||||||
|
MAGIC_VERSION
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue