From c5a6e53b41feb5201ce88a0ec1c72fa7cd5e2bcf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 22 Aug 2022 10:28:28 -0400 Subject: Update stale zix/common.h --- src/zix/common.h | 85 ++++++++------------------------------------------------ 1 file changed, 12 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/zix/common.h b/src/zix/common.h index bdd845f..5919fa9 100644 --- a/src/zix/common.h +++ b/src/zix/common.h @@ -4,6 +4,8 @@ #ifndef ZIX_COMMON_H #define ZIX_COMMON_H +#include "zix/attributes.h" + #include /** @@ -11,51 +13,10 @@ @{ */ -/** @cond */ -#if defined(_WIN32) && !defined(ZIX_STATIC) && defined(ZIX_INTERNAL) -# define ZIX_API __declspec(dllexport) -#elif defined(_WIN32) && !defined(ZIX_STATIC) -# define ZIX_API __declspec(dllimport) -#elif defined(__GNUC__) -# define ZIX_API __attribute__((visibility("default"))) -#else -# define ZIX_API -#endif - -#ifdef __GNUC__ -# 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 -#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 - -/** @endcond */ - #ifdef __cplusplus extern "C" { #endif -#ifdef __GNUC__ -# define ZIX_LOG_FUNC(fmt, arg1) __attribute__((format(printf, fmt, arg1))) -#else -# define ZIX_LOG_FUNC(fmt, arg1) -#endif - typedef enum { ZIX_STATUS_SUCCESS, ZIX_STATUS_ERROR, @@ -63,47 +24,25 @@ typedef enum { ZIX_STATUS_NOT_FOUND, ZIX_STATUS_EXISTS, ZIX_STATUS_BAD_ARG, - ZIX_STATUS_BAD_PERMS + ZIX_STATUS_BAD_PERMS, + ZIX_STATUS_REACHED_END } 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"; -} +/// Return a string describing a status code +ZIX_CONST_API +const char* +zix_strerror(ZixStatus status); -/** - Function for comparing two elements. -*/ +/// Function for comparing two elements typedef int (*ZixComparator)(const void* a, const void* b, const void* user_data); -/** - Function for testing equality of two elements. -*/ +/// Function for testing equality of two elements typedef bool (*ZixEqualFunc)(const void* a, const void* b); -/** - Function to destroy an element. -*/ -typedef void (*ZixDestroyFunc)(void* ptr); +/// Function to destroy an element +typedef void (*ZixDestroyFunc)(void* ptr, const void* user_data); /** @} -- cgit v1.2.1