- Fixed a bunch of compilation errors and warnings

- Added frameworks for retrieving specific filesystem information for a target platform
This commit is contained in:
2025-07-10 01:10:13 -04:00
parent cc20af7504
commit 4c0d36c933
22 changed files with 510 additions and 85 deletions

View File

@@ -0,0 +1,56 @@
// =====================================================================================================================
// fennec, a free and open source game engine
// Copyright © 2025 Medusa Slockbower
//
// 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/>.
// =====================================================================================================================
#include <fennec/fproc/io/common.h>
#ifdef _WIN32
namespace fennec
{
string getcwd() {
char cstr[MAX_PATH];
if (GetCurrentDirectory(sizeof(str), str) == 0) {
return string("");
}
string result(cstr);
return result;
}
}
#else
#include <unistd.h>
#include <linux/limits.h>
namespace fennec
{
string getcwd() {
char cstr[PATH_MAX];
if (::getcwd(cstr, sizeof(cstr)) == NULL) {
return string("");
}
string result(cstr);
return result;
}
#endif
}

View File

@@ -14,4 +14,4 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================
// =====================================================================================================================

View File

@@ -20,7 +20,7 @@
using assert_handler = void (*)(const char *, const char *, int , const char *);
extern void __assert_callback(const char* expression, const char* file, int line, const char* function, const char* description);
void __assert_callback(const char* expression, const char* file, int line, const char* function, const char* description);
void __assert_impl(const char* expression, const char* file, int line, const char* function, const char* description)
{

View File

@@ -28,16 +28,14 @@
#else
// Allocation functions
inline void* operator new (fennec::size_t size) { return ::malloc(size); }
inline void* operator new[](fennec::size_t size) { return ::malloc(size); }
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 & deallocation functions
// Windows does not define ISO C aligned allocation 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) noexcept { ::_aligned_free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t) noexcept { ::_aligned_free(ptr); }
inline void operator delete (void* ptr, fennec::size_t, fennec::align_t) noexcept { ::_aligned_free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t, fennec::align_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 delete[](void* ptr, fennec::align_t, const fennec::nothrow_t&) noexcept { _aligned_free(ptr); }
@@ -45,9 +43,15 @@ inline void* operator new (fennec::size_t size, fennec::align_t align)
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) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t) noexcept { ::free(ptr); }
inline void operator delete (void* ptr, fennec::size_t, fennec::align_t) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t, fennec::align_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); }
@@ -55,22 +59,54 @@ inline void* operator new (fennec::size_t size, fennec::align_t align)
inline void* operator new[](fennec::size_t size, fennec::align_t align) { return ::aligned_alloc(static_cast<fennec::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<fennec::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<fennec::size_t>(align), size); }
#endif
// Aligned deallocation functions
inline void operator delete (void* ptr, fennec::align_t) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::align_t) noexcept { ::free(ptr); }
// Allocation functions
inline void* operator new (fennec::size_t size) { return ::malloc(size); }
inline void* operator new[](fennec::size_t size) { return ::malloc(size); }
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); }
// Sized deallocation functions
inline void operator delete (void* ptr, fennec::size_t) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t) noexcept { ::free(ptr); }
inline void operator delete (void* ptr, fennec::size_t, fennec::align_t) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t, fennec::align_t) noexcept { ::free(ptr); }
// Non-throwing deallocation functions
// Deallocation Functions
inline void operator delete (void* ptr, fennec::size_t) noexcept { ::free(ptr); }
inline void operator delete[](void* ptr, fennec::size_t) noexcept { ::free(ptr); }
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::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); }
#endif
// Platform specific code
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
namespace fennec
{
size_T pagesize() {
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
return sysInfo.dwPageSize;
}
}
#else
#include <unistd.h>
namespace fennec
{
size_t pagesize() {
return sysconf(_SC_PAGESIZE);
}
}
#endif
#endif