diff --git a/core/c/c.odin b/core/c/c.odin index edd88d228..3dfc19ffc 100644 --- a/core/c/c.odin +++ b/core/c/c.odin @@ -104,3 +104,13 @@ NULL :: rawptr(uintptr(0)) NDEBUG :: !ODIN_DEBUG CHAR_BIT :: 8 + +// Since there are no types in C with an alignment larger than that of +// max_align_t, which cannot be larger than sizeof(long double) as any other +// exposed type wouldn't be valid C, the maximum alignment possible in a +// strictly conformant C implementation is 16 on the platforms we care about. +// The choice of 4096 bytes for storage of this type is more than enough on all +// relevant platforms. +va_list :: struct #align(16) { + _: [4096]u8, +} diff --git a/core/c/libc/stdarg.odin b/core/c/libc/stdarg.odin index faae6a6c6..232471713 100644 --- a/core/c/libc/stdarg.odin +++ b/core/c/libc/stdarg.odin @@ -4,6 +4,8 @@ package libc import "base:intrinsics" +import "core:c" + @(private="file") @(default_calling_convention="none") foreign _ { @@ -12,15 +14,7 @@ foreign _ { @(link_name="llvm.va_copy") _va_copy :: proc(dst, src: ^i8) --- } -// Since there are no types in C with an alignment larger than that of -// max_align_t, which cannot be larger than sizeof(long double) as any other -// exposed type wouldn't be valid C, the maximum alignment possible in a -// strictly conformant C implementation is 16 on the platforms we care about. -// The choice of 4096 bytes for storage of this type is more than enough on all -// relevant platforms. -va_list :: struct #align(16) { - _: [4096]u8, -} +va_list :: c.va_list va_start :: #force_inline proc(ap: ^va_list, _: any) { _va_start(cast(^i8)ap) diff --git a/vendor/raylib/raylib.odin b/vendor/raylib/raylib.odin index d1e761700..7ced450e6 100644 --- a/vendor/raylib/raylib.odin +++ b/vendor/raylib/raylib.odin @@ -925,15 +925,9 @@ NPatchLayout :: enum c.int { THREE_PATCH_HORIZONTAL, // Npatch layout: 3x1 tiles } -// NOTE: Castable to `core:c/libc`'s `va_list`. -// But some use cases of raylib do not want `libc` imported. -va_list :: struct #align(16) { - _: [4096]u8, -} - // Callbacks to hook some internal functions // WARNING: This callbacks are intended for advance users -TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: va_list) // Logging: Redirect trace log messages +TraceLogCallback :: #type proc "c" (logLevel: TraceLogLevel, text: cstring, args: c.va_list) // Logging: Redirect trace log messages LoadFileDataCallback :: #type proc "c"(fileName: cstring, dataSize: ^c.int) -> [^]u8 // FileIO: Load binary data SaveFileDataCallback :: #type proc "c" (fileName: cstring, data: rawptr, dataSize: c.int) -> bool // FileIO: Save binary data LoadFileTextCallback :: #type proc "c" (fileName: cstring) -> [^]u8 // FileIO: Load text data