diff --git a/build/build_.sh b/build/build_.sh index caf84ba..68daf04 100755 --- a/build/build_.sh +++ b/build/build_.sh @@ -146,10 +146,10 @@ CompilerFlags_wasm+=" -Wl,--no-entry" # CompilerFlags_wasm+=" -Wl,--allow-undefined" # CompilerFlags_wasm+=" -Wl,--export-all" # -CompilerFlags_linux="" +CompilerFlags_linux=" -pthread" -CompilerFlags_raspi="" # "--target=arm-rpi-linux-gnueabihf" # "--target=arm-linux-gnueabihf" #target -CompilerFlags_raspi+="-lm" # link with local system math libraries +CompilerFlags_raspi=" -pthread" # "--target=arm-rpi-linux-gnueabihf" # "--target=arm-linux-gnueabihf" #target +CompilerFlags_raspi+=" -lm" # link with local system math libraries CompilerFlags_DEBUG_win32="" diff --git a/run_tree/raspi/arm64/debug/convert_csv b/run_tree/raspi/arm64/debug/convert_csv index 8667000..26df40e 100755 Binary files a/run_tree/raspi/arm64/debug/convert_csv and b/run_tree/raspi/arm64/debug/convert_csv differ diff --git a/run_tree/raspi/arm64/debug/lumenarium b/run_tree/raspi/arm64/debug/lumenarium index d4f1722..c90c4e9 100755 Binary files a/run_tree/raspi/arm64/debug/lumenarium and b/run_tree/raspi/arm64/debug/lumenarium differ diff --git a/src_v2/platform/linux/lumenarium_linux_file.h b/src_v2/platform/linux/lumenarium_linux_file.h index f9489f6..f0df869 100644 --- a/src_v2/platform/linux/lumenarium_linux_file.h +++ b/src_v2/platform/linux/lumenarium_linux_file.h @@ -57,7 +57,7 @@ os_file_open(String path, File_Access_Flags flags_access, File_Create_Flags fla invalid_default_case; } - s32 file_handle = open((char*)path.str, flags); + s32 file_handle = open((char*)path.str, flags, mode); if (file_handle >= 0) { result = open_files_put_handle(file_handle, path); diff --git a/src_v2/platform/osx/lumenarium_osx_thread.h b/src_v2/platform/osx/lumenarium_osx_thread.h index aae4c13..0cb8781 100644 --- a/src_v2/platform/osx/lumenarium_osx_thread.h +++ b/src_v2/platform/osx/lumenarium_osx_thread.h @@ -98,9 +98,11 @@ void os_thread_end(Thread_Handle thread_handle) { Os_Osx_Thread* t = osx_threads_ + thread_handle.value; - pthread_kill(t->thread, 0); + //pthread_kill(t->thread, 0); } +#if defined(PLATFORM_osx) + u32 os_interlocked_increment(volatile u32* value) { @@ -117,4 +119,24 @@ os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value) return result; } +#else +u32 +os_interlocked_increment(volatile u32* value) +{ + *value += 1; + return *value; +} + +bool +os_interlocked_cmp_exchg(volatile u32* dest, u32 old_value, u32 new_value) +{ + assert(*dest <= s32_max); + if (*dest == old_value) { + *dest = new_value; + return true; + } + return false; +} +#endif + #endif //LUMENARIUM_OSX_THREAD_H diff --git a/src_v2/platform/raspi/lumenarium_first_raspi.c b/src_v2/platform/raspi/lumenarium_first_raspi.c index 25684c9..5052ee7 100644 --- a/src_v2/platform/raspi/lumenarium_first_raspi.c +++ b/src_v2/platform/raspi/lumenarium_first_raspi.c @@ -24,6 +24,8 @@ #include #include +#include + #define linux_err_print(sub_proc) linux_err_print_((char*)__FUNCTION__, (char*)(sub_proc), errno) void linux_err_print_(char* proc, char* sub_proc, s32 errsv) @@ -42,6 +44,7 @@ linux_err_print_(char* proc, char* sub_proc, s32 errsv) #include "../linux/lumenarium_linux_file.h" #include "../linux/lumenarium_linux_time.h" #include "../osx/lumenarium_osx_network.h" +#include "../osx/lumenarium_osx_thread.h" int main (int arg_count, char** args) @@ -51,6 +54,11 @@ int main (int arg_count, char** args) }; App_State* state = lumenarium_init(&ed_desc); + time_t t = time(NULL); + struct tm* lt = localtime(&t); + // lt.tm_sec, tm_min, tm_hour, tm_mday, etc. + printf("Local Time: %s\n", asctime(lt)); + bool running = true; Ticks ticks_start = os_get_ticks(); while (has_flag(state->flags, AppState_IsRunning)) @@ -61,14 +69,18 @@ int main (int arg_count, char** args) lumenarium_env_validate(); Ticks ticks_end = os_get_ticks(); - r64 seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); - while (seconds_elapsed < state->target_seconds_per_frame) - { - u32 sleep_time = (u32)(1000.0f * (state->target_seconds_per_frame - seconds_elapsed)); - usleep(sleep_time); - ticks_end = os_get_ticks(); - seconds_elapsed = get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); - } + usleep((1.f / 30.f) * 1000000); + + // r64 seconds_elapsed = (r64)(ticks_end.value - ticks_start.value) / (r64)1e+9; + // //get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + // while (seconds_elapsed < state->target_seconds_per_frame) + // { + // printf("Sleeping\n"); + // u32 sleep_time = (u32)(1000000.0f * (state->target_seconds_per_frame - seconds_elapsed)); + + // ticks_end = os_get_ticks(); + // seconds_elapsed = (r64)(ticks_end.value - ticks_start.value) / (r64)1e+9; //get_seconds_elapsed(ticks_start, ticks_end, os_get_ticks_per_second()); + // } ticks_start = ticks_end; }