mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-24 20:59:52 +00:00
Map the C va_* to the intrinsics
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Defines the basic types used by `C` programs for foreign function and data structure interop.
|
||||
package c
|
||||
|
||||
import builtin "base:builtin"
|
||||
import builtin "base:builtin"
|
||||
import intrinsics "base:intrinsics"
|
||||
|
||||
char :: builtin.u8 // assuming -funsigned-char
|
||||
|
||||
@@ -115,14 +116,6 @@ 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,
|
||||
}
|
||||
va_list :: intrinsics.c_va_list
|
||||
|
||||
FILE :: struct {}
|
||||
|
||||
@@ -4,29 +4,12 @@ package libc
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
import "core:c"
|
||||
va_list :: intrinsics.va_list
|
||||
|
||||
@(private="file")
|
||||
@(default_calling_convention="none")
|
||||
foreign _ {
|
||||
@(link_name="llvm.va_start") _va_start :: proc(arglist: ^i8) ---
|
||||
@(link_name="llvm.va_end") _va_end :: proc(arglist: ^i8) ---
|
||||
@(link_name="llvm.va_copy") _va_copy :: proc(dst, src: ^i8) ---
|
||||
}
|
||||
va_start :: intrinsics.va_start
|
||||
va_end :: intrinsics.va_end
|
||||
va_copy :: intrinsics.va_copy
|
||||
|
||||
va_list :: c.va_list
|
||||
|
||||
va_start :: #force_inline proc(ap: ^va_list, _: any) {
|
||||
_va_start(cast(^i8)ap)
|
||||
}
|
||||
|
||||
va_end :: #force_inline proc(ap: ^va_list) {
|
||||
_va_end(cast(^i8)ap)
|
||||
}
|
||||
|
||||
va_copy :: #force_inline proc(dst, src: ^va_list) {
|
||||
_va_copy(cast(^i8)dst, cast(^i8)src)
|
||||
}
|
||||
|
||||
// We cannot provide va_arg as there is no way to create "C" style procedures
|
||||
// in Odin which take variable arguments the C way. The #c_vararg attribute only
|
||||
|
||||
Reference in New Issue
Block a user