diff options
author | 2025-08-03 15:29:48 +0100 | |
---|---|---|
committer | 2025-08-03 15:29:48 +0100 | |
commit | b11cf48853bc4eccde60bc82180025f0797fa823 (patch) | |
tree | 7244ab889590066ff2a26ba3c1f475e7dae79130 /src | |
parent | 9853d19b4de3e66138da8b3e66ccdaea356ea35b (diff) | |
download | sst-b11cf48853bc4eccde60bc82180025f0797fa823.tar.gz sst-b11cf48853bc4eccde60bc82180025f0797fa823.zip |
Use shorter spellings of __asm and __attribute
Turns out, there's no need for the trailing underscores. Plus, glibc
does some stupid stuff with __attribute__ for non-GCC compilers. Not
that that matters here, but it seems like a good practice just to use
the forms that never have such problems. And it's shorter too.
Diffstat (limited to 'src')
-rw-r--r-- | src/accessor.h | 2 | ||||
-rw-r--r-- | src/chunklets/fastspin.c | 6 | ||||
-rw-r--r-- | src/con_.h | 10 | ||||
-rw-r--r-- | src/inputhud.c | 2 | ||||
-rw-r--r-- | src/l4d1democompat.c | 4 | ||||
-rw-r--r-- | src/langext.h | 4 | ||||
-rw-r--r-- | src/sst.c | 2 | ||||
-rw-r--r-- | src/vcall.h | 2 | ||||
-rw-r--r-- | src/wincrt.c | 8 |
9 files changed, 20 insertions, 20 deletions
diff --git a/src/accessor.h b/src/accessor.h index ec63b3c..ef05309 100644 --- a/src/accessor.h +++ b/src/accessor.h @@ -21,7 +21,7 @@ #include "mem.h" #if defined(__GNUC__) || defined(__clang__) -#define _ACCESSOR_UNUSED __attribute__((unused)) +#define _ACCESSOR_UNUSED __attribute((unused)) #else #define _ACCESSOR_UNUSED #endif diff --git a/src/chunklets/fastspin.c b/src/chunklets/fastspin.c index e972b23..d349395 100644 --- a/src/chunklets/fastspin.c +++ b/src/chunklets/fastspin.c @@ -29,12 +29,12 @@ _Static_assert(_Alignof(int) == _Alignof(_Atomic int), #if defined(__GNUC__) || defined(__clang__) || defined(__TINYC__) #if defined(__i386__) || defined(__x86_64__) || defined(_WIN32) || \ defined(__mips__) // same asm syntax for pause -#define RELAX() __asm__ volatile ("pause" ::: "memory") +#define RELAX() __asm volatile ("pause" ::: "memory") #elif defined(__arm__) || defined(__aarch64__) -#define RELAX() __asm__ volatile ("yield" ::: "memory") +#define RELAX() __asm volatile ("yield" ::: "memory") #elif defined(__powerpc__) || defined(__ppc64__) // POWER7 (2010) - older arches may be less efficient -#define RELAX() __asm__ volatile ("or 27, 27, 27" ::: "memory") +#define RELAX() __asm volatile ("or 27, 27, 27" ::: "memory") #endif #elif defined(_MSC_VER) #if defined(_M_ARM) || defined(_M_ARM64) @@ -21,7 +21,7 @@ #include "intdefs.h" #if defined(__GNUC__) || defined(__clang__) -#define _CON_PRINTF(x, y) __attribute__((format(printf, (x), (y)))) +#define _CON_PRINTF(x, y) __attribute((format(printf, (x), (y)))) #else #define _CON_PRINTF(x, y) #endif @@ -198,11 +198,11 @@ con_cmdcbv1 con_getcmdcbv1(const struct con_cmd *cmd); */ #if defined(__GNUC__) || defined(__clang__) #ifdef _WIN32 -#define __asm__(x) __asm__("_" x) // stupid mangling meme, only on windows! +#define __asm(x) __asm("_" x) // stupid mangling meme, only on windows! #endif -void con_msg(const char *fmt, ...) _CON_PRINTF(1, 2) __asm__("Msg"); -void con_warn(const char *fmt, ...) _CON_PRINTF(1, 2) __asm__("Warning"); -#undef __asm__ +void con_msg(const char *fmt, ...) _CON_PRINTF(1, 2) __asm("Msg"); +void con_warn(const char *fmt, ...) _CON_PRINTF(1, 2) __asm("Warning"); +#undef __asm #else #error Need an equivalent of asm names for your compiler! #endif diff --git a/src/inputhud.c b/src/inputhud.c index 2620f3c..fbcbe79 100644 --- a/src/inputhud.c +++ b/src/inputhud.c @@ -151,7 +151,7 @@ static inline int bsf(uint x) { // a false dependency on many CPUs, which compilers don't understand somehow int ret = 0; #if defined(__GNUC__) || defined(__clang__) - __asm__ volatile ( + __asm volatile ( "bsf %0, %1\n" : "+r" (ret) : "r" (x) diff --git a/src/l4d1democompat.c b/src/l4d1democompat.c index 1d27984..4b84dd3 100644 --- a/src/l4d1democompat.c +++ b/src/l4d1democompat.c @@ -115,14 +115,14 @@ static void VCALLCONV hook_ReadDemoHeader(struct CDemoFile *this) { } #if defined(__clang__) -__attribute__((naked)) +__attribute((naked)) #elif defined(_MSC_VER) #error Inadequate inline assembly syntax, use Clang instead. #else #error No way to do naked functions! We only support Clang at the moment. #endif static int hook_midpoint() { - __asm__ volatile ( + __asm volatile ( "push eax\n" "mov eax, %1\n" "mov eax, [eax]\n" // dereference this_protocol diff --git a/src/langext.h b/src/langext.h index de96ef5..d2d9a23 100644 --- a/src/langext.h +++ b/src/langext.h @@ -16,7 +16,7 @@ #define if_random(x) if (__builtin_expect_with_probability(!!(x), 1, 0.5)) #define unreachable __builtin_unreachable() #define assume(x) ((void)(!!(x) || (unreachable, 0))) -#define cold __attribute__((__cold__, __noinline__)) +#define cold __attribute((__cold__, __noinline__)) #else #define if_hot(x) if (x) #define if_cold(x) if (x) @@ -57,7 +57,7 @@ static inline _Noreturn void _invoke_ub() {} #define import #ifdef __GNUC__ // N.B. we assume -fvisibility=hidden -#define export __attribute__((visibility("default")) +#define export __attribute((visibility("default")) #else #define export int exp[-!!"compiler needs a way to export symbols!"]; #endif @@ -508,7 +508,7 @@ static void hook_plugin_unload_cbv2(const struct con_cmdargs *args) { // thanks clang for forcing use of return here and ALSO warning! #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpedantic" - __attribute__((musttail)) return orig_plugin_unload_cb.v2(args); + __attribute((musttail)) return orig_plugin_unload_cb.v2(args); #pragma clang diagnostic pop #else #error We are tied to clang without an assembly solution for this! diff --git a/src/vcall.h b/src/vcall.h index f3a1f02..20cde7e 100644 --- a/src/vcall.h +++ b/src/vcall.h @@ -104,7 +104,7 @@ // I thought static inline was supposed to prevent unused warnings??? #if defined(__GNUC__) || defined(__clang__) -#define _VCALL_UNUSED __attribute__((unused)) +#define _VCALL_UNUSED __attribute((unused)) #else #define _VCALL_UNUSED #endif diff --git a/src/wincrt.c b/src/wincrt.c index 566b272..9e8b9f5 100644 --- a/src/wincrt.c +++ b/src/wincrt.c @@ -13,7 +13,7 @@ int memcmp(const void *restrict x, const void *restrict y, unsigned int sz) { #if defined(__GNUC__) || defined(__clang__) int a, b; - __asm__ volatile ( + __asm volatile ( "xor eax, eax\n" "repz cmpsb\n" : "+D" (x), "+S" (y), "+c" (sz), "=@cca"(a), "=@ccb"(b) @@ -34,7 +34,7 @@ int memcmp(const void *restrict x, const void *restrict y, unsigned int sz) { void *memcpy(void *restrict x, const void *restrict y, unsigned int sz) { #if defined(__GNUC__) || defined(__clang__) void *r = x; - __asm__ volatile ( + __asm volatile ( "rep movsb\n" : "+D" (x), "+S" (y), "+c" (sz) : @@ -51,7 +51,7 @@ void *memcpy(void *restrict x, const void *restrict y, unsigned int sz) { void *memset(void *x, int c, unsigned int sz) { #if defined(__GNUC__) || defined(__clang__) void *r = x; - __asm__ volatile ( + __asm volatile ( "rep stosb\n" : "+D" (x), "+c" (sz) : "a"(c) @@ -71,7 +71,7 @@ int __stdcall _DllMainCRTStartup(void *inst, unsigned int reason, } #ifdef __clang__ -__attribute__((used)) +__attribute((used)) #endif int _fltused = 1; |