CORE_Static
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
const size_t os_page_size = 4096;
|
||||
|
||||
function OS_Memory
|
||||
CORE_Static OS_Memory
|
||||
os_reserve(size_t size){
|
||||
OS_Memory result = {};
|
||||
size_t adjusted_size = align_up(size, os_page_size);
|
||||
@@ -14,7 +14,7 @@ os_reserve(size_t size){
|
||||
return result;
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
os_commit(OS_Memory *m, size_t size){
|
||||
size_t commit = align_up(size, os_page_size);
|
||||
size_t total_commit = m->commit + commit;
|
||||
@@ -29,7 +29,7 @@ os_commit(OS_Memory *m, size_t size){
|
||||
return false;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
os_release(OS_Memory *m){
|
||||
BOOL result = VirtualFree(m->data, 0, MEM_RELEASE);
|
||||
assert_message(result != 0, "Failed to release OS_Memory");
|
||||
@@ -40,7 +40,7 @@ os_release(OS_Memory *m){
|
||||
}
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
os_decommit_pos(OS_Memory *m, size_t pos){
|
||||
size_t aligned = align_down(pos, os_page_size);
|
||||
size_t adjusted_pos = clamp_top(aligned, m->commit);
|
||||
@@ -56,7 +56,7 @@ os_decommit_pos(OS_Memory *m, size_t pos){
|
||||
return false;
|
||||
}
|
||||
|
||||
function void
|
||||
CORE_Static void
|
||||
test_os_memory(){
|
||||
assert(align_down(4096, 4096) == 4096);
|
||||
assert(align_down(4095, 4096) == 0);
|
||||
@@ -103,7 +103,7 @@ api F64 os_time() {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Filesystem
|
||||
//-----------------------------------------------------------------------------
|
||||
function B32
|
||||
CORE_Static B32
|
||||
os_write_file(String filename, String filecontent){
|
||||
FILE *f = fopen((const char *)filename.str, "w");
|
||||
if(f){
|
||||
@@ -114,7 +114,7 @@ os_write_file(String filename, String filecontent){
|
||||
return false;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
os_read_file(Arena *a, String name){
|
||||
String result = {0};
|
||||
FILE *f = fopen((char *)name.str, "rb");
|
||||
@@ -131,7 +131,7 @@ os_read_file(Arena *a, String name){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
os_get_working_dir(Arena *a){
|
||||
wchar_t buffer[2048];
|
||||
DWORD written = GetCurrentDirectoryW(2048, buffer);
|
||||
@@ -142,7 +142,7 @@ os_get_working_dir(Arena *a){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
os_get_exe_dir(Arena *a){
|
||||
wchar_t buffer[2048];
|
||||
DWORD written = GetModuleFileNameW(0, buffer, 2048);
|
||||
@@ -157,7 +157,7 @@ os_get_exe_dir(Arena *a){
|
||||
return result;
|
||||
}
|
||||
|
||||
function String
|
||||
CORE_Static String
|
||||
os_get_absolute_path(Arena *a, String path){
|
||||
Scratch scratch(a);
|
||||
String16 path16 = string8_to_string16(scratch, path);
|
||||
@@ -172,7 +172,7 @@ os_get_absolute_path(Arena *a, String path){
|
||||
return absolute;
|
||||
}
|
||||
|
||||
function B32
|
||||
CORE_Static B32
|
||||
os_does_file_exist(String path){
|
||||
Scratch scratch;
|
||||
String16 path16 = string8_to_string16(scratch, path);
|
||||
@@ -181,7 +181,7 @@ os_does_file_exist(String path){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Array<OS_File_Info>
|
||||
CORE_Static Array<OS_File_Info>
|
||||
os_list_dir(Arena *a, String dir, U32 flags = LIST_NO_FLAGS){
|
||||
Scratch scratch(a);
|
||||
Array<String> dirs_to_read = {scratch};
|
||||
|
||||
Reference in New Issue
Block a user