mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
update sys/haiku
This commit is contained in:
+22
-22
@@ -2,39 +2,39 @@ package os
|
|||||||
|
|
||||||
foreign import libc "system:c"
|
foreign import libc "system:c"
|
||||||
|
|
||||||
import "core:strings"
|
|
||||||
import "core:c"
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
|
import "core:c"
|
||||||
|
import "core:strings"
|
||||||
|
import "core:sys/haiku"
|
||||||
|
|
||||||
Handle :: distinct i32
|
Handle :: i32
|
||||||
Pid :: distinct i32
|
Pid :: i32
|
||||||
File_Time :: distinct i64
|
File_Time :: i64
|
||||||
Errno :: distinct i32
|
Errno :: i32
|
||||||
|
|
||||||
MAX_PATH :: 260
|
MAX_PATH :: haiku.PATH_MAX
|
||||||
|
|
||||||
B_GENERAL_ERROR_BASE :: min(i32)
|
ENOSYS :: haiku.Errno.POSIX_ERROR_BASE + 9
|
||||||
B_POSIX_ERROR_BASE :: B_GENERAL_ERROR_BASE + 0x7000
|
|
||||||
|
|
||||||
INVALID_HANDLE :: ~Handle(0)
|
INVALID_HANDLE :: ~Handle(0)
|
||||||
|
|
||||||
ERROR_NONE: Errno: 0
|
ERROR_NONE: Errno: 0
|
||||||
|
|
||||||
stdin: Handle = 0
|
stdin: Handle = 0
|
||||||
stdout: Handle = 1
|
stdout: Handle = 1
|
||||||
stderr: Handle = 2
|
stderr: Handle = 2
|
||||||
|
|
||||||
pid_t :: distinct i32
|
pid_t :: haiku.pid_t
|
||||||
off_t :: i64
|
off_t :: haiku.off_t
|
||||||
dev_t :: distinct i32
|
dev_t :: haiku.dev_t
|
||||||
ino_t :: distinct i64
|
ino_t :: haiku.ino_t
|
||||||
mode_t :: distinct u32
|
mode_t :: haiku.mode_t
|
||||||
nlink_t :: distinct i32
|
nlink_t :: haiku.nlink_t
|
||||||
uid_t :: distinct u32
|
uid_t :: haiku.uid_t
|
||||||
gid_t :: distinct u32
|
gid_t :: haiku.gid_t
|
||||||
blksize_t :: distinct i32
|
blksize_t :: haiku.blksize_t
|
||||||
blkcnt_t :: distinct i64
|
blkcnt_t :: haiku.blkcnt_t
|
||||||
time_t :: i64
|
time_t :: haiku.time_t
|
||||||
|
|
||||||
|
|
||||||
Unix_File_Time :: struct {
|
Unix_File_Time :: struct {
|
||||||
@@ -166,7 +166,7 @@ foreign libc {
|
|||||||
@(link_name="dlerror") _unix_dlerror :: proc() -> cstring ---
|
@(link_name="dlerror") _unix_dlerror :: proc() -> cstring ---
|
||||||
}
|
}
|
||||||
|
|
||||||
MAXNAMLEN :: 255
|
MAXNAMLEN :: haiku.NAME_MAX
|
||||||
|
|
||||||
Dirent :: struct {
|
Dirent :: struct {
|
||||||
dev: dev_t,
|
dev: dev_t,
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
//+build haiku
|
//+build haiku
|
||||||
package sys_haiku
|
package sys_haiku
|
||||||
|
|
||||||
status_t :: i32
|
|
||||||
|
|
||||||
Errno :: enum i32 {
|
Errno :: enum i32 {
|
||||||
// Error baselines
|
// Error baselines
|
||||||
GENERAL_ERROR_BASE = min(i32),
|
GENERAL_ERROR_BASE = min(i32),
|
||||||
@@ -225,6 +223,6 @@ Errno :: enum i32 {
|
|||||||
|
|
||||||
foreign import libroot "system:c"
|
foreign import libroot "system:c"
|
||||||
foreign libroot {
|
foreign libroot {
|
||||||
i32 _to_positive_error(error: i32) ---
|
_to_positive_error :: proc(error: i32) -> i32 ---
|
||||||
i32 _to_negative_error(error: i32) ---
|
_to_negative_error :: proc(error: i32) -> i32 ---
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
//+build haiku
|
||||||
|
package sys_haiku
|
||||||
|
|
||||||
|
import "core:c"
|
||||||
|
|
||||||
|
PATH_MAX :: 1024
|
||||||
|
NAME_MAX :: 256
|
||||||
|
MAXPATHLEN :: PATH_MAX
|
||||||
|
|
||||||
|
FILE_NAME_LENGTH :: NAME_MAX
|
||||||
|
PATH_NAME_LENGTH :: MAXPATHLEN
|
||||||
|
OS_NAME_LENGTH :: 32
|
||||||
|
|
||||||
|
// System information
|
||||||
|
|
||||||
|
cpu_info :: struct {
|
||||||
|
active_time: bigtime_t,
|
||||||
|
enabled: bool,
|
||||||
|
current_frequency: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
system_info :: struct {
|
||||||
|
boot_time: bigtime_t, // time of boot (usecs since 1/1/1970)
|
||||||
|
|
||||||
|
cpu_count: u32, // number of cpus
|
||||||
|
|
||||||
|
max_pages: u64, // total # of accessible pages
|
||||||
|
used_pages: u64, // # of accessible pages in use
|
||||||
|
cached_pages: u64,
|
||||||
|
block_cache_pages: u64,
|
||||||
|
ignored_pages: u64, // # of ignored/inaccessible pages
|
||||||
|
|
||||||
|
needed_memory: u64,
|
||||||
|
free_memory: u64,
|
||||||
|
|
||||||
|
max_swap_pages: u64,
|
||||||
|
free_swap_pages: u64,
|
||||||
|
|
||||||
|
page_faults: u32, // # of page faults
|
||||||
|
|
||||||
|
max_sems: u32,
|
||||||
|
used_sems: u32,
|
||||||
|
|
||||||
|
max_ports: u32,
|
||||||
|
used_ports: u32,
|
||||||
|
|
||||||
|
max_threads: u32,
|
||||||
|
used_threads: u32,
|
||||||
|
|
||||||
|
max_teams: u32,
|
||||||
|
used_teams: u32,
|
||||||
|
|
||||||
|
kernel_name: [FILE_NAME_LENGTH]c.char,
|
||||||
|
kernel_build_date: [OS_NAME_LENGTH]c.char,
|
||||||
|
kernel_build_time: [OS_NAME_LENGTH]c.char,
|
||||||
|
|
||||||
|
kernel_version: i64,
|
||||||
|
abi: u32, // the system API
|
||||||
|
}
|
||||||
|
|
||||||
|
topology_level_type :: enum c.int {
|
||||||
|
UNKNOWN,
|
||||||
|
ROOT,
|
||||||
|
SMT,
|
||||||
|
CORE,
|
||||||
|
PACKAGE,
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu_platform :: enum c.int {
|
||||||
|
UNKNOWN,
|
||||||
|
x86,
|
||||||
|
x86_64,
|
||||||
|
PPC,
|
||||||
|
PPC_64,
|
||||||
|
M68K,
|
||||||
|
ARM,
|
||||||
|
ARM_64,
|
||||||
|
ALPHA,
|
||||||
|
MIPS,
|
||||||
|
SH,
|
||||||
|
SPARC,
|
||||||
|
RISC_V,
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu_vendor :: enum c.int {
|
||||||
|
UNKNOWN,
|
||||||
|
AMD,
|
||||||
|
CYRIX,
|
||||||
|
IDT,
|
||||||
|
INTEL,
|
||||||
|
NATIONAL_SEMICONDUCTOR,
|
||||||
|
RISE,
|
||||||
|
TRANSMETA,
|
||||||
|
VIA,
|
||||||
|
IBM,
|
||||||
|
MOTOROLA,
|
||||||
|
NEC,
|
||||||
|
HYGON,
|
||||||
|
SUN,
|
||||||
|
FUJITSU,
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu_topology_node_info :: struct {
|
||||||
|
id: u32,
|
||||||
|
type: topology_level_type,
|
||||||
|
level: u32,
|
||||||
|
|
||||||
|
data: struct #raw_union {
|
||||||
|
root: struct {
|
||||||
|
platform: cpu_platform,
|
||||||
|
},
|
||||||
|
package: struct {
|
||||||
|
vendor: cpu_vendor,
|
||||||
|
cache_line_size: u32
|
||||||
|
},
|
||||||
|
core: struct {
|
||||||
|
model: u32,
|
||||||
|
default_frequency: u64,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
foreign import libroot "system:c"
|
||||||
|
foreign libroot {
|
||||||
|
get_system_info :: proc(info: ^system_info) -> status_t ---
|
||||||
|
_get_cpu_info_etc :: proc(firstCPU: u32, cpuCount: u32, info: ^cpu_info, size: c.size_t) -> status_t ---
|
||||||
|
get_cpu_topology_info :: proc(topologyInfos: [^]cpu_topology_node_info, topologyInfoCount: ^u32) -> status_t ---
|
||||||
|
|
||||||
|
debugger :: proc(message: cstring) ---
|
||||||
|
/*
|
||||||
|
calling this function with a non-zero value will cause your thread
|
||||||
|
to receive signals for any exceptional conditions that occur (i.e.
|
||||||
|
you'll get SIGSEGV for data access exceptions, SIGFPE for floating
|
||||||
|
point errors, SIGILL for illegal instructions, etc).
|
||||||
|
|
||||||
|
to re-enable the default debugger pass a zero.
|
||||||
|
*/
|
||||||
|
disable_debugger :: proc(state: c.int) -> c.int ---
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
//+build haiku
|
||||||
|
package sys_haiku
|
||||||
|
|
||||||
|
import "core:c"
|
||||||
|
|
||||||
|
status_t :: i32
|
||||||
|
bigtime_t :: i64
|
||||||
|
nanotime_t :: i64
|
||||||
|
type_code :: u32
|
||||||
|
perform_code :: u32
|
||||||
|
|
||||||
|
phys_addr_t :: u64 when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 else u32
|
||||||
|
phys_size_t :: phys_addr_t
|
||||||
|
generic_addr_t :: u64 when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 else u32
|
||||||
|
generic_size_t :: generic_addr_t
|
||||||
|
|
||||||
|
area_id :: i32
|
||||||
|
port_id :: i32
|
||||||
|
sem_id :: i32
|
||||||
|
team_id :: i32
|
||||||
|
thread_id :: i32
|
||||||
|
|
||||||
|
blkcnt_t :: i64
|
||||||
|
blksize_t :: i32
|
||||||
|
fsblkcnt_t :: i64
|
||||||
|
fsfilcnt_t :: i64
|
||||||
|
off_t :: i64
|
||||||
|
ino_t :: i64
|
||||||
|
cnt_t :: i32
|
||||||
|
dev_t :: i32
|
||||||
|
pid_t :: i32
|
||||||
|
id_t :: i32
|
||||||
|
|
||||||
|
uid_t :: u32
|
||||||
|
gid_t :: u32
|
||||||
|
mode_t :: u32
|
||||||
|
umode_t :: u32
|
||||||
|
nlink_t :: i32
|
||||||
|
|
||||||
|
caddr_t :: ^c.char
|
||||||
|
|
||||||
|
addr_t :: phys_addr_t
|
||||||
|
key_t :: i32
|
||||||
|
|
||||||
|
clockid_t :: i32
|
||||||
|
|
||||||
|
time_t :: i64 when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 else i32
|
||||||
Reference in New Issue
Block a user