From 6c36b3da63ce0c0a4a2281d182f1b4de2e5bef69 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 13 Oct 2024 15:53:32 -0400 Subject: all: #ifdef -> #if defined Signed-off-by: Andrew Opalach --- include/al/array_typed.h | 2 +- include/al/atomic.h | 4 ++-- include/al/lib.h | 20 ++++++++++++-------- include/al/log.h | 5 ++++- include/al/types.h | 6 +++--- include/al/wstr.h | 7 ++++--- 6 files changed, 26 insertions(+), 18 deletions(-) (limited to 'include/al') diff --git a/include/al/array_typed.h b/include/al/array_typed.h index a48b230..09289f2 100644 --- a/include/al/array_typed.h +++ b/include/al/array_typed.h @@ -1,7 +1,7 @@ #ifndef _AL_ARRAY_TYPED_H #define _AL_ARRAY_TYPED_H -#ifndef AL_HAVE_GNU_EXTENSIONS +#if !defined AL_HAVE_GNU_EXTENSIONS #error "missing required GNU C extensions" #endif diff --git a/include/al/atomic.h b/include/al/atomic.h index 7f8a087..7d070ab 100644 --- a/include/al/atomic.h +++ b/include/al/atomic.h @@ -20,8 +20,8 @@ #define al_atomic_sub(T) _al_atomic_sub_##T // Special case for pointers. -#define _al_atomic_load_void(p, order) c89atomic_load_explicit_ptr(((volatile void **)p), order) -#define _al_atomic_store_void(p, v, order) c89atomic_store_explicit_ptr(((volatile void **)p), (void *)v, order) +#define _al_atomic_load_void(p, order) c89atomic_load_explicit_ptr((volatile void **)p, order) +#define _al_atomic_store_void(p, v, order) c89atomic_store_explicit_ptr((volatile void **)p, (void *)v, order) // c89atomic compat. typedef f64 c89atomic_f64; diff --git a/include/al/lib.h b/include/al/lib.h index 32b91ad..606d24d 100644 --- a/include/al/lib.h +++ b/include/al/lib.h @@ -4,9 +4,10 @@ #include "types.h" #define AL_USE_STDLIB 1 + #define AL_FORCE_DISABLE_OUTPUT 0 -#if defined(__clang__) || defined(__GNUC__) +#if defined __clang__ || defined __GNUC__ #define AL_UNUSED_FUNCTION_PUSH \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wunused-function\"") @@ -33,7 +34,7 @@ void *al_malloc(size_t n); void *al_calloc(size_t n, size_t size); void *al_realloc(void *ptr, size_t n); void al_free(void *ptr); -#ifdef AL_HAVE_POSIX_MEMALIGN +#if defined AL_HAVE_POSIX_MEMALIGN int al_posix_memalign(void **ptr, size_t alignment, size_t n); #endif void al_malloc_stats(u32 *current, u32 *peak, u32 *total); @@ -48,7 +49,7 @@ void al_set_alloc(void *(*malloc_func)(size_t), void *(*calloc_func)(size_t, siz #define al_bzero bzero #define al_strlen strlen #define al_sprintf sprintf -#ifdef _DEBUG_ +#if defined _DEBUG_ #define al_assert assert #else #define al_assert(expr) do { (void)sizeof(expr); } while (0) // NOLINT(bugprone-sizeof-expression) @@ -66,6 +67,7 @@ AL_UNUSED_FUNCTION_PUSH static inline s32 al_printf(const char *fmt, ...) { #if AL_FORCE_DISABLE_OUTPUT + (void)fmt; return 0; #else va_list args; @@ -79,6 +81,8 @@ static inline s32 al_printf(const char *fmt, ...) static inline s32 al_vprintf(const char *fmt, va_list args) { #if AL_FORCE_DISABLE_OUTPUT + (void)fmt; + (void)args; return 0; #else s32 ret = vprintf(fmt, args); @@ -100,16 +104,16 @@ static inline void *al_memrchr(const void *s, s32 c, size_t n) AL_UNUSED_FUNCTION_POP #endif -#ifndef LIKELY -#ifdef AL_HAVE_BUILTIN_EXPECT +#if !defined LIKELY +#if defined AL_HAVE_BUILTIN_EXPECT #define LIKELY(x) __builtin_expect((x), 1) #else #define LIKELY(x) x #endif #endif -#ifndef UNLIKELY -#ifdef AL_HAVE_BUILTIN_EXPECT +#if !defined UNLIKELY +#if defined AL_HAVE_BUILTIN_EXPECT #define UNLIKELY(x) __builtin_expect((x), 0) #else #define UNLIKELY(x) x @@ -145,7 +149,7 @@ AL_UNUSED_FUNCTION_POP #define AL_BOOLSTR(b) ((b) ? "true" : "false") -#ifndef _MSVC_ +#if !defined _MSVC_ #define __al_thread __thread #else #define __al_thread __declspec(thread) diff --git a/include/al/log.h b/include/al/log.h index cf53503..87b25c2 100644 --- a/include/al/log.h +++ b/include/al/log.h @@ -18,15 +18,18 @@ s32 _al_logv(const char *level, const char *section, const char *name, const s32 #define al_log_info(section, fmt, ...) al_log("info", section, fmt, ##__VA_ARGS__) #define al_log_warn(section, fmt, ...) al_log("warn", section, fmt, ##__VA_ARGS__) #define al_log_error(section, fmt, ...) al_log("error", section, fmt, ##__VA_ARGS__) -#ifdef _DEBUG_ +#if defined _DEBUG_ #define al_log_debug(section, fmt, ...) al_log("debug", section, fmt, ##__VA_ARGS__) #else AL_UNUSED_FUNCTION_PUSH + static inline s32 al_log_nop(const char *section, const char *fmt, ...) { (void)section; (void)fmt; return 0; } + AL_UNUSED_FUNCTION_POP + #define al_log_debug(section, fmt, ...) al_log_nop(section, fmt, ##__VA_ARGS__) #endif diff --git a/include/al/types.h b/include/al/types.h index 3a04539..136d8bd 100644 --- a/include/al/types.h +++ b/include/al/types.h @@ -1,7 +1,7 @@ #ifndef _AL_TYPES_H #define _AL_TYPES_H -#ifdef _POSIX_C_SOURCE +#if defined _POSIX_C_SOURCE #if _POSIX_C_SOURCE < 200112L #error "libalabaster requires _POSIX_C_SOURCE >= 200112L" #endif @@ -9,7 +9,7 @@ #define _POSIX_C_SOURCE 200112L #endif -#ifdef _XOPEN_SOURCE +#if defined _XOPEN_SOURCE #if _XOPEN_SOURCE < 500 #error "libalabaster requires _XOPEN_SOURCE >= 500" #endif @@ -35,7 +35,7 @@ typedef uint64_t u64; typedef float f32; typedef double f64; -#ifdef _MSC_VER +#if defined _MSC_VER #include typedef SSIZE_T ssize_t; #endif diff --git a/include/al/wstr.h b/include/al/wstr.h index ed2c051..1202882 100644 --- a/include/al/wstr.h +++ b/include/al/wstr.h @@ -1,6 +1,6 @@ #ifndef _AL_WSTR_H #define _AL_WSTR_H -#include "types.h" + #include "lib.h" #include "str.h" @@ -31,7 +31,7 @@ AL_UNUSED_FUNCTION_PUSH static inline s32 al_wchar_width(wchar_t wc) { -#ifdef AL_HAVE_WIDE_STRING +#if defined AL_HAVE_WIDE_STRING return wcwidth(wc); #else (void)wc; @@ -98,7 +98,7 @@ static inline void al_wstr_to_str(wstr *w, str *s) static inline s32 al_wstr_width(wstr *w) { -#ifdef AL_HAVE_WIDE_STRING +#if defined AL_HAVE_WIDE_STRING return wcswidth(w->data, w->len); #else (void)w; @@ -120,4 +120,5 @@ static inline s32 al_wstr_rfind(wstr *w, wchar_t c) } AL_UNUSED_FUNCTION_POP + #endif // _AL_WSTR_H -- cgit v1.2.3-101-g0448