mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-07 16:18:49 +00:00
progress on base, deciding to keep the MD namespace minimal on macros pre-c11 or cpp17 gen refactors
This commit is contained in:
@@ -31,6 +31,15 @@ struct ArenaParams
|
|||||||
void* optional_backing_buffer;
|
void* optional_backing_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* NOTE(Ed): This is a combination of several concepts into a single interface:
|
||||||
|
* A arena 'block' of memory with segmented chaining of the blocks
|
||||||
|
* An OS virtual memory allocation scheme
|
||||||
|
* A push/pop stack allocation interface for the arena
|
||||||
|
|
||||||
|
TODO(Ed): We need to lift the virtual memory tracking to its own data structure
|
||||||
|
and virtual memory interface utilizing memory_substrate.h
|
||||||
|
*/
|
||||||
|
|
||||||
typedef struct Arena Arena;
|
typedef struct Arena Arena;
|
||||||
struct Arena
|
struct Arena
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# include "platform.h"
|
# include "platform.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( MD_COMPILER_MSVC )
|
#if defined( COMPILER_MSVC )
|
||||||
# if _MSC_VER < 1300
|
# if _MSC_VER < 1300
|
||||||
typedef unsigned char U8;
|
typedef unsigned char U8;
|
||||||
typedef signed char S8;
|
typedef signed char S8;
|
||||||
|
|||||||
@@ -40,12 +40,12 @@
|
|||||||
#define MD_S64_MIN ( -0x7fffffffffffffffll - 1 )
|
#define MD_S64_MIN ( -0x7fffffffffffffffll - 1 )
|
||||||
#define MD_S64_MAX 0x7fffffffffffffffll
|
#define MD_S64_MAX 0x7fffffffffffffffll
|
||||||
|
|
||||||
#if defined( MD_ARCH_32_BIT )
|
#if defined( ARCH_32_BIT )
|
||||||
# define MD_USIZE_MIN MD_U32_MIN
|
# define MD_USIZE_MIN MD_U32_MIN
|
||||||
# define MD_USIZE_MAX MD_U32_MAX
|
# define MD_USIZE_MAX MD_U32_MAX
|
||||||
# define MD_ISIZE_MIN MD_S32_MIN
|
# define MD_ISIZE_MIN MD_S32_MIN
|
||||||
# define MD_ISIZE_MAX MD_S32_MAX
|
# define MD_ISIZE_MAX MD_S32_MAX
|
||||||
#elif defined( MD_ARCH_64_BIT )
|
#elif defined( ARCH_64_BIT )
|
||||||
# define MD_USIZE_MIN MD_U64_MIN
|
# define MD_USIZE_MIN MD_U64_MIN
|
||||||
# define MD_USIZE_MAX MD_U64_MAX
|
# define MD_USIZE_MAX MD_U64_MAX
|
||||||
# define MD_ISIZE_MIN MD_S64_MIN
|
# define MD_ISIZE_MIN MD_S64_MIN
|
||||||
|
|||||||
+108
-108
@@ -6,83 +6,83 @@
|
|||||||
|
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
# pragma message("Detected MSVC")
|
# pragma message("Detected MSVC")
|
||||||
// # define MD_COMPILER_CLANG 0
|
// # define COMPILER_CLANG 0
|
||||||
# define MD_COMPILER_MSVC 1
|
# define COMPILER_MSVC 1
|
||||||
// # define MD_COMPILER_GCC 0
|
// # define COMPILER_GCC 0
|
||||||
# if _MSC_VER >= 1920
|
# if _MSC_VER >= 1920
|
||||||
# define MD_COMPILER_MSVC_YEAR 2019
|
# define COMPILER_MSVC_YEAR 2019
|
||||||
# elif _MSC_VER >= 1910
|
# elif _MSC_VER >= 1910
|
||||||
# define MD_COMPILER_MSVC_YEAR 2017
|
# define COMPILER_MSVC_YEAR 2017
|
||||||
# elif _MSC_VER >= 1900
|
# elif _MSC_VER >= 1900
|
||||||
# define MD_COMPILER_MSVC_YEAR 2015
|
# define COMPILER_MSVC_YEAR 2015
|
||||||
# elif _MSC_VER >= 1800
|
# elif _MSC_VER >= 1800
|
||||||
# define MD_COMPILER_MSVC_YEAR 2013
|
# define COMPILER_MSVC_YEAR 2013
|
||||||
# elif _MSC_VER >= 1700
|
# elif _MSC_VER >= 1700
|
||||||
# define MD_COMPILER_MSVC_YEAR 2012
|
# define COMPILER_MSVC_YEAR 2012
|
||||||
# elif _MSC_VER >= 1600
|
# elif _MSC_VER >= 1600
|
||||||
# define MD_COMPILER_MSVC_YEAR 2010
|
# define COMPILER_MSVC_YEAR 2010
|
||||||
# elif _MSC_VER >= 1500
|
# elif _MSC_VER >= 1500
|
||||||
# define M_DCOMPILER_MSVC_YEAR 2008
|
# define M_DCOMPILER_MSVC_YEAR 2008
|
||||||
# elif _MSC_VER >= 1400
|
# elif _MSC_VER >= 1400
|
||||||
# define MD_COMPILER_MSVC_YEAR 2005
|
# define COMPILER_MSVC_YEAR 2005
|
||||||
# else
|
# else
|
||||||
# define MD_COMPILER_MSVC_YEAR 0
|
# define COMPILER_MSVC_YEAR 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#elif defined( __GNUC__ )
|
#elif defined( __GNUC__ )
|
||||||
# pragma message("Detected GCC")
|
# pragma message("Detected GCC")
|
||||||
// # define MD_COMPILER_CLANG 0
|
// # define COMPILER_CLANG 0
|
||||||
// # define MD_COMPILER_MSVC 0
|
// # define COMPILER_MSVC 0
|
||||||
# define MD_COMPILER_GCC 1
|
# define COMPILER_GCC 1
|
||||||
#elif defined( __clang__ )
|
#elif defined( __clang__ )
|
||||||
# pragma message("Detected CLANG")
|
# pragma message("Detected CLANG")
|
||||||
# define MD_COMPILER_CLANG 1
|
# define COMPILER_CLANG 1
|
||||||
// # define MD_COMPILER_MSVC 0
|
// # define COMPILER_MSVC 0
|
||||||
// # define MD_COMPILER_GCC 0
|
// # define COMPILER_GCC 0
|
||||||
#else
|
#else
|
||||||
# error Unknown compiler
|
# error Unknown compiler
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined( __has_attribute )
|
#if defined( __has_attribute )
|
||||||
# define MD_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
# define HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
|
||||||
#else
|
#else
|
||||||
# define MD_HAS_ATTRIBUTE( attribute ) ( 0 )
|
# define HAS_ATTRIBUTE( attribute ) ( 0 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MD_GCC_VERSION_CHECK)
|
#if defined(GCC_VERSION_CHECK)
|
||||||
# undef MD_GCC_VERSION_CHECK
|
# undef GCC_VERSION_CHECK
|
||||||
#endif
|
#endif
|
||||||
#if defined(GEN_GCC_VERSION)
|
#if defined(GEN_GCC_VERSION)
|
||||||
# define MD_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
|
# define GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
|
||||||
#else
|
#else
|
||||||
# define MD_GCC_VERSION_CHECK(major,minor,patch) (0)
|
# define GCC_VERSION_CHECK(major,minor,patch) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma endregion Compiler Vendor
|
#pragma endregion Compiler Vendor
|
||||||
|
|
||||||
#pragma endregion Language
|
#pragma endregion Language
|
||||||
|
|
||||||
#if ! defined(MD_LANG_C)
|
#if ! defined(LANG_C)
|
||||||
# ifdef __cplusplus
|
# ifdef __cplusplus
|
||||||
# define MD_LANG_C 0
|
# define LANG_C 0
|
||||||
# define MD_LANG_CPP 1
|
# define LANG_CPP 1
|
||||||
# else
|
# else
|
||||||
# if defined(__STDC__)
|
# if defined(__STDC__)
|
||||||
# define MD_LANG_C 1
|
# define LANG_C 1
|
||||||
# define MD_LANG_CPP 0
|
# define LANG_CPP 0
|
||||||
# else
|
# else
|
||||||
// Fallback for very old C compilers
|
// Fallback for very old C compilers
|
||||||
# define MD_LANG_C 1
|
# define LANG_C 1
|
||||||
# define MD_LANG_CPP 0
|
# define LANG_CPP 0
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# pragma message("MD: Detected C")
|
# pragma message("MD: Detected C")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_CPP
|
#if LANG_CPP
|
||||||
# pragma message("MD: Detected CPP")
|
# pragma message("MD: Detected CPP")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -90,56 +90,56 @@
|
|||||||
|
|
||||||
#pragma region Hardware Architecture
|
#pragma region Hardware Architecture
|
||||||
|
|
||||||
#if MD_COMPILER_CLANG
|
#if COMPILER_CLANG
|
||||||
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(__aarch64__)
|
# elif defined(__aarch64__)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(__arm__)
|
# elif defined(__arm__)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error Architecture not supported.
|
# error Architecture not supported.
|
||||||
# endif
|
# endif
|
||||||
#endif // MD_COMPILER_CLANG
|
#endif // COMPILER_CLANG
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# if defined(_M_AMD64)
|
# if defined(_M_AMD64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(_M_IX86)
|
# elif defined(_M_IX86)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(_M_ARM64)
|
# elif defined(_M_ARM64)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(_M_ARM)
|
# elif defined(_M_ARM)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error Architecture not supported.
|
# error Architecture not supported.
|
||||||
# endif
|
# endif
|
||||||
#endif // MD_COMPILER_MSVC
|
#endif // COMPILER_MSVC
|
||||||
|
|
||||||
#if MD_COMPILER_GCC
|
#if COMPILER_GCC
|
||||||
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(__aarch64__)
|
# elif defined(__aarch64__)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(__arm__)
|
# elif defined(__arm__)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error Architecture not supported.
|
# error Architecture not supported.
|
||||||
# endif
|
# endif
|
||||||
#endif // MD_COMPILER_GCC
|
#endif // COMPILER_GCC
|
||||||
|
|
||||||
#if defined(MD_ARCH_X64)
|
#if defined(ARCH_X64)
|
||||||
# define MD_ARCH_64BIT 1
|
# define ARCH_64BIT 1
|
||||||
#elif defined(MD_ARCH_X86)
|
#elif defined(ARCH_X86)
|
||||||
# define MD_ARCH_32BIT 1
|
# define ARCH_32BIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_ARCH_ARM32 || MD_ARCH_ARM64 || MD_ARCH_X64 || MD_ARCH_X86
|
#if ARCH_ARM32 || ARCH_ARM64 || ARCH_X64 || ARCH_X86
|
||||||
# define MD_ARCH_LITTLE_ENDIAN 1
|
# define ARCH_LITTLE_ENDIAN 1
|
||||||
#else
|
#else
|
||||||
# error Endianness of this architecture not understood by context cracker.
|
# error Endianness of this architecture not understood by context cracker.
|
||||||
#endif
|
#endif
|
||||||
@@ -149,46 +149,46 @@
|
|||||||
#pragma region Operating System
|
#pragma region Operating System
|
||||||
|
|
||||||
#if defined( _WIN32 ) || defined( _WIN64 )
|
#if defined( _WIN32 ) || defined( _WIN64 )
|
||||||
# ifndef MD_OS_WINDOWS
|
# ifndef OS_WINDOWS
|
||||||
# define MD_OS_WINDOWS 1
|
# define OS_WINDOWS 1
|
||||||
# endif
|
# endif
|
||||||
#elif defined( __APPLE__ ) && defined( __MACH__ )
|
#elif defined( __APPLE__ ) && defined( __MACH__ )
|
||||||
# ifndef MD_OS_OSX
|
# ifndef OS_OSX
|
||||||
# define MD_OS_OSX 1
|
# define OS_OSX 1
|
||||||
# endif
|
# endif
|
||||||
# ifndef MD_OS_MACOS
|
# ifndef OS_MACOS
|
||||||
# define MD_OS_MACOS 1
|
# define OS_MACOS 1
|
||||||
# endif
|
# endif
|
||||||
#elif defined( __unix__ )
|
#elif defined( __unix__ )
|
||||||
# ifndef MD_OS_UNIX
|
# ifndef OS_UNIX
|
||||||
# define MD_OS_UNIX 1
|
# define OS_UNIX 1
|
||||||
# endif
|
# endif
|
||||||
# if defined( ANDROID ) || defined( __ANDROID__ )
|
# if defined( ANDROID ) || defined( __ANDROID__ )
|
||||||
# ifndef MD_OS_ANDROID
|
# ifndef OS_ANDROID
|
||||||
# define MD_OS_ANDROID 1
|
# define OS_ANDROID 1
|
||||||
# endif
|
# endif
|
||||||
# ifndef MD_OS_LINUX
|
# ifndef OS_LINUX
|
||||||
# define MD_OS_LINUX 1
|
# define OS_LINUX 1
|
||||||
# endif
|
# endif
|
||||||
# elif defined( __linux__ )
|
# elif defined( __linux__ )
|
||||||
# ifndef MD_OS_LINUX
|
# ifndef OS_LINUX
|
||||||
# define MD_OS_LINUX 1
|
# define OS_LINUX 1
|
||||||
# endif
|
# endif
|
||||||
# elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
|
# elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
|
||||||
# ifndef MD_OS_FREEBSD
|
# ifndef OS_FREEBSD
|
||||||
# define MD_OS_FREEBSD 1
|
# define OS_FREEBSD 1
|
||||||
# endif
|
# endif
|
||||||
# elif defined( __OpenBSD__ )
|
# elif defined( __OpenBSD__ )
|
||||||
# ifndef MD_OS_OPENBSD
|
# ifndef OS_OPENBSD
|
||||||
# define MD_OS_OPENBSD 1
|
# define OS_OPENBSD 1
|
||||||
# endif
|
# endif
|
||||||
# elif defined( __EMSCRIPTEN__ )
|
# elif defined( __EMSCRIPTEN__ )
|
||||||
# ifndef MD_OS_EMSCRIPTEN
|
# ifndef OS_EMSCRIPTEN
|
||||||
# define MD_OS_EMSCRIPTEN 1
|
# define OS_EMSCRIPTEN 1
|
||||||
# endif
|
# endif
|
||||||
# elif defined( __CYGWIN__ )
|
# elif defined( __CYGWIN__ )
|
||||||
# ifndef MD_OS_CYGWIN
|
# ifndef OS_CYGWIN
|
||||||
# define MD_OS_CYGWIN 1
|
# define OS_CYGWIN 1
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# error This UNIX operating system is not supported
|
# error This UNIX operating system is not supported
|
||||||
@@ -205,55 +205,55 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Zero All Undefined Options
|
//~ rjf: Zero All Undefined Options
|
||||||
|
|
||||||
#if !defined(MD_ARCH_32BIT)
|
#if !defined(ARCH_32BIT)
|
||||||
# define MD_ARCH_32BIT 0
|
# define ARCH_32BIT 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_64BIT)
|
#if !defined(ARCH_64BIT)
|
||||||
# define MD_ARCH_64BIT 0
|
# define ARCH_64BIT 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_X64)
|
#if !defined(ARCH_X64)
|
||||||
# define MD_ARCH_X64 0
|
# define ARCH_X64 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_X86)
|
#if !defined(ARCH_X86)
|
||||||
# define MD_ARCH_X86 0
|
# define ARCH_X86 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_ARM64)
|
#if !defined(ARCH_ARM64)
|
||||||
# define MD_ARCH_ARM64 0
|
# define ARCH_ARM64 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_ARM32)
|
#if !defined(ARCH_ARM32)
|
||||||
# define MD_ARCH_ARM32 0
|
# define ARCH_ARM32 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_MSVC)
|
#if !defined(COMPILER_MSVC)
|
||||||
# define MD_COMPILER_MSVC 0
|
# define COMPILER_MSVC 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_GCC)
|
#if !defined(COMPILER_GCC)
|
||||||
# define MD_COMPILER_GCC 0
|
# define COMPILER_GCC 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_CLANG)
|
#if !defined(COMPILER_CLANG)
|
||||||
# define MD_COMPILER_CLANG 0
|
# define COMPILER_CLANG 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_WINDOWS)
|
#if !defined(OS_WINDOWS)
|
||||||
# define MD_OS_WINDOWS 0
|
# define OS_WINDOWS 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_LINUX)
|
#if !defined(OS_LINUX)
|
||||||
# define MD_OS_LINUX 0
|
# define OS_LINUX 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_MAC)
|
#if !defined(OS_MAC)
|
||||||
# define MD_OS_MAC 0
|
# define OS_MAC 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_LANG_CPP)
|
#if !defined(LANG_CPP)
|
||||||
# define MD_LANG_CPP 0
|
# define LANG_CPP 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_LANG_C)
|
#if !defined(LANG_C)
|
||||||
# define MD_LANG_C 0
|
# define LANG_C 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Unsupported Errors
|
//~ rjf: Unsupported Errors
|
||||||
|
|
||||||
#if MD_ARCH_X86
|
#if ARCH_X86
|
||||||
# error You tried to build in x86 (32 bit) mode, but currently, only building in x64 (64 bit) mode is supported.
|
# error You tried to build in x86 (32 bit) mode, but currently, only building in x64 (64 bit) mode is supported.
|
||||||
#endif
|
#endif
|
||||||
#if ! MD_ARCH_X64
|
#if ! ARCH_X64
|
||||||
# error You tried to build with an unsupported architecture. Currently, only building in x64 mode is supported.
|
# error You tried to build with an unsupported architecture. Currently, only building in x64 mode is supported.
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MD_API
|
#ifndef MD_API
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# ifdef MD_DYN_LINK
|
# ifdef MD_DYN_LINK
|
||||||
# ifdef MD_DYN_EXPORT
|
# ifdef MD_DYN_EXPORT
|
||||||
# define MD_API __declspec(dllexport)
|
# define MD_API __declspec(dllexport)
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
#endif // GEN_API
|
#endif // GEN_API
|
||||||
|
|
||||||
#ifndef MD_API_C_BEGIN
|
#ifndef MD_API_C_BEGIN
|
||||||
# if MD_LANG_C
|
# if LANG_C
|
||||||
# define MD_API_C_BEGIN
|
# define MD_API_C_BEGIN
|
||||||
# define MD_API_C_END
|
# define MD_API_C_END
|
||||||
# define MD_API_C
|
# define MD_API_C
|
||||||
|
|||||||
+10
-10
@@ -8,16 +8,16 @@
|
|||||||
#define local_persist static
|
#define local_persist static
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# define thread_static __declspec(thread)
|
# define thread_static __declspec(thread)
|
||||||
#elif MD_COMPILER_CLANG || MD_COMPILER_GCC
|
#elif COMPILER_CLANG || COMPILER_GCC
|
||||||
# define thread_static __thread
|
# define thread_static __thread
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Branch Predictor Hints
|
//~ rjf: Branch Predictor Hints
|
||||||
|
|
||||||
#if MD_COMPILER_CLANG
|
#if COMPILER_CLANG
|
||||||
# define expect(expr, val) __builtin_expect((expr), (val))
|
# define expect(expr, val) __builtin_expect((expr), (val))
|
||||||
#else
|
#else
|
||||||
# define expect(expr, val) (expr)
|
# define expect(expr, val) (expr)
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ erg: type casting
|
//~ erg: type casting
|
||||||
|
|
||||||
#if MD_LANG_CPP
|
#if LANG_CPP
|
||||||
# ifndef ccast
|
# ifndef ccast
|
||||||
# define ccast( type, value ) ( const_cast< type >( (value) ) )
|
# define ccast( type, value ) ( const_cast< type >( (value) ) )
|
||||||
# endif
|
# endif
|
||||||
@@ -57,8 +57,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ! defined(typeof) && ( ! MD_LANG_C || __STDC_VERSION__ < 202311L)
|
#if ! defined(typeof) && ( ! LANG_C || __STDC_VERSION__ < 202311L)
|
||||||
# if ! MD_LANG_C
|
# if ! LANG_C
|
||||||
# define typeof decltype
|
# define typeof decltype
|
||||||
# elif defined(_MSC_VER)
|
# elif defined(_MSC_VER)
|
||||||
# define typeof __typeof__
|
# define typeof __typeof__
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# if __STDC_VERSION__ >= 202311L
|
# if __STDC_VERSION__ >= 202311L
|
||||||
# define enum_underlying(type) : type
|
# define enum_underlying(type) : type
|
||||||
# else
|
# else
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
# define enum_underlying(type) : type
|
# define enum_underlying(type) : type
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# ifndef nullptr
|
# ifndef nullptr
|
||||||
# define nullptr NULL
|
# define nullptr NULL
|
||||||
# endif
|
# endif
|
||||||
@@ -89,13 +89,13 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ! defined(MD_PARAM_DEFAULT) && MD_LANG_CPP
|
#if ! defined(MD_PARAM_DEFAULT) && LANG_CPP
|
||||||
# define MD_PARAM_DEFAULT = {}
|
# define MD_PARAM_DEFAULT = {}
|
||||||
#else
|
#else
|
||||||
# define MD_PARAM_DEFAULT
|
# define MD_PARAM_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# ifndef static_assert
|
# ifndef static_assert
|
||||||
# undef static_assert
|
# undef static_assert
|
||||||
# if __STDC_VERSION__ >= 201112L
|
# if __STDC_VERSION__ >= 201112L
|
||||||
|
|||||||
+85
-24
@@ -4,40 +4,75 @@
|
|||||||
# include "linkage.h"
|
# include "linkage.h"
|
||||||
# include "macros.h"
|
# include "macros.h"
|
||||||
# include "platform.h"
|
# include "platform.h"
|
||||||
# include "memory_substrate.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Units
|
//~ rjf: Units
|
||||||
|
|
||||||
#define KB(n) (((U64)(n)) << 10)
|
#ifndef KILOBTYES
|
||||||
#define MB(n) (((U64)(n)) << 20)
|
#define KILOBYTES( x ) ( ( x ) * ( S64 )( 1024 ) )
|
||||||
#define GB(n) (((U64)(n)) << 30)
|
#endif
|
||||||
#define TB(n) (((U64)(n)) << 40)
|
#ifndef MEGABYTES
|
||||||
|
#define MEGABYTES( x ) ( MD_KILOBYTES( x ) * ( S64 )( 1024 ) )
|
||||||
|
#endif
|
||||||
|
#ifndef GIGABYTES
|
||||||
|
#define GIGABYTES( x ) ( MD_MEGABYTES( x ) * ( S64 )( 1024 ) )
|
||||||
|
#endif
|
||||||
|
#ifndef TERABYTES
|
||||||
|
#define TERABYTES( x ) ( MD_GIGABYTES( x ) * ( S64 )( 1024 ) )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef KB
|
||||||
|
#define KB(n) (((U64)(n)) << 10)
|
||||||
|
#endif
|
||||||
|
#ifndef MB
|
||||||
|
#define MB(n) (((U64)(n)) << 20)
|
||||||
|
#endif
|
||||||
|
#ifndef GB
|
||||||
|
#define GB(n) (((U64)(n)) << 30)
|
||||||
|
#endif
|
||||||
|
#ifndef TB
|
||||||
|
#define TB(n) (((U64)(n)) << 40)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef thosuand
|
||||||
#define thousand(n) ((n) * 1000)
|
#define thousand(n) ((n) * 1000)
|
||||||
|
#endif
|
||||||
|
#ifndef million
|
||||||
#define million(n) ((n) * 1000000)
|
#define million(n) ((n) * 1000000)
|
||||||
|
#endif
|
||||||
|
#ifndef billion
|
||||||
#define billion(n) ((n) * 1000000000)
|
#define billion(n) ((n) * 1000000000)
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Clamps, Mins, Maxes
|
//~ rjf: Clamps, Mins, Maxes
|
||||||
|
|
||||||
|
#ifndef min
|
||||||
#define min(A,B) (((A) < (B)) ? (A) : (B))
|
#define min(A,B) (((A) < (B)) ? (A) : (B))
|
||||||
|
#endif
|
||||||
|
#ifndef max
|
||||||
#define max(A,B) (((A) > (B)) ? (A) : (B))
|
#define max(A,B) (((A) > (B)) ? (A) : (B))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef clamp_top
|
||||||
#define clamp_top(A,X) Min(A, X)
|
#define clamp_top(A,X) Min(A, X)
|
||||||
|
#endif
|
||||||
|
#ifndef clamp_bot
|
||||||
#define clamp_bot(X,B) Max(X, B)
|
#define clamp_bot(X,B) Max(X, B)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define clamp(A,X,B) (((X) < (A)) ? (A) : ((X) > (B)) ? (B) : (X))
|
#define clamp(A,X,B) (((X) < (A)) ? (A) : ((X) > (B)) ? (B) : (X))
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Type -> Alignment
|
//~ rjf: Type -> Alignment
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# define align_of(T) __alignof(T)
|
# define align_of(T) __alignof(T)
|
||||||
#elif MD_COMPILER_CLANG
|
#elif COMPILER_CLANG
|
||||||
# define align_of(T) __alignof(T)
|
# define align_of(T) __alignof(T)
|
||||||
#elif MD_COMPILER_GCC
|
#elif COMPILER_GCC
|
||||||
# define align_of(T) __alignof__(T)
|
# define align_of(T) __alignof__(T)
|
||||||
#else
|
#else
|
||||||
# error AlignOf not defined for this compiler.
|
# error AlignOf not defined for this compiler.
|
||||||
@@ -87,9 +122,9 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Asserts
|
//~ rjf: Asserts
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# define trap() __debugbreak()
|
# define trap() __debugbreak()
|
||||||
#elif MD_COMPILER_CLANG || COMPILER_GCC
|
#elif COMPILER_CLANG || COMPILER_GCC
|
||||||
# define trap() __builtin_trap()
|
# define trap() __builtin_trap()
|
||||||
#else
|
#else
|
||||||
# error Unknown trap intrinsic for this compiler.
|
# error Unknown trap intrinsic for this compiler.
|
||||||
@@ -111,8 +146,8 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Atomic Operations
|
//~ rjf: Atomic Operations
|
||||||
|
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
# if MD_ARCH_X64
|
# if ARCH_X64
|
||||||
# define ins_atomic_u64_eval(x) InterlockedAdd64((volatile __int64 *)(x), 0)
|
# define ins_atomic_u64_eval(x) InterlockedAdd64((volatile __int64 *)(x), 0)
|
||||||
# define ins_atomic_u64_inc_eval(x) InterlockedIncrement64((volatile __int64 *)(x))
|
# define ins_atomic_u64_inc_eval(x) InterlockedIncrement64((volatile __int64 *)(x))
|
||||||
# define ins_atomic_u64_dec_eval(x) InterlockedDecrement64((volatile __int64 *)(x))
|
# define ins_atomic_u64_dec_eval(x) InterlockedDecrement64((volatile __int64 *)(x))
|
||||||
@@ -126,8 +161,8 @@
|
|||||||
# else
|
# else
|
||||||
# error Atomic intrinsics not defined for this operating system / architecture combination.
|
# error Atomic intrinsics not defined for this operating system / architecture combination.
|
||||||
# endif
|
# endif
|
||||||
#elif MD_OS_LINUX
|
#elif OS_LINUX
|
||||||
# if MD_ARCH_X64
|
# if ARCH_X64
|
||||||
# define ins_atomic_u64_inc_eval(x) __sync_fetch_and_add((volatile U64 *)(x), 1)
|
# define ins_atomic_u64_inc_eval(x) __sync_fetch_and_add((volatile U64 *)(x), 1)
|
||||||
# else
|
# else
|
||||||
# error Atomic intrinsics not defined for this operating system / architecture combination.
|
# error Atomic intrinsics not defined for this operating system / architecture combination.
|
||||||
@@ -279,14 +314,14 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Address Sanitizer Markup
|
//~ rjf: Address Sanitizer Markup
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC
|
#if COMPILER_MSVC
|
||||||
# if defined(__SANITIZE_ADDRESS__)
|
# if defined(__SANITIZE_ADDRESS__)
|
||||||
# define ASAN_ENABLED 1
|
# define ASAN_ENABLED 1
|
||||||
# define NO_ASAN __declspec(no_sanitize_address)
|
# define NO_ASAN __declspec(no_sanitize_address)
|
||||||
# else
|
# else
|
||||||
# define NO_ASAN
|
# define NO_ASAN
|
||||||
# endif
|
# endif
|
||||||
#elif MD_COMPILER_CLANG
|
#elif COMPILER_CLANG
|
||||||
# if defined(__has_feature)
|
# if defined(__has_feature)
|
||||||
# if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
# if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||||
# define ASAN_ENABLED 1
|
# define ASAN_ENABLED 1
|
||||||
@@ -312,24 +347,36 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Misc. Helper Macros
|
//~ rjf: Misc. Helper Macros
|
||||||
|
|
||||||
|
#ifndef stringify
|
||||||
#define stringify_(S) #S
|
#define stringify_(S) #S
|
||||||
#define stringify(S) stringify_(S)
|
#define stringify(S) stringify_(S)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef glue
|
||||||
#define glue_(A,B) A ## B
|
#define glue_(A,B) A ## B
|
||||||
#define glue(A,B) glue_(A,B)
|
#define glue(A,B) glue_(A,B)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef array_count
|
||||||
#define array_count(a) (sizeof(a) / sizeof((a)[0]))
|
#define array_count(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ceil_integer_div
|
||||||
#define ceil_integer_div(a,b) (((a) + (b) - 1) / (b))
|
#define ceil_integer_div(a,b) (((a) + (b) - 1) / (b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef swap
|
||||||
#define swap(T, a, b) do { T t__ = a; a = b; b = t__; } while(0)
|
#define swap(T, a, b) do { T t__ = a; a = b; b = t__; } while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MD_ARCH_64BIT
|
#ifndef int_from_ptr
|
||||||
# define int_from_ptr(ptr) ((U64)(ptr))
|
# if ARCH_64BIT
|
||||||
#elif MD_ARCH_32BIT
|
# define int_from_ptr(ptr) ((U64)(ptr))
|
||||||
# define int_from_ptr(ptr) ((U32)(ptr))
|
# elif ARCH_32BIT
|
||||||
#else
|
# define int_from_ptr(ptr) ((U32)(ptr))
|
||||||
# error Missing pointer-to-integer cast for this architecture.
|
# else
|
||||||
|
# error Missing pointer-to-integer cast for this architecture.
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ptr_from_int(i) (void*)((U8*)0 + (i))
|
#define ptr_from_int(i) (void*)((U8*)0 + (i))
|
||||||
@@ -343,14 +390,28 @@
|
|||||||
|
|
||||||
#define extract_bit(word, idx) (((word) >> (idx)) & 1)
|
#define extract_bit(word, idx) (((word) >> (idx)) & 1)
|
||||||
|
|
||||||
#if MD_LANG_CPP
|
#if LANG_CPP
|
||||||
# define zero_struct {}
|
# define zero_struct {}
|
||||||
#else
|
#else
|
||||||
# define zero_struct {0}
|
# define zero_struct {0}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC && MD_COMPILER_MSVC_YEAR < 2015
|
#if COMPILER_MSVC && COMPILER_MSVC_YEAR < 2015
|
||||||
# define this_function_name "unknown"
|
# define this_function_name "unknown"
|
||||||
#else
|
#else
|
||||||
# define this_function_name __func__
|
# define this_function_name __func__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if COMPILER_MSVC || (COMPILER_CLANG && OS_WINDOWS)
|
||||||
|
# pragma section(".rdata$", read)
|
||||||
|
# define read_only __declspec(allocate(".rdata$"))
|
||||||
|
#elif (COMPILER_CLANG && OS_LINUX)
|
||||||
|
# define read_only __attribute__((section(".rodata")))
|
||||||
|
#else
|
||||||
|
// NOTE(rjf): I don't know of a useful way to do this in GCC land.
|
||||||
|
// __attribute__((section(".rodata"))) looked promising, but it introduces a
|
||||||
|
// strange warning about malformed section attributes, and it doesn't look
|
||||||
|
// like writing to that section reliably produces access violations, strangely
|
||||||
|
// enough. (It does on Clang)
|
||||||
|
# define read_only
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
# include "context_cracking.h"
|
# include "context_cracking.h"
|
||||||
# include "linkage.h"
|
# include "linkage.h"
|
||||||
# include "macros.h"
|
# include "macros.h"
|
||||||
# include "linkage.h"
|
# include "platform.h"
|
||||||
# include "base_types.h"
|
# include "base_types.h"
|
||||||
|
# include "memory.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This provides an alterntive memory strategy to HMH/Casey Muratori/RJF styled arenas
|
// This provides an alterntive memory strategy to HMH/Casey Muratori/RJF styled arenas
|
||||||
@@ -12,29 +13,10 @@
|
|||||||
// is related to the gb headers an thus the Odin-lang memory strategy
|
// is related to the gb headers an thus the Odin-lang memory strategy
|
||||||
// Users can override the underlying memory allocator used, even for the HMH arena memory strategy.
|
// Users can override the underlying memory allocator used, even for the HMH arena memory strategy.
|
||||||
|
|
||||||
#define MD_KILOBYTES( x ) ( ( x ) * ( S64 )( 1024 ) )
|
|
||||||
#define MD_MEGABYTES( x ) ( MD_KILOBYTES( x ) * ( S64 )( 1024 ) )
|
|
||||||
#define MD_GIGABYTES( x ) ( MD_MEGABYTES( x ) * ( S64 )( 1024 ) )
|
|
||||||
#define MD_TERABYTES( x ) ( MD_GIGABYTES( x ) * ( S64 )( 1024 ) )
|
|
||||||
|
|
||||||
#define MD__ONES ( scast( GEN_NS usize, - 1) / MD_U8_MAX )
|
#define MD__ONES ( scast( GEN_NS usize, - 1) / MD_U8_MAX )
|
||||||
#define MD__HIGHS ( MD__ONES * ( MD_U8_MAX / 2 + 1 ) )
|
#define MD__HIGHS ( MD__ONES * ( MD_U8_MAX / 2 + 1 ) )
|
||||||
#define MD__HAS_ZERO( x ) ( ( ( x ) - MD__ONES ) & ~( x ) & MD__HIGHS )
|
#define MD__HAS_ZERO( x ) ( ( ( x ) - MD__ONES ) & ~( x ) & MD__HIGHS )
|
||||||
|
|
||||||
#if MD_COMPILER_MSVC || (MD_COMPILER_CLANG && MD_OS_WINDOWS)
|
|
||||||
# pragma section(".rdata$", read)
|
|
||||||
# define read_only __declspec(allocate(".rdata$"))
|
|
||||||
#elif (MD_COMPILER_CLANG && MD_OS_LINUX)
|
|
||||||
# define read_only __attribute__((section(".rodata")))
|
|
||||||
#else
|
|
||||||
// NOTE(rjf): I don't know of a useful way to do this in GCC land.
|
|
||||||
// __attribute__((section(".rodata"))) looked promising, but it introduces a
|
|
||||||
// strange warning about malformed section attributes, and it doesn't look
|
|
||||||
// like writing to that section reliably produces access violations, strangely
|
|
||||||
// enough. (It does on Clang)
|
|
||||||
# define read_only
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef U32 AllocType;
|
typedef U32 AllocType;
|
||||||
enum AllocType enum_underlying(U32)
|
enum AllocType enum_underlying(U32)
|
||||||
{
|
{
|
||||||
@@ -114,3 +96,17 @@ MD_API void* heap_allocator_proc( void* allocator_data, AllocType type, SSIZE si
|
|||||||
|
|
||||||
//! Helper to free memory allocated by heap allocator.
|
//! Helper to free memory allocated by heap allocator.
|
||||||
#define mfree( ptr ) free( heap(), ptr )
|
#define mfree( ptr ) free( heap(), ptr )
|
||||||
|
|
||||||
|
typedef struct VMem;
|
||||||
|
struct VMem {
|
||||||
|
U32 cmt_size;
|
||||||
|
U32 res_size;
|
||||||
|
U64 base_pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
AllocatorInfo vm_allocator(VMem* vm) {
|
||||||
|
AllocatorInfo info = { vm_allocator_proc, vm }
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
|
MD_API void* vm_allocator_proc(void * allocator_data, AllocType type, SSIZE size, SSIZE alignment, void* old_memory, SSIZE old_size, U64 flags);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++ namespace support
|
// C++ namespace support
|
||||||
#if defined(MD_DONT_USE_NAMESPACE) || MD_LANG_C
|
#if defined(MD_DONT_USE_NAMESPACE) || LANG_C
|
||||||
# if MD_LANG_C
|
# if LANG_C
|
||||||
# define MD_NS
|
# define MD_NS
|
||||||
# define MD_NS_BEGIN
|
# define MD_NS_BEGIN
|
||||||
# define MD_NS_END
|
# define MD_NS_END
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#if defined( MD_OS_WINDOWS )
|
#if defined( OS_WINDOWS )
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
# include <tmmintrin.h>
|
# include <tmmintrin.h>
|
||||||
# include <wmmintrin.h>
|
# include <wmmintrin.h>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
# undef VC_EXTRALEAN
|
# undef VC_EXTRALEAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-2
@@ -102,9 +102,9 @@ typedef enum PathStyle
|
|||||||
PathStyle_WindowsAbsolute,
|
PathStyle_WindowsAbsolute,
|
||||||
PathStyle_UnixAbsolute,
|
PathStyle_UnixAbsolute,
|
||||||
|
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
PathStyle_SystemAbsolute = PathStyle_WindowsAbsolute
|
PathStyle_SystemAbsolute = PathStyle_WindowsAbsolute
|
||||||
#elif MD_OS_LINUX
|
#elif OS_LINUX
|
||||||
PathStyle_SystemAbsolute = PathStyle_UnixAbsolute
|
PathStyle_SystemAbsolute = PathStyle_UnixAbsolute
|
||||||
#else
|
#else
|
||||||
# error "absolute path style is undefined for this OS"
|
# error "absolute path style is undefined for this OS"
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
#include "md.h"
|
#include "md.h"
|
||||||
#include "md.c"
|
#include "md.c"
|
||||||
|
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
#elif MD_OS_MAC || MD_OS_LINUX
|
#elif OS_MAC || OS_LINUX
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#else
|
#else
|
||||||
# error Not implemented for this OS
|
# error Not implemented for this OS
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
#if MD_COMPILER_CL
|
#if MD_COMPILER_CL
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
# define atomic_inc_then_eval_u64(p) _InterlockedIncrement64((volatile __int64*)p)
|
# define atomic_inc_then_eval_u64(p) _InterlockedIncrement64((volatile __int64*)p)
|
||||||
#elif MD_COMPILER_CLANG || MD_COMPILER_GCC
|
#elif COMPILER_CLANG || COMPILER_GCC
|
||||||
# define atomic_inc_then_eval_u64(p) __sync_add_and_fetch(p, 1)
|
# define atomic_inc_then_eval_u64(p) __sync_add_and_fetch(p, 1)
|
||||||
#else
|
#else
|
||||||
# error Not implemented for this compiler
|
# error Not implemented for this compiler
|
||||||
@@ -95,14 +95,14 @@ parse_worker_loop(ThreadData *thread_data)
|
|||||||
atomic_inc_then_eval_u64(&task->thread_counter);
|
atomic_inc_then_eval_u64(&task->thread_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
DWORD
|
DWORD
|
||||||
parse_worker_win32(LPVOID parameter)
|
parse_worker_win32(LPVOID parameter)
|
||||||
{
|
{
|
||||||
parse_worker_loop((ThreadData*)parameter);
|
parse_worker_loop((ThreadData*)parameter);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#elif MD_OS_MAC || MD_OS_LINUX
|
#elif OS_MAC || OS_LINUX
|
||||||
void *
|
void *
|
||||||
parse_worker_pthread(void *parameter)
|
parse_worker_pthread(void *parameter)
|
||||||
{
|
{
|
||||||
@@ -143,13 +143,13 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
// launch the worker threads
|
// launch the worker threads
|
||||||
// (no worker thread 0)
|
// (no worker thread 0)
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
HANDLE handles[THREAD_COUNT];
|
HANDLE handles[THREAD_COUNT];
|
||||||
for (int i = 1; i < THREAD_COUNT; i += 1)
|
for (int i = 1; i < THREAD_COUNT; i += 1)
|
||||||
{
|
{
|
||||||
handles[i] = CreateThread(0, 0, &parse_worker_win32, threads + i, 0, 0);
|
handles[i] = CreateThread(0, 0, &parse_worker_win32, threads + i, 0, 0);
|
||||||
}
|
}
|
||||||
#elif MD_OS_MAC || MD_OS_LINUX
|
#elif OS_MAC || OS_LINUX
|
||||||
pthread_t handles[THREAD_COUNT];
|
pthread_t handles[THREAD_COUNT];
|
||||||
for (int i = 1; i < THREAD_COUNT; i += 1)
|
for (int i = 1; i < THREAD_COUNT; i += 1)
|
||||||
{
|
{
|
||||||
@@ -163,13 +163,13 @@ main(int argc, char **argv)
|
|||||||
parse_worker_loop(&threads[0]);
|
parse_worker_loop(&threads[0]);
|
||||||
|
|
||||||
// wait for all threads to be finished
|
// wait for all threads to be finished
|
||||||
#if MD_OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
WaitForMultipleObjects(THREAD_COUNT-1, handles+1, TRUE, INFINITE);
|
WaitForMultipleObjects(THREAD_COUNT-1, handles+1, TRUE, INFINITE);
|
||||||
for (int i = 1; i < THREAD_COUNT; i += 1)
|
for (int i = 1; i < THREAD_COUNT; i += 1)
|
||||||
{
|
{
|
||||||
CloseHandle(handles[i]);
|
CloseHandle(handles[i]);
|
||||||
}
|
}
|
||||||
#elif MD_OS_MAC || MD_OS_LINUX
|
#elif OS_MAC || OS_LINUX
|
||||||
for (int i = 1; i < THREAD_COUNT; i += 1)
|
for (int i = 1; i < THREAD_COUNT; i += 1)
|
||||||
{
|
{
|
||||||
pthread_join(handles[i], 0);
|
pthread_join(handles[i], 0);
|
||||||
|
|||||||
+60
-2
@@ -15,11 +15,21 @@
|
|||||||
|
|
||||||
// base module
|
// base module
|
||||||
|
|
||||||
word global, md_global
|
word HAS_ATTRIBUTE, MD_HAS_ATTRIBUTE
|
||||||
word internal, md_internal
|
|
||||||
|
namespace ARCH_, MD_ARCH_
|
||||||
|
namespace COMPILER_, MD_COMPILER_
|
||||||
|
namespace GCC_, MD_GCC_
|
||||||
|
namespace LANG_, MD_LANG_
|
||||||
|
namespace OS_, MD_OS_
|
||||||
|
|
||||||
|
word global, md_global
|
||||||
|
word internal, md_internal
|
||||||
|
|
||||||
word local_persist, md_local_persist
|
word local_persist, md_local_persist
|
||||||
word thread_static, md_thread_static
|
word thread_static, md_thread_static
|
||||||
|
|
||||||
|
word expect, md_expect
|
||||||
word likely, md_likely
|
word likely, md_likely
|
||||||
word unlikely, md_unlikely
|
word unlikely, md_unlikely
|
||||||
|
|
||||||
@@ -56,6 +66,54 @@ word B8, MD_B8
|
|||||||
word B16, MD_B16
|
word B16, MD_B16
|
||||||
word B32, MD_B32
|
word B32, MD_B32
|
||||||
|
|
||||||
|
word KILOBYTES, MD_KILOBYTES
|
||||||
|
word MEGABYTES, MD_MEGABYTES
|
||||||
|
word GIGABYTES, MD_GIGABYTES
|
||||||
|
word TERABYTES, MD_TERABYTES
|
||||||
|
|
||||||
|
word KB, MD_KB
|
||||||
|
word MB, MD_MB
|
||||||
|
word GB, MD_GB
|
||||||
|
word TB, MD_TB
|
||||||
|
|
||||||
|
word thosuand, md_thousand
|
||||||
|
word million, md_million
|
||||||
|
word billion, md_billion
|
||||||
|
|
||||||
|
word min, md_min
|
||||||
|
word max, md_max
|
||||||
|
|
||||||
|
word clamp_top, md_clamp_top
|
||||||
|
word clamp_bot, md_clamp_bot
|
||||||
|
word clamp, md_clamp
|
||||||
|
|
||||||
|
word align_of, md_align_of
|
||||||
|
word offset_of, md_offset_of
|
||||||
|
word member_from_offset, md_member_from_offset
|
||||||
|
word cast_from_member, md_cast_from_member
|
||||||
|
|
||||||
|
word defer_loop, md_defer_loop
|
||||||
|
word defer_loop_checked, md_defer_loop_checked
|
||||||
|
|
||||||
|
word each_enum_val, md_each_enum_val
|
||||||
|
word each_non_zero_enum_val, md_each_non_zero_enum_val
|
||||||
|
|
||||||
|
word memory_copy, md_memory_copy
|
||||||
|
word memory_set, md_memory_set
|
||||||
|
word memory_compare, md_memory_compare
|
||||||
|
word memory_str_len, md_memory_str_len
|
||||||
|
|
||||||
|
word memory_copy_struct, md_memory_copy_struct
|
||||||
|
word memory_copy_array, md_memory_copy_array
|
||||||
|
word memory_copy_type, md_memory_copy_type
|
||||||
|
|
||||||
|
word memory_zero, md_memory_zero
|
||||||
|
word memory_zero_struct, md_memory_zero_struct
|
||||||
|
word memroy_zero_array, md_memory_zero_array
|
||||||
|
word memory_zero_type, md_memory_zero_type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
word swap, md_swap
|
word swap, md_swap
|
||||||
|
|
||||||
word readonly, md_readonly
|
word readonly, md_readonly
|
||||||
|
|||||||
+6
-6
@@ -127,13 +127,13 @@ MD_CRT_LoadEntireFile(MD_Arena *arena, MD_String8 filename)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//- win32 header
|
//- win32 header
|
||||||
#if (MD_DEFAULT_FILE_ITER || MD_2DEFAULT_MEMORY) && MD_OS_WINDOWS
|
#if (MD_DEFAULT_FILE_ITER || MD_2DEFAULT_MEMORY) && OS_WINDOWS
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
# pragma comment(lib, "User32.lib")
|
# pragma comment(lib, "User32.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- win32 "file iteration"
|
//- win32 "file iteration"
|
||||||
#if MD_DEFAULT_FILE_ITER && MD_OS_WINDOWS
|
#if MD_DEFAULT_FILE_ITER && OS_WINDOWS
|
||||||
|
|
||||||
#if !defined(MD_IMPL_FileIterBegin)
|
#if !defined(MD_IMPL_FileIterBegin)
|
||||||
# define MD_IMPL_FileIterBegin MD_WIN32_FileIterBegin
|
# define MD_IMPL_FileIterBegin MD_WIN32_FileIterBegin
|
||||||
@@ -230,7 +230,7 @@ MD_WIN32_FileIterEnd(MD_FileIter *it)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- win32 "low level memory"
|
//- win32 "low level memory"
|
||||||
#if MD_DEFAULT_MEMORY && MD_OS_WINDOWS
|
#if MD_DEFAULT_MEMORY && OS_WINDOWS
|
||||||
|
|
||||||
#if !defined(MD_IMPL_Reserve)
|
#if !defined(MD_IMPL_Reserve)
|
||||||
# define MD_IMPL_Reserve MD_WIN32_Reserve
|
# define MD_IMPL_Reserve MD_WIN32_Reserve
|
||||||
@@ -279,7 +279,7 @@ MD_WIN32_Release(void *ptr, MD_u64 size)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//- linux headers
|
//- linux headers
|
||||||
#if (MD_DEFAULT_FILE_ITER || MD_DEFAULT_MEMORY) && (MD_OS_LINUX || MD_OS_MAC)
|
#if (MD_DEFAULT_FILE_ITER || MD_DEFAULT_MEMORY) && (OS_LINUX || OS_MAC)
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
@@ -300,7 +300,7 @@ MD_WIN32_Release(void *ptr, MD_u64 size)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- linux "file iteration"
|
//- linux "file iteration"
|
||||||
#if MD_DEFAULT_FILE_ITER && MD_OS_LINUX
|
#if MD_DEFAULT_FILE_ITER && OS_LINUX
|
||||||
|
|
||||||
#if !defined(MD_IMPL_FileIterIncrement)
|
#if !defined(MD_IMPL_FileIterIncrement)
|
||||||
# define MD_IMPL_FileIterIncrement MD_LINUX_FileIterIncrement
|
# define MD_IMPL_FileIterIncrement MD_LINUX_FileIterIncrement
|
||||||
@@ -368,7 +368,7 @@ MD_LINUX_FileIterIncrement(MD_Arena *arena, MD_FileIter *opaque_it, MD_String8 p
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- linux "low level memory"
|
//- linux "low level memory"
|
||||||
#if MD_DEFAULT_MEMORY && (MD_OS_LINUX || MD_OS_MAC)
|
#if MD_DEFAULT_MEMORY && (OS_LINUX || OS_MAC)
|
||||||
|
|
||||||
#if !defined(MD_IMPL_Reserve)
|
#if !defined(MD_IMPL_Reserve)
|
||||||
# define MD_IMPL_Reserve MD_LINUX_Reserve
|
# define MD_IMPL_Reserve MD_LINUX_Reserve
|
||||||
|
|||||||
+56
-56
@@ -92,26 +92,26 @@
|
|||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
|
|
||||||
# define MD_COMPILER_CLANG 1
|
# define COMPILER_CLANG 1
|
||||||
|
|
||||||
# if defined(__APPLE__) && defined(__MACH__)
|
# if defined(__APPLE__) && defined(__MACH__)
|
||||||
# define MD_OS_MAC 1
|
# define OS_MAC 1
|
||||||
# elif defined(__gnu_linux__)
|
# elif defined(__gnu_linux__)
|
||||||
# define MD_OS_LINUX 1
|
# define OS_LINUX 1
|
||||||
# elif defined(_WIN32)
|
# elif defined(_WIN32)
|
||||||
# define MD_OS_WINDOWS 1
|
# define OS_WINDOWS 1
|
||||||
# else
|
# else
|
||||||
# error This compiler/platform combo is not supported yet
|
# error This compiler/platform combo is not supported yet
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(__aarch64__)
|
# elif defined(__aarch64__)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(__arm__)
|
# elif defined(__arm__)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error architecture not supported yet
|
# error architecture not supported yet
|
||||||
# endif
|
# endif
|
||||||
@@ -121,19 +121,19 @@
|
|||||||
# define MD_COMPILER_CL 1
|
# define MD_COMPILER_CL 1
|
||||||
|
|
||||||
# if defined(_WIN32)
|
# if defined(_WIN32)
|
||||||
# define MD_OS_WINDOWS 1
|
# define OS_WINDOWS 1
|
||||||
# else
|
# else
|
||||||
# error This compiler/platform combo is not supported yet
|
# error This compiler/platform combo is not supported yet
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(_M_AMD64)
|
# if defined(_M_AMD64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(_M_IX86)
|
# elif defined(_M_IX86)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(_M_ARM64)
|
# elif defined(_M_ARM64)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(_M_ARM)
|
# elif defined(_M_ARM)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error architecture not supported yet
|
# error architecture not supported yet
|
||||||
# endif
|
# endif
|
||||||
@@ -160,22 +160,22 @@
|
|||||||
|
|
||||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||||
|
|
||||||
# define MD_COMPILER_GCC 1
|
# define COMPILER_GCC 1
|
||||||
|
|
||||||
# if defined(__gnu_linux__)
|
# if defined(__gnu_linux__)
|
||||||
# define MD_OS_LINUX 1
|
# define OS_LINUX 1
|
||||||
# else
|
# else
|
||||||
# error This compiler/platform combo is not supported yet
|
# error This compiler/platform combo is not supported yet
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
|
||||||
# define MD_ARCH_X64 1
|
# define ARCH_X64 1
|
||||||
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
# elif defined(i386) || defined(__i386) || defined(__i386__)
|
||||||
# define MD_ARCH_X86 1
|
# define ARCH_X86 1
|
||||||
# elif defined(__aarch64__)
|
# elif defined(__aarch64__)
|
||||||
# define MD_ARCH_ARM64 1
|
# define ARCH_ARM64 1
|
||||||
# elif defined(__arm__)
|
# elif defined(__arm__)
|
||||||
# define MD_ARCH_ARM32 1
|
# define ARCH_ARM32 1
|
||||||
# else
|
# else
|
||||||
# error architecture not supported yet
|
# error architecture not supported yet
|
||||||
# endif
|
# endif
|
||||||
@@ -184,14 +184,14 @@
|
|||||||
# error This compiler is not supported yet
|
# error This compiler is not supported yet
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MD_ARCH_X64)
|
#if defined(ARCH_X64)
|
||||||
# define MD_ARCH_64BIT 1
|
# define ARCH_64BIT 1
|
||||||
#elif defined(MD_ARCH_X86)
|
#elif defined(ARCH_X86)
|
||||||
# define MD_ARCH_32BIT 1
|
# define ARCH_32BIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
# define MD_LANG_CPP 1
|
# define LANG_CPP 1
|
||||||
|
|
||||||
// We can't get this 100% correct thanks to Microsoft's compiler.
|
// We can't get this 100% correct thanks to Microsoft's compiler.
|
||||||
// So this check lets us pre-define MD_CPP_VERSION if we have to.
|
// So this check lets us pre-define MD_CPP_VERSION if we have to.
|
||||||
@@ -242,64 +242,64 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# define MD_LANG_C 1
|
# define LANG_C 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// zeroify
|
// zeroify
|
||||||
|
|
||||||
#if !defined(MD_ARCH_32BIT)
|
#if !defined(ARCH_32BIT)
|
||||||
# define MD_ARCH_32BIT 0
|
# define ARCH_32BIT 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_64BIT)
|
#if !defined(ARCH_64BIT)
|
||||||
# define MD_ARCH_64BIT 0
|
# define ARCH_64BIT 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_X64)
|
#if !defined(ARCH_X64)
|
||||||
# define MD_ARCH_X64 0
|
# define ARCH_X64 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_X86)
|
#if !defined(ARCH_X86)
|
||||||
# define MD_ARCH_X86 0
|
# define ARCH_X86 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_ARM64)
|
#if !defined(ARCH_ARM64)
|
||||||
# define MD_ARCH_ARM64 0
|
# define ARCH_ARM64 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_ARCH_ARM32)
|
#if !defined(ARCH_ARM32)
|
||||||
# define MD_ARCH_ARM32 0
|
# define ARCH_ARM32 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_CL)
|
#if !defined(MD_COMPILER_CL)
|
||||||
# define MD_COMPILER_CL 0
|
# define MD_COMPILER_CL 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_GCC)
|
#if !defined(COMPILER_GCC)
|
||||||
# define MD_COMPILER_GCC 0
|
# define COMPILER_GCC 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_COMPILER_CLANG)
|
#if !defined(COMPILER_CLANG)
|
||||||
# define MD_COMPILER_CLANG 0
|
# define COMPILER_CLANG 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_WINDOWS)
|
#if !defined(OS_WINDOWS)
|
||||||
# define MD_OS_WINDOWS 0
|
# define OS_WINDOWS 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_LINUX)
|
#if !defined(OS_LINUX)
|
||||||
# define MD_OS_LINUX 0
|
# define OS_LINUX 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_OS_MAC)
|
#if !defined(OS_MAC)
|
||||||
# define MD_OS_MAC 0
|
# define OS_MAC 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_LANG_C)
|
#if !defined(LANG_C)
|
||||||
# define MD_LANG_C 0
|
# define LANG_C 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_LANG_CPP)
|
#if !defined(LANG_CPP)
|
||||||
# define MD_LANG_CPP 0
|
# define LANG_CPP 0
|
||||||
#endif
|
#endif
|
||||||
#if !defined(MD_CPP_VERSION)
|
#if !defined(MD_CPP_VERSION)
|
||||||
# define MD_CPP_VERSION 0
|
# define MD_CPP_VERSION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_CPP
|
#if LANG_CPP
|
||||||
# define MD_ZERO_STRUCT {}
|
# define MD_ZERO_STRUCT {}
|
||||||
#else
|
#else
|
||||||
# define MD_ZERO_STRUCT {0}
|
# define MD_ZERO_STRUCT {0}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# define MD_C_LINKAGE_BEGIN
|
# define MD_C_LINKAGE_BEGIN
|
||||||
# define MD_C_LINKAGE_END
|
# define MD_C_LINKAGE_END
|
||||||
#else
|
#else
|
||||||
@@ -309,7 +309,7 @@
|
|||||||
|
|
||||||
#if MD_COMPILER_CL
|
#if MD_COMPILER_CL
|
||||||
# define MD_THREAD_LOCAL __declspec(thread)
|
# define MD_THREAD_LOCAL __declspec(thread)
|
||||||
#elif MD_COMPILER_GCC || MD_COMPILER_CLANG
|
#elif COMPILER_GCC || COMPILER_CLANG
|
||||||
# define MD_THREAD_LOCAL __thread
|
# define MD_THREAD_LOCAL __thread
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -968,9 +968,9 @@ MD_FUNCTION MD_u64 MD_CalculateCStringLength(char *cstr);
|
|||||||
MD_FUNCTION MD_String8 MD_S8(MD_u8 *str, MD_u64 size);
|
MD_FUNCTION MD_String8 MD_S8(MD_u8 *str, MD_u64 size);
|
||||||
#define MD_S8CString(s) MD_S8((MD_u8 *)(s), MD_CalculateCStringLength(s))
|
#define MD_S8CString(s) MD_S8((MD_u8 *)(s), MD_CalculateCStringLength(s))
|
||||||
|
|
||||||
#if MD_LANG_C
|
#if LANG_C
|
||||||
# define MD_S8Lit(s) (MD_String8){(MD_u8 *)(s), sizeof(s)-1}
|
# define MD_S8Lit(s) (MD_String8){(MD_u8 *)(s), sizeof(s)-1}
|
||||||
#elif MD_LANG_CPP
|
#elif LANG_CPP
|
||||||
# define MD_S8Lit(s) MD_S8((MD_u8*)(s), sizeof(s) - 1)
|
# define MD_S8Lit(s) MD_S8((MD_u8*)(s), sizeof(s) - 1)
|
||||||
#endif
|
#endif
|
||||||
#define MD_S8LitComp(s) {(MD_u8 *)(s), sizeof(s)-1}
|
#define MD_S8LitComp(s) {(MD_u8 *)(s), sizeof(s)-1}
|
||||||
|
|||||||
Reference in New Issue
Block a user