mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-03-05 10:16:30 +00:00
externals: Update zycore to 1.4.1
Merge commit 'cd2ede593acee9c4956c79da4377ce890ac3a9c0'
This commit is contained in:
5
externals/zycore/include/Zycore/API/Memory.h
vendored
5
externals/zycore/include/Zycore/API/Memory.h
vendored
@@ -32,11 +32,12 @@
|
||||
#ifndef ZYCORE_API_MEMORY_H
|
||||
#define ZYCORE_API_MEMORY_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
#if defined(ZYAN_WINDOWS)
|
||||
# include <windows.h>
|
||||
#elif defined(ZYAN_POSIX)
|
||||
@@ -131,4 +132,6 @@ ZYCORE_EXPORT ZyanStatus ZyanMemoryVirtualFree(void* address, ZyanUSize size);
|
||||
|
||||
/* ============================================================================================== */
|
||||
|
||||
#endif /* ZYAN_NO_LIBC */
|
||||
|
||||
#endif /* ZYCORE_API_MEMORY_H */
|
||||
|
||||
@@ -32,10 +32,11 @@
|
||||
#ifndef ZYCORE_API_PROCESS_H
|
||||
#define ZYCORE_API_PROCESS_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Enums and types */
|
||||
/* ============================================================================================== */
|
||||
@@ -64,4 +65,6 @@ ZYCORE_EXPORT ZyanStatus ZyanProcessFlushInstructionCache(void* address, ZyanUSi
|
||||
|
||||
/* ============================================================================================== */
|
||||
|
||||
#endif /* ZYAN_NO_LIBC */
|
||||
|
||||
#endif /* ZYCORE_API_PROCESS_H */
|
||||
|
||||
@@ -32,12 +32,11 @@
|
||||
#ifndef ZYCORE_API_SYNCHRONIZATION_H
|
||||
#define ZYCORE_API_SYNCHRONIZATION_H
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Status.h>
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_API_TERMINAL_H
|
||||
#define ZYCORE_API_TERMINAL_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/LibC.h>
|
||||
#include <Zycore/Status.h>
|
||||
|
||||
|
||||
5
externals/zycore/include/Zycore/API/Thread.h
vendored
5
externals/zycore/include/Zycore/API/Thread.h
vendored
@@ -32,12 +32,11 @@
|
||||
#ifndef ZYCORE_API_THREAD_H
|
||||
#define ZYCORE_API_THREAD_H
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Status.h>
|
||||
|
||||
#ifndef ZYAN_NO_LIBC
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
1
externals/zycore/include/Zycore/Allocator.h
vendored
1
externals/zycore/include/Zycore/Allocator.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_ALLOCATOR_H
|
||||
#define ZYCORE_ALLOCATOR_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
|
||||
236
externals/zycore/include/Zycore/Atomic.h
vendored
Normal file
236
externals/zycore/include/Zycore/Atomic.h
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
/***************************************************************************************************
|
||||
|
||||
Zyan Core Library (Zyan-C)
|
||||
|
||||
Original Author : Florian Bernd
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
|
||||
***************************************************************************************************/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Cross compiler atomic intrinsics.
|
||||
*/
|
||||
|
||||
#ifndef ZYCORE_ATOMIC_H
|
||||
#define ZYCORE_ATOMIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Enums and Types */
|
||||
/* ============================================================================================== */
|
||||
|
||||
/*
|
||||
* Wraps a 32-bit value to provide atomic access.
|
||||
*/
|
||||
typedef struct ZyanAtomic32_
|
||||
{
|
||||
ZyanU32 volatile value;
|
||||
} ZyanAtomic32;
|
||||
|
||||
/*
|
||||
* Wraps a 64-bit value to provide atomic access.
|
||||
*/
|
||||
typedef struct ZyanAtomic64_
|
||||
{
|
||||
ZyanU64 volatile value;
|
||||
} ZyanAtomic64;
|
||||
|
||||
/*
|
||||
* Wraps a pointer-sized value to provide atomic access.
|
||||
*/
|
||||
typedef struct ZyanAtomicPointer_
|
||||
{
|
||||
ZyanVoidPointer volatile value;
|
||||
} ZyanAtomicPointer;
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Macros */
|
||||
/* ============================================================================================== */
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* Pointer sized */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicCompareExchange
|
||||
*/
|
||||
#define ZYAN_ATOMIC_COMPARE_EXCHANGE(destination, comparand, value) \
|
||||
ZyanAtomicCompareExchange((ZyanAtomicPointer*)&(destination), (comparand), (value))
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicIncrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_INCREMENT(destination) \
|
||||
ZyanAtomicIncrement((ZyanAtomicPointer*)&(destination));
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicDecrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_DECREMENT(destination) \
|
||||
ZyanAtomicDecrement((ZyanAtomicPointer*)&(destination));
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 32-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicCompareExchange
|
||||
*/
|
||||
#define ZYAN_ATOMIC_COMPARE_EXCHANGE32(destination, comparand, value) \
|
||||
ZyanAtomicCompareExchange32((ZyanAtomic32*)&(destination), (comparand), (value))
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicIncrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_INCREMENT32(destination) \
|
||||
ZyanAtomicIncrement32((ZyanAtomic32*)&(destination));
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicDecrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_DECREMENT32(destination) \
|
||||
ZyanAtomicDecrement32((ZyanAtomic32*)&(destination));
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 64-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicCompareExchange
|
||||
*/
|
||||
#define ZYAN_ATOMIC_COMPARE_EXCHANGE64(destination, comparand, value) \
|
||||
ZyanAtomicCompareExchange64((ZyanAtomic64*)&(destination), (comparand), (value))
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicIncrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_INCREMENT64(destination) \
|
||||
ZyanAtomicIncrement64((ZyanAtomic64*)&(destination));
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicDecrement
|
||||
*/
|
||||
#define ZYAN_ATOMIC_DECREMENT64(destination) \
|
||||
ZyanAtomicDecrement64((ZyanAtomic64*)&(destination));
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Functions */
|
||||
/* ============================================================================================== */
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* Pointer sized */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Compares two values for equality and, if they are equal, replaces the first value.
|
||||
*
|
||||
* @param destination A pointer to the destination value.
|
||||
* @param comparand The value to compare with.
|
||||
* @param value The replacement value.
|
||||
*
|
||||
* @return The original value.
|
||||
*/
|
||||
static ZyanUPointer ZyanAtomicCompareExchange(ZyanAtomicPointer* destination,
|
||||
ZyanUPointer comparand, ZyanUPointer value);
|
||||
|
||||
/**
|
||||
* Increments the given value and stores the result, as an atomic operation.
|
||||
*
|
||||
* @param destination A pointer to the destination value.
|
||||
*
|
||||
* @return The incremented value.
|
||||
*/
|
||||
static ZyanUPointer ZyanAtomicIncrement(ZyanAtomicPointer* destination);
|
||||
|
||||
/**
|
||||
* Decrements the given value and stores the result, as an atomic operation.
|
||||
*
|
||||
* @param destination A pointer to the destination value.
|
||||
*
|
||||
* @return The decremented value.
|
||||
*/
|
||||
static ZyanUPointer ZyanAtomicDecrement(ZyanAtomicPointer* destination);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 32-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicCompareExchange
|
||||
*/
|
||||
static ZyanU32 ZyanAtomicCompareExchange32(ZyanAtomic32* destination,
|
||||
ZyanU32 comparand, ZyanU32 value);
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicIncrement
|
||||
*/
|
||||
static ZyanU32 ZyanAtomicIncrement32(ZyanAtomic32* destination);
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicDecrement
|
||||
*/
|
||||
static ZyanU32 ZyanAtomicDecrement32(ZyanAtomic32* destination);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 64-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicCompareExchange
|
||||
*/
|
||||
static ZyanU64 ZyanAtomicCompareExchange64(ZyanAtomic64* destination,
|
||||
ZyanU64 comparand, ZyanU64 value);
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicIncrement
|
||||
*/
|
||||
static ZyanU64 ZyanAtomicIncrement64(ZyanAtomic64* destination);
|
||||
|
||||
/**
|
||||
* @copydoc ZyanAtomicDecrement
|
||||
*/
|
||||
static ZyanU64 ZyanAtomicDecrement64(ZyanAtomic64* destination);
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* ============================================================================================== */
|
||||
|
||||
#if defined(ZYAN_CLANG) || defined(ZYAN_GCC) || defined(ZYAN_ICC)
|
||||
# include <Zycore/Internal/AtomicGNU.h>
|
||||
#elif defined(ZYAN_MSVC)
|
||||
# include <Zycore/Internal/AtomicMSVC.h>
|
||||
#else
|
||||
# error "Unsupported compiler detected"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZYCORE_ATOMIC_H */
|
||||
23
externals/zycore/include/Zycore/Bitset.h
vendored
23
externals/zycore/include/Zycore/Bitset.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_BITSET_H
|
||||
#define ZYCORE_BITSET_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Allocator.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/Types.h>
|
||||
@@ -96,7 +95,7 @@ typedef ZyanStatus (*ZyanBitsetByteOperation)(ZyanU8* v1, const ZyanU8* v2);
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The space for the bitset is dynamically allocated by the default allocator using the default
|
||||
* growth factor of `2.0f` and the default shrink threshold of `0.5f`.
|
||||
* growth factor and the default shrink threshold.
|
||||
*/
|
||||
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanBitsetInit(ZyanBitset* bitset, ZyanUSize count);
|
||||
|
||||
@@ -109,16 +108,16 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanBitsetInit(ZyanBitset* bitset, Z
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
* @param count The initial amount of bits.
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetInitEx(ZyanBitset* bitset, ZyanUSize count,
|
||||
ZyanAllocator* allocator, float growth_factor, float shrink_threshold);
|
||||
ZyanAllocator* allocator, ZyanU8 growth_factor, ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes the given `ZyanBitset` instance and configures it to use a custom user
|
||||
@@ -266,7 +265,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetToggle(ZyanBitset* bitset, ZyanUSize index);
|
||||
* @param index The bit index.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the bit is set or `ZYAN_STATUS_FALSE`, if not, Another zyan
|
||||
* status code, if an error occured.
|
||||
* status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetTest(ZyanBitset* bitset, ZyanUSize index);
|
||||
|
||||
@@ -276,7 +275,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetTest(ZyanBitset* bitset, ZyanUSize index);
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the bit is set or `ZYAN_STATUS_FALSE`, if not. Another zyan
|
||||
* status code, if an error occured.
|
||||
* status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetTestMSB(ZyanBitset* bitset);
|
||||
|
||||
@@ -286,7 +285,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetTestMSB(ZyanBitset* bitset);
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the bit is set or `ZYAN_STATUS_FALSE`, if not. Another zyan
|
||||
* status code, if an error occured.
|
||||
* status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetTestLSB(ZyanBitset* bitset);
|
||||
|
||||
@@ -427,7 +426,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetCount(const ZyanBitset* bitset, ZyanUSize* co
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if all bits are set, `ZYAN_STATUS_FALSE`, if not. Another zyan
|
||||
* status code, if an error occured.
|
||||
* status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetAll(const ZyanBitset* bitset);
|
||||
|
||||
@@ -437,7 +436,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetAll(const ZyanBitset* bitset);
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if at least one bit is set, `ZYAN_STATUS_FALSE`, if not. Another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetAny(const ZyanBitset* bitset);
|
||||
|
||||
@@ -447,7 +446,7 @@ ZYCORE_EXPORT ZyanStatus ZyanBitsetAny(const ZyanBitset* bitset);
|
||||
* @param bitset A pointer to the `ZyanBitset` instance.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if none bits are set, `ZYAN_STATUS_FALSE`, if not. Another zyan
|
||||
* status code, if an error occured.
|
||||
* status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanBitsetNone(const ZyanBitset* bitset);
|
||||
|
||||
|
||||
92
externals/zycore/include/Zycore/Defines.h
vendored
92
externals/zycore/include/Zycore/Defines.h
vendored
@@ -85,6 +85,9 @@
|
||||
# define ZYAN_WINDOWS
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
# define ZYAN_EMSCRIPTEN
|
||||
#elif defined(__wasi__) || defined(__WASI__)
|
||||
// via: https://reviews.llvm.org/D57155
|
||||
# define ZYAN_WASI
|
||||
#elif defined(__APPLE__)
|
||||
# define ZYAN_APPLE
|
||||
# define ZYAN_POSIX
|
||||
@@ -131,8 +134,14 @@
|
||||
# define ZYAN_AARCH64
|
||||
#elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__)
|
||||
# define ZYAN_ARM
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
// Nothing to do, `ZYAN_EMSCRIPTEN` is both platform and arch macro for this one.
|
||||
#elif defined(__EMSCRIPTEN__) || defined(__wasm__) || defined(__WASM__)
|
||||
# define ZYAN_WASM
|
||||
#elif defined(__powerpc64__)
|
||||
# define ZYAN_PPC64
|
||||
#elif defined(__powerpc__)
|
||||
# define ZYAN_PPC
|
||||
#elif defined(__riscv) && __riscv_xlen == 64
|
||||
# define ZYAN_RISCV64
|
||||
#else
|
||||
# error "Unsupported architecture detected"
|
||||
#endif
|
||||
@@ -157,6 +166,73 @@
|
||||
# define ZYAN_RELEASE
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Deprecation hint */
|
||||
/* ============================================================================================== */
|
||||
|
||||
#if defined(ZYAN_GCC) || defined(ZYAN_CLANG)
|
||||
# define ZYAN_DEPRECATED __attribute__((__deprecated__))
|
||||
#elif defined(ZYAN_MSVC)
|
||||
# define ZYAN_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
# define ZYAN_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Generic DLL import/export helpers */
|
||||
/* ============================================================================================== */
|
||||
|
||||
#if defined(ZYAN_MSVC)
|
||||
# define ZYAN_DLLEXPORT __declspec(dllexport)
|
||||
# define ZYAN_DLLIMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define ZYAN_DLLEXPORT
|
||||
# define ZYAN_DLLIMPORT
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Zycore dll{export,import} */
|
||||
/* ============================================================================================== */
|
||||
|
||||
// This is a cut-down version of what CMake's `GenerateExportHeader` would usually generate. To
|
||||
// simplify builds without CMake, we define these things manually instead of relying on CMake
|
||||
// to generate the header.
|
||||
//
|
||||
// For static builds, our CMakeList will define `ZYCORE_STATIC_BUILD`. For shared library builds,
|
||||
// our CMake will define `ZYCORE_SHOULD_EXPORT` depending on whether the target is being imported or
|
||||
// exported. If CMake isn't used, users can manually define these to fit their use-case.
|
||||
|
||||
// Backward compatibility: CMake would previously generate these variables names. However, because
|
||||
// they have pretty cryptic names, we renamed them when we got rid of `GenerateExportHeader`. For
|
||||
// backward compatibility for users that don't use CMake and previously manually defined these, we
|
||||
// translate the old defines here and print a warning.
|
||||
#if defined(ZYCORE_STATIC_DEFINE)
|
||||
# pragma message("ZYCORE_STATIC_DEFINE was renamed to ZYCORE_STATIC_BUILD.")
|
||||
# define ZYCORE_STATIC_BUILD
|
||||
#endif
|
||||
#if defined(Zycore_EXPORTS)
|
||||
# pragma message("Zycore_EXPORTS was renamed to ZYCORE_SHOULD_EXPORT.")
|
||||
# define ZYCORE_SHOULD_EXPORT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Symbol is exported in shared library builds.
|
||||
*/
|
||||
#if defined(ZYCORE_STATIC_BUILD)
|
||||
# define ZYCORE_EXPORT
|
||||
#else
|
||||
# if defined(ZYCORE_SHOULD_EXPORT)
|
||||
# define ZYCORE_EXPORT ZYAN_DLLEXPORT
|
||||
# else
|
||||
# define ZYCORE_EXPORT ZYAN_DLLIMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Symbol is not exported and for internal use only.
|
||||
*/
|
||||
#define ZYCORE_NO_EXPORT
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Misc compatibility macros */
|
||||
/* ============================================================================================== */
|
||||
@@ -173,6 +249,14 @@
|
||||
# define ZYAN_INLINE static inline
|
||||
#endif
|
||||
|
||||
#if defined(ZYAN_MSVC)
|
||||
# define ZYAN_NOINLINE __declspec(noinline)
|
||||
#elif defined(ZYAN_GCC) || defined(ZYAN_CLANG)
|
||||
# define ZYAN_NOINLINE __attribute__((noinline))
|
||||
#else
|
||||
# define ZYAN_NOINLINE
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Debugging and optimization macros */
|
||||
/* ============================================================================================== */
|
||||
@@ -193,7 +277,7 @@
|
||||
/**
|
||||
* Compiler-time assertion.
|
||||
*/
|
||||
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
|
||||
# define ZYAN_STATIC_ASSERT(x) _Static_assert(x, #x)
|
||||
#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \
|
||||
(defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \
|
||||
@@ -256,7 +340,7 @@
|
||||
* Intentional fallthrough.
|
||||
*/
|
||||
#if defined(ZYAN_GCC) && __GNUC__ >= 7
|
||||
# define ZYAN_FALLTHROUGH __attribute__((fallthrough))
|
||||
# define ZYAN_FALLTHROUGH ; __attribute__((__fallthrough__))
|
||||
#else
|
||||
# define ZYAN_FALLTHROUGH
|
||||
#endif
|
||||
|
||||
1
externals/zycore/include/Zycore/Format.h
vendored
1
externals/zycore/include/Zycore/Format.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_FORMAT_H
|
||||
#define ZYCORE_FORMAT_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/String.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
117
externals/zycore/include/Zycore/Internal/AtomicGNU.h
vendored
Normal file
117
externals/zycore/include/Zycore/Internal/AtomicGNU.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/***************************************************************************************************
|
||||
|
||||
Zyan Core Library (Zyan-C)
|
||||
|
||||
Original Author : Florian Bernd
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef ZYCORE_ATOMIC_GNU_H
|
||||
#define ZYCORE_ATOMIC_GNU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Functions */
|
||||
/* ============================================================================================== */
|
||||
|
||||
#if defined(ZYAN_CLANG) || defined(ZYAN_GCC) || defined(ZYAN_ICC)
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* Pointer sized */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
ZYAN_INLINE ZyanUPointer ZyanAtomicCompareExchange(ZyanAtomicPointer* destination,
|
||||
ZyanUPointer comparand, ZyanUPointer value)
|
||||
{
|
||||
return (ZyanUPointer)(__sync_val_compare_and_swap(
|
||||
&destination->value, (void*)comparand, (void*)value, &destination->value));
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanUPointer ZyanAtomicIncrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)(__sync_fetch_and_add(&destination->value, (void*)1,
|
||||
&destination->value)) + 1;
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanUPointer ZyanAtomicDecrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)(__sync_sub_and_fetch(&destination->value, (void*)1, &destination->value));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 32-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
ZYAN_INLINE ZyanU32 ZyanAtomicCompareExchange32(ZyanAtomic32* destination,
|
||||
ZyanU32 comparand, ZyanU32 value)
|
||||
{
|
||||
return (ZyanU32)(__sync_val_compare_and_swap(&destination->value, comparand, value,
|
||||
&destination->value));
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanU32 ZyanAtomicIncrement32(ZyanAtomic32* destination)
|
||||
{
|
||||
return (ZyanU32)(__sync_fetch_and_add(&destination->value, 1, &destination->value)) + 1;
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanU32 ZyanAtomicDecrement32(ZyanAtomic32* destination)
|
||||
{
|
||||
return (ZyanU32)(__sync_sub_and_fetch(&destination->value, 1, &destination->value));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 64-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
ZYAN_INLINE ZyanU64 ZyanAtomicCompareExchange64(ZyanAtomic64* destination,
|
||||
ZyanU64 comparand, ZyanU64 value)
|
||||
{
|
||||
return (ZyanU64)(__sync_val_compare_and_swap(&destination->value, comparand, value,
|
||||
&destination->value));
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanU64 ZyanAtomicIncrement64(ZyanAtomic64* destination)
|
||||
{
|
||||
return (ZyanU64)(__sync_fetch_and_add(&destination->value, 1, &destination->value)) + 1;
|
||||
}
|
||||
|
||||
ZYAN_INLINE ZyanU64 ZyanAtomicDecrement64(ZyanAtomic64* destination)
|
||||
{
|
||||
return (ZyanU64)(__sync_sub_and_fetch(&destination->value, 1, &destination->value));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZYCORE_ATOMIC_GNU_H */
|
||||
141
externals/zycore/include/Zycore/Internal/AtomicMSVC.h
vendored
Normal file
141
externals/zycore/include/Zycore/Internal/AtomicMSVC.h
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
/***************************************************************************************************
|
||||
|
||||
Zyan Core Library (Zyan-C)
|
||||
|
||||
Original Author : Florian Bernd
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
|
||||
***************************************************************************************************/
|
||||
|
||||
#ifndef ZYCORE_ATOMIC_MSVC_H
|
||||
#define ZYCORE_ATOMIC_MSVC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include <Zycore/Defines.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Functions */
|
||||
/* ============================================================================================== */
|
||||
|
||||
#if defined(ZYAN_MSVC)
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* Pointer sized */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(ZYAN_X86)
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicCompareExchange(ZyanAtomicPointer* destination,
|
||||
ZyanUPointer comparand, ZyanUPointer value)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicCompareExchange32((ZyanAtomic32*)destination, comparand, value);
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicIncrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicIncrement32((ZyanAtomic32*)destination);
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicDecrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicDecrement32((ZyanAtomic32*)destination);
|
||||
}
|
||||
|
||||
#elif defined(ZYAN_X64)
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicCompareExchange(ZyanAtomicPointer* destination,
|
||||
ZyanUPointer comparand, ZyanUPointer value)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicCompareExchange64((ZyanAtomic64*)destination, comparand, value);
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicIncrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicIncrement64((ZyanAtomic64*)destination);
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanUPointer ZyanAtomicDecrement(ZyanAtomicPointer* destination)
|
||||
{
|
||||
return (ZyanUPointer)ZyanAtomicDecrement64((ZyanAtomic64*)destination);
|
||||
}
|
||||
|
||||
#else
|
||||
# error "Unsupported architecture detected"
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 32-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
static ZYAN_INLINE ZyanU32 ZyanAtomicCompareExchange32(ZyanAtomic32* destination,
|
||||
ZyanU32 comparand, ZyanU32 value)
|
||||
{
|
||||
return (ZyanU32)(_InterlockedCompareExchange((volatile LONG*)&(destination->value),
|
||||
(LONG)value, (LONG)comparand));
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanU32 ZyanAtomicIncrement32(ZyanAtomic32* destination)
|
||||
{
|
||||
return (ZyanU32)(_InterlockedIncrement((volatile LONG*)&(destination->value)));
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanU32 ZyanAtomicDecrement32(ZyanAtomic32* destination)
|
||||
{
|
||||
return (ZyanU32)(_InterlockedDecrement((volatile LONG*)&(destination->value)));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* 64-bit */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
static ZYAN_INLINE ZyanU64 ZyanAtomicCompareExchange64(ZyanAtomic64* destination,
|
||||
ZyanU64 comparand, ZyanU64 value)
|
||||
{
|
||||
return (ZyanU64)(_InterlockedCompareExchange64((volatile LONG64*)&(destination->value),
|
||||
(LONG64)value, (LONG64)comparand));
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanU64 ZyanAtomicIncrement64(ZyanAtomic64* destination)
|
||||
{
|
||||
return (ZyanU64)(_InterlockedIncrement64((volatile LONG64*)&(destination->value)));
|
||||
}
|
||||
|
||||
static ZYAN_INLINE ZyanU64 ZyanAtomicDecrement64(ZyanAtomic64* destination)
|
||||
{
|
||||
return (ZyanU64)(_InterlockedDecrement64((volatile LONG64*)&(destination->value)));
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
#endif
|
||||
|
||||
/* ============================================================================================== */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZYCORE_ATOMIC_MSVC_H */
|
||||
1
externals/zycore/include/Zycore/List.h
vendored
1
externals/zycore/include/Zycore/List.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_LIST_H
|
||||
#define ZYCORE_LIST_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Allocator.h>
|
||||
#include <Zycore/Object.h>
|
||||
#include <Zycore/Status.h>
|
||||
|
||||
61
externals/zycore/include/Zycore/String.h
vendored
61
externals/zycore/include/Zycore/String.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_STRING_H
|
||||
#define ZYCORE_STRING_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Allocator.h>
|
||||
#include <Zycore/Status.h>
|
||||
#include <Zycore/Types.h>
|
||||
@@ -55,12 +54,12 @@ extern "C" {
|
||||
/**
|
||||
* The default growth factor for all string instances.
|
||||
*/
|
||||
#define ZYAN_STRING_DEFAULT_GROWTH_FACTOR 2.00f
|
||||
#define ZYAN_STRING_DEFAULT_GROWTH_FACTOR 2
|
||||
|
||||
/**
|
||||
* The default shrink threshold for all string instances.
|
||||
*/
|
||||
#define ZYAN_STRING_DEFAULT_SHRINK_THRESHOLD 0.25f
|
||||
#define ZYAN_STRING_DEFAULT_SHRINK_THRESHOLD 4
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Enums and types */
|
||||
@@ -71,7 +70,7 @@ extern "C" {
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Defines the `ZyanStringFlags` datatype.
|
||||
* Defines the `ZyanStringFlags` data-type.
|
||||
*/
|
||||
typedef ZyanU8 ZyanStringFlags;
|
||||
|
||||
@@ -181,8 +180,8 @@ typedef struct ZyanStringView_
|
||||
/* vector */ \
|
||||
{ \
|
||||
/* allocator */ ZYAN_NULL, \
|
||||
/* growth_factor */ 1.0f, \
|
||||
/* shrink_threshold */ 0.0f, \
|
||||
/* growth_factor */ 1, \
|
||||
/* shrink_threshold */ 0, \
|
||||
/* size */ sizeof(string), \
|
||||
/* capacity */ sizeof(string), \
|
||||
/* element_size */ sizeof(char), \
|
||||
@@ -213,7 +212,7 @@ typedef struct ZyanStringView_
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The memory for the string is dynamically allocated by the default allocator using the default
|
||||
* growth factor of `2.0f` and the default shrink threshold of `0.25f`.
|
||||
* growth factor and the default shrink threshold.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
* space for the terminating '\0'.
|
||||
@@ -231,12 +230,12 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringInit(ZyanString* string, Z
|
||||
* @param string A pointer to the `ZyanString` instance.
|
||||
* @param capacity The initial capacity (number of characters).
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
@@ -245,7 +244,7 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringInit(ZyanString* string, Z
|
||||
* Finalization with `ZyanStringDestroy` is required for all strings created by this function.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanStringInitEx(ZyanString* string, ZyanUSize capacity,
|
||||
ZyanAllocator* allocator, float growth_factor, float shrink_threshold);
|
||||
ZyanAllocator* allocator, ZyanU8 growth_factor, ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes the given `ZyanString` instance and configures it to use a custom user
|
||||
@@ -295,7 +294,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringDestroy(ZyanString* string);
|
||||
* string or `destination` points to an already initialized `ZyanString` instance.
|
||||
*
|
||||
* The memory for the string is dynamically allocated by the default allocator using the default
|
||||
* growth factor of `2.0f` and the default shrink threshold of `0.25f`.
|
||||
* growth factor and the default shrink threshold.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
* space for the terminating '\0'.
|
||||
@@ -318,15 +317,15 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringDuplicate(ZyanString* dest
|
||||
* This value is automatically adjusted to the size of the source
|
||||
* string, if a smaller value was passed.
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The behavior of this function is undefined, if `source` is a view into the `destination`
|
||||
* string or `destination` points to an already initialized `ZyanString` instance.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
@@ -336,7 +335,7 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringDuplicate(ZyanString* dest
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanStringDuplicateEx(ZyanString* destination,
|
||||
const ZyanStringView* source, ZyanUSize capacity, ZyanAllocator* allocator,
|
||||
float growth_factor, float shrink_threshold);
|
||||
ZyanU8 growth_factor, ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes a new `ZyanString` instance by duplicating an existing string and
|
||||
@@ -387,7 +386,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringDuplicateCustomBuffer(ZyanString* destination
|
||||
* string or `destination` points to an already initialized `ZyanString` instance.
|
||||
*
|
||||
* The memory for the string is dynamically allocated by the default allocator using the default
|
||||
* growth factor of `2.0f` and the default shrink threshold of `0.25f`.
|
||||
* growth factor and the default shrink threshold.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
* space for the terminating '\0'.
|
||||
@@ -414,15 +413,15 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringConcat(ZyanString* destina
|
||||
* This value is automatically adjusted to the combined size of the
|
||||
* source strings, if a smaller value was passed.
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The behavior of this function is undefined, if `s1` or `s2` are views into the `destination`
|
||||
* string or `destination` points to an already initialized `ZyanString` instance.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*
|
||||
* The allocated buffer will be at least one character larger than the given `capacity`, to reserve
|
||||
@@ -431,8 +430,8 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanStringConcat(ZyanString* destina
|
||||
* Finalization with `ZyanStringDestroy` is required for all strings created by this function.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanStringConcatEx(ZyanString* destination, const ZyanStringView* s1,
|
||||
const ZyanStringView* s2, ZyanUSize capacity, ZyanAllocator* allocator, float growth_factor,
|
||||
float shrink_threshold);
|
||||
const ZyanStringView* s2, ZyanUSize capacity, ZyanAllocator* allocator, ZyanU8 growth_factor,
|
||||
ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes a new `ZyanString` instance by concatenating two existing strings and
|
||||
@@ -531,8 +530,8 @@ ZYCORE_EXPORT ZyanStatus ZyanStringViewGetSize(const ZyanStringView* view, ZyanU
|
||||
*
|
||||
* @warning The string is not guaranteed to be null terminated!
|
||||
*
|
||||
* @param string A pointer to the `ZyanStringView` instance.
|
||||
* @param value Receives a pointer to the C-style string.
|
||||
* @param view A pointer to the `ZyanStringView` instance.
|
||||
* @param buffer Receives a pointer to the C-style string.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*/
|
||||
@@ -741,7 +740,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringLPosI(const ZyanStringView* haystack,
|
||||
* `index`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the needle was found, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the needle was not found.
|
||||
*/
|
||||
@@ -758,7 +757,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringLPosIEx(const ZyanStringView* haystack,
|
||||
* `needle`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the needle was found, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the needle was not found.
|
||||
*/
|
||||
@@ -778,7 +777,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringRPos(const ZyanStringView* haystack,
|
||||
* `index`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the needle was found, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the needle was not found.
|
||||
*/
|
||||
@@ -795,7 +794,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringRPosEx(const ZyanStringView* haystack,
|
||||
* `needle`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the needle was found, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the needle was not found.
|
||||
*/
|
||||
@@ -815,7 +814,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringRPosI(const ZyanStringView* haystack,
|
||||
* `index`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the needle was found, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the needle was not found.
|
||||
*/
|
||||
@@ -841,7 +840,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringRPosIEx(const ZyanStringView* haystack,
|
||||
* in `s1` than in `s2`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the strings are equal, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanStringCompare(const ZyanStringView* s1, const ZyanStringView* s2,
|
||||
ZyanI32* result);
|
||||
@@ -861,7 +860,7 @@ ZYCORE_EXPORT ZyanStatus ZyanStringCompare(const ZyanStringView* s1, const ZyanS
|
||||
* in `s1` than in `s2`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE`, if the strings are equal, `ZYAN_STATUS_FALSE`, if not, or another
|
||||
* zyan status code, if an error occured.
|
||||
* zyan status code, if an error occurred.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanStringCompareI(const ZyanStringView* s1, const ZyanStringView* s2,
|
||||
ZyanI32* result);
|
||||
|
||||
47
externals/zycore/include/Zycore/Types.h
vendored
47
externals/zycore/include/Zycore/Types.h
vendored
@@ -77,6 +77,34 @@
|
||||
# else
|
||||
# error "Unsupported compiler for no-libc mode."
|
||||
# endif
|
||||
|
||||
# if defined(ZYAN_MSVC)
|
||||
# define ZYAN_INT8_MIN (-127i8 - 1)
|
||||
# define ZYAN_INT16_MIN (-32767i16 - 1)
|
||||
# define ZYAN_INT32_MIN (-2147483647i32 - 1)
|
||||
# define ZYAN_INT64_MIN (-9223372036854775807i64 - 1)
|
||||
# define ZYAN_INT8_MAX 127i8
|
||||
# define ZYAN_INT16_MAX 32767i16
|
||||
# define ZYAN_INT32_MAX 2147483647i32
|
||||
# define ZYAN_INT64_MAX 9223372036854775807i64
|
||||
# define ZYAN_UINT8_MAX 0xffui8
|
||||
# define ZYAN_UINT16_MAX 0xffffui16
|
||||
# define ZYAN_UINT32_MAX 0xffffffffui32
|
||||
# define ZYAN_UINT64_MAX 0xffffffffffffffffui64
|
||||
# else
|
||||
# define ZYAN_INT8_MAX __INT8_MAX__
|
||||
# define ZYAN_INT8_MIN (-ZYAN_INT8_MAX - 1)
|
||||
# define ZYAN_INT16_MAX __INT16_MAX__
|
||||
# define ZYAN_INT16_MIN (-ZYAN_INT16_MAX - 1)
|
||||
# define ZYAN_INT32_MAX __INT32_MAX__
|
||||
# define ZYAN_INT32_MIN (-ZYAN_INT32_MAX - 1)
|
||||
# define ZYAN_INT64_MAX __INT64_MAX__
|
||||
# define ZYAN_INT64_MIN (-ZYAN_INT64_MAX - 1)
|
||||
# define ZYAN_UINT8_MAX __UINT8_MAX__
|
||||
# define ZYAN_UINT16_MAX __UINT16_MAX__
|
||||
# define ZYAN_UINT32_MAX __UINT32_MAX__
|
||||
# define ZYAN_UINT64_MAX __UINT64_MAX__
|
||||
# endif
|
||||
#else
|
||||
// If is LibC present, we use stdint types.
|
||||
# include <stdint.h>
|
||||
@@ -93,6 +121,19 @@
|
||||
typedef ptrdiff_t ZyanISize;
|
||||
typedef uintptr_t ZyanUPointer;
|
||||
typedef intptr_t ZyanIPointer;
|
||||
|
||||
# define ZYAN_INT8_MIN INT8_MIN
|
||||
# define ZYAN_INT16_MIN INT16_MIN
|
||||
# define ZYAN_INT32_MIN INT32_MIN
|
||||
# define ZYAN_INT64_MIN INT64_MIN
|
||||
# define ZYAN_INT8_MAX INT8_MAX
|
||||
# define ZYAN_INT16_MAX INT16_MAX
|
||||
# define ZYAN_INT32_MAX INT32_MAX
|
||||
# define ZYAN_INT64_MAX INT64_MAX
|
||||
# define ZYAN_UINT8_MAX UINT8_MAX
|
||||
# define ZYAN_UINT16_MAX UINT16_MAX
|
||||
# define ZYAN_UINT32_MAX UINT32_MAX
|
||||
# define ZYAN_UINT64_MAX UINT64_MAX
|
||||
#endif
|
||||
|
||||
// Verify size assumptions.
|
||||
@@ -122,7 +163,7 @@ ZYAN_STATIC_ASSERT((ZyanI64)-1 >> 1 < (ZyanI64)((ZyanU64)-1 >> 1));
|
||||
/**
|
||||
* Defines the `ZyanVoidPointer` data-type.
|
||||
*/
|
||||
typedef char* ZyanVoidPointer;
|
||||
typedef void* ZyanVoidPointer;
|
||||
|
||||
/**
|
||||
* Defines the `ZyanConstVoidPointer` data-type.
|
||||
@@ -139,8 +180,8 @@ typedef const void* ZyanConstVoidPointer;
|
||||
/* Boolean */
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
|
||||
#define ZYAN_FALSE 0
|
||||
#define ZYAN_TRUE 1
|
||||
#define ZYAN_FALSE 0u
|
||||
#define ZYAN_TRUE 1u
|
||||
|
||||
/**
|
||||
* Defines the `ZyanBool` data-type.
|
||||
|
||||
45
externals/zycore/include/Zycore/Vector.h
vendored
45
externals/zycore/include/Zycore/Vector.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_VECTOR_H
|
||||
#define ZYCORE_VECTOR_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Allocator.h>
|
||||
#include <Zycore/Comparison.h>
|
||||
#include <Zycore/Object.h>
|
||||
@@ -56,12 +55,12 @@ extern "C" {
|
||||
/**
|
||||
* The default growth factor for all vector instances.
|
||||
*/
|
||||
#define ZYAN_VECTOR_DEFAULT_GROWTH_FACTOR 2.00f
|
||||
#define ZYAN_VECTOR_DEFAULT_GROWTH_FACTOR 2
|
||||
|
||||
/**
|
||||
* The default shrink threshold for all vector instances.
|
||||
*/
|
||||
#define ZYAN_VECTOR_DEFAULT_SHRINK_THRESHOLD 0.25f
|
||||
#define ZYAN_VECTOR_DEFAULT_SHRINK_THRESHOLD 4
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* Enums and types */
|
||||
@@ -82,11 +81,11 @@ typedef struct ZyanVector_
|
||||
/**
|
||||
* The growth factor.
|
||||
*/
|
||||
float growth_factor;
|
||||
ZyanU8 growth_factor;
|
||||
/**
|
||||
* The shrink threshold.
|
||||
*/
|
||||
float shrink_threshold;
|
||||
ZyanU8 shrink_threshold;
|
||||
/**
|
||||
* The current number of elements in the vector.
|
||||
*/
|
||||
@@ -123,8 +122,8 @@ typedef struct ZyanVector_
|
||||
#define ZYAN_VECTOR_INITIALIZER \
|
||||
{ \
|
||||
/* allocator */ ZYAN_NULL, \
|
||||
/* growth_factor */ 0.0f, \
|
||||
/* shrink_threshold */ 0.0f, \
|
||||
/* growth_factor */ 0, \
|
||||
/* shrink_threshold */ 0, \
|
||||
/* size */ 0, \
|
||||
/* capacity */ 0, \
|
||||
/* element_size */ 0, \
|
||||
@@ -223,7 +222,7 @@ typedef struct ZyanVector_
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The memory for the vector elements is dynamically allocated by the default allocator using the
|
||||
* default growth factor of `2.0f` and the default shrink threshold of `0.25f`.
|
||||
* default growth factor and the default shrink threshold.
|
||||
*
|
||||
* Finalization with `ZyanVectorDestroy` is required for all instances created by this function.
|
||||
*/
|
||||
@@ -242,19 +241,19 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanVectorInit(ZyanVector* vector,
|
||||
* @param destructor A destructor callback that is invoked every time an item is deleted,
|
||||
* or `ZYAN_NULL` if not needed.
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*
|
||||
* Finalization with `ZyanVectorDestroy` is required for all instances created by this function.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanVectorInitEx(ZyanVector* vector, ZyanUSize element_size,
|
||||
ZyanUSize capacity, ZyanMemberProcedure destructor, ZyanAllocator* allocator,
|
||||
float growth_factor, float shrink_threshold);
|
||||
ZyanU8 growth_factor, ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes the given `ZyanVector` instance and configures it to use a custom user
|
||||
@@ -302,7 +301,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorDestroy(ZyanVector* vector);
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* The memory for the vector is dynamically allocated by the default allocator using the default
|
||||
* growth factor of `2.0f` and the default shrink threshold of `0.25f`.
|
||||
* growth factor and the default shrink threshold.
|
||||
*
|
||||
* Finalization with `ZyanVectorDestroy` is required for all instances created by this function.
|
||||
*/
|
||||
@@ -322,18 +321,18 @@ ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus ZyanVectorDuplicate(ZyanVector* dest
|
||||
* This value is automatically adjusted to the size of the source
|
||||
* vector, if a smaller value was passed.
|
||||
* @param allocator A pointer to a `ZyanAllocator` instance.
|
||||
* @param growth_factor The growth factor (from `1.0f` to `x.xf`).
|
||||
* @param shrink_threshold The shrink threshold (from `0.0f` to `1.0f`).
|
||||
* @param growth_factor The growth factor.
|
||||
* @param shrink_threshold The shrink threshold.
|
||||
*
|
||||
* @return A zyan status code.
|
||||
*
|
||||
* A growth factor of `1.0f` disables overallocation and a shrink threshold of `0.0f` disables
|
||||
* A growth factor of `1` disables overallocation and a shrink threshold of `0` disables
|
||||
* dynamic shrinking.
|
||||
*
|
||||
* Finalization with `ZyanVectorDestroy` is required for all instances created by this function.
|
||||
*/
|
||||
ZYCORE_EXPORT ZyanStatus ZyanVectorDuplicateEx(ZyanVector* destination, const ZyanVector* source,
|
||||
ZyanUSize capacity, ZyanAllocator* allocator, float growth_factor, float shrink_threshold);
|
||||
ZyanUSize capacity, ZyanAllocator* allocator, ZyanU8 growth_factor, ZyanU8 shrink_threshold);
|
||||
|
||||
/**
|
||||
* Initializes a new `ZyanVector` instance by duplicating an existing vector and
|
||||
@@ -365,7 +364,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorDuplicateCustomBuffer(ZyanVector* destination
|
||||
* @param index The element index.
|
||||
*
|
||||
* @return A constant pointer to the desired element in the vector or `ZYAN_NULL`, if an error
|
||||
* occured.
|
||||
* occurred.
|
||||
*
|
||||
* Note that the returned pointer might get invalid when the vector is resized by either a manual
|
||||
* call to the memory-management functions or implicitly by inserting or removing elements.
|
||||
@@ -382,7 +381,7 @@ ZYCORE_EXPORT const void* ZyanVectorGet(const ZyanVector* vector, ZyanUSize inde
|
||||
* @param index The element index.
|
||||
*
|
||||
* @return A mutable pointer to the desired element in the vector or `ZYAN_NULL`, if an error
|
||||
* occured.
|
||||
* occurred.
|
||||
*
|
||||
* Note that the returned pointer might get invalid when the vector is resized by either a manual
|
||||
* call to the memory-management functions or implicitly by inserting or removing elements.
|
||||
@@ -576,7 +575,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorClear(ZyanVector* vector);
|
||||
* @param comparison The comparison function to use.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE` if the element was found, `ZYAN_STATUS_FALSE` if not or a generic
|
||||
* zyan status code if an error occured.
|
||||
* zyan status code if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the element was not found.
|
||||
*/
|
||||
@@ -594,7 +593,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorFind(const ZyanVector* vector, const void* el
|
||||
* @param count The maximum number of elements to iterate, beginning from the start `index`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE` if the element was found, `ZYAN_STATUS_FALSE` if not or a generic
|
||||
* zyan status code if an error occured.
|
||||
* zyan status code if an error occurred.
|
||||
*
|
||||
* The `found_index` is set to `-1`, if the element was not found.
|
||||
*/
|
||||
@@ -611,7 +610,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorFindEx(const ZyanVector* vector, const void*
|
||||
* @param comparison The comparison function to use.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE` if the element was found, `ZYAN_STATUS_FALSE` if not or a generic
|
||||
* zyan status code if an error occured.
|
||||
* zyan status code if an error occurred.
|
||||
*
|
||||
* If found, `found_index` contains the zero-based index of `element`. If not found, `found_index`
|
||||
* contains the index of the first entry larger than `element`.
|
||||
@@ -633,7 +632,7 @@ ZYCORE_EXPORT ZyanStatus ZyanVectorBinarySearch(const ZyanVector* vector, const
|
||||
* @param count The maximum number of elements to iterate, beginning from the start `index`.
|
||||
*
|
||||
* @return `ZYAN_STATUS_TRUE` if the element was found, `ZYAN_STATUS_FALSE` if not or a generic
|
||||
* zyan status code if an error occured.
|
||||
* zyan status code if an error occurred.
|
||||
*
|
||||
* If found, `found_index` contains the zero-based index of `element`. If not found, `found_index`
|
||||
* contains the index of the first entry larger than `element`.
|
||||
|
||||
3
externals/zycore/include/Zycore/Zycore.h
vendored
3
externals/zycore/include/Zycore/Zycore.h
vendored
@@ -32,7 +32,6 @@
|
||||
#ifndef ZYCORE_H
|
||||
#define ZYCORE_H
|
||||
|
||||
#include <ZycoreExportConfig.h>
|
||||
#include <Zycore/Types.h>
|
||||
|
||||
// TODO:
|
||||
@@ -52,7 +51,7 @@ extern "C" {
|
||||
/**
|
||||
* A macro that defines the zycore version.
|
||||
*/
|
||||
#define ZYCORE_VERSION (ZyanU64)0x0001000000000000
|
||||
#define ZYCORE_VERSION (ZyanU64)0x0001000400010000
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------- */
|
||||
/* Helper macros */
|
||||
|
||||
Reference in New Issue
Block a user