mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Merge remote-tracking branch 'offical/master'
# Conflicts: # .gitignore
This commit is contained in:
@@ -159,7 +159,7 @@ blkcnt_t :: i64
|
||||
blksize_t :: i32
|
||||
fflags_t :: u32
|
||||
|
||||
when ODIN_ARCH == .amd64 /* LP64 */ {
|
||||
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 /* LP64 */ {
|
||||
time_t :: i64
|
||||
} else {
|
||||
time_t :: i32
|
||||
|
||||
@@ -36,7 +36,7 @@ _mm_lddqu_si128 :: #force_inline proc "c" (mem_addr: ^__m128i) -> __m128i {
|
||||
_mm_movedup_pd :: #force_inline proc "c" (a: __m128d) -> __m128d {
|
||||
return simd.shuffle(a, a, 0, 0)
|
||||
}
|
||||
@(require_results, enable_target_feature="sse3")
|
||||
@(require_results, enable_target_feature="sse2,sse3")
|
||||
_mm_loaddup_pd :: #force_inline proc "c" (mem_addr: [^]f64) -> __m128d {
|
||||
return _mm_load1_pd(mem_addr)
|
||||
}
|
||||
@@ -65,4 +65,4 @@ foreign _ {
|
||||
hsubps :: proc(a, b: __m128) -> __m128 ---
|
||||
@(link_name = "llvm.x86.sse3.ldu.dq")
|
||||
lddqu :: proc(mem_addr: rawptr) -> i8x16 ---
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ _mm_testnzc_si128 :: #force_inline proc "c" (a: __m128i, mask: __m128i) -> i32 {
|
||||
_mm_test_all_zeros :: #force_inline proc "c" (a: __m128i, mask: __m128i) -> i32 {
|
||||
return _mm_testz_si128(a, mask)
|
||||
}
|
||||
@(require_results, enable_target_feature="sse4.1")
|
||||
@(require_results, enable_target_feature="sse2,sse4.1")
|
||||
_mm_test_all_ones :: #force_inline proc "c" (a: __m128i) -> i32 {
|
||||
return _mm_testc_si128(a, _mm_cmpeq_epi32(a, a))
|
||||
}
|
||||
@@ -349,4 +349,4 @@ foreign _ {
|
||||
ptestc :: proc(a, mask: i64x2) -> i32 ---
|
||||
@(link_name = "llvm.x86.sse41.ptestnzc")
|
||||
ptestnzc :: proc(a, mask: i64x2) -> i32 ---
|
||||
}
|
||||
}
|
||||
|
||||
+31
-13
@@ -5,31 +5,49 @@ package sync
|
||||
import "base:intrinsics"
|
||||
import "core:time"
|
||||
|
||||
// NOTE: because `core:sync` is in the dependency chain of a lot of the core packages (mostly through `core:mem`)
|
||||
// without actually calling into it much, I opted for a runtime panic instead of a compile error here.
|
||||
|
||||
_futex_wait :: proc "contextless" (f: ^Futex, expected: u32) -> bool {
|
||||
s := intrinsics.wasm_memory_atomic_wait32((^u32)(f), expected, -1)
|
||||
return s != 0
|
||||
when !intrinsics.has_target_feature("atomics") {
|
||||
_panic("usage of `core:sync` requires the `-target-feature:\"atomics\"` or a `-microarch` that supports it")
|
||||
} else {
|
||||
s := intrinsics.wasm_memory_atomic_wait32((^u32)(f), expected, -1)
|
||||
return s != 0
|
||||
}
|
||||
}
|
||||
|
||||
_futex_wait_with_timeout :: proc "contextless" (f: ^Futex, expected: u32, duration: time.Duration) -> bool {
|
||||
s := intrinsics.wasm_memory_atomic_wait32((^u32)(f), expected, i64(duration))
|
||||
return s != 0
|
||||
|
||||
when !intrinsics.has_target_feature("atomics") {
|
||||
_panic("usage of `core:sync` requires the `-target-feature:\"atomics\"` or a `-microarch` that supports it")
|
||||
} else {
|
||||
s := intrinsics.wasm_memory_atomic_wait32((^u32)(f), expected, i64(duration))
|
||||
return s != 0
|
||||
}
|
||||
}
|
||||
|
||||
_futex_signal :: proc "contextless" (f: ^Futex) {
|
||||
loop: for {
|
||||
s := intrinsics.wasm_memory_atomic_notify32((^u32)(f), 1)
|
||||
if s >= 1 {
|
||||
return
|
||||
when !intrinsics.has_target_feature("atomics") {
|
||||
_panic("usage of `core:sync` requires the `-target-feature:\"atomics\"` or a `-microarch` that supports it")
|
||||
} else {
|
||||
loop: for {
|
||||
s := intrinsics.wasm_memory_atomic_notify32((^u32)(f), 1)
|
||||
if s >= 1 {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_futex_broadcast :: proc "contextless" (f: ^Futex) {
|
||||
loop: for {
|
||||
s := intrinsics.wasm_memory_atomic_notify32((^u32)(f), ~u32(0))
|
||||
if s >= 0 {
|
||||
return
|
||||
when !intrinsics.has_target_feature("atomics") {
|
||||
_panic("usage of `core:sync` requires the `-target-feature:\"atomics\"` or a `-microarch` that supports it")
|
||||
} else {
|
||||
loop: for {
|
||||
s := intrinsics.wasm_memory_atomic_notify32((^u32)(f), ~u32(0))
|
||||
if s >= 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
-15
@@ -153,23 +153,42 @@ Errno :: enum i32 {
|
||||
Open_Flags_Bits :: enum {
|
||||
WRONLY = 0,
|
||||
RDWR = 1,
|
||||
CREAT = 8,
|
||||
EXCL = 9,
|
||||
NOCTTY = 10,
|
||||
TRUNC = 11,
|
||||
APPEND = 12,
|
||||
NONBLOCK = 14,
|
||||
DSYNC = 16,
|
||||
ASYNC = 17,
|
||||
DIRECT = 18,
|
||||
LARGEFILE = 20,
|
||||
DIRECTORY = 21,
|
||||
NOFOLLOW = 22,
|
||||
NOATIME = 24,
|
||||
CLOEXEC = 25,
|
||||
PATH = 28,
|
||||
CREAT = 6,
|
||||
EXCL = 7,
|
||||
NOCTTY = 8,
|
||||
TRUNC = 9,
|
||||
APPEND = 10,
|
||||
NONBLOCK = 11,
|
||||
DSYNC = 12,
|
||||
ASYNC = 13,
|
||||
DIRECT = 14,
|
||||
LARGEFILE = 15,
|
||||
DIRECTORY = 16,
|
||||
NOFOLLOW = 17,
|
||||
NOATIME = 18,
|
||||
CLOEXEC = 19,
|
||||
PATH = 21,
|
||||
}
|
||||
|
||||
// https://github.com/torvalds/linux/blob/7367539ad4b0f8f9b396baf02110962333719a48/include/uapi/asm-generic/fcntl.h#L19
|
||||
#assert(1 << uint(Open_Flags_Bits.WRONLY) == 0o0000000_1)
|
||||
#assert(1 << uint(Open_Flags_Bits.RDWR) == 0o0000000_2)
|
||||
#assert(1 << uint(Open_Flags_Bits.CREAT) == 0o00000_100)
|
||||
#assert(1 << uint(Open_Flags_Bits.EXCL) == 0o00000_200)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOCTTY) == 0o00000_400)
|
||||
#assert(1 << uint(Open_Flags_Bits.TRUNC) == 0o0000_1000)
|
||||
#assert(1 << uint(Open_Flags_Bits.APPEND) == 0o0000_2000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NONBLOCK) == 0o0000_4000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DSYNC) == 0o000_10000)
|
||||
#assert(1 << uint(Open_Flags_Bits.ASYNC) == 0o000_20000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECT) == 0o000_40000)
|
||||
#assert(1 << uint(Open_Flags_Bits.LARGEFILE) == 0o00_100000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECTORY) == 0o00_200000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOFOLLOW) == 0o00_400000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOATIME) == 0o0_1000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.CLOEXEC) == 0o0_2000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.PATH) == 0o_10000000)
|
||||
|
||||
/*
|
||||
Bits for FD_Flags bitset
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user