diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/container.h | 42 | ||||
-rw-r--r-- | include/rstypes.h | 3 |
2 files changed, 24 insertions, 21 deletions
diff --git a/include/container.h b/include/container.h index c84b894..9491477 100644 --- a/include/container.h +++ b/include/container.h @@ -19,24 +19,24 @@ typedef unsigned char byte; /// Find closest powers of 2 #ifdef __GNUC__ - #define upper_2_power_32(number) (32 - __builtin_clz(number)) - #define upper_2_power_64(number) (64 - __builtin_clzl(number)) +# define upper_2_power_32(number) (32 - __builtin_clz(number)) +# define upper_2_power_64(number) (64 - __builtin_clzl(number)) #else - #include <intrin.h> - #include <stdint.h> - #define upper_2_power_32(number) __bit_scan_32(number) - #define upper_2_power_64(number) __bit_scan_64(number) +# include <intrin.h> +# include <stdint.h> +# define upper_2_power_32(number) __bit_scan_32(number) +# define upper_2_power_64(number) __bit_scan_64(number) unsigned long __bit_scan_32(int32_t number); unsigned long __bit_scan_64(int64_t number); #endif /// define FALLTHROUGH macro #if defined(__clang__) || defined(__GNUC__) -#define FALLTHROUGH __attribute__((fallthrough)) +# define FALLTHROUGH __attribute__((fallthrough)) #elif defined(_MSC_VER) -#define FALLTHROUGH __fallthrough() +# define FALLTHROUGH __fallthrough() #else -#define FALLTHROUGH ((void)0) +# define FALLTHROUGH ((void)0) #endif /// define TODO macro @@ -50,14 +50,14 @@ typedef void*(*memcpy_t)(void* restrict, const void*, size_t); /// default qsort_cmp_t functions to be used with integral types. #ifdef CONTAINER_EXPOSE_HELPERS - #define _CONTAINER_STATIC +# define _CONTAINER_STATIC int __default_char_cmp(const void* a, const void* b); int __default_short_cmp(const void* a, const void* b); int __default_int_cmp(const void* a, const void* b); int __default_long_cmp(const void* a, const void* b); int __default_long_long_cmp(const void* a, const void* b); #else - #define _CONTAINER_STATIC static +# define _CONTAINER_STATIC static #endif // CONTAINER_EXPOSE_HELPERS @@ -279,10 +279,10 @@ struct linked_list ll_deep_copy(const struct linked_list* list, memcpy_t cpy); /* ----------------------------------------------------------------- */ #ifndef HMAP_MAX_BUCKET_SIZE - #define HMAP_MAX_BUCKET_SIZE 8 +# define HMAP_MAX_BUCKET_SIZE 8 #endif #ifndef HMAP_INIT_SIZE - #define HMAP_INIT_SIZE 32 +# define HMAP_INIT_SIZE 32 #endif /// should return `0` only if first argument is equal to second, /// otherwise should return `1` or any other integer @@ -365,10 +365,10 @@ char hmapi_end(const struct hash_map_iter* iter); /* ----------------------------------------------------------------- */ #ifndef HSET_MAX_BUCKET_SIZE - #define HSET_MAX_BUCKET_SIZE 8 +# define HSET_MAX_BUCKET_SIZE 8 #endif #ifndef HSET_INIT_SIZE - #define HSET_INIT_SIZE 32 +# define HSET_INIT_SIZE 32 #endif /// should return `0` only if first argument is equal to second, /// otherwise should return `1` or any other integer @@ -472,32 +472,32 @@ void* _array_extend(void* array, void* buffer, size_t len); #ifndef __GNUC__ unsigned long __bit_scan_32(int32_t number) { - #ifdef _MSC_VER +# ifdef _MSC_VER unsigned long index; if (_BitScanReverse(&index, number)) { return index + 1; } else { return 1; } - #else // _MSC_VER +# else // _MSC_VER unsigned long count; for (count = 0; number; number >>= 1) { ++count; } return count; - #endif // _MSC_VER +# endif // _MSC_VER } unsigned long __bit_scan_64(int64_t number) { - #ifdef _MSC_VER +# ifdef _MSC_VER unsigned long index; if (_BitScanReverse64(&index, number)) { return index + 1; } else { return 1; } - #else // _MSC_VER +# else // _MSC_VER unsigned long count; for (count = 0; number; number >>= 1) { ++count; } return count; - #endif // _MSC_VER +# endif // _MSC_VER } #endif // __GNUC__ diff --git a/include/rstypes.h b/include/rstypes.h index 5af5ec5..57bfb63 100644 --- a/include/rstypes.h +++ b/include/rstypes.h @@ -3,6 +3,9 @@ #include <stdint.h> +typedef void _0; +#define u0 bool + typedef uint8_t u8; typedef int8_t i8; typedef uint16_t u16; |