mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-06 10:44:06 +00:00
Merge branch 'master' of https://github.com/odin-lang/Odin
This commit is contained in:
12
.github/workflows/nightly.yml
vendored
12
.github/workflows/nightly.yml
vendored
@@ -50,8 +50,8 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 17
|
||||
echo "/usr/lib/llvm-17/bin" >> $GITHUB_PATH
|
||||
sudo ./llvm.sh 18
|
||||
echo "/usr/lib/llvm-18/bin" >> $GITHUB_PATH
|
||||
- name: build odin
|
||||
run: make nightly
|
||||
- name: Odin run
|
||||
@@ -82,8 +82,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download LLVM and setup PATH
|
||||
run: |
|
||||
brew install llvm@17 dylibbundler
|
||||
echo "/usr/local/opt/llvm@17/bin" >> $GITHUB_PATH
|
||||
brew install llvm@18 dylibbundler
|
||||
echo "/usr/local/opt/llvm@18/bin" >> $GITHUB_PATH
|
||||
- name: build odin
|
||||
# These -L makes the linker prioritize system libraries over LLVM libraries, this is mainly to
|
||||
# not link with libunwind bundled with LLVM but link with libunwind on the system.
|
||||
@@ -116,8 +116,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Download LLVM and setup PATH
|
||||
run: |
|
||||
brew install llvm@17 dylibbundler
|
||||
echo "/opt/homebrew/opt/llvm@17/bin" >> $GITHUB_PATH
|
||||
brew install llvm@18 dylibbundler
|
||||
echo "/opt/homebrew/opt/llvm@18/bin" >> $GITHUB_PATH
|
||||
- name: build odin
|
||||
# These -L makes the linker prioritize system libraries over LLVM libraries, this is mainly to
|
||||
# not link with libunwind bundled with LLVM but link with libunwind on the system.
|
||||
|
||||
@@ -5,11 +5,24 @@ package runtime
|
||||
import "base:intrinsics"
|
||||
|
||||
_stderr_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
|
||||
WRITE :: 0x2000004
|
||||
STDERR :: 2
|
||||
ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data)))
|
||||
if ret < 0 {
|
||||
return 0, _OS_Errno(-ret)
|
||||
when ODIN_NO_CRT {
|
||||
WRITE :: 0x2000004
|
||||
ret := intrinsics.syscall(WRITE, STDERR, uintptr(raw_data(data)), uintptr(len(data)))
|
||||
if ret < 0 {
|
||||
return 0, _OS_Errno(-ret)
|
||||
}
|
||||
return int(ret), 0
|
||||
} else {
|
||||
foreign {
|
||||
write :: proc(handle: i32, buffer: [^]byte, count: uint) -> int ---
|
||||
__error :: proc() -> ^i32 ---
|
||||
}
|
||||
|
||||
if ret := write(STDERR, raw_data(data), len(data)); ret >= 0 {
|
||||
return int(ret), 0
|
||||
}
|
||||
|
||||
return 0, _OS_Errno(__error()^)
|
||||
}
|
||||
return int(ret), 0
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package darwin
|
||||
import "core:c"
|
||||
import "base:runtime"
|
||||
|
||||
// IMPORTANT NOTE: direct syscall usage is not allowed by Apple's review process of apps and should
|
||||
// be entirely avoided in the builtin Odin collections, these are here for users if they don't
|
||||
// care about the Apple review process.
|
||||
|
||||
// this package uses the sys prefix for the proc names to indicate that these aren't native syscalls but directly call such
|
||||
sys_write_string :: proc (fd: c.int, message: string) -> bool {
|
||||
return syscall_write(fd, raw_data(message), cast(u64)len(message))
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package darwin
|
||||
|
||||
// IMPORTANT NOTE: direct syscall usage is not allowed by Apple's review process of apps and should
|
||||
// be entirely avoided in the builtin Odin collections, these are here for users if they don't
|
||||
// care about the Apple review process.
|
||||
|
||||
unix_offset_syscall :: proc "contextless" (number: System_Call_Number) -> uintptr {
|
||||
return uintptr(number) + uintptr(0x2000000)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package darwin
|
||||
import "core:c"
|
||||
import "base:intrinsics"
|
||||
|
||||
// IMPORTANT NOTE: direct syscall usage is not allowed by Apple's review process of apps and should
|
||||
// be entirely avoided in the builtin Odin collections, these are here for users if they don't
|
||||
// care about the Apple review process.
|
||||
|
||||
/* flock */
|
||||
LOCK_SH :: 1 /* shared lock */
|
||||
LOCK_EX :: 2 /* exclusive lock */
|
||||
|
||||
@@ -7,7 +7,7 @@ init_cpu_features :: proc "contextless" () {
|
||||
@(static) features: CPU_Features
|
||||
defer cpu_features = features
|
||||
|
||||
try_set :: proc "contextless" (name: string, feature: CPU_Feature) -> (ok: bool) {
|
||||
try_set :: proc "contextless" (name: cstring, feature: CPU_Feature) -> (ok: bool) {
|
||||
support: b32
|
||||
if ok = unix.sysctlbyname(name, &support); ok && support {
|
||||
features += { feature }
|
||||
|
||||
@@ -3,29 +3,60 @@ package unix
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
import "core:c"
|
||||
import "core:sys/darwin"
|
||||
|
||||
_ :: darwin
|
||||
|
||||
sysctl :: proc "contextless" (mib: []i32, val: ^$T) -> (ok: bool) {
|
||||
result_size := c.size_t(size_of(T))
|
||||
res := darwin.syscall_sysctl(
|
||||
raw_data(mib), len(mib),
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
result_size := uint(size_of(T))
|
||||
when ODIN_NO_CRT {
|
||||
res := darwin.syscall_sysctl(
|
||||
raw_data(mib), len(mib),
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
} else {
|
||||
foreign {
|
||||
@(link_name="sysctl") _sysctl :: proc(
|
||||
name: [^]i32, namelen: u32,
|
||||
oldp: rawptr, oldlenp: ^uint,
|
||||
newp: rawptr, newlen: uint,
|
||||
) -> i32 ---
|
||||
}
|
||||
res := _sysctl(
|
||||
raw_data(mib), u32(len(mib)),
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
}
|
||||
}
|
||||
|
||||
sysctlbyname :: proc "contextless" (name: string, val: ^$T) -> (ok: bool) {
|
||||
result_size := c.size_t(size_of(T))
|
||||
res := darwin.syscall_sysctlbyname(
|
||||
name,
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
sysctlbyname :: proc "contextless" (name: cstring, val: ^$T) -> (ok: bool) {
|
||||
result_size := uint(size_of(T))
|
||||
when ODIN_NO_CRT {
|
||||
res := darwin.syscall_sysctlbyname(
|
||||
string(name),
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
} else {
|
||||
foreign {
|
||||
@(link_name="sysctlbyname") _sysctlbyname :: proc(
|
||||
name: cstring,
|
||||
oldp: rawptr, oldlenp: ^uint,
|
||||
newp: rawptr, newlen: uint,
|
||||
) -> i32 ---
|
||||
}
|
||||
res := _sysctlbyname(
|
||||
name,
|
||||
val, &result_size,
|
||||
nil, 0,
|
||||
)
|
||||
return res == 0
|
||||
}
|
||||
}
|
||||
|
||||
// See sysctl.h for darwin for details
|
||||
|
||||
Reference in New Issue
Block a user