This commit is contained in:
2025-06-25 20:57:52 -04:00
6 changed files with 114 additions and 39 deletions

View File

@@ -75,13 +75,13 @@
#define DBL_MAX_10_EXP 308
#define DBL_TRAPS 0
#define DBL_TINYNESS_BEFORE 0
#define DBL_MIN fennec::bit_cast<double>(0x10000000000000l)
#define DBL_MAX fennec::bit_cast<double>(0x7fefffffffffffffl)
#define DBL_EPSILON fennec::bit_cast<double>(0x3cb0000000000000l)
#define DBL_INF fennec::bit_cast<double>(0x7ff0000000000000l)
#define DBL_QUIET_NAN fennec::bit_cast<double>(0x7ff8000000000000l)
#define DBL_SIGNALING_NAN fennec::bit_cast<double>(0x7ff4000000000000l)
#define DBL_DENORM_MIN fennec::bit_cast<double>(0x1l)
#define DBL_ROUND_ERR fennec::bit_cast<double>(0x3fe0000000000000l)
#define DBL_MIN fennec::bit_cast<double>(0x10000000000000ll)
#define DBL_MAX fennec::bit_cast<double>(0x7fefffffffffffffll)
#define DBL_EPSILON fennec::bit_cast<double>(0x3cb0000000000000ll)
#define DBL_INF fennec::bit_cast<double>(0x7ff0000000000000ll)
#define DBL_QUIET_NAN fennec::bit_cast<double>(0x7ff8000000000000ll)
#define DBL_SIGNALING_NAN fennec::bit_cast<double>(0x7ff4000000000000ll)
#define DBL_DENORM_MIN fennec::bit_cast<double>(0x1ll)
#define DBL_ROUND_ERR fennec::bit_cast<double>(0x3fe0000000000000ll)
#endif // FENNEC_LANG_FLOAT_H

View File

@@ -30,8 +30,26 @@
#ifndef FENNEC_LANG_INTEGER_H
#define FENNEC_LANG_INTEGER_H
#undef CHAR_MIN
#undef CHAR_MAX
#undef WCHAR_MIN
#undef WCHAR_MAX
#undef SCHAR_MIN
#undef SCHAR_MAX
#undef UCHAR_MIN
#undef UCHAR_MAX
#undef INT_MIN
#undef INT_MAX
#undef UINT_MIN
#undef UINT_MAX
#undef LONG_MIN
#undef LONG_MAX
#undef ULONG_MIN
#undef ULONG_MAX
#undef LLONG_MIN
#undef LLONG_MAX
#undef ULLONG_MIN
#undef ULLONG_MAX
#define CHAR_IS_SIGNED true
#define CHAR_ROUNDS 0x0
@@ -43,15 +61,15 @@
#define CHAR_MIN 0xffffff80
#define CHAR_MAX 0x7f
#define WCHAR_IS_SIGNED true
#define WCHAR_IS_SIGNED false
#define WCHAR_ROUNDS 0x0
#define WCHAR_RADIX_DIG 0x1f
#define WCHAR_DIG 0x9
#define WCHAR_RADIX_DIG 0x10
#define WCHAR_DIG 0x4
#define WCHAR_DECIMAL_DIG 0x0
#define WCHAR_RADIX 0x2
#define WCHAR_TRAPS 0xtrue
#define WCHAR_MIN 0x80000000
#define WCHAR_MAX 0x7fffffff
#define WCHAR_MIN 0x0
#define WCHAR_MAX 0xffff
#define SCHAR_ROUNDS 0x0
#define SCHAR_RADIX_DIG 0x7
@@ -108,22 +126,22 @@
#define UINT_MAX 0xffffffff
#define LONG_ROUNDS 0x0
#define LONG_RADIX_DIG 0x3f
#define LONG_DIG 0x12
#define LONG_RADIX_DIG 0x1f
#define LONG_DIG 0x9
#define LONG_DECIMAL_DIG 0x0
#define LONG_RADIX 0x2
#define LONG_TRAPS 0xtrue
#define LONG_MIN 0x8000000000000000
#define LONG_MAX 0x7fffffffffffffff
#define LONG_MIN 0x80000000
#define LONG_MAX 0x7fffffff
#define ULONG_ROUNDS 0x0
#define ULONG_RADIX_DIG 0x40
#define ULONG_DIG 0x13
#define ULONG_RADIX_DIG 0x20
#define ULONG_DIG 0x9
#define ULONG_DECIMAL_DIG 0x0
#define ULONG_RADIX 0x2
#define ULONG_TRAPS 0xtrue
#define ULONG_MIN 0x0
#define ULONG_MAX 0xffffffffffffffff
#define ULONG_MAX 0xffffffff
#define LLONG_ROUNDS 0x0
#define LLONG_RADIX_DIG 0x3f

View File

@@ -1,6 +1,20 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// Created by medusa on 5/19/25.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_MEMORY_DETAIL_MEMORY_H
#define FENNEC_MEMORY_DETAIL_MEMORY_H

View File

