mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix libc.aligned_alloc for Windows (thanks Microsoft(!))
This commit is contained in:
+16
-3
@@ -88,8 +88,6 @@ foreign libc {
|
|||||||
srand :: proc(seed: uint) ---
|
srand :: proc(seed: uint) ---
|
||||||
|
|
||||||
// 7.22.3 Memory management functions
|
// 7.22.3 Memory management functions
|
||||||
@(link_name="_aligned_malloc" when ODIN_OS == .Windows else "aligned_alloc")
|
|
||||||
aligned_alloc :: proc(aligment, size: size_t) -> rawptr ---
|
|
||||||
calloc :: proc(nmemb, size: size_t) -> rawptr ---
|
calloc :: proc(nmemb, size: size_t) -> rawptr ---
|
||||||
free :: proc(ptr: rawptr) ---
|
free :: proc(ptr: rawptr) ---
|
||||||
malloc :: proc(size: size_t) -> rawptr ---
|
malloc :: proc(size: size_t) -> rawptr ---
|
||||||
@@ -128,7 +126,22 @@ foreign libc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
aligned_free :: proc "c" (ptr: rawptr) {
|
aligned_alloc :: #force_inline proc "c" (alignment, size: size_t) -> rawptr {
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
foreign libc {
|
||||||
|
_aligned_malloc :: proc(size, alignment: size_t) -> rawptr ---
|
||||||
|
}
|
||||||
|
return _aligned_malloc(size=size, alignment=alignment)
|
||||||
|
} else {
|
||||||
|
foreign libc {
|
||||||
|
aligned_alloc :: proc(alignment, size: size_t) -> rawptr ---
|
||||||
|
}
|
||||||
|
return aligned_alloc(alignment=alignment, size=size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
aligned_free :: #force_inline proc "c" (ptr: rawptr) {
|
||||||
when ODIN_OS == .Windows {
|
when ODIN_OS == .Windows {
|
||||||
foreign libc {
|
foreign libc {
|
||||||
_aligned_free :: proc(ptr: rawptr) ---
|
_aligned_free :: proc(ptr: rawptr) ---
|
||||||
|
|||||||
Reference in New Issue
Block a user