refactor(libc): __attribute__ replacing and removing
This commit is contained in:
parent
c8391bfb67
commit
ba6d7afc22
|
|
@ -5,7 +5,13 @@
|
|||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
|
||||
#elif defined(_MSC_VER)
|
||||
#include <xmmintrin.h>
|
||||
#else
|
||||
struct alignas(16) __m128 { float v[4]; };
|
||||
#endif
|
||||
|
||||
using Bool = std::uint8_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
#define GCC_LOCAL_ALIAS(alias, target) \
|
||||
asm(".local " #alias "\n.set " #alias "," #target "\n")
|
||||
|
||||
#define GCC_HIDDEN_FN __attribute__((visibility("hidden")))
|
||||
#define GCC_HIDDEN_FN
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
extern "C" void LibcCaptureRegisters(std::uintptr_t*) __attribute__((visibility("hidden")));
|
||||
extern "C" [[noreturn]] void LibcRestoreRegisters(const std::uintptr_t*) __attribute__((visibility("hidden")));
|
||||
extern "C" void LibcCaptureRegisters(std::uintptr_t*);
|
||||
extern "C" [[noreturn]] void LibcRestoreRegisters(const std::uintptr_t*);
|
||||
|
||||
asm(
|
||||
".text\n"
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ struct Other { virtual ~Other() = default; int padding = 9; };
|
|||
struct Derived : Other, Base {};
|
||||
struct Virtual : virtual Base {};
|
||||
|
||||
__attribute__((noinline)) void ThrowInt() { Guard guard; throw 42; }
|
||||
__attribute__((noinline)) void ThrowClass() { Guard guard; throw Derived(); }
|
||||
[[gnu::noinline]] void ThrowInt() { Guard guard; throw 42; }
|
||||
[[gnu::noinline]] void ThrowClass() { Guard guard; throw Derived(); }
|
||||
|
||||
struct Left : Base {};
|
||||
struct Right : Base {};
|
||||
|
|
@ -47,8 +47,8 @@ struct PrivateDerived : private Derived {
|
|||
Base* source() { return this; }
|
||||
Derived* target() { return this; }
|
||||
};
|
||||
__attribute__((noinline)) Derived* ToDerived(Base* p) { return dynamic_cast<Derived*>(p); }
|
||||
__attribute__((noinline)) Repeated* ToRepeated(Base* p) { return dynamic_cast<Repeated*>(p); }
|
||||
[[gnu::noinline]] Derived* ToDerived(Base* p) { return dynamic_cast<Derived*>(p); }
|
||||
[[gnu::noinline]] Repeated* ToRepeated(Base* p) { return dynamic_cast<Repeated*>(p); }
|
||||
void CheckRtti() {
|
||||
Repeated repeated;
|
||||
Base* left = static_cast<Left*>(&repeated);
|
||||
|
|
@ -85,7 +85,7 @@ void CheckForeign() {
|
|||
}
|
||||
|
||||
int staticAttempts = 0;
|
||||
__attribute__((noinline)) int StaticValue() {
|
||||
[[gnu::noinline]] int StaticValue() {
|
||||
static int value = [] { if (++staticAttempts == 1) throw 91; return 37; }();
|
||||
return value;
|
||||
}
|
||||
|
|
@ -135,8 +135,8 @@ void CheckThreads() {
|
|||
for (auto& thread : threads) assert(pthread_create(&thread, nullptr, ThreadTest, nullptr) == 0);
|
||||
for (auto& thread : threads) assert(pthread_join(thread, nullptr) == 0);
|
||||
}
|
||||
__attribute__((noinline)) void UncaughtThrow() { throw 19; }
|
||||
__attribute__((noinline)) void NoexceptThrow() noexcept { UncaughtThrow(); }
|
||||
[[gnu::noinline]] void UncaughtThrow() { throw 19; }
|
||||
[[gnu::noinline]] void NoexceptThrow() noexcept { UncaughtThrow(); }
|
||||
void CheckTerminate(void (*function)()) {
|
||||
pid_t child = fork();
|
||||
assert(child >= 0);
|
||||
|
|
@ -150,7 +150,7 @@ void CheckTerminate(void (*function)()) {
|
|||
assert(WIFEXITED(status) && WEXITSTATUS(status) == 61);
|
||||
}
|
||||
struct ForcedGuard { ~ForcedGuard() { ++destroyed; } };
|
||||
__attribute__((noinline)) void ForceUnwind() {
|
||||
[[gnu::noinline]] void ForceUnwind() {
|
||||
ForcedGuard guard;
|
||||
auto* exception = new _Unwind_Exception {};
|
||||
_Unwind_ForcedUnwind_nid_postfix(exception,
|
||||
|
|
|
|||
Loading…
Reference in New Issue