mirror of
https://github.com/Ed94/metadesk.git
synced 2026-07-31 03:40:06 +00:00
progress on sanity_tests.c, adding back md_str8_styllize
Eventually a heavy reduction of base & OS should be provided via libgen or done here to reduce the overall surface area of the library for the user. Base and os were dragged from raddbg and the original metadesk didn't need as many definitions.
This commit is contained in:
+14
-14
@@ -24,7 +24,7 @@ struct MD_OS_LNX_FileIter
|
||||
{
|
||||
DIR* dir;
|
||||
struct dirent* dp;
|
||||
MD_String8 path;
|
||||
MD_String8 path;
|
||||
};
|
||||
md_assert(sizeof(Member(MD_OS_FileIter, memory)) >= sizeof(MD_OS_LNX_FileIter), md_os_lnx_file_iter_size_check);
|
||||
|
||||
@@ -85,7 +85,7 @@ struct MD_OS_LNX_State
|
||||
MD_Arena* arena;
|
||||
MD_OS_SystemInfo system_info;
|
||||
MD_OS_ProcessInfo process_info;
|
||||
pthread_mutex_t entity_mutex;
|
||||
pthread_mutex_t entity_mutex;
|
||||
MD_Arena* entity_arena;
|
||||
MD_OS_LNX_Entity* entity_free;
|
||||
};
|
||||
@@ -95,17 +95,17 @@ struct MD_OS_LNX_State
|
||||
//~ rjf: Helpers
|
||||
|
||||
MD_DateTime md_os_lnx_date_time_from_tm (tm in, MD_U32 msec);
|
||||
tm md_os_lnx_tm_from_date_time (MD_DateTime dt);
|
||||
timespec md_os_lnx_timespec_from_date_time (MD_DateTime dt);
|
||||
tm md_os_lnx_tm_from_date_time (MD_DateTime dt);
|
||||
timespec md_os_lnx_timespec_from_date_time (MD_DateTime dt);
|
||||
MD_DenseTime md_os_lnx_dense_time_from_timespec (timespec in);
|
||||
MD_FileProperties md_os_lnx_file_properties_from_stat(struct stat* s);
|
||||
void md_os_lnx_safe_call_sig_handler (int x);
|
||||
void md_os_lnx_safe_call_sig_handler (int x);
|
||||
|
||||
inline MD_DateTime
|
||||
md_os_lnx_date_time_from_tm(tm in, MD_U32 msec) {
|
||||
MD_DateTime dt = {0};
|
||||
dt.sec = in.tm_sec;
|
||||
dt.md_min = in.tm_min;
|
||||
dt.min = in.tm_min;
|
||||
dt.hour = in.tm_hour;
|
||||
|
||||
dt.day = in.tm_mday-1;
|
||||
@@ -173,7 +173,7 @@ md_os_lnx_safe_call_sig_handler(int x) {
|
||||
//~ rjf: Entities
|
||||
|
||||
MD_API MD_OS_LNX_Entity* md_os_lnx_entity_alloc (MD_OS_LNX_EntityKind kind);
|
||||
MD_API void md_os_lnx_entity_release(MD_OS_LNX_Entity* entity);
|
||||
MD_API void md_os_lnx_entity_release(MD_OS_LNX_Entity* entity);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Thread Entry Point
|
||||
@@ -185,7 +185,7 @@ MD_API void* md_os_lnx_thread_entry_point(void* ptr);
|
||||
|
||||
inline MD_String8
|
||||
md_os_get_current_path__ainfo(MD_AllocatorInfo ainfo) {
|
||||
char* cwdir = getcwd(0, 0);
|
||||
char* cwdir = getcwd(0, 0);
|
||||
MD_String8 string = md_str8_copy(ainfo, md_str8_cstring(cwdir));
|
||||
return string;
|
||||
}
|
||||
@@ -195,15 +195,15 @@ md_os_get_current_path__ainfo(MD_AllocatorInfo ainfo) {
|
||||
|
||||
//- rjf: basic
|
||||
|
||||
inline void* md_os_reserve ( MD_U64 size) { void* result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); return result; }
|
||||
inline MD_B32 md_os_commit (void *ptr, MD_U64 size) { mprotect(ptr, size, PROT_READ | PROT_WRITE); return 1; }
|
||||
inline void md_os_decommit(void *ptr, MD_U64 size) { madvise(ptr, size, MADV_DONTNEED); mprotect(ptr, size, PROT_NONE); }
|
||||
inline void md_os_release (void *ptr, MD_U64 size) { munmap(ptr, size); }
|
||||
inline void* md_os_reserve ( MD_U64 size) { void* result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); return result; }
|
||||
inline MD_B32 md_os_commit (void *ptr, MD_U64 size) { mprotect(ptr, size, PROT_READ | PROT_WRITE); return 1; }
|
||||
inline void md_os_decommit(void *ptr, MD_U64 size) { madvise(ptr, size, MADV_DONTNEED); mprotect(ptr, size, PROT_NONE); }
|
||||
inline void md_os_release (void *ptr, MD_U64 size) { munmap(ptr, size); }
|
||||
|
||||
//- rjf: large pages
|
||||
|
||||
inline void* md_os_reserve_large( MD_U64 size) { void* result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); return result; }
|
||||
inline MD_B32 md_os_commit_large (void *ptr, MD_U64 size) { mprotect(ptr, size, PROT_READ | PROT_WRITE); return 1; }
|
||||
inline void* md_os_reserve_large( MD_U64 size) { void* result = mmap(0, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); return result; }
|
||||
inline MD_B32 md_os_commit_large (void *ptr, MD_U64 size) { mprotect(ptr, size, PROT_READ | PROT_WRITE); return 1; }
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @md_os_hooks Thread Info (Implemented Per-OS)
|
||||
|
||||
Reference in New Issue
Block a user