0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::assert: Minor reorg.

This commit is contained in:
Jason Volk 2019-06-01 02:06:54 -07:00
parent 351f1804c8
commit 483d3da64f

View file

@ -12,19 +12,26 @@
#if !defined(NDEBUG) && defined(RB_ASSERT) #if !defined(NDEBUG) && defined(RB_ASSERT)
void void
__attribute__((visibility("default"))) __assert(const char *__assertion,
ircd::debugtrap() const char *__file,
int __line)
{ {
#if defined(__clang__) __assert_fail(__assertion, __file, __line, "<no function>");
__builtin_debugtrap();
#elif defined(__x86_64__)
__asm__ volatile ("int $3");
#elif defined(HAVE_SIGNAL_H)
raise(SIGTRAP);
#else
__builtin_trap();
#endif
} }
#endif
#if !defined(NDEBUG) && defined(RB_ASSERT)
void
__assert_perror_fail(int __errnum,
const char *__file,
unsigned int __line,
const char *__function)
{
char buf[32];
snprintf(buf, sizeof(buf), "perror #%d: ", __errnum);
__assert_fail(buf, __file, __line, __function);
}
#endif
#if !defined(NDEBUG) && defined(RB_ASSERT) #if !defined(NDEBUG) && defined(RB_ASSERT)
void void
@ -84,25 +91,17 @@ __assert_fail(const char *__assertion,
} }
#endif #endif
#if !defined(NDEBUG) && defined(RB_ASSERT)
void void
__assert_perror_fail(int __errnum, __attribute__((visibility("default")))
const char *__file, ircd::debugtrap()
unsigned int __line,
const char *__function)
{ {
char buf[32]; #if defined(__clang__)
snprintf(buf, sizeof(buf), "perror #%d: ", __errnum); __builtin_debugtrap();
__assert_fail(buf, __file, __line, __function); #elif defined(__x86_64__)
__asm__ volatile ("int $3");
#elif defined(HAVE_SIGNAL_H)
raise(SIGTRAP);
#else
__builtin_trap();
#endif
} }
#endif
#if !defined(NDEBUG) && defined(RB_ASSERT)
void
__assert(const char *__assertion,
const char *__file,
int __line)
{
__assert_fail(__assertion, __file, __line, "<no function>");
}
#endif