Remove HERE macro

Some cleanup.
Add location to some functions.
This commit is contained in:
Nekotekina 2020-12-09 18:04:52 +03:00
parent d25c401aec
commit 36c8654fb8
130 changed files with 969 additions and 889 deletions

View file

@ -7,6 +7,7 @@
#endif
#include "Utilities/sync.h"
#include "Utilities/StrFmt.h"
#include <utility>
#include <mutex>
@ -71,8 +72,7 @@ ptr_cmp(const void* data, u32 _size, __m128i old128, __m128i mask128, atomic_wai
case 8: new_value = reinterpret_cast<const atomic_t<u64>*>(data)->load(); break;
default:
{
fprintf(stderr, "ptr_cmp(): bad size (arg=0x%x)" HERE "\n", _size);
std::abort();
fmt::throw_exception("Bad size (arg=0x%x)", _size);
}
}
@ -160,7 +160,7 @@ ptr_cmp(const void* data, u32 _size, __m128i old128, __m128i mask128, atomic_wai
}
default:
{
fmt::raw_error("ptr_cmp(): unrecognized atomic wait operation.");
fmt::throw_exception("ptr_cmp(): unrecognized atomic wait operation.");
}
}
}
@ -181,7 +181,7 @@ ptr_cmp(const void* data, u32 _size, __m128i old128, __m128i mask128, atomic_wai
}
else if (size == 16)
{
fmt::raw_error("ptr_cmp(): no alternative operations are supported for 16-byte atomic wait yet.");
fmt::throw_exception("ptr_cmp(): no alternative operations are supported for 16-byte atomic wait yet.");
}
if (flag & op_flag::inverse)
@ -236,7 +236,7 @@ cmp_mask(u32 size1, __m128i mask1, __m128i val1, u32 size2, __m128i mask2, __m12
if (flag != op::eq && flag != (op::eq | op_flag::inverse))
{
fmt::raw_error("cmp_mask(): no operations are supported for notification with forced value yet.");
fmt::throw_exception("cmp_mask(): no operations are supported for notification with forced value yet.");
}
if (size <= 8)
@ -258,8 +258,7 @@ cmp_mask(u32 size1, __m128i mask1, __m128i val1, u32 size2, __m128i mask2, __m12
}
else
{
fprintf(stderr, "cmp_mask(): bad size (size1=%u, size2=%u)" HERE "\n", size1, size2);
std::abort();
fmt::throw_exception("bad size (size1=%u, size2=%u)", size1, size2);
}
return !(flag & op_flag::inverse);
@ -634,15 +633,14 @@ cond_alloc(std::uintptr_t iptr, __m128i mask, u32 tls_slot = -1)
return id;
}
fmt::raw_error("Thread semaphore limit " STRINGIZE(UINT16_MAX) " reached in atomic wait.");
fmt::throw_exception("Thread semaphore limit (65535) reached in atomic wait.");
}
static void cond_free(u32 cond_id, u32 tls_slot = -1)
{
if (cond_id - 1 >= u32{UINT16_MAX}) [[unlikely]]
{
fprintf(stderr, "cond_free(): bad id %u" HERE "\n", cond_id);
std::abort();
fmt::throw_exception("bad id %u", cond_id);
}
const auto cond = s_cond_list + cond_id;
@ -767,7 +765,7 @@ cond_id_lock(u32 cond_id, u32 size, __m128i mask, u64 thread_id = 0, std::uintpt
if ((old & s_ref_mask) == s_ref_mask)
{
fmt::raw_error("Reference count limit (131071) reached in an atomic notifier.");
fmt::throw_exception("Reference count limit (131071) reached in an atomic notifier.");
}
}
@ -898,7 +896,7 @@ atomic_t<u16>* root_info::slot_alloc(std::uintptr_t ptr) noexcept
// Increment reference counter on every hashtable slot we attempt to allocate on
if (bits.ref == UINT16_MAX)
{
fmt::raw_error("Thread limit " STRINGIZE(UINT16_MAX) " reached for a single hashtable slot.");
fmt::throw_exception("Thread limit (65535) reached for a single hashtable slot.");
return nullptr;
}
@ -931,7 +929,7 @@ atomic_t<u16>* root_info::slot_alloc(std::uintptr_t ptr) noexcept
if (limit == max_distance) [[unlikely]]
{
fmt::raw_error("Distance limit (500) exceeded for the atomic wait hashtable.");
fmt::throw_exception("Distance limit (500) exceeded for the atomic wait hashtable.");
return nullptr;
}
}
@ -949,7 +947,7 @@ void root_info::slot_free(std::uintptr_t iptr, atomic_t<u16>* slot, u32 tls_slot
if (ptr >= sizeof(s_hashtable))
{
fmt::raw_error("Failed to find slot in hashtable slot deallocation." HERE);
fmt::throw_exception("Failed to find slot in hashtable slot deallocation.");
return;
}
@ -957,7 +955,7 @@ void root_info::slot_free(std::uintptr_t iptr, atomic_t<u16>* slot, u32 tls_slot
if (!(slot >= _this->slots && slot < std::end(_this->slots)))
{
fmt::raw_error("Failed to find slot in hashtable slot deallocation." HERE);
fmt::throw_exception("Failed to find slot in hashtable slot deallocation.");
return;
}
@ -1068,14 +1066,14 @@ atomic_wait_engine::wait(const void* data, u32 size, __m128i old_value, u64 time
{
if (data == e->data)
{
fmt::raw_error("Address duplication in atomic_wait::list" HERE);
fmt::throw_exception("Address duplication in atomic_wait::list");
}
for (u32 j = 0; j < ext_size; j++)
{
if (e->data == ext[j].data)
{
fmt::raw_error("Address duplication in atomic_wait::list" HERE);
fmt::throw_exception("Address duplication in atomic_wait::list");
}
}