progress on compiler errors

This commit is contained in:
ed
2025-02-08 22:36:11 -05:00
parent 835bfe654b
commit 3b12268f46
31 changed files with 535 additions and 468 deletions
+5 -23
View File
@@ -1,33 +1,15 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "base/base.h"
# include "base/debug.h"
# include "base/strings.h"
# include "base/thread_context.h"
# include "os/os.h"
# include "os/linux/os_linux_includes.h"
#endif
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Includes
#define _GNU_SOURCE
#include <features.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/limits.h>
#include <time.h>
#include <dirent.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <signal.h>
#include <errno.h>
#include <dlfcn.h>
#include <sys/sysinfo.h>
#include <sys/random.h>
int pthread_setname_np(pthread_t thread, const char* name);
int pthread_getname_np(pthread_t thread, char* name, size_t size);
+25
View File
@@ -0,0 +1,25 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
#endif
////////////////////////////////
//~ rjf: Includes
#define _GNU_SOURCE
#include <features.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/limits.h>
#include <time.h>
#include <dirent.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <signal.h>
#include <errno.h>
#include <dlfcn.h>
#include <sys/sysinfo.h>
#include <sys/random.h>
+49 -63
View File
@@ -1,22 +1,8 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "base/base.h"
#endif
#if !defined(OS_FEATURE_GRAPHICAL)
# define OS_FEATURE_GRAPHICAL 0
#endif
#if !defined(OS_GFX_STUB)
# define OS_GFX_STUB 0
#endif
#if OS_WINDOWS
# include "os/win32/os_win32.h"
#elif OS_LINUX
# include "os/linux/os_linux.h"
#else
# error OS core layer not implemented for this operating system.
# include "base/file.h"
# include "base/debug.h"
# include "os_resolve.h"
#endif
// Copyright (c) 2024 Epic Games Tools
@@ -177,7 +163,7 @@ os_handle_list_push(Arena* arena, OS_HandleList* handles, OS_Handle handle) {
sll_queue_push(handles->first, handles->last, n);
handles->count += 1;
#else
return os_handle_list_alloc(arena_allocator(arena), handles, handle);
os_handle_list_alloc(arena_allocator(arena), handles, handle);
#endif
}
@@ -220,6 +206,17 @@ os_handle_array_from_list_alloc(AllocatorInfo ainfo, OS_HandleList* list) {
////////////////////////////////
//~ rjf: Command Line Argc/Argv Helper (Helper, Implemented Once)
inline String8List
os_string_list_from_argcv_alloc(AllocatorInfo ainfo, int argc, char** argv) {
String8List result = {0};
for(int i = 0; i < argc; i += 1)
{
String8 str = str8_cstring(argv[i]);
str8_list_alloc(ainfo, &result, str);
}
return result;
}
inline String8List
os_string_list_from_argcv(Arena* arena, int argc, char** argv) {
String8List result = {0};
@@ -231,16 +228,36 @@ os_string_list_from_argcv(Arena* arena, int argc, char** argv) {
return result;
}
inline String8List
os_string_list_from_argcv(AllocatorInfo ainfo, int argc, char** argv) {
String8List result = {0};
for(int i = 0; i < argc; i += 1)
{
String8 str = str8_cstring(argv[i]);
str8_list_alloc(ainfo, &result, str);
}
return result;
}
////////////////////////////////
//~ rjf: @os_hooks File System (Implemented Per-OS)
//- rjf: files
MD_API OS_Handle os_file_open (OS_AccessFlags flags, String8 path);
MD_API void os_file_close (OS_Handle file);
MD_API U64 os_file_read (OS_Handle file, Rng1U64 rng, void *out_data);
MD_API U64 os_file_write (OS_Handle file, Rng1U64 rng, void *data);
MD_API B32 os_file_set_times (OS_Handle file, DateTime time);
MD_API FileProperties os_properties_from_file (OS_Handle file);
MD_API OS_FileID os_id_from_file (OS_Handle file);
MD_API B32 os_delete_file_at_path (String8 path);
MD_API B32 os_copy_file_path (String8 dst, String8 src);
MD_API String8 os_full_path_from_path (Arena* arena, String8 path);
MD_API B32 os_file_path_exists (String8 path);
MD_API FileProperties os_properties_from_file_path(String8 path);
//- rjf: file maps
MD_API OS_Handle os_file_map_open (OS_AccessFlags flags, OS_Handle file);
MD_API void os_file_map_close (OS_Handle map);
MD_API void* os_file_map_view_open (OS_Handle map, OS_AccessFlags flags, Rng1U64 range);
MD_API void os_file_map_view_close(OS_Handle map, void* ptr, Rng1U64 range);
//- rjf: directory iteration
MD_API OS_FileIter* os_file_iter_begin(Arena* arena, String8 path, OS_FileIterFlags flags);
MD_API B32 os_file_iter_next (Arena* arena, OS_FileIter* iter, OS_FileInfo* info_out);
MD_API void os_file_iter_end ( OS_FileIter* iter);
//- rjf: directory creation
MD_API B32 os_make_directory(String8 path);
////////////////////////////////
//~ rjf: Filesystem Helpers (Helpers, Implemented Once)
@@ -295,8 +312,8 @@ inline S64 os_file_id_compare(OS_FileID a, OS_FileID b) { S64 cmp = memory_compa
//~ rjf: GUID Helpers (Helpers, Implemented Once)
inline String8
os_string_from_guid(Arena* arena, OS_Guid guid) {
String8 result = push_str8f(arena,
os_string_from_guid_alloc(AllocatorInfo ainfo, OS_Guid guid) {
String8 result = alloc_str8f(ainfo,
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
guid.data1,
guid.data2,
@@ -314,8 +331,8 @@ os_string_from_guid(Arena* arena, OS_Guid guid) {
}
inline String8
os_string_from_guid(AllocatorInfo ainfo, OS_Guid guid) {
String8 result = alloc_str8f(ainfo,
os_string_from_guid(Arena* arena, OS_Guid guid) {
String8 result = push_str8f(arena,
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
guid.data1,
guid.data2,
@@ -364,37 +381,6 @@ MD_API void os_set_thread_name(String8 string);
MD_API void os_abort(S32 exit_code);
////////////////////////////////
//~ rjf: @os_hooks File System (Implemented Per-OS)
//- rjf: files
MD_API OS_Handle os_file_open (OS_AccessFlags flags, String8 path);
MD_API void os_file_close (OS_Handle file);
MD_API U64 os_file_read (OS_Handle file, Rng1U64 rng, void *out_data);
MD_API U64 os_file_write (OS_Handle file, Rng1U64 rng, void *data);
MD_API B32 os_file_set_times (OS_Handle file, DateTime time);
MD_API FileProperties os_properties_from_file (OS_Handle file);
MD_API OS_FileID os_id_from_file (OS_Handle file);
MD_API B32 os_delete_file_at_path (String8 path);
MD_API B32 os_copy_file_path (String8 dst, String8 src);
MD_API String8 os_full_path_from_path (Arena* arena, String8 path);
MD_API B32 os_file_path_exists (String8 path);
MD_API FileProperties os_properties_from_file_path(String8 path);
//- rjf: file maps
MD_API OS_Handle os_file_map_open (OS_AccessFlags flags, OS_Handle file);
MD_API void os_file_map_close (OS_Handle map);
MD_API void* os_file_map_view_open (OS_Handle map, OS_AccessFlags flags, Rng1U64 range);
MD_API void os_file_map_view_close(OS_Handle map, void* ptr, Rng1U64 range);
//- rjf: directory iteration
MD_API OS_FileIter* os_file_iter_begin(Arena* arena, String8 path, OS_FileIterFlags flags);
MD_API B32 os_file_iter_next (Arena* arena, OS_FileIter* iter, OS_FileInfo* info_out);
MD_API void os_file_iter_end ( OS_FileIter* iter);
//- rjf: directory creation
MD_API B32 os_make_directory(String8 path);
////////////////////////////////
//~ rjf: @os_hooks Shared Memory (Implemented Per-OS)
+28
View File
@@ -0,0 +1,28 @@
#ifdef INTELLISENSE_DIRECTIVES
# include "base/context_cracking.h"
# include "base/namespace.h"
#endif
#if !defined(OS_FEATURE_GRAPHICAL)
# define OS_FEATURE_GRAPHICAL 0
#endif
#if !defined(OS_GFX_STUB)
# define OS_GFX_STUB 0
#endif
#if OS_WINDOWS
# include "os/win32/os_win32_includes.h"
MD_NS_BEGIN
# include "os/win32/os_win32.h"
MD_NS_END
#elif OS_LINUX
# include "os/linux/os_linux_includes.h"
MD_NS_BEGIN
# include "os/linux/os_linux.h"
MD_NS_END
# error OS core layer not implemented for this operating system.
#endif
+41 -65
View File
@@ -1,39 +1,14 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "base/base.h"
# include "base/strings.h"
# include "base/thread_context.h"
# include "os.h"
# include "os_win32_includes.h"
#endif
// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Includes / Libraries
#ifndef NOMINMAX
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN
#define WIN32_MEAN_AND_LEAN
#define VC_EXTRALEAN
#include <windows.h>
#include <windowsx.h>
#include <timeapi.h>
#include <tlhelp32.h>
#include <Shlobj.h>
#include <processthreadsapi.h>
#pragma comment(lib, "user32")
#pragma comment(lib, "winmm")
#pragma comment(lib, "shell32")
#pragma comment(lib, "advapi32")
#pragma comment(lib, "rpcrt4")
#pragma comment(lib, "shlwapi")
#pragma comment(lib, "comctl32")
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // this is required for loading correct comctl32 dll file
#undef NOMINMAX
#undef WIN32_LEAN_AND_MEAN
#undef WIN32_MEAN_AND_LEAN
#undef VC_EXTRALEAN
////////////////////////////////
//~ rjf: File Iterator Types
@@ -108,26 +83,6 @@ struct OS_W32_State
MD_API extern OS_W32_State os_w32_state = {0};
////////////////////////////////
//~ rjf: File Info Conversion Helpers
inline FilePropertyFlags
os_w32_file_property_flags_from_dwFileAttributes(DWORD dwFileAttributes)
{
FilePropertyFlags flags = 0;
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
flags |= FilePropertyFlag_IsFolder;
}
return flags;
}
inline void
os_w32_file_properties_from_attribute_data(FileProperties* properties, WIN32_FILE_ATTRIBUTE_DATA* attributes) {
properties->size = compose_64bit(attributes->nFileSizeHigh, attributes->nFileSizeLow);
os_w32_dense_time_from_file_time(&properties->created, &attributes->ftCreationTime);
os_w32_dense_time_from_file_time(&properties->modified, &attributes->ftLastWriteTime);
properties->flags = os_w32_file_property_flags_from_dwFileAttributes(attributes->dwFileAttributes);
}
////////////////////////////////
//~ rjf: Time Conversion Helpers
@@ -173,6 +128,27 @@ os_w32_dense_time_from_file_time(DenseTime* out, FILETIME* in) {
*out = dense_time_from_date_time(date_time);
}
////////////////////////////////
//~ rjf: File Info Conversion Helpers
inline FilePropertyFlags
os_w32_file_property_flags_from_dwFileAttributes(DWORD dwFileAttributes)
{
FilePropertyFlags flags = 0;
if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
flags |= FilePropertyFlag_IsFolder;
}
return flags;
}
inline void
os_w32_file_properties_from_attribute_data(FileProperties* properties, WIN32_FILE_ATTRIBUTE_DATA* attributes) {
properties->size = compose_64bit(attributes->nFileSizeHigh, attributes->nFileSizeLow);
os_w32_dense_time_from_file_time(&properties->created, &attributes->ftCreationTime);
os_w32_dense_time_from_file_time(&properties->modified, &attributes->ftLastWriteTime);
properties->flags = os_w32_file_property_flags_from_dwFileAttributes(attributes->dwFileAttributes);
}
////////////////////////////////
//~ rjf: Entity Functions
@@ -188,21 +164,7 @@ MD_API DWORD os_w32_thread_entry_point(void* ptr);
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
inline String8
os_get_current_path(Arena* arena) {
String8 name;
TempArena scratch = scratch_begin(&arena, 1);
{
DWORD length = GetCurrentDirectoryW(0, 0);
U16* memory = push_array_no_zero(scratch.arena, U16, length + 1);
length = GetCurrentDirectoryW(length + 1, (WCHAR*)memory);
name = str8_from_16(arena, str16(memory, length));
}
scratch_end(scratch);
return name;
}
inline String8
os_get_current_path(AllocatorInfo ainfo) {
os_get_current_path_alloc(AllocatorInfo ainfo) {
String8 name;
// TODO(Ed): Review
TempArena scratch = scratch_begin(0, 0);
@@ -216,6 +178,20 @@ os_get_current_path(AllocatorInfo ainfo) {
return name;
}
inline String8
os_get_current_path(Arena* arena) {
String8 name;
TempArena scratch = scratch_begin(&arena, 1);
{
DWORD length = GetCurrentDirectoryW(0, 0);
U16* memory = push_array_no_zero(scratch.arena, U16, length + 1);
length = GetCurrentDirectoryW(length + 1, (WCHAR*)memory);
name = str8_from_16(arena, str16(memory, length));
}
scratch_end(scratch);
return name;
}
////////////////////////////////
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
@@ -240,7 +216,7 @@ os_reserve_large(U64 size) {
return result;
}
inline B32 os_commit_large(void *ptr, U64 size) { return 1; }
inline B32 os_commit_large(void* ptr, U64 size) { return 1; }
////////////////////////////////
//~ rjf: @os_hooks Thread Info (Implemented Per-OS)
+31
View File
@@ -0,0 +1,31 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
#endif
////////////////////////////////
//~ rjf: Includes / Libraries
#ifndef NOMINMAX
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN
#define WIN32_MEAN_AND_LEAN
#define VC_EXTRALEAN
#include <windows.h>
#include <windowsx.h>
#include <timeapi.h>
#include <tlhelp32.h>
#include <Shlobj.h>
#include <processthreadsapi.h>
#pragma comment(lib, "user32")
#pragma comment(lib, "winmm")
#pragma comment(lib, "shell32")
#pragma comment(lib, "advapi32")
#pragma comment(lib, "rpcrt4")
#pragma comment(lib, "shlwapi")
#pragma comment(lib, "comctl32")
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") // this is required for loading correct comctl32 dll file
#undef NOMINMAX
#undef WIN32_LEAN_AND_MEAN
#undef WIN32_MEAN_AND_LEAN
#undef VC_EXTRALEAN