diff options
author | David Robillard <d@drobilla.net> | 2020-12-31 15:15:05 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-12-31 15:21:29 +0100 |
commit | 741c3349b09c8774fcd013e3bdd7d9e7f6b470ce (patch) | |
tree | a941f6567b85255570e5492f3c66a842704ba9f7 /zix/common.h | |
parent | 841c766d86dc35ab37c4fef8ec866d06c41bc383 (diff) | |
download | zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.tar.gz zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.tar.bz2 zix-741c3349b09c8774fcd013e3bdd7d9e7f6b470ce.zip |
Format all code with clang-format
Diffstat (limited to 'zix/common.h')
-rw-r--r-- | zix/common.h | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/zix/common.h b/zix/common.h index f7ec4c3..865d232 100644 --- a/zix/common.h +++ b/zix/common.h @@ -26,40 +26,48 @@ /** @cond */ #ifdef ZIX_SHARED -# ifdef _WIN32 -# define ZIX_LIB_IMPORT __declspec(dllimport) -# define ZIX_LIB_EXPORT __declspec(dllexport) -# else -# define ZIX_LIB_IMPORT __attribute__((visibility("default"))) -# define ZIX_LIB_EXPORT __attribute__((visibility("default"))) -# endif -# ifdef ZIX_INTERNAL -# define ZIX_API ZIX_LIB_EXPORT -# else -# define ZIX_API ZIX_LIB_IMPORT -# endif -# define ZIX_PRIVATE static +# ifdef _WIN32 +# define ZIX_LIB_IMPORT __declspec(dllimport) +# define ZIX_LIB_EXPORT __declspec(dllexport) +# else +# define ZIX_LIB_IMPORT __attribute__((visibility("default"))) +# define ZIX_LIB_EXPORT __attribute__((visibility("default"))) +# endif +# ifdef ZIX_INTERNAL +# define ZIX_API ZIX_LIB_EXPORT +# else +# define ZIX_API ZIX_LIB_IMPORT +# endif +# define ZIX_PRIVATE static #elif defined(ZIX_INLINE) -# define ZIX_API static inline -# define ZIX_PRIVATE static inline +# define ZIX_API static inline +# define ZIX_PRIVATE static inline #else -# define ZIX_API -# define ZIX_PRIVATE static +# define ZIX_API +# define ZIX_PRIVATE static #endif #ifdef __GNUC__ -# define ZIX_PURE_FUNC __attribute__((pure)) -# define ZIX_CONST_FUNC __attribute__((const)) -# define ZIX_MALLOC_FUNC __attribute__((malloc)) +# define ZIX_PURE_FUNC __attribute__((pure)) +# define ZIX_CONST_FUNC __attribute__((const)) +# define ZIX_MALLOC_FUNC __attribute__((malloc)) #else -# define ZIX_PURE_FUNC -# define ZIX_CONST_FUNC -# define ZIX_MALLOC_FUNC +# define ZIX_PURE_FUNC +# define ZIX_CONST_FUNC +# define ZIX_MALLOC_FUNC #endif -#define ZIX_PURE_API ZIX_API ZIX_PURE_FUNC -#define ZIX_CONST_API ZIX_API ZIX_CONST_FUNC -#define ZIX_MALLOC_API ZIX_API ZIX_MALLOC_FUNC +#define ZIX_PURE_API \ + ZIX_API \ + ZIX_PURE_FUNC + +#define ZIX_CONST_API \ + ZIX_API \ + ZIX_CONST_FUNC + +#define ZIX_MALLOC_API \ + ZIX_API \ + ZIX_MALLOC_FUNC /** @endcond */ @@ -68,43 +76,50 @@ extern "C" { #endif #ifdef __GNUC__ -#define ZIX_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) +# define ZIX_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) #else -#define ZIX_LOG_FUNC(fmt, arg1) +# define ZIX_LOG_FUNC(fmt, arg1) #endif // Unused parameter macro to suppresses warnings and make it impossible to use #if defined(__cplusplus) -# define ZIX_UNUSED(name) +# define ZIX_UNUSED(name) #elif defined(__GNUC__) -# define ZIX_UNUSED(name) name##_unused __attribute__((__unused__)) +# define ZIX_UNUSED(name) name##_unused __attribute__((__unused__)) #else -# define ZIX_UNUSED(name) name +# define ZIX_UNUSED(name) name #endif typedef enum { - ZIX_STATUS_SUCCESS, - ZIX_STATUS_ERROR, - ZIX_STATUS_NO_MEM, - ZIX_STATUS_NOT_FOUND, - ZIX_STATUS_EXISTS, - ZIX_STATUS_BAD_ARG, - ZIX_STATUS_BAD_PERMS + ZIX_STATUS_SUCCESS, + ZIX_STATUS_ERROR, + ZIX_STATUS_NO_MEM, + ZIX_STATUS_NOT_FOUND, + ZIX_STATUS_EXISTS, + ZIX_STATUS_BAD_ARG, + ZIX_STATUS_BAD_PERMS } ZixStatus; static inline const char* zix_strerror(const ZixStatus status) { - switch (status) { - case ZIX_STATUS_SUCCESS: return "Success"; - case ZIX_STATUS_ERROR: return "Unknown error"; - case ZIX_STATUS_NO_MEM: return "Out of memory"; - case ZIX_STATUS_NOT_FOUND: return "Not found"; - case ZIX_STATUS_EXISTS: return "Exists"; - case ZIX_STATUS_BAD_ARG: return "Bad argument"; - case ZIX_STATUS_BAD_PERMS: return "Bad permissions"; - } - return "Unknown error"; + switch (status) { + case ZIX_STATUS_SUCCESS: + return "Success"; + case ZIX_STATUS_ERROR: + return "Unknown error"; + case ZIX_STATUS_NO_MEM: + return "Out of memory"; + case ZIX_STATUS_NOT_FOUND: + return "Not found"; + case ZIX_STATUS_EXISTS: + return "Exists"; + case ZIX_STATUS_BAD_ARG: + return "Bad argument"; + case ZIX_STATUS_BAD_PERMS: + return "Bad permissions"; + } + return "Unknown error"; } /** @@ -129,7 +144,7 @@ typedef void (*ZixDestroyFunc)(void* ptr); */ #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif -#endif /* ZIX_COMMON_H */ +#endif /* ZIX_COMMON_H */ |