Skip to content

Commit

Permalink
fatal error making less C for C++20.
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Dec 4, 2022
1 parent 0a5eb40 commit 942a0e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/snmalloc/ds_core/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ namespace snmalloc
#define TOSTRING(expr) TOSTRING2(expr)
#define TOSTRING2(expr) #expr

#if defined(SNMALLOC_USE_CXX17)
# define SNMALLOC_CURRENT_LINE TOSTRING(__LINE__)
# define SNMALLOC_CURRENT_FILE __FILE__
#else
# include <source_location>
# define SNMALLOC_CURRENT_LINE std::source_location::current().line()
# define SNMALLOC_CURRENT_FILE std::source_location::current().file_name()
#endif

#ifdef NDEBUG
# define SNMALLOC_ASSERT_MSG(...) \
{}
Expand All @@ -121,8 +130,8 @@ namespace snmalloc
snmalloc::report_fatal_error( \
"assert fail: {} in {} on {} " fmt "\n", \
#expr, \
__FILE__, \
TOSTRING(__LINE__), \
SNMALLOC_CURRENT_FILE, \
SNMALLOC_CURRENT_LINE, \
##__VA_ARGS__); \
} \
} while (0)
Expand All @@ -137,8 +146,8 @@ namespace snmalloc
snmalloc::report_fatal_error( \
"Check fail: {} in {} on {} " fmt "\n", \
#expr, \
__FILE__, \
TOSTRING(__LINE__), \
SNMALLOC_CURRENT_FILE, \
SNMALLOC_CURRENT_LINE, \
##__VA_ARGS__); \
} \
} while (0)
Expand Down
3 changes: 2 additions & 1 deletion src/test/func/pagemap/pagemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void set(bool bounded, address_t address, T new_value)
pagemap_test_unbound.set(address, new_value);
}

#define CHECK_GET(b, a, e) check_get(b, a, e, __FILE__, __LINE__)
#define CHECK_GET(b, a, e) \
check_get(b, a, e, SNMALLOC_CURRENT_FILE, SNMALLOC_CURRENT_LINE)

void test_pagemap(bool bounded)
{
Expand Down

0 comments on commit 942a0e5

Please sign in to comment.