progress on base

This commit is contained in:
2025-02-01 19:08:54 -05:00
parent 102f5af2c7
commit e65974a9b2
12 changed files with 156 additions and 50 deletions
+30 -27
View File
@@ -1,6 +1,7 @@
#ifdef MD_INTELLISENSE_DIRECTIVES
#pragma once
#include
#include "base/macros.h"
#include "base/base_types.h"
#endif
// Copyright (c) 2024 Epic Games Tools
@@ -31,7 +32,7 @@
int pthread_setname_np(pthread_t thread, const char *name);
int pthread_getname_np(pthread_t thread, char *name, size_t size);
typedef struct tm tm;
typedef struct tm tm;
typedef struct timespec timespec;
////////////////////////////////
@@ -40,9 +41,9 @@ typedef struct timespec timespec;
typedef struct OS_LNX_FileIter OS_LNX_FileIter;
struct OS_LNX_FileIter
{
DIR *dir;
struct dirent *dp;
String8 path;
DIR* dir;
struct dirent* dp;
String8 path;
};
StaticAssert(sizeof(Member(OS_FileIter, memory)) >= sizeof(OS_LNX_FileIter), os_lnx_file_iter_size_check);
@@ -52,8 +53,8 @@ StaticAssert(sizeof(Member(OS_FileIter, memory)) >= sizeof(OS_LNX_FileIter), os_
typedef struct OS_LNX_SafeCallChain OS_LNX_SafeCallChain;
struct OS_LNX_SafeCallChain
{
OS_LNX_SafeCallChain *next;
OS_ThreadFunctionType *fail_handler;
OS_LNX_SafeCallChain* next;
OS_ThreadFunctionType* fail_handler;
void *ptr;
};
@@ -72,21 +73,23 @@ OS_LNX_EntityKind;
typedef struct OS_LNX_Entity OS_LNX_Entity;
struct OS_LNX_Entity
{
OS_LNX_Entity *next;
OS_LNX_Entity* next;
OS_LNX_EntityKind kind;
union
{
struct
{
pthread_t handle;
OS_ThreadFunctionType *func;
void *ptr;
pthread_t handle;
OS_ThreadFunctionType* func;
void* ptr;
} thread;
pthread_mutex_t mutex_handle;
pthread_mutex_t mutex_handle;
pthread_rwlock_t rwmutex_handle;
struct
{
pthread_cond_t cond_handle;
pthread_cond_t cond_handle;
pthread_mutex_t rwlock_mutex_handle;
} cv;
};
@@ -98,14 +101,14 @@ struct OS_LNX_Entity
typedef struct OS_LNX_State OS_LNX_State;
struct OS_LNX_State
{
Arena *arena;
OS_SystemInfo system_info;
OS_ProcessInfo process_info;
Arena* arena;
OS_SystemInfo system_info;
OS_ProcessInfo process_info;
pthread_mutex_t entity_mutex;
Arena *entity_arena;
OS_LNX_Entity *entity_free;
Arena* entity_arena;
OS_LNX_Entity* entity_free;
};
k
////////////////////////////////
//~ rjf: Globals
@@ -115,18 +118,18 @@ thread_static OS_LNX_SafeCallChain *os_lnx_safe_call_chain = 0;
////////////////////////////////
//~ rjf: Helpers
internal DateTime os_lnx_date_time_from_tm(tm in, U32 msec);
internal tm os_lnx_tm_from_date_time(DateTime dt);
internal timespec os_lnx_timespec_from_date_time(DateTime dt);
internal DenseTime os_lnx_dense_time_from_timespec(timespec in);
internal DateTime os_lnx_date_time_from_tm(tm in, U32 msec);
internal tm os_lnx_tm_from_date_time(DateTime dt);
internal timespec os_lnx_timespec_from_date_time( DateTime dt);
internal DenseTime os_lnx_dense_time_from_timespec(timespec in);
internal FileProperties os_lnx_file_properties_from_stat(struct stat *s);
internal void os_lnx_safe_call_sig_handler(int x);
internal void os_lnx_safe_call_sig_handler (int x);
k
////////////////////////////////
//~ rjf: Entities
internal OS_LNX_Entity *os_lnx_entity_alloc(OS_LNX_EntityKind kind);
internal void os_lnx_entity_release(OS_LNX_Entity *entity);
internal OS_LNX_Entity* os_lnx_entity_alloc(OS_LNX_EntityKind kind);
internal void os_lnx_entity_release(OS_LNX_Entity *entity);
////////////////////////////////
//~ rjf: Thread Entry Point