ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: f8b371000159f64844784c46f89e734f640bd5f8
Parent: 6ba7f488631b2640c276ea51212688fe5192e1df
Author: Randy Palamar
Date:   Fri, 14 Nov 2025 12:57:13 -0700

build: cleanup; give in to garbage feature test macro

Diffstat:
M.github/workflows/build.yml | 2+-
Mbuild.c | 26+++++++++++++-------------
Mintrinsics.c | 15+++++++++------
Mos_linux.c | 10----------
4 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: sudo apt install libxkbcommon-dev xorg-dev - name: Build run: | - ${{matrix.cc}} -march=native -O3 build.c -Iexternal/include -o build && \ + ${{matrix.cc}} -march=native -O3 -D_GNU_SOURCE build.c -Iexternal/include -o build && \ ./build --tests && \ ./build --debug diff --git a/build.c b/build.c @@ -31,8 +31,8 @@ global char *g_argv0; #define COMMON_FLAGS "-std=c11", "-pipe", "-Wall" #define DEBUG_FLAGS "-O0", "-D_DEBUG", "-Wno-unused-function" #define OPTIMIZED_FLAGS "-O3" - #define EXTRA_FLAGS_BASE "-Werror", "-Wextra", "-Wshadow", "-Wconversion", "-Wno-unused-parameter", \ - "-Wno-error=unused-function", "-funsafe-math-optimizations", "-fno-math-errno" + #define EXTRA_FLAGS_BASE "-Werror", "-Wextra", "-Wshadow", "-Wno-unused-parameter", \ + "-Wno-error=unused-function", "-fno-builtin" #if COMPILER_GCC #define EXTRA_FLAGS EXTRA_FLAGS_BASE, "-Wno-unused-variable" #else @@ -425,9 +425,9 @@ os_get_filetime(char *file) u64 result = (u64)-1; iptr h = CreateFileA(file, 0, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (h != INVALID_FILE) { - struct { u32 low, high; } w32_filetime; + union { struct { u32 low, high; }; u64 U64; } w32_filetime; GetFileTime(h, 0, 0, (iptr)&w32_filetime); - result = (u64)w32_filetime.high << 32ULL | w32_filetime.low; + result = w32_filetime.U64; CloseHandle(h); } return result; @@ -529,7 +529,7 @@ cmd_base(Arena *a, Options *o) else cmd_append(a, &result, OPTIMIZED_FLAGS); /* NOTE: glibc devs are actually buffoons who never write any real code */ - if (is_unix) cmd_append(a, &result, "-D_XOPEN_SOURCE=600"); + if (is_unix) cmd_append(a, &result, "-D_GNU_SOURCE"); /* NOTE: ancient gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80454 */ if (is_gcc) cmd_append(a, &result, "-Wno-missing-braces"); @@ -721,7 +721,7 @@ check_build_raylib(Arena a, CommandList cc, b32 shared) { b32 result = 1; char *libraylib = shared ? OS_SHARED_LINK_LIB("raylib") : OUTPUT_LIB(OS_STATIC_LIB("raylib")); - if (needs_rebuild(libraylib, __FILE__, "external/include/rlgl.h", "external/raylib")) { + if (needs_rebuild(libraylib, "external/include/rlgl.h", "external/raylib")) { git_submodule_update(a, "external/raylib"); os_copy_file("external/raylib/src/rlgl.h", "external/include/rlgl.h"); @@ -1387,7 +1387,7 @@ typedef struct { function MetaEntryScope meta_entry_extract_scope(MetaEntry *base, iz entry_count) { - assert(base->kind != MetaEntryKind_BeginScope || base->kind != MetaEntryKind_EndScope); + assert(base->kind != MetaEntryKind_BeginScope && base->kind != MetaEntryKind_EndScope); assert(entry_count > 0); MetaEntryScope result = {.start = base + 1, .consumed = 1}; @@ -1723,7 +1723,7 @@ meta_pack_shader_bake_parameters(MetaContext *ctx, MetaEntry *e, iz entry_count, bp->shader_id = shader_id; if (table_id) *table_id = (u32)da_index(bp, &ctx->shader_bake_parameters); - if (e->argument_count) meta_entry_argument_expected(e); + if (e->argument_count) meta_entry_argument_expected_(e, 0, 0); MetaEntryScope scope = meta_entry_extract_scope(e, entry_count); if (scope.consumed > 1) { @@ -2150,7 +2150,7 @@ meta_generate_expansion_set(MetaContext *ctx, Arena *arena, s8 expansion_string, case MetaExpansionToken_TypeEvalElements: { if (meta_expansion_token(p) != MetaExpansionToken_Identifier) { - loc.column += p->save.data - expansion_string.data; + loc.column += (u32)(p->save.data - expansion_string.data); meta_expansion_expected(loc, MetaExpansionToken_Identifier, token); } MetaExpansionPartKind kind = token == MetaExpansionToken_TypeEval ? @@ -2164,7 +2164,7 @@ meta_generate_expansion_set(MetaContext *ctx, Arena *arena, s8 expansion_string, s8 string = meta_expansion_extract_string(p); token = meta_expansion_token(p); if (token != MetaExpansionToken_Quote) { - loc.column += point - expansion_string.data; + loc.column += (u32)(point - expansion_string.data); /* TODO(rnp): point at start */ meta_compiler_error(loc, "unterminated string in expansion\n"); } @@ -2866,7 +2866,7 @@ meta_push_shader_bake(MetaprogramContext *m, MetaContext *ctx) } meta_end_scope(m, s8("};\n")); } -read_only global s8 c_file_header = s8("" +read_only global s8 c_file_header = s8_comp("" "/* See LICENSE for license details. */\n\n" "// GENERATED CODE\n\n" ); @@ -3118,13 +3118,13 @@ metagen_matlab_union(MetaprogramContext *m, MetaContext *ctx, MetaMUnion *mu, s8 (u32)enumeration_members->count, mu->sub_table_count); } - struct { + struct table_match { MetaTable *table; MetaKind *kinds; u32 name_index; } *table_matches; - table_matches = push_array(&scratch, typeof(*table_matches), mu->sub_table_count); + table_matches = push_array(&scratch, struct table_match, mu->sub_table_count); for (u32 index = 0; index < mu->sub_table_count; index++) { s8 sub_table_name = mu->sub_table_names[index]; MetaTable *t = ctx->tables.data + meta_lookup_string_slow(ctx->table_names.data, diff --git a/intrinsics.c b/intrinsics.c @@ -26,7 +26,11 @@ #define debugbreak() __debugbreak() #define unreachable() __assume(0) - #define memory_write_barrier() _WriteBarrier() + #if ARCH_ARM64 + #define cpu_yield() __yield() + #endif + + #define memory_write_barrier() _WriteBarrier() #define atomic_add_u32(ptr, n) _InterlockedExchangeAdd((volatile u32 *)(ptr), (n)) #define atomic_add_u64(ptr, n) _InterlockedExchangeAdd64((volatile u64 *)(ptr), (n)) @@ -37,10 +41,10 @@ #define atomic_load_u32(ptr) *((volatile u32 *)(ptr)) #define atomic_load_u64(ptr) *((volatile u64 *)(ptr)) #define atomic_or_u32(ptr, n) _InterlockedOr((volatile u32 *)(ptr), (n)) - #define atomic_store_u32(ptr, n) *((volatile u32 *)(ptr)) = (n) - #define atomic_store_u64(ptr, n) *((volatile u64 *)(ptr)) = (n) + #define atomic_store_u32(ptr, n) *((volatile u32 *)(ptr)) = (u32)(n) + #define atomic_store_u64(ptr, n) *((volatile u64 *)(ptr)) = (u64)(n) #define atomic_swap_u32(ptr, n) _InterlockedExchange((volatile u32 *)(ptr), n) - #define atomic_swap_u64(ptr, n) _InterlockedExchange64((volatile u32 *)(ptr), n) + #define atomic_swap_u64(ptr, n) _InterlockedExchange64((volatile u64 *)(ptr), n) #define atan2_f32(y, x) atan2f(y, x) #define cos_f32(a) cosf(a) @@ -60,6 +64,7 @@ #if ARCH_ARM64 /* TODO? debuggers just loop here forever and need a manual PC increment (step over) */ #define debugbreak() asm volatile ("brk 0xf000") + #define cpu_yield() asm volatile ("yield") #else #define debugbreak() asm volatile ("int3; nop") #endif @@ -184,8 +189,6 @@ typedef uint32x4_t u32x4; #define store_i32x4(o, a) vst1q_s32(o, a) #define sub_f32x4(a, b) vsubq_f32(a, b) -#define cpu_yield() asm volatile ("yield") - #elif ARCH_X64 #include <immintrin.h> typedef __m128 f32x4; diff --git a/os_linux.c b/os_linux.c @@ -30,15 +30,6 @@ typedef struct { } OS_LinuxContext; global OS_LinuxContext os_linux_context; -/* NOTE(rnp): hidden behind feature flags -> screw compiler/standards idiots */ -#ifndef CLOCK_MONOTONIC - #define CLOCK_MONOTONIC 1 -#endif -i32 ftruncate(i32, i64); -i64 syscall(i64, ...); -i32 clock_gettime(i32, struct timespec *); -int getpagesize(void); - #ifdef _DEBUG function void * os_get_module(char *name, Stream *e) @@ -359,7 +350,6 @@ os_create_thread(iptr user_context, os_thread_entry_point_fn *fn) return (iptr)result; } -i32 pthread_setname_np(pthread_t, char *); function void os_set_thread_name(iptr thread, s8 name) {