a998f6b981
Release / release (push) Successful in 8s
## Summary Standardize naming conventions across the entire wizapp-stdlib codebase by replacing inconsistent prefixes and snake_case with a unified `wp` prefix + CamelCase scheme. ## Changes ### Naming convention applied | Pattern | Before | After | |---|---|---| | Public functions | `wapp_module_function` | `wpModuleFunction` | | Public types | `GenericXxx`, bare `Xxx` | `WpXxx` | | Constants / enum values | `WAPP_XXX`, `SHELL_XXX` | `WP_XXX`, `WP_SHELL_XXX` | | Internal functions | `_module_function` | `_moduleFunction` | | Storage-class macros | `wapp_extern`, `wapp_intern` | `wp_extern`, `wp_intern` | ### Modules affected All 20 modules were renamed: `arena`, `array`, `dbl_list`, `queue`, `str8`, `mem_allocator`, `mem_utils`, `mem_os`, `file`, `cpath`, `log`, `shell_commander`, `shell_termcolour`, `shell_utils`, `prng/xorshift`, `uuid`, `tester`, `aliases`, `assert`, `misc_utils`, `platform` — plus their test files. ### Backward compatibility Added `src/oldnames.h` with `#define OLD_NAME NEW_NAME` for every renamed symbol, organized by module under Constants → Types → Functions sections. Existing code that includes this file will compile without changes. Reviewed-on: #12 Co-authored-by: Abdelrahman <said.abdelrahman89@gmail.com> Co-committed-by: Abdelrahman <said.abdelrahman89@gmail.com>
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
// vim:fileencoding=utf-8:foldmethod=marker
|
|
|
|
#ifndef MISC_UTILS_H
|
|
#define MISC_UTILS_H
|
|
|
|
#include "../aliases/aliases.h"
|
|
|
|
#ifdef WP_PLATFORM_CPP
|
|
BEGIN_C_LINKAGE
|
|
#endif // !WP_PLATFORM_CPP
|
|
|
|
#define KiB(SIZE) (((u64)SIZE) << 10)
|
|
#define MiB(SIZE) (((u64)SIZE) << 20)
|
|
#define GiB(SIZE) (((u64)SIZE) << 30)
|
|
#define TiB(SIZE) (((u64)SIZE) << 40)
|
|
#define PiB(SIZE) (((u64)SIZE) << 50)
|
|
#define EiB(SIZE) (((u64)SIZE) << 60)
|
|
|
|
#define KB(SIZE) (((u64)SIZE) * 1000llu)
|
|
#define MB(SIZE) (KB(SIZE) * 1000llu)
|
|
#define GB(SIZE) (MB(SIZE) * 1000llu)
|
|
#define TB(SIZE) (GB(SIZE) * 1000llu)
|
|
#define PB(SIZE) (TB(SIZE) * 1000llu)
|
|
#define EB(SIZE) (PB(SIZE) * 1000llu)
|
|
|
|
#define wpMiscUtilsReservePadding(SIZE) u8 reserved_padding[sizeof(void *) - ((SIZE) % sizeof(void *))]
|
|
|
|
#define U64_RSHIFT_OR_1(X) (((u64)X) | (((u64)X) >> 1))
|
|
#define U64_RSHIFT_OR_2(X) (((u64)X) | (((u64)X) >> 2))
|
|
#define U64_RSHIFT_OR_4(X) (((u64)X) | (((u64)X) >> 4))
|
|
#define U64_RSHIFT_OR_8(X) (((u64)X) | (((u64)X) >> 8))
|
|
#define U64_RSHIFT_OR_16(X) (((u64)X) | (((u64)X) >> 16))
|
|
#define U64_RSHIFT_OR_32(X) (((u64)X) | (((u64)X) >> 32))
|
|
#define wpMiscUtilsU64RoundUpPow2(X) ( \
|
|
( \
|
|
U64_RSHIFT_OR_32( \
|
|
U64_RSHIFT_OR_16( \
|
|
U64_RSHIFT_OR_8( \
|
|
U64_RSHIFT_OR_4( \
|
|
U64_RSHIFT_OR_2( \
|
|
U64_RSHIFT_OR_1(X - 1) \
|
|
) \
|
|
) \
|
|
) \
|
|
) \
|
|
) \
|
|
) + 1 \
|
|
)
|
|
|
|
#define wpMiscUtilsIsPowerOfTwo(NUM) ((NUM & (NUM - 1)) == 0)
|
|
#define wpMiscUtilsOffsetPointer(PTR, OFFSET) ((void *)((uptr)(PTR) + (OFFSET)))
|
|
|
|
#ifdef WP_PLATFORM_CPP
|
|
END_C_LINKAGE
|
|
|
|
#include <tuple>
|
|
|
|
#define wpMiscUtilsVaArgsCount(T, ...) (std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value)
|
|
#else
|
|
#define wpMiscUtilsVaArgsCount(T, ...) (sizeof((T[]){__VA_ARGS__})/sizeof(T))
|
|
#endif // !WP_PLATFORM_CPP
|
|
|
|
#endif // !MISC_UTILS_H
|