@@ -1,6 +1,20 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// Created by medusa on 6/14/25.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
#ifndef FENNEC_METAPROGRAMMING_FLOAT_H
#define FENNEC_METAPROGRAMMING_FLOAT_H
@@ -102,14 +116,14 @@ inline void float_h()
out << "#define DBL_TRAPS " << std::dec << std::numeric_limits<double>::traps << std::endl;
out << "#define DBL_TINYNESS_BEFORE " << std::dec << std::numeric_limits<double>::tinyness_before << std::endl;
out << "#define DBL_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::min() ) << "l)" << std::endl;
out << "#define DBL_MAX " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::max() ) << "l)" << std::endl;
out << "#define DBL_EPSILON " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::epsilon() ) << "l)" << std::endl;
out << "#define DBL_INF " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::infinity() ) << "l)" << std::endl;
out << "#define DBL_QUIET_NAN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::quiet_NaN() ) << "l)" << std::endl;
out << "#define DBL_SIGNALING_NAN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::signaling_NaN()) << "l)" << std::endl;
out << "#define DBL_DENORM_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::denorm_min() ) << "l)" << std::endl;
out << "#define DBL_ROUND_ERR " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::round_error() ) << "l)" << std::endl;
out << "#define DBL_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::min() ) << "ll)" << std::endl;
out << "#define DBL_MAX " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::max() ) << "ll)" << std::endl;
out << "#define DBL_EPSILON " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::epsilon() ) << "ll)" << std::endl;
out << "#define DBL_INF " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::infinity() ) << "ll)" << std::endl;
out << "#define DBL_QUIET_NAN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::quiet_NaN() ) << "ll)" << std::endl;
out << "#define DBL_SIGNALING_NAN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::signaling_NaN()) << "ll)" << std::endl;
out << "#define DBL_DENORM_MIN " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::denorm_min() ) << "ll)" << std::endl;
out << "#define DBL_ROUND_ERR " << "fennec::bit_cast<double>(0x" << std::hex << std::bit_cast<long long>(std::numeric_limits<double>::round_error() ) << "ll)" << std::endl;
out << "" << std::endl;

View File

@@ -64,8 +64,26 @@ inline void integer_h()
out << "" << std::endl;
out << "#undef CHAR_MIN" << std::endl;
out << "#undef CHAR_MAX" << std::endl;
out << "#undef WCHAR_MIN" << std::endl;
out << "#undef WCHAR_MAX" << std::endl;
out << "#undef SCHAR_MIN" << std::endl;
out << "#undef SCHAR_MAX" << std::endl;
out << "#undef UCHAR_MIN" << std::endl;
out << "#undef UCHAR_MAX" << std::endl;
out << "#undef INT_MIN" << std::endl;
out << "#undef INT_MAX" << std::endl;
out << "#undef UINT_MIN" << std::endl;
out << "#undef UINT_MAX" << std::endl;
out << "#undef LONG_MIN" << std::endl;
out << "#undef LONG_MAX" << std::endl;
out << "#undef ULONG_MIN" << std::endl;
out << "#undef ULONG_MAX" << std::endl;
out << "#undef LLONG_MIN" << std::endl;
out << "#undef LLONG_MAX" << std::endl;
out << "#undef ULLONG_MIN" << std::endl;
out << "#undef ULLONG_MAX" << std::endl;
out << "" << std::endl;

View File

@@ -34,15 +34,28 @@ inline void* operator new[](fennec::size_t size) { ret
inline void* operator new (fennec::size_t size, const fennec::nothrow_t&) { return malloc(size); }
inline void* operator new[](fennec::size_t size, const fennec::nothrow_t&) { return malloc(size); }
// Aligned allocation functions
// Aligned allocation & deallocation functions
#ifdef _WIN32
inline void operator delete (void* ptr) noexcept { _aligned_free(ptr); }
inline void operator delete[](void* ptr) noexcept { _aligned_free(ptr); }
inline void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { _aligned_free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { _aligned_free(ptr); }
inline void* operator new (fennec::size_t size, fennec::align_t align) { return _aligned_malloc(static_cast<size_t>(align), size); }
inline void* operator new[](fennec::size_t size, fennec::align_t align) { return _aligned_malloc(static_cast<size_t>(align), size); }
inline void* operator new (fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return _aligned_malloc(static_cast<size_t>(align), size); }
inline void* operator new[](fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return _aligned_malloc(static_cast<size_t>(align), size); }
#else
inline void operator delete (void* ptr) noexcept { free(ptr); }
inline void operator delete[](void* ptr) noexcept { free(ptr); }
inline void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void* operator new (fennec::size_t size, fennec::align_t align) { return aligned_alloc(static_cast<size_t>(align), size); }
inline void* operator new[](fennec::size_t size, fennec::align_t align) { return aligned_alloc(static_cast<size_t>(align), size); }
inline void* operator new (fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return aligned_alloc(static_cast<size_t>(align), size); }
inline void* operator new[](fennec::size_t size, fennec::align_t align, const fennec::nothrow_t&) { return aligned_alloc(static_cast<size_t>(align), size); }
// Deallocation functions
inline void operator delete (void* ptr) noexcept { free(ptr); }
inline void operator delete[](void* ptr) noexcept { free(ptr); }
#endif
// Aligned deallocation functions
inline void operator delete (void* ptr, fennec::align_t) noexcept { free(ptr); }
@@ -57,8 +70,6 @@ inline void operator delete[](void* ptr, fennec::size_t, fennec::align_t) noexce
// Non-throwing deallocation functions
inline void operator delete (void* ptr, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete[](void* ptr, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete (void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete (void* ptr, fennec::size_t, const fennec::nothrow_t&) noexcept { free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t, const fennec::nothrow_t&) noexcept { free(ptr); }