ogl_beamforming

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

Commit: 01c3ff8dd7311ad2019dd79ed36d27408a5fc331
Parent: 9b8f6157ec59ab7877cee2bef9538c8161682a28
Author: Randy Palamar
Date:   Mon, 19 May 2025 17:36:10 -0600

intrinsics: detect compiler once, add read_only attribute

Diffstat:
Mintrinsics.c | 28+++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/intrinsics.c b/intrinsics.c @@ -1,4 +1,30 @@ -#define force_inline inline __attribute__((always_inline)) +/* See LICENSE for license details. */ +#ifdef __clang__ + #define COMPILER_CLANG 1 +#elif _MSC_VER + #define COMPILER_MSVC 1 +#elif __GNUC__ + #define COMPILER_GCC 1 +#else + #error Unsupported Compiler +#endif + +#if COMPILER_CLANG || COMPILER_GCC + #define force_inline inline __attribute__((always_inline)) +#elif COMPILER_MSVC + #define force_inline __forceinline +#endif + +#if COMPILER_MSVC || (COMPILER_CLANG && _WIN32) + #pragma section(".rdata$", read) + #define read_only __declspec(allocate(".rdata$")) +#elif COMPILER_CLANG + #define read_only __attribute__((section(".rodata"))) +#elif COMPILER_GCC + /* TODO(rnp): how do we do this with gcc, putting it in rodata causes warnings and writing to + * it doesn't cause a fault */ + #define read_only +#endif /* TODO(rnp): msvc probably won't build this but there are other things preventing that as well */ #define sqrt_f32(a) __builtin_sqrtf(a)