mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-27 09:50:03 +00:00
Merge branch 'master' into macharena
This commit is contained in:
@@ -223,6 +223,11 @@ _Proc_Bsdinfo :: struct {
|
||||
|
||||
/*--==========================================================================--*/
|
||||
|
||||
/* Get window size */
|
||||
TIOCGWINSZ :: 0x40087468
|
||||
|
||||
/*--==========================================================================--*/
|
||||
|
||||
syscall_fsync :: #force_inline proc "contextless" (fildes: c.int) -> bool {
|
||||
return !(cast(bool)intrinsics.syscall(unix_offset_syscall(.fsync), uintptr(fildes)))
|
||||
}
|
||||
@@ -275,6 +280,10 @@ syscall_lseek :: #force_inline proc "contextless" (fd: c.int, offset: i64, whenc
|
||||
return cast(i64)intrinsics.syscall(unix_offset_syscall(.lseek), uintptr(fd), uintptr(offset), uintptr(whence))
|
||||
}
|
||||
|
||||
syscall_ioctl :: #force_inline proc "contextless" (fd: c.int, request: u32, arg: rawptr) -> c.int {
|
||||
return (cast(c.int)intrinsics.syscall(unix_offset_syscall(.ioctl), uintptr(fd), uintptr(request), uintptr(arg)))
|
||||
}
|
||||
|
||||
syscall_gettid :: #force_inline proc "contextless" () -> u64 {
|
||||
return cast(u64)intrinsics.syscall(unix_offset_syscall(.gettid))
|
||||
}
|
||||
|
||||
+890
-890
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
package sys_freebsd
|
||||
|
||||
/* Get window size */
|
||||
TIOCGWINSZ :: 0x40087468
|
||||
|
||||
@@ -34,6 +34,7 @@ init_platform :: proc() {
|
||||
} else {
|
||||
os_version.platform = .MacOS
|
||||
switch version.majorVersion {
|
||||
case 26: ws(&b, "macOS Tahoe")
|
||||
case 15: ws(&b, "macOS Sequoia")
|
||||
case 14: ws(&b, "macOS Sonoma")
|
||||
case 13: ws(&b, "macOS Ventura")
|
||||
|
||||
+18
-15
@@ -1618,36 +1618,39 @@ PER_HPUX :: 0x0010
|
||||
PER_MASK :: 0x00ff
|
||||
|
||||
/*
|
||||
Bits for access modes for shared memory
|
||||
Bits for SystemV IPC flags.
|
||||
|
||||
In this enum, access modes are common for any shared memory. Prefixed
|
||||
entries (i.e. `IPC_` or `SHM_`) denote flags, where `IPC_` are common flags
|
||||
for all SystemV IPC primitives, and `SHM_`, `SEM_` and `MSG_` are specific
|
||||
to shared memory segments, semaphores and message queues respectively.
|
||||
|
||||
These bits overlap, because they are meant to be used within the
|
||||
context of specific procedures. Creation flags, used for `*get` procedures,
|
||||
and usage flags used by all other IPC procedures. Do not mix creation and
|
||||
usage flags, as well as flags prefixed differently (excluding `IPC_`
|
||||
prefix).
|
||||
*/
|
||||
IPC_Mode_Bits :: enum {
|
||||
IPC_Flags_Bits :: enum {
|
||||
// Access modes for shared memory.
|
||||
WROTH = 1,
|
||||
RDOTH = 2,
|
||||
WRGRP = 4,
|
||||
RDGRP = 5,
|
||||
WRUSR = 7,
|
||||
RDUSR = 8,
|
||||
DEST = 9,
|
||||
LOCKED = 10,
|
||||
}
|
||||
|
||||
/*
|
||||
Shared memory flags bits
|
||||
*/
|
||||
IPC_Flags_Bits :: enum {
|
||||
// Creation flags for shared memory.
|
||||
IPC_CREAT = 9,
|
||||
IPC_EXCL = 10,
|
||||
IPC_NOWAIT = 11,
|
||||
// Semaphore
|
||||
SEM_UNDO = 9,
|
||||
// Shared memory
|
||||
SHM_HUGETLB = 11,
|
||||
SHM_NORESERVE = 12,
|
||||
// Usage flags for shared memory.
|
||||
IPC_NOWAIT = 11,
|
||||
SEM_UNDO = 9,
|
||||
SHM_RDONLY = 12,
|
||||
SHM_RND = 13,
|
||||
SHM_REMAP = 14,
|
||||
SHM_EXEC = 15,
|
||||
// Message queue
|
||||
MSG_NOERROR = 12,
|
||||
MSG_EXCEPT = 13,
|
||||
MSG_COPY = 14,
|
||||
|
||||
@@ -391,4 +391,7 @@ MAP_HUGE_256MB :: transmute(Map_Flags)(u32(28) << MAP_HUGE_SHIFT)
|
||||
MAP_HUGE_512MB :: transmute(Map_Flags)(u32(29) << MAP_HUGE_SHIFT)
|
||||
MAP_HUGE_1GB :: transmute(Map_Flags)(u32(30) << MAP_HUGE_SHIFT)
|
||||
MAP_HUGE_2GB :: transmute(Map_Flags)(u32(31) << MAP_HUGE_SHIFT)
|
||||
MAP_HUGE_16GB :: transmute(Map_Flags)(u32(34) << MAP_HUGE_SHIFT)
|
||||
MAP_HUGE_16GB :: transmute(Map_Flags)(u32(34) << MAP_HUGE_SHIFT)
|
||||
|
||||
/* Get window size */
|
||||
TIOCGWINSZ :: 0x5413
|
||||
|
||||
@@ -937,17 +937,12 @@ IO_Vec :: struct {
|
||||
}
|
||||
|
||||
/*
|
||||
Access mode for shared memory
|
||||
*/
|
||||
IPC_Mode :: bit_set[IPC_Mode_Bits; u32]
|
||||
|
||||
/*
|
||||
Flags used by IPC objects
|
||||
Access modes and flags used by SystemV IPC procedures.
|
||||
*/
|
||||
IPC_Flags :: bit_set[IPC_Flags_Bits; i16]
|
||||
|
||||
/*
|
||||
Permissions for IPC objects
|
||||
Permissions for SystemV IPC primitives.
|
||||
*/
|
||||
IPC_Perm :: struct {
|
||||
key: Key,
|
||||
@@ -955,7 +950,7 @@ IPC_Perm :: struct {
|
||||
gid: u32,
|
||||
cuid: u32,
|
||||
cgid: u32,
|
||||
mode: IPC_Mode,
|
||||
mode: IPC_Flags, // Only contains mode flags.
|
||||
seq: u16,
|
||||
_: [2 + 2*size_of(int)]u8,
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ when ODIN_OS == .Darwin {
|
||||
} else when ODIN_OS == .FreeBSD || ODIN_OS == .NetBSD {
|
||||
foreign import lib "system:dl"
|
||||
} else {
|
||||
foreign import lib "system:c"
|
||||
foreign import lib {
|
||||
"system:c",
|
||||
"system:dl",
|
||||
}
|
||||
}
|
||||
|
||||
// dlfcn.h - dynamic linking
|
||||
|
||||
@@ -31,7 +31,7 @@ Unimplemented headers:
|
||||
- iso646.h | Impossible
|
||||
- math.h | See `core:c/libc`
|
||||
- mqueue.h | Targets don't seem to have implemented it
|
||||
- regex.h | See `core:regex`
|
||||
- regex.h | See `core:text/regex`
|
||||
- search.h | Not useful in Odin
|
||||
- spawn.h | Use `fork`, `execve`, etc.
|
||||
- stdarg.h | See `core:c/libc`
|
||||
@@ -53,6 +53,8 @@ import "base:intrinsics"
|
||||
|
||||
import "core:c"
|
||||
|
||||
IS_SUPPORTED :: _IS_SUPPORTED
|
||||
|
||||
result :: enum c.int {
|
||||
// Use `errno` and `strerror` for more information.
|
||||
FAIL = -1,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#+build !linux
|
||||
#+build !darwin
|
||||
#+build !netbsd
|
||||
#+build !openbsd
|
||||
#+build !freebsd
|
||||
#+build !haiku
|
||||
package posix
|
||||
|
||||
_IS_SUPPORTED :: false
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
|
||||
package posix
|
||||
|
||||
_IS_SUPPORTED :: true
|
||||
|
||||
@@ -350,4 +350,4 @@ NEWTEXTMETRICW :: struct {
|
||||
ntmAvgWidth: UINT,
|
||||
}
|
||||
|
||||
FONTENUMPROCW :: #type proc(lpelf: ^ENUMLOGFONTW, lpntm: ^NEWTEXTMETRICW, FontType: DWORD, lParam: LPARAM) -> INT
|
||||
FONTENUMPROCW :: #type proc "system" (lpelf: ^ENUMLOGFONTW, lpntm: ^NEWTEXTMETRICW, FontType: DWORD, lParam: LPARAM) -> INT
|
||||
|
||||
@@ -168,6 +168,7 @@ foreign kernel32 {
|
||||
ResumeThread :: proc(thread: HANDLE) -> DWORD ---
|
||||
GetThreadPriority :: proc(thread: HANDLE) -> c_int ---
|
||||
SetThreadPriority :: proc(thread: HANDLE, priority: c_int) -> BOOL ---
|
||||
GetThreadDescription :: proc(hThread: HANDLE, ppszThreadDescription: ^PCWSTR) -> HRESULT ---
|
||||
SetThreadDescription :: proc(hThread: HANDLE, lpThreadDescription: PCWSTR) -> HRESULT ---
|
||||
GetExitCodeThread :: proc(thread: HANDLE, exit_code: ^DWORD) -> BOOL ---
|
||||
TerminateThread :: proc(thread: HANDLE, exit_code: DWORD) -> BOOL ---
|
||||
|
||||
@@ -75,7 +75,7 @@ LANGIDFROMLCID :: #force_inline proc "contextless" (lcid: LCID) -> LANGID {
|
||||
return LANGID(lcid)
|
||||
}
|
||||
|
||||
utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
|
||||
utf8_to_utf16_alloc :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
|
||||
if len(s) < 1 {
|
||||
return nil
|
||||
}
|
||||
@@ -101,14 +101,42 @@ utf8_to_utf16 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
|
||||
}
|
||||
return text[:n]
|
||||
}
|
||||
utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> wstring {
|
||||
|
||||
utf8_to_utf16_buf :: proc(buf: []u16, s: string) -> []u16 {
|
||||
n1 := MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), i32(len(s)), nil, 0)
|
||||
if n1 == 0 {
|
||||
return nil
|
||||
} else if int(n1) > len(buf) {
|
||||
return nil
|
||||
}
|
||||
|
||||
n1 = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, raw_data(s), i32(len(s)), raw_data(buf[:]), n1)
|
||||
if n1 == 0 {
|
||||
return nil
|
||||
} else if int(n1) > len(buf) {
|
||||
return nil
|
||||
}
|
||||
return buf[:n1]
|
||||
}
|
||||
utf8_to_utf16 :: proc{utf8_to_utf16_alloc, utf8_to_utf16_buf}
|
||||
|
||||
utf8_to_wstring_alloc :: proc(s: string, allocator := context.temp_allocator) -> wstring {
|
||||
if res := utf8_to_utf16(s, allocator); len(res) > 0 {
|
||||
return raw_data(res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
utf8_to_wstring_buf :: proc(buf: []u16, s: string) -> wstring {
|
||||
if res := utf8_to_utf16(buf, s); len(res) > 0 {
|
||||
return raw_data(res)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
utf8_to_wstring :: proc{utf8_to_wstring_alloc, utf8_to_wstring_buf}
|
||||
|
||||
wstring_to_utf8_alloc :: proc(s: wstring, N: int, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
context.allocator = allocator
|
||||
|
||||
if N == 0 {
|
||||
@@ -142,13 +170,49 @@ wstring_to_utf8 :: proc(s: wstring, N: int, allocator := context.temp_allocator)
|
||||
return string(text[:n]), nil
|
||||
}
|
||||
|
||||
utf16_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
wstring_to_utf8_buf :: proc(buf: []u8, s: wstring) -> (res: string) {
|
||||
n := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, -1, nil, 0, nil, nil)
|
||||
if n == 0 {
|
||||
return
|
||||
} else if int(n) > len(buf) {
|
||||
return
|
||||
}
|
||||
|
||||
n2 := WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, s, -1, raw_data(buf), n, nil, nil)
|
||||
if n2 == 0 {
|
||||
return
|
||||
} else if int(n2) > len(buf) {
|
||||
return
|
||||
}
|
||||
|
||||
for i in 0..<n2 {
|
||||
if buf[i] == 0 {
|
||||
n2 = i
|
||||
break
|
||||
}
|
||||
}
|
||||
return string(buf[:n2])
|
||||
}
|
||||
|
||||
wstring_to_utf8 :: proc{wstring_to_utf8_alloc, wstring_to_utf8_buf}
|
||||
|
||||
utf16_to_utf8_alloc :: proc(s: []u16, allocator := context.temp_allocator) -> (res: string, err: runtime.Allocator_Error) {
|
||||
if len(s) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
return wstring_to_utf8(raw_data(s), len(s), allocator)
|
||||
}
|
||||
|
||||
utf16_to_utf8_buf :: proc(buf: []u8, s: []u16) -> (res: string) {
|
||||
if len(s) == 0 {
|
||||
return
|
||||
}
|
||||
return wstring_to_utf8(buf, raw_data(s))
|
||||
}
|
||||
|
||||
utf16_to_utf8 :: proc{utf16_to_utf8_alloc, utf16_to_utf8_buf}
|
||||
|
||||
|
||||
// AdvAPI32, NetAPI32 and UserENV helpers.
|
||||
|
||||
allowed_username :: proc(username: string) -> bool {
|
||||
|
||||
@@ -589,7 +589,7 @@ WAVE_FORMAT_FLAC :: 0xF1AC /* flac.sourceforge.net */
|
||||
WAVE_FORMAT_EXTENSIBLE :: 0xFFFE /* Microsoft */
|
||||
|
||||
|
||||
WAVEFORMATEX :: struct {
|
||||
WAVEFORMATEX :: struct #packed {
|
||||
wFormatTag: WORD,
|
||||
nChannels: WORD,
|
||||
nSamplesPerSec: DWORD,
|
||||
@@ -603,7 +603,7 @@ LPCWAVEFORMATEX :: ^WAVEFORMATEX
|
||||
// New wave format development should be based on the WAVEFORMATEXTENSIBLE structure.
|
||||
// WAVEFORMATEXTENSIBLE allows you to avoid having to register a new format tag with Microsoft.
|
||||
// Simply define a new GUID value for the WAVEFORMATEXTENSIBLE.SubFormat field and use WAVE_FORMAT_EXTENSIBLE in the WAVEFORMATEXTENSIBLE.Format.wFormatTag field.
|
||||
WAVEFORMATEXTENSIBLE :: struct {
|
||||
WAVEFORMATEXTENSIBLE :: struct #packed {
|
||||
using Format: WAVEFORMATEX,
|
||||
Samples: struct #raw_union {
|
||||
wValidBitsPerSample: WORD, /* bits of precision */
|
||||
|
||||
Reference in New Issue
Block a user