diff options
Diffstat (limited to 'reduced_system_layer.c')
-rwxr-xr-x | reduced_system_layer.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/reduced_system_layer.c b/reduced_system_layer.c index 0240f08..a81e02d 100755 --- a/reduced_system_layer.c +++ b/reduced_system_layer.c @@ -273,6 +273,10 @@ i32 main(i32 argc, c8 **argv); #define ENABLE_X11 1 #endif +#ifndef ENABLE_ALSA +#define ENABLE_ALSA 1 +#endif + #ifndef STATIC_MEMORY_BUFFER_SIZE #define STATIC_MEMORY_BUFFER_SIZE (400 * 1024 * 1024) #endif @@ -1604,6 +1608,24 @@ void PROFILER_end(u32 slot) { normalize_time_(&_profiler_slots[slot].time_sec, &_profiler_slots[slot].time_nsec); } +void PROFILER_report_(void) { + // TODO: Implement printing for WebAssembly. + +#if !defined(__wasm__) + if (_profiler_num_slots > 0) { + printf("\nPROFILER REPORT\n\n"); + for (i64 i = 0; i < _profiler_num_slots; ++i) { + if (_profiler_slots[i].name == NULL || _profiler_slots[i].amount == 0) + continue; + f64 k = _profiler_slots[i].amount == 0 ? 0. : 1. / _profiler_slots[i].amount; + f64 f = ((f64) _profiler_slots[i].time_sec) * k + ((f64 )_profiler_slots[i].time_nsec * .000000001) * k; + printf("%-31s %3lld.%09lld / %4lld = %.6f\n", _profiler_slots[i].name, _profiler_slots[i].time_sec, _profiler_slots[i].time_nsec, _profiler_slots[i].amount, f); + } + printf("\n"); + } +#endif +} + // ================================================================ // // Platform @@ -2358,7 +2380,7 @@ i64 network_send(u16 slot, Network_Address address, i64 size, u8 *data, u16 *loc // // ================================================================ -#if defined(__linux__) +#if defined(__linux__) && ENABLE_ALSA #include <alsa/asoundlib.h> @@ -2526,7 +2548,7 @@ void queue_primary_sound(i64 delay_in_samples, i64 num_samples, f32 *frames) { } } -#endif // defined(__linux__) +#endif // defined(__linux__) && ENABLE_ALSA // ================================================================ // @@ -3399,17 +3421,7 @@ void init_main_window(void) { } void shutdown_all_systems(void) { - if (_profiler_num_slots > 0) { - printf("\nPROFILER REPORT\n\n"); - for (i64 i = 0; i < _profiler_num_slots; ++i) { - if (_profiler_slots[i].name == NULL || _profiler_slots[i].amount == 0) - continue; - f64 k = _profiler_slots[i].amount == 0 ? 0. : 1. / _profiler_slots[i].amount; - f64 f = ((f64) _profiler_slots[i].time_sec) * k + ((f64 )_profiler_slots[i].time_nsec * .000000001) * k; - printf("%-31s %3lld.%09lld / %4lld = %.6f\n", _profiler_slots[i].name, _profiler_slots[i].time_sec, _profiler_slots[i].time_nsec, _profiler_slots[i].amount, f); - } - printf("\n"); - } + PROFILER_report_(); g_platform.done = 1; @@ -4599,6 +4611,33 @@ __attribute__((export_name("js_drop_data"))) void *js_drop_data(void) { // ================================================================ // +// No system +// +// ================================================================ + +#if !defined(__linux__) || !ENABLE_X11 || !ENABLE_WAYLAND +void init_main_window(void) { + LOG_ERROR("Not implemented."); +} + +void update_and_render_frame(void) { + LOG_ERROR("Not implemented."); +} + +void shutdown_all_systems(void) { + // TODO: Factor out common code. + + PROFILER_report_(); + + g_platform.done = 1; +} +#endif + +#if !defined(__linux__) || !ENABLE_ALSA +#endif + +// ================================================================ +// // Test suite // // ================================================================ |