Browse Source

move `va_list` into `core:c`

Laytan Laats 1 year ago
parent
commit
50ded324e0
3 changed files with 14 additions and 16 deletions
  1. 10 0
      core/c/c.odin
  2. 3 9
      core/c/libc/stdarg.odin
  3. 1 7
      vendor/raylib/raylib.odin

+ 10 - 0
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,
+}

+ 3 - 9
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)

+ 1 - 7
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