move va_list into core:c

This commit is contained in:
Laytan Laats
2024-03-01 20:30:19 +01:00
parent 6734a7096a
commit 50ded324e0
3 changed files with 14 additions and 16 deletions

View File

@@ -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,
}

View File

@@ -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)

View File

@@ -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