mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-12 23:51:37 -07:00
initial pass done for os
This commit is contained in:
Vendored
+14
-1
@@ -52,7 +52,20 @@
|
||||
"os_win32.h": "c",
|
||||
"windows.h": "c",
|
||||
"base.h": "c",
|
||||
"os_linux.h": "c"
|
||||
"os_linux.h": "c",
|
||||
"array": "c",
|
||||
"vector": "c",
|
||||
"dbghelp.h": "c",
|
||||
"namespace.h": "c",
|
||||
"space.h": "c",
|
||||
"logger.h": "c",
|
||||
"entry_point.h": "c",
|
||||
"markup.h": "c",
|
||||
"generic_macros.h": "c",
|
||||
"profiling.h": "c",
|
||||
"ring.h": "c",
|
||||
"debug.h": "c",
|
||||
"arena.h": "c"
|
||||
},
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#713fb8",
|
||||
|
||||
@@ -13,6 +13,53 @@
|
||||
# define BUILD_SUPPLEMENTARY_UNIT 0
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_ENTRY_DEFINING_UNIT)
|
||||
# define BUILD_ENTRY_DEFINING_UNIT 0
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_CONSOLE_INTERFACE)
|
||||
# define BUILD_CONSOLE_INTERFACE 0
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_VERSION_MAJOR)
|
||||
# define BUILD_VERSION_MAJOR 0
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_VERSION_MINOR)
|
||||
# define BUILD_VERSION_MINOR 1
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_VERSION_PATCH)
|
||||
# define BUILD_VERSION_PATCH 0
|
||||
#endif
|
||||
|
||||
#define BUILD_VERSION_STRING_LITERAL stringify(BUILD_VERSION_MAJOR) "." stringify(BUILD_VERSION_MINOR) "." stringify(BUILD_VERSION_PATCH)
|
||||
|
||||
#if BUILD_DEBUG
|
||||
# define BUILD_MODE_STRING_LITERAL_APPEND " [Debug]"
|
||||
#else
|
||||
# define BUILD_MODE_STRING_LITERAL_APPEND ""
|
||||
#endif
|
||||
#if defined(BUILD_GIT_HASH)
|
||||
# define BUILD_GIT_HASH_STRING_LITERAL_APPEND " [" BUILD_GIT_HASH "]"
|
||||
#else
|
||||
# define BUILD_GIT_HASH_STRING_LITERAL_APPEND ""
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_TITLE)
|
||||
# define BUILD_TITLE "Untitled"
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_RELEASE_PHASE_STRING_LITERAL)
|
||||
# define BUILD_RELEASE_PHASE_STRING_LITERAL "ALPHA"
|
||||
#endif
|
||||
|
||||
#if !defined(BUILD_ISSUES_LINK_STRING_LITERAL)
|
||||
# define BUILD_ISSUES_LINK_STRING_LITERAL "ADD_BUILD_ISSUES_LINK"
|
||||
#endif
|
||||
|
||||
#define BUILD_TITLE_STRING_LITERAL BUILD_TITLE " (" BUILD_VERSION_STRING_LITERAL " " BUILD_RELEASE_PHASE_STRING_LITERAL ") - " __DATE__ "" BUILD_GIT_HASH_STRING_LITERAL_APPEND BUILD_MODE_STRING_LITERAL_APPEND
|
||||
|
||||
#pragma region Compiler Vendor
|
||||
|
||||
#if defined( _MSC_VER )
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
{ \
|
||||
if ( ! ( cond ) ) \
|
||||
{ \
|
||||
assert_handler( #cond, __FILE__, __func__, scast( s64, __LINE__ ), msg, ##__VA_ARGS__ ); \
|
||||
assert_handler( #cond, __FILE__, __func__, scast( S64, __LINE__ ), msg, ##__VA_ARGS__ ); \
|
||||
GEN_DEBUG_TRAP(); \
|
||||
} \
|
||||
} while ( 0 )
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
# include <intrin.h>
|
||||
# include <tmmintrin.h>
|
||||
# include <wmmintrin.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if LANG_C
|
||||
|
||||
@@ -287,6 +287,18 @@ str8_is_integer(String8 string, U32 radix){
|
||||
return(result);
|
||||
}
|
||||
|
||||
U64
|
||||
u64_from_str8(String8 string, U32 radix) {
|
||||
U64 x = 0;
|
||||
if (1 < radix && radix <= 16) {
|
||||
for (U64 i = 0; i < string.size; i += 1) {
|
||||
x *= radix;
|
||||
x += integer_symbol_reverse[string.str[i]&0x7F];
|
||||
}
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
|
||||
B32
|
||||
try_u64_from_str8_c_rules(String8 string, U64 *x)
|
||||
{
|
||||
|
||||
@@ -349,18 +349,6 @@ MD_API String8 str8_from_allocator_size(AllocatorInfo ainfo, U64 z);
|
||||
MD_API String8 str8_from_allocator_u64 (AllocatorInfo ainfo, U64 u64, U32 radix, U8 min_digits, U8 digit_group_separator);
|
||||
MD_API String8 str8_from_alloctor_s64 (AllocatorInfo ainfo, S64 u64, U32 radix, U8 min_digits, U8 digit_group_separator);
|
||||
|
||||
inline U64
|
||||
u64_from_str8(String8 string, U32 radix) {
|
||||
U64 x = 0;
|
||||
if (1 < radix && radix <= 16) {
|
||||
for (U64 i = 0; i < string.size; i += 1) {
|
||||
x *= radix;
|
||||
x += integer_symbol_reverse[string.str[i]&0x7F];
|
||||
}
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
|
||||
inline S64
|
||||
s64_from_str8(String8 string, U32 radix) {
|
||||
S64 sign = sign_from_str8(string, &string);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Metagen
|
||||
|
||||
|
||||
+666
-662
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -191,23 +191,30 @@ os_lnx_safe_call_sig_handler(int x) {
|
||||
//~ rjf: Entities
|
||||
|
||||
MD_API OS_LNX_Entity* os_lnx_entity_alloc (OS_LNX_EntityKind kind);
|
||||
MD_API void os_lnx_entity_release(OS_LNX_Entity* entity);
|
||||
MD_API void os_lnx_entity_release(OS_LNX_Entity* entity);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Thread Entry Point
|
||||
|
||||
void* os_lnx_thread_entry_point(void* ptr);
|
||||
MD_API void* os_lnx_thread_entry_point(void* ptr);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
|
||||
|
||||
String8
|
||||
inline String8
|
||||
os_get_current_path(Arena* arena) {
|
||||
char* cwdir = getcwd(0, 0);
|
||||
String8 string = push_str8_copy(arena, str8_cstring(cwdir));
|
||||
return string;
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_get_current_path(AllocatorInfo ainfo) {
|
||||
char* cwdir = getcwd(0, 0);
|
||||
String8 string = str8_copy(ainfo, str8_cstring(cwdir));
|
||||
return string;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||
|
||||
@@ -236,10 +243,3 @@ os_tid(void) {
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Aborting (Implemented Per-OS)
|
||||
|
||||
inline void os_abort(S32 exit_code) { exit(exit_code); }
|
||||
|
||||
|
||||
|
||||
+128
-95
@@ -231,6 +231,17 @@ 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: Filesystem Helpers (Helpers, Implemented Once)
|
||||
|
||||
@@ -285,173 +296,195 @@ inline S64 os_file_id_compare(OS_FileID a, OS_FileID b) { S64 cmp = memory_compa
|
||||
|
||||
inline String8
|
||||
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,
|
||||
guid.data3,
|
||||
guid.data4[0],
|
||||
guid.data4[1],
|
||||
guid.data4[2],
|
||||
guid.data4[3],
|
||||
guid.data4[4],
|
||||
guid.data4[5],
|
||||
guid.data4[6],
|
||||
guid.data4[7]);
|
||||
return result;
|
||||
String8 result = push_str8f(arena,
|
||||
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
guid.data1,
|
||||
guid.data2,
|
||||
guid.data3,
|
||||
guid.data4[0],
|
||||
guid.data4[1],
|
||||
guid.data4[2],
|
||||
guid.data4[3],
|
||||
guid.data4[4],
|
||||
guid.data4[5],
|
||||
guid.data4[6],
|
||||
guid.data4[7]
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_string_from_guid(AllocatorInfo ainfo, OS_Guid guid) {
|
||||
String8 result = str8f(ainfo,
|
||||
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
guid.data1,
|
||||
guid.data2,
|
||||
guid.data3,
|
||||
guid.data4[0],
|
||||
guid.data4[1],
|
||||
guid.data4[2],
|
||||
guid.data4[3],
|
||||
guid.data4[4],
|
||||
guid.data4[5],
|
||||
guid.data4[6],
|
||||
guid.data4[7]
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks System/Process Info (Implemented Per-OS)
|
||||
|
||||
internal OS_SystemInfo* os_get_system_info(void);
|
||||
internal OS_ProcessInfo* os_get_process_info(void);
|
||||
internal String8 os_get_current_path(Arena *arena);
|
||||
MD_API OS_SystemInfo* os_get_system_info (void);
|
||||
MD_API OS_ProcessInfo* os_get_process_info(void);
|
||||
|
||||
String8 os_get_current_path(Arena* arena);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||
|
||||
//- rjf: basic
|
||||
internal void *os_reserve(U64 size);
|
||||
internal B32 os_commit(void *ptr, U64 size);
|
||||
internal void os_decommit(void *ptr, U64 size);
|
||||
internal void os_release(void *ptr, U64 size);
|
||||
void* os_reserve ( U64 size);
|
||||
B32 os_commit (void* ptr, U64 size);
|
||||
void os_decommit(void* ptr, U64 size);
|
||||
void os_release (void* ptr, U64 size);
|
||||
|
||||
//- rjf: large pages
|
||||
internal void *os_reserve_large(U64 size);
|
||||
internal B32 os_commit_large(void *ptr, U64 size);
|
||||
void* os_reserve_large( U64 size);
|
||||
B32 os_commit_large (void* ptr, U64 size);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Thread Info (Implemented Per-OS)
|
||||
|
||||
internal U32 os_tid(void);
|
||||
internal void os_set_thread_name(String8 string);
|
||||
U32 os_tid (void);
|
||||
MD_API void os_set_thread_name(String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Aborting (Implemented Per-OS)
|
||||
|
||||
internal void os_abort(S32 exit_code);
|
||||
MD_API void os_abort(S32 exit_code);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks File System (Implemented Per-OS)
|
||||
|
||||
//- rjf: files
|
||||
internal OS_Handle os_file_open(OS_AccessFlags flags, String8 path);
|
||||
internal void os_file_close(OS_Handle file);
|
||||
internal U64 os_file_read(OS_Handle file, Rng1U64 rng, void *out_data);
|
||||
internal U64 os_file_write(OS_Handle file, Rng1U64 rng, void *data);
|
||||
internal B32 os_file_set_times(OS_Handle file, DateTime time);
|
||||
internal FileProperties os_properties_from_file(OS_Handle file);
|
||||
internal OS_FileID os_id_from_file(OS_Handle file);
|
||||
internal B32 os_delete_file_at_path(String8 path);
|
||||
internal B32 os_copy_file_path(String8 dst, String8 src);
|
||||
internal String8 os_full_path_from_path(Arena *arena, String8 path);
|
||||
internal B32 os_file_path_exists(String8 path);
|
||||
internal FileProperties os_properties_from_file_path(String8 path);
|
||||
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
|
||||
internal OS_Handle os_file_map_open(OS_AccessFlags flags, OS_Handle file);
|
||||
internal void os_file_map_close(OS_Handle map);
|
||||
internal void* os_file_map_view_open(OS_Handle map, OS_AccessFlags flags, Rng1U64 range);
|
||||
internal void os_file_map_view_close(OS_Handle map, void *ptr, Rng1U64 range);
|
||||
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
|
||||
internal OS_FileIter* os_file_iter_begin(Arena *arena, String8 path, OS_FileIterFlags flags);
|
||||
internal B32 os_file_iter_next(Arena *arena, OS_FileIter *iter, OS_FileInfo *info_out);
|
||||
internal void os_file_iter_end(OS_FileIter *iter);
|
||||
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
|
||||
internal B32 os_make_directory(String8 path);
|
||||
MD_API B32 os_make_directory(String8 path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shared Memory (Implemented Per-OS)
|
||||
|
||||
internal OS_Handle os_shared_memory_alloc(U64 size, String8 name);
|
||||
internal OS_Handle os_shared_memory_open(String8 name);
|
||||
internal void os_shared_memory_close(OS_Handle handle);
|
||||
internal void* os_shared_memory_view_open(OS_Handle handle, Rng1U64 range);
|
||||
internal void os_shared_memory_view_close(OS_Handle handle, void *ptr, Rng1U64 range);
|
||||
MD_API OS_Handle os_shared_memory_alloc (U64 size, String8 name);
|
||||
MD_API OS_Handle os_shared_memory_open (String8 name);
|
||||
MD_API void os_shared_memory_close (OS_Handle handle);
|
||||
MD_API void* os_shared_memory_view_open (OS_Handle handle, Rng1U64 range);
|
||||
MD_API void os_shared_memory_view_close(OS_Handle handle, void* ptr, Rng1U64 range);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Time (Implemented Per-OS)
|
||||
|
||||
internal U64 os_now_microseconds(void);
|
||||
internal U32 os_now_unix(void);
|
||||
internal DateTime os_now_universal_time(void);
|
||||
internal DateTime os_universal_time_from_local(DateTime *local_time);
|
||||
internal DateTime os_local_time_from_universal(DateTime *universal_time);
|
||||
internal void os_sleep_milliseconds(U32 msec);
|
||||
MD_API U64 os_now_microseconds (void);
|
||||
MD_API U32 os_now_unix (void);
|
||||
MD_API DateTime os_now_universal_time (void);
|
||||
MD_API DateTime os_universal_time_from_local(DateTime* local_time);
|
||||
MD_API DateTime os_local_time_from_universal(DateTime* universal_time);
|
||||
MD_API void os_sleep_milliseconds (U32 msec);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Child Processes (Implemented Per-OS)
|
||||
|
||||
internal OS_Handle os_process_launch(OS_ProcessLaunchParams *params);
|
||||
internal B32 os_process_join(OS_Handle handle, U64 endt_us);
|
||||
internal void os_process_detach(OS_Handle handle);
|
||||
MD_API OS_Handle os_process_launch(OS_ProcessLaunchParams* params);
|
||||
MD_API B32 os_process_join (OS_Handle handle, U64 endt_us);
|
||||
MD_API void os_process_detach(OS_Handle handle);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Threads (Implemented Per-OS)
|
||||
|
||||
internal OS_Handle os_thread_launch(OS_ThreadFunctionType *func, void *ptr, void *params);
|
||||
internal B32 os_thread_join(OS_Handle handle, U64 endt_us);
|
||||
internal void os_thread_detach(OS_Handle handle);
|
||||
MD_API OS_Handle os_thread_launch(OS_ThreadFunctionType* func, void* ptr, void* params);
|
||||
MD_API B32 os_thread_join (OS_Handle handle, U64 endt_us);
|
||||
MD_API void os_thread_detach(OS_Handle handle);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Synchronization Primitives (Implemented Per-OS)
|
||||
|
||||
//- rjf: recursive mutexes
|
||||
internal OS_Handle os_mutex_alloc(void);
|
||||
internal void os_mutex_release(OS_Handle mutex);
|
||||
internal void os_mutex_take(OS_Handle mutex);
|
||||
internal void os_mutex_drop(OS_Handle mutex);
|
||||
MD_API OS_Handle os_mutex_alloc (void);
|
||||
MD_API void os_mutex_release(OS_Handle mutex);
|
||||
MD_API void os_mutex_take (OS_Handle mutex);
|
||||
MD_API void os_mutex_drop (OS_Handle mutex);
|
||||
|
||||
//- rjf: reader/writer mutexes
|
||||
internal OS_Handle os_rw_mutex_alloc(void);
|
||||
internal void os_rw_mutex_release(OS_Handle rw_mutex);
|
||||
internal void os_rw_mutex_take_r(OS_Handle mutex);
|
||||
internal void os_rw_mutex_drop_r(OS_Handle mutex);
|
||||
internal void os_rw_mutex_take_w(OS_Handle mutex);
|
||||
internal void os_rw_mutex_drop_w(OS_Handle mutex);
|
||||
MD_API OS_Handle os_rw_mutex_alloc(void);
|
||||
MD_API void os_rw_mutex_release(OS_Handle rw_mutex);
|
||||
MD_API void os_rw_mutex_take_r(OS_Handle mutex);
|
||||
MD_API void os_rw_mutex_drop_r(OS_Handle mutex);
|
||||
MD_API void os_rw_mutex_take_w(OS_Handle mutex);
|
||||
MD_API void os_rw_mutex_drop_w(OS_Handle mutex);
|
||||
|
||||
//- rjf: condition variables
|
||||
internal OS_Handle os_condition_variable_alloc(void);
|
||||
internal void os_condition_variable_release(OS_Handle cv);
|
||||
MD_API OS_Handle os_condition_variable_alloc (void);
|
||||
MD_API void os_condition_variable_release(OS_Handle cv);
|
||||
// returns false on timeout, true on signal, (max_wait_ms = max_U64) -> no timeout
|
||||
internal B32 os_condition_variable_wait(OS_Handle cv, OS_Handle mutex, U64 endt_us);
|
||||
internal B32 os_condition_variable_wait_rw_r(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us);
|
||||
internal B32 os_condition_variable_wait_rw_w(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us);
|
||||
internal void os_condition_variable_signal(OS_Handle cv);
|
||||
internal void os_condition_variable_broadcast(OS_Handle cv);
|
||||
MD_API B32 os_condition_variable_wait (OS_Handle cv, OS_Handle mutex, U64 endt_us);
|
||||
MD_API B32 os_condition_variable_wait_rw_r(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us);
|
||||
MD_API B32 os_condition_variable_wait_rw_w(OS_Handle cv, OS_Handle mutex_rw, U64 endt_us);
|
||||
MD_API void os_condition_variable_signal (OS_Handle cv);
|
||||
MD_API void os_condition_variable_broadcast(OS_Handle cv);
|
||||
|
||||
//- rjf: cross-process semaphores
|
||||
internal OS_Handle os_semaphore_alloc(U32 initial_count, U32 max_count, String8 name);
|
||||
internal void os_semaphore_release(OS_Handle semaphore);
|
||||
internal OS_Handle os_semaphore_open(String8 name);
|
||||
internal void os_semaphore_close(OS_Handle semaphore);
|
||||
internal B32 os_semaphore_take(OS_Handle semaphore, U64 endt_us);
|
||||
internal void os_semaphore_drop(OS_Handle semaphore);
|
||||
MD_API OS_Handle os_semaphore_alloc (U32 initial_count, U32 max_count, String8 name);
|
||||
MD_API void os_semaphore_release(OS_Handle semaphore);
|
||||
MD_API OS_Handle os_semaphore_open (String8 name);
|
||||
MD_API void os_semaphore_close (OS_Handle semaphore);
|
||||
MD_API B32 os_semaphore_take (OS_Handle semaphore, U64 endt_us);
|
||||
MD_API void os_semaphore_drop (OS_Handle semaphore);
|
||||
|
||||
//- rjf: scope macros
|
||||
#define OS_MutexScope(mutex) DeferLoop(os_mutex_take(mutex), os_mutex_drop(mutex))
|
||||
#define OS_MutexScopeR(mutex) DeferLoop(os_rw_mutex_take_r(mutex), os_rw_mutex_drop_r(mutex))
|
||||
#define OS_MutexScopeW(mutex) DeferLoop(os_rw_mutex_take_w(mutex), os_rw_mutex_drop_w(mutex))
|
||||
#define OS_MutexScopeRWPromote(mutex) DeferLoop((os_rw_mutex_drop_r(mutex), os_rw_mutex_take_w(mutex)), (os_rw_mutex_drop_w(mutex), os_rw_mutex_take_r(mutex)))
|
||||
#define OS_MutexScope(mutex) defer_loop( os_mutex_take (mutex), os_mutex_drop (mutex))
|
||||
#define OS_MutexScopeR(mutex) defer_loop( os_rw_mutex_take_r(mutex), os_rw_mutex_drop_r(mutex))
|
||||
#define OS_MutexScopeW(mutex) defer_loop( os_rw_mutex_take_w(mutex), os_rw_mutex_drop_w(mutex))
|
||||
#define OS_MutexScopeRWPromote(mutex) defer_loop((os_rw_mutex_drop_r(mutex), os_rw_mutex_take_w(mutex)), (os_rw_mutex_drop_w(mutex), os_rw_mutex_take_r(mutex)))
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Dynamically-Loaded Libraries (Implemented Per-OS)
|
||||
|
||||
internal OS_Handle os_library_open(String8 path);
|
||||
internal void os_library_close(OS_Handle lib);
|
||||
internal VoidProc *os_library_load_proc(OS_Handle lib, String8 name);
|
||||
MD_API OS_Handle os_library_open (String8 path);
|
||||
MD_API void os_library_close (OS_Handle lib);
|
||||
MD_API VoidProc* os_library_load_proc(OS_Handle lib, String8 name);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Safe Calls (Implemented Per-OS)
|
||||
|
||||
internal void os_safe_call(OS_ThreadFunctionType *func, OS_ThreadFunctionType *fail_handler, void *ptr);
|
||||
MD_API void os_safe_call(OS_ThreadFunctionType* func, OS_ThreadFunctionType* fail_handler, void* ptr);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks GUIDs (Implemented Per-OS)
|
||||
|
||||
internal OS_Guid os_make_guid(void);
|
||||
MD_API OS_Guid os_make_guid(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Entry Points (Implemented Per-OS)
|
||||
@@ -461,5 +494,5 @@ internal OS_Guid os_make_guid(void);
|
||||
// into the standard codebase program entry points, named "entry_point".
|
||||
|
||||
#if BUILD_ENTRY_DEFINING_UNIT
|
||||
internal void entry_point(CmdLine *cmdline);
|
||||
void entry_point(CmdLine* cmdline);
|
||||
#endif
|
||||
|
||||
+975
-980
File diff suppressed because it is too large
Load Diff
+30
-26
@@ -154,14 +154,14 @@ os_w32_date_time_from_system_time(DateTime* out, SYSTEMTIME* in)
|
||||
inline void
|
||||
os_w32_system_time_from_date_time(SYSTEMTIME* out, DateTime* in)
|
||||
{
|
||||
out->wYear = (WORD)(in->year);
|
||||
out->wMonth = in->mon + 1;
|
||||
out->wDay = in->day;
|
||||
out->wYear = (WORD)(in->year);
|
||||
out->wMonth = in->mon + 1;
|
||||
out->wDay = in->day;
|
||||
|
||||
out->wHour = in->hour;
|
||||
out->wMinute = in->min;
|
||||
out->wSecond = in->sec;
|
||||
out->wMilliseconds = in->msec;
|
||||
out->wHour = in->hour;
|
||||
out->wMinute = in->min;
|
||||
out->wSecond = in->sec;
|
||||
out->wMilliseconds = in->msec;
|
||||
}
|
||||
|
||||
inline void
|
||||
@@ -201,28 +201,43 @@ os_get_current_path(Arena* arena) {
|
||||
return name;
|
||||
}
|
||||
|
||||
inline String8
|
||||
os_get_current_path(AllocatorInfo ainfo) {
|
||||
String8 name;
|
||||
// TODO(Ed): Review
|
||||
TempArena scratch = scratch_begin(0, 0);
|
||||
{
|
||||
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_alloc(ainfo, str16(memory, length));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return name;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Memory Allocation (Implemented Per-OS)
|
||||
|
||||
//- rjf: basic
|
||||
|
||||
force_inline void* os_reserve ( U64 size) { void* result = VirtualAlloc( 0, size, MEM_RESERVE, PAGE_READWRITE); return result; }
|
||||
force_inline B32 os_commit (void* ptr, U64 size) { B32 result = (VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE) != 0); return result; }
|
||||
force_inline void os_decommit(void* ptr, U64 size) { VirtualFree (ptr, size, MEM_DECOMMIT); }
|
||||
inline void* os_reserve ( U64 size) { void* result = VirtualAlloc( 0, size, MEM_RESERVE, PAGE_READWRITE); return result; }
|
||||
inline B32 os_commit (void* ptr, U64 size) { B32 result = (VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE) != 0); return result; }
|
||||
inline void os_decommit(void* ptr, U64 size) { VirtualFree (ptr, size, MEM_DECOMMIT); }
|
||||
|
||||
inline void
|
||||
os_release(void* ptr, U64 size) {
|
||||
// NOTE(rjf): size not used - not necessary on Windows, but necessary for other OSes.
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
// NOTE(rjf): size not used - not necessary on Windows, but necessary for other OSes.
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
//- rjf: large pages
|
||||
|
||||
inline void*
|
||||
os_reserve_large(U64 size) {
|
||||
// we commit on reserve because windows
|
||||
void* result = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||
return result;
|
||||
// we commit on reserve because windows
|
||||
void* result = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_LARGE_PAGES, PAGE_READWRITE);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline B32 os_commit_large(void *ptr, U64 size) { return 1; }
|
||||
@@ -231,14 +246,3 @@ inline B32 os_commit_large(void *ptr, U64 size) { return 1; }
|
||||
//~ rjf: @os_hooks Thread Info (Implemented Per-OS)
|
||||
|
||||
inline U32 os_tid(void) { DWORD id = GetCurrentThreadId(); return (U32)id; }
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Aborting (Implemented Per-OS)
|
||||
|
||||
inline void os_abort(S32 exit_code) { ExitProcess(exit_code); }
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks File System (Implemented Per-OS)
|
||||
|
||||
//- rjf: files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user