Recreate base64 project
This commit is contained in:
67
wapp/common/aliases/aliases.h
Normal file
67
wapp/common/aliases/aliases.h
Normal file
@@ -0,0 +1,67 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef ALIASES_H
|
||||
#define ALIASES_H
|
||||
|
||||
#include "../platform/platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#if WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C11_VERSION && !defined(WAPP_PLATFORM_APPLE)
|
||||
#include <uchar.h>
|
||||
|
||||
#if WAPP_PLATFORM_C_VERSION >= WAPP_PLATFORM_C23_VERSION
|
||||
#define c8 char8_t
|
||||
#else
|
||||
#define c8 uint8_t
|
||||
#endif // !WAPP_PLATFORM_C23_VERSION
|
||||
|
||||
#define c16 char16_t
|
||||
#define c32 char32_t
|
||||
#else
|
||||
#define c8 uint8_t
|
||||
#define c16 uint16_t
|
||||
#define c32 uint32_t
|
||||
#endif // !WAPP_PLATFORM_C11_VERSION
|
||||
|
||||
#define u8 uint8_t
|
||||
#define u16 uint16_t
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#define b32 uint32_t
|
||||
|
||||
#ifndef WAPP_PLATFORM_CPP
|
||||
|
||||
#ifndef false
|
||||
#define false (b32)0
|
||||
#endif // !false
|
||||
|
||||
#ifndef true
|
||||
#define true (b32)1
|
||||
#endif // !true
|
||||
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#define i8 int8_t
|
||||
#define i16 int16_t
|
||||
#define i32 int32_t
|
||||
#define i64 int64_t
|
||||
|
||||
#define f32 float
|
||||
#define f64 double
|
||||
#define f128 long double
|
||||
|
||||
#define uptr uintptr_t
|
||||
#define iptr intptr_t
|
||||
|
||||
#define external extern
|
||||
#define internal static
|
||||
#define persistent static
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define class_mem static
|
||||
#define BEGIN_C_LINKAGE extern "C" {
|
||||
#define END_C_LINKAGE }
|
||||
#endif // WAPP_PLATFORM_CPP
|
||||
|
||||
#endif // !ALIASES_H
|
||||
41
wapp/common/assert/assert.h
Normal file
41
wapp/common/assert/assert.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef WAPP_ASSERT_H
|
||||
#define WAPP_ASSERT_H
|
||||
|
||||
#include "../aliases/aliases.h"
|
||||
#include "../platform/platform.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#define wapp_static_assert(EXPR, MSG) extern char ASSERTION_FAILED[EXPR ? 1 : -1]
|
||||
#define wapp_runtime_assert(EXPR, MSG) __wapp_runtime_assert(EXPR, MSG)
|
||||
|
||||
#ifdef WAPP_DEBUG_ASSERT
|
||||
#define wapp_debug_assert(EXPR, MSG) wapp_runtime_assert(EXPR, MSG)
|
||||
#else
|
||||
#define wapp_debug_assert(EXPR, MSG)
|
||||
#endif
|
||||
|
||||
#define __wapp_runtime_assert(EXPR, MSG) do { \
|
||||
if (!(EXPR)) { \
|
||||
fprintf( \
|
||||
stderr, \
|
||||
"%s:%d (In function `%s`): Assertion failed (%" PRIu32 ")\nDiagnostic: %s\n\n", \
|
||||
__FILE__, __LINE__, __func__, \
|
||||
EXPR, MSG \
|
||||
); \
|
||||
abort(); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#endif // !WAPP_ASSERT_H
|
||||
56
wapp/common/misc/misc_utils.h
Normal file
56
wapp/common/misc/misc_utils.h
Normal file
@@ -0,0 +1,56 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef MISC_UTILS_H
|
||||
#define MISC_UTILS_H
|
||||
|
||||
#include "../aliases/aliases.h"
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#define KB(SIZE) (SIZE * 1024ull)
|
||||
#define MB(SIZE) (KB(SIZE) * 1024)
|
||||
#define GB(SIZE) (MB(SIZE) * 1024)
|
||||
#define TB(SIZE) (GB(SIZE) * 1024)
|
||||
|
||||
#define wapp_misc_utils_padding_size(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 wapp_misc_utils_u64_round_up_pow2(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 \
|
||||
)
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_misc_utils_va_args_count(T, ...) va_args_count<T>(__VA_ARGS__)
|
||||
#else
|
||||
#define wapp_misc_utils_va_args_count(T, ...) (sizeof((T[]){__VA_ARGS__})/sizeof(T))
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
template <typename T, typename... Args>
|
||||
constexpr u64 va_args_count(Args&&...) {
|
||||
return sizeof...(Args);
|
||||
}
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#endif // !MISC_UTILS_H
|
||||
114
wapp/common/platform/platform.h
Normal file
114
wapp/common/platform/platform.h
Normal file
@@ -0,0 +1,114 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#define WAPP_PLATFORM_ANDROID
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__FreeBSD__)
|
||||
#define WAPP_PLATFORM_FREE_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__NetBSD__)
|
||||
#define WAPP_PLATFORM_NET_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__OpenBSD__)
|
||||
#define WAPP_PLATFORM_OPEN_BSD
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__DragonFly__)
|
||||
#define WAPP_PLATFORM_DRAGON_FLY
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__bsdi__)
|
||||
#define WAPP_PLATFORM_BSD
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__linux__) || defined(linux) || defined(__linux) || defined(__gnu_linux__)
|
||||
#define WAPP_PLATFORM_LINUX
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__GNU__) || defined(__gnu_hurd__)
|
||||
#define WAPP_PLATFORM_GNU
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif defined(__APPLE__) || defined(__MACH__)
|
||||
#include <TargetConditionals.h>
|
||||
#if TARGET_OS_IPHONE
|
||||
#define WAPP_PLATFORM_IOS
|
||||
#define WAPP_PLATFORM_APPLE
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#elif TARGET_OS_MAC
|
||||
#define WAPP_PLATFORM_MACOS
|
||||
#define WAPP_PLATFORM_APPLE
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#else
|
||||
#error "Unrecognised Apple platform"
|
||||
#endif
|
||||
#elif defined(_WIN64)
|
||||
#define WAPP_PLATFORM_WINDOWS64
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#elif defined(_WIN32)
|
||||
#define WAPP_PLATFORM_WINDOWS32
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#elif defined(__CYGWIN__)
|
||||
#define WAPP_PLATFORM_CYGWIN
|
||||
#define WAPP_PLATFORM_WINDOWS
|
||||
#elif defined(__unix__) || defined(__unix)
|
||||
#define WAPP_PLATFORM_UNIX
|
||||
#define WAPP_PLATFORM_POSIX
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define WAPP_PLATFORM_CPP
|
||||
#define WAPP_PLATFORM_CPP_VERSION __cplusplus
|
||||
#define WAPP_PLATFORM_CPP98_VERSION 199711L
|
||||
#define WAPP_PLATFORM_CPP11_VERSION 201103L
|
||||
#define WAPP_PLATFORM_CPP14_VERSION 201402L
|
||||
#define WAPP_PLATFORM_CPP17_VERSION 201703L
|
||||
#define WAPP_PLATFORM_CPP20_VERSION 202002L
|
||||
#define WAPP_PLATFORM_CPP23_VERSION 202302L
|
||||
|
||||
#if WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP98_VERSION
|
||||
#define WAPP_PLATFORM_CPP98
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP11_VERSION
|
||||
#define WAPP_PLATFORM_CPP11
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP14_VERSION
|
||||
#define WAPP_PLATFORM_CPP14
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP17_VERSION
|
||||
#define WAPP_PLATFORM_CPP17
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP20_VERSION
|
||||
#define WAPP_PLATFORM_CPP20
|
||||
#elif WAPP_PLATFORM_CPP_VERSION == WAPP_PLATFORM_CPP23_VERSION
|
||||
#define WAPP_PLATFORM_CPP23
|
||||
#else
|
||||
#error "Unrecognised C++ version"
|
||||
#endif
|
||||
#else
|
||||
#define WAPP_PLATFORM_C
|
||||
|
||||
#if defined(__STDC_VERSION__)
|
||||
#define WAPP_PLATFORM_C_VERSION __STDC_VERSION__
|
||||
#define WAPP_PLATFORM_C99_VERSION 199901L
|
||||
#define WAPP_PLATFORM_C11_VERSION 201112L
|
||||
#define WAPP_PLATFORM_C17_VERSION 201710L
|
||||
#define WAPP_PLATFORM_C23_VERSION 202311L
|
||||
|
||||
#if WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C99_VERSION
|
||||
#define WAPP_PLATFORM_C99
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C11_VERSION
|
||||
#define WAPP_PLATFORM_C11
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C17_VERSION
|
||||
#define WAPP_PLATFORM_C17
|
||||
#elif WAPP_PLATFORM_C_VERSION == WAPP_PLATFORM_C23_VERSION
|
||||
#define WAPP_PLATFORM_C23
|
||||
#else
|
||||
#error "Unrecognised C version"
|
||||
#endif
|
||||
#else
|
||||
#define WAPP_PLATFORM_C89
|
||||
#endif
|
||||
#endif // !__cplusplus
|
||||
|
||||
#endif // !PLATFORM_H
|
||||
11
wapp/common/wapp_common.h
Normal file
11
wapp/common/wapp_common.h
Normal file
@@ -0,0 +1,11 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#ifndef WAPP_COMMON_H
|
||||
#define WAPP_COMMON_H
|
||||
|
||||
#include "aliases/aliases.h"
|
||||
#include "assert/assert.h"
|
||||
#include "misc/misc_utils.h"
|
||||
#include "platform/platform.h"
|
||||
|
||||
#endif // !WAPP_COMMON_H
|
||||
Reference in New Issue
Block a user