mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-28 07:51:33 +00:00
removed Haiku from compiler targets, and tests
Signed-off-by: Ignacy Koper <ignacy423@gmail.com>
This commit is contained in:
@@ -117,11 +117,6 @@ OpenBSD)
|
||||
LDFLAGS="$LDFLAGS -lstdc++ -L/usr/local/lib -liconv"
|
||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
|
||||
;;
|
||||
Haiku)
|
||||
CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE $($LLVM_CONFIG --cxxflags --ldflags) -I/system/develop/headers/private/shared -I/system/develop/headers/private/kernel"
|
||||
LDFLAGS="$LDFLAGS -lstdc++ -liconv"
|
||||
LDFLAGS="$LDFLAGS $($LLVM_CONFIG --libs core native --system-libs)"
|
||||
;;
|
||||
*)
|
||||
error "Platform \"$OS_NAME\" unsupported"
|
||||
;;
|
||||
|
||||
@@ -51,8 +51,6 @@ if "%1" == "freestanding" (
|
||||
if "%1" == "rare" (
|
||||
echo Checking freebsd_i386
|
||||
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
|
||||
echo Checking haiku_amd64
|
||||
odin check examples\all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
|
||||
)
|
||||
|
||||
if "%1" == "wasm" (
|
||||
|
||||
@@ -21,8 +21,6 @@ freestanding)
|
||||
rare)
|
||||
echo Checking freebsd_i386
|
||||
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:freebsd_i386
|
||||
echo Checking haiku_amd64
|
||||
odin check examples/all -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -target:haiku_amd64
|
||||
;;
|
||||
|
||||
wasm)
|
||||
|
||||
@@ -20,7 +20,6 @@ enum TargetOsKind : u16 {
|
||||
TargetOs_freebsd,
|
||||
TargetOs_openbsd,
|
||||
TargetOs_netbsd,
|
||||
TargetOs_haiku,
|
||||
|
||||
TargetOs_wasi,
|
||||
TargetOs_js,
|
||||
@@ -39,7 +38,6 @@ gb_global String target_os_names[TargetOs_COUNT] = {
|
||||
str_lit("freebsd"),
|
||||
str_lit("openbsd"),
|
||||
str_lit("netbsd"),
|
||||
str_lit("haiku"),
|
||||
|
||||
str_lit("wasi"),
|
||||
str_lit("js"),
|
||||
@@ -774,12 +772,6 @@ gb_global TargetMetrics target_netbsd_arm64 = {
|
||||
str_lit("aarch64-unknown-netbsd-elf"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_haiku_amd64 = {
|
||||
TargetOs_haiku,
|
||||
TargetArch_amd64,
|
||||
8, 8, AMD64_MAX_ALIGNMENT, 32,
|
||||
str_lit("x86_64-unknown-haiku"),
|
||||
};
|
||||
|
||||
gb_global TargetMetrics target_freestanding_wasm32 = {
|
||||
TargetOs_freestanding,
|
||||
@@ -906,7 +898,6 @@ gb_global NamedTargetMetrics named_targets[] = {
|
||||
{ str_lit("netbsd_arm64"), &target_netbsd_arm64 },
|
||||
|
||||
{ str_lit("openbsd_amd64"), &target_openbsd_amd64 },
|
||||
{ str_lit("haiku_amd64"), &target_haiku_amd64 },
|
||||
|
||||
{ str_lit("freestanding_wasm32"), &target_freestanding_wasm32 },
|
||||
{ str_lit("wasi_wasm32"), &target_wasi_wasm32 },
|
||||
@@ -1168,58 +1159,6 @@ gb_internal String internal_odin_root_dir(void) {
|
||||
return path;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
|
||||
#include <FindDirectory.h>
|
||||
|
||||
gb_internal String path_to_fullpath(gbAllocator a, String s, bool *ok_);
|
||||
|
||||
gb_internal String internal_odin_root_dir(void) {
|
||||
String path = global_module_path;
|
||||
isize len, i;
|
||||
u8 *text;
|
||||
|
||||
if (global_module_path_set) {
|
||||
return global_module_path;
|
||||
}
|
||||
|
||||
TEMPORARY_ALLOCATOR_GUARD();
|
||||
auto path_buf = array_make<char>(temporary_allocator(), 300);
|
||||
|
||||
len = 0;
|
||||
for (;;) {
|
||||
u32 sz = path_buf.count;
|
||||
int res = find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH, nullptr, &path_buf[0], sz);
|
||||
if(res == B_OK) {
|
||||
len = sz;
|
||||
break;
|
||||
} else {
|
||||
array_resize(&path_buf, sz + 1);
|
||||
}
|
||||
}
|
||||
|
||||
mutex_lock(&string_buffer_mutex);
|
||||
defer (mutex_unlock(&string_buffer_mutex));
|
||||
|
||||
text = permanent_alloc_array<u8>(len + 1);
|
||||
gb_memmove(text, &path_buf[0], len);
|
||||
|
||||
path = path_to_fullpath(heap_allocator(), make_string(text, len), nullptr);
|
||||
|
||||
for (i = path.len-1; i >= 0; i--) {
|
||||
u8 c = path[i];
|
||||
if (c == '/' || c == '\\') {
|
||||
break;
|
||||
}
|
||||
path.len--;
|
||||
}
|
||||
|
||||
global_module_path = path;
|
||||
global_module_path_set = true;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_OSX)
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
@@ -1825,8 +1764,6 @@ gb_internal void init_build_context(TargetMetrics *cross_target, Subtarget subta
|
||||
#else
|
||||
metrics = &target_netbsd_amd64;
|
||||
#endif
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
metrics = &target_haiku_amd64;
|
||||
#elif defined(GB_CPU_ARM)
|
||||
metrics = &target_linux_arm64;
|
||||
#elif defined(GB_CPU_RISCV)
|
||||
@@ -2593,7 +2530,6 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
case TargetOs_freebsd:
|
||||
case TargetOs_openbsd:
|
||||
case TargetOs_netbsd:
|
||||
case TargetOs_haiku:
|
||||
gb_printf_err("-no-crt on Unix systems requires either -default-to-nil-allocator or -default-to-panic-allocator to also be present, because the default allocator requires CRT\n");
|
||||
no_crt_checks_failed = true;
|
||||
}
|
||||
@@ -2606,7 +2542,6 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
case TargetOs_freebsd:
|
||||
case TargetOs_openbsd:
|
||||
case TargetOs_netbsd:
|
||||
case TargetOs_haiku:
|
||||
gb_printf_err("-no-crt on Unix systems requires the -no-thread-local flag to also be present, because the TLS is inaccessible without CRT\n");
|
||||
no_crt_checks_failed = true;
|
||||
}
|
||||
|
||||
@@ -6598,7 +6598,6 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
|
||||
switch (build_context.metrics.os) {
|
||||
case TargetOs_darwin:
|
||||
case TargetOs_linux:
|
||||
case TargetOs_haiku:
|
||||
switch (build_context.metrics.arch) {
|
||||
case TargetArch_i386:
|
||||
case TargetArch_amd64:
|
||||
|
||||
@@ -1171,7 +1171,6 @@ gb_internal void init_universal(void) {
|
||||
{"Darwin", TargetOs_darwin},
|
||||
{"Linux", TargetOs_linux},
|
||||
{"FreeBSD", TargetOs_freebsd},
|
||||
{"Haiku", TargetOs_haiku},
|
||||
{"OpenBSD", TargetOs_openbsd},
|
||||
{"NetBSD", TargetOs_netbsd},
|
||||
{"WASI", TargetOs_wasi},
|
||||
|
||||
48
src/gb/gb.h
48
src/gb/gb.h
@@ -87,10 +87,6 @@ extern "C" {
|
||||
#ifndef GB_SYSTEM_NETBSD
|
||||
#define GB_SYSTEM_NETBSD 1
|
||||
#endif
|
||||
#elif defined(__HAIKU__) || defined(__haiku__)
|
||||
#ifndef GB_SYSTEM_HAIKU
|
||||
#define GB_SYSTEM_HAIKU 1
|
||||
#endif
|
||||
#else
|
||||
#error This UNIX operating system is not supported
|
||||
#endif
|
||||
@@ -219,7 +215,7 @@ extern "C" {
|
||||
#endif
|
||||
#include <stdlib.h> // NOTE(bill): malloc on linux
|
||||
#include <sys/mman.h>
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__HAIKU__)
|
||||
#if !defined(GB_SYSTEM_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
|
||||
#include <sys/sendfile.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
@@ -267,13 +263,6 @@ extern "C" {
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_HAIKU)
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <kernel/OS.h>
|
||||
#define lseek64 lseek
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_UNIX)
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
@@ -847,13 +836,6 @@ typedef struct gbAffinity {
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
typedef struct gbAffinity {
|
||||
b32 is_accurate;
|
||||
isize core_count;
|
||||
isize thread_count;
|
||||
isize threads_per_core;
|
||||
} gbAffinity;
|
||||
#else
|
||||
#error TODO(bill): Unknown system
|
||||
#endif
|
||||
@@ -3042,8 +3024,6 @@ gb_inline u32 gb_thread_current_id(void) {
|
||||
__asm__("mov %%fs:0x10,%0" : "=r"(thread_id));
|
||||
#elif defined(GB_SYSTEM_LINUX)
|
||||
thread_id = gettid();
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
thread_id = find_thread(NULL);
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
thread_id = pthread_getthreadid_np();
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
@@ -3256,9 +3236,6 @@ b32 gb_affinity_set(gbAffinity *a, isize core, isize thread_index) {
|
||||
//info.affinity_tag = cast(integer_t)index;
|
||||
//result = thread_policy_set(thread, THREAD_AFFINITY_POLICY, cast(thread_policy_t)&info, THREAD_AFFINITY_POLICY_COUNT);
|
||||
|
||||
#if !defined(GB_SYSTEM_HAIKU)
|
||||
result = pthread_setaffinity_np(thread, sizeof(cpuset_t), &mn);
|
||||
#endif
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
@@ -3339,29 +3316,6 @@ isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
return a->threads_per_core;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
#include <unistd.h>
|
||||
|
||||
void gb_affinity_init(gbAffinity *a) {
|
||||
a->core_count = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
a->threads_per_core = 1;
|
||||
a->is_accurate = a->core_count > 0;
|
||||
a->core_count = a->is_accurate ? a->core_count : 1;
|
||||
a->thread_count = a->core_count;
|
||||
}
|
||||
|
||||
void gb_affinity_destroy(gbAffinity *a) {
|
||||
gb_unused(a);
|
||||
}
|
||||
|
||||
b32 gb_affinity_set(gbAffinity *a, isize core, isize thread_index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
|
||||
GB_ASSERT(0 <= core && core < a->core_count);
|
||||
return a->threads_per_core;
|
||||
}
|
||||
#else
|
||||
#error TODO(bill): Unknown system
|
||||
#endif
|
||||
|
||||
@@ -791,11 +791,10 @@ try_cross_linking:;
|
||||
// Do not disable PIE, let the linker choose. (most likely you want it enabled)
|
||||
} else if (build_context.build_mode != BuildMode_DynamicLibrary) {
|
||||
if (build_context.metrics.os != TargetOs_openbsd
|
||||
&& build_context.metrics.os != TargetOs_haiku
|
||||
&& build_context.metrics.arch != TargetArch_riscv64
|
||||
&& !is_android
|
||||
) {
|
||||
// OpenBSD and Haiku default to PIE executable. do not pass -no-pie for it.
|
||||
// OpenBSD defaults to PIE executable, do not pass -no-pie for it.
|
||||
link_settings = gb_string_appendc(link_settings, "-no-pie ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3156,8 +3156,8 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
|
||||
|
||||
switch (build_context.reloc_mode) {
|
||||
case RelocMode_Default:
|
||||
if (build_context.metrics.os == TargetOs_openbsd || build_context.metrics.os == TargetOs_haiku) {
|
||||
// Always use PIC for OpenBSD and Haiku: they default to PIE
|
||||
if (build_context.metrics.os == TargetOs_openbsd) {
|
||||
// Always use PIC for OpenBSD: it defaults to PIE
|
||||
reloc_mode = LLVMRelocPIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
|
||||
|
||||
return ReadDirectory_None;
|
||||
}
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD) || defined(GB_SYSTEM_HAIKU)
|
||||
#elif defined(GB_SYSTEM_LINUX) || defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_FREEBSD) || defined(GB_SYSTEM_OPENBSD) || defined(GB_SYSTEM_NETBSD)
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
|
||||
@@ -549,8 +549,6 @@ gb_internal u32 thread_current_id(void) {
|
||||
__asm__("mov %%fs:0x10,%0" : "=r"(thread_id));
|
||||
#elif defined(GB_SYSTEM_LINUX)
|
||||
thread_id = gettid();
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
thread_id = find_thread(NULL);
|
||||
#elif defined(GB_SYSTEM_FREEBSD)
|
||||
thread_id = pthread_getthreadid_np();
|
||||
#elif defined(GB_SYSTEM_NETBSD)
|
||||
@@ -1027,175 +1025,6 @@ gb_internal void futex_wait(Futex *f, Footex val) {
|
||||
} while (f->load() == val);
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_HAIKU)
|
||||
|
||||
// Futex implementation taken from https://tavianator.com/2023/futex.html
|
||||
|
||||
#include <pthread.h>
|
||||
#include <atomic>
|
||||
|
||||
struct _Spinlock {
|
||||
std::atomic_flag state;
|
||||
|
||||
void init() {
|
||||
state.clear();
|
||||
}
|
||||
|
||||
void lock() {
|
||||
while (state.test_and_set(std::memory_order_acquire)) {
|
||||
#if defined(GB_CPU_X86)
|
||||
_mm_pause();
|
||||
#else
|
||||
(void)0; // spin...
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
state.clear(std::memory_order_release);
|
||||
}
|
||||
};
|
||||
|
||||
struct Futex_Waitq;
|
||||
|
||||
struct Futex_Waiter {
|
||||
_Spinlock lock;
|
||||
pthread_t thread;
|
||||
Futex *futex;
|
||||
Futex_Waitq *waitq;
|
||||
Futex_Waiter *prev, *next;
|
||||
};
|
||||
|
||||
struct Futex_Waitq {
|
||||
_Spinlock lock;
|
||||
Futex_Waiter list;
|
||||
|
||||
void init() {
|
||||
auto head = &list;
|
||||
head->prev = head->next = head;
|
||||
}
|
||||
};
|
||||
|
||||
// FIXME: This approach may scale badly in the future,
|
||||
// possible solution - hash map (leads to deadlocks now).
|
||||
|
||||
Futex_Waitq g_waitq = {
|
||||
.lock = ATOMIC_FLAG_INIT,
|
||||
.list = {
|
||||
.prev = &g_waitq.list,
|
||||
.next = &g_waitq.list,
|
||||
},
|
||||
};
|
||||
|
||||
Futex_Waitq *get_waitq(Futex *f) {
|
||||
// Future hash map method...
|
||||
return &g_waitq;
|
||||
}
|
||||
|
||||
void futex_signal(Futex *f) {
|
||||
auto waitq = get_waitq(f);
|
||||
|
||||
waitq->lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
for (auto waiter = head->next; waiter != head; waiter = waiter->next) {
|
||||
if (waiter->futex != f) {
|
||||
continue;
|
||||
}
|
||||
waitq->lock.unlock();
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
return;
|
||||
}
|
||||
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
void futex_broadcast(Futex *f) {
|
||||
auto waitq = get_waitq(f);
|
||||
|
||||
waitq->lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
for (auto waiter = head->next; waiter != head; waiter = waiter->next) {
|
||||
if (waiter->futex != f) {
|
||||
continue;
|
||||
}
|
||||
if (waiter->next == head) {
|
||||
waitq->lock.unlock();
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
return;
|
||||
} else {
|
||||
pthread_kill(waiter->thread, SIGCONT);
|
||||
}
|
||||
}
|
||||
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
void futex_wait(Futex *f, Footex val) {
|
||||
Futex_Waiter waiter;
|
||||
waiter.thread = pthread_self();
|
||||
waiter.futex = f;
|
||||
|
||||
auto waitq = get_waitq(f);
|
||||
while (waitq->lock.state.test_and_set(std::memory_order_acquire)) {
|
||||
if (f->load(std::memory_order_relaxed) != val) {
|
||||
return;
|
||||
}
|
||||
#if defined(GB_CPU_X86)
|
||||
_mm_pause();
|
||||
#else
|
||||
(void)0; // spin...
|
||||
#endif
|
||||
}
|
||||
|
||||
waiter.waitq = waitq;
|
||||
waiter.lock.init();
|
||||
waiter.lock.lock();
|
||||
|
||||
auto head = &waitq->list;
|
||||
waiter.prev = head->prev;
|
||||
waiter.next = head;
|
||||
waiter.prev->next = &waiter;
|
||||
waiter.next->prev = &waiter;
|
||||
|
||||
waiter.prev->next = &waiter;
|
||||
waiter.next->prev = &waiter;
|
||||
|
||||
sigset_t old_mask, mask;
|
||||
sigemptyset(&mask);
|
||||
sigaddset(&mask, SIGCONT);
|
||||
pthread_sigmask(SIG_BLOCK, &mask, &old_mask);
|
||||
|
||||
if (f->load(std::memory_order_relaxed) == val) {
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
|
||||
int sig;
|
||||
sigwait(&mask, &sig);
|
||||
|
||||
waitq->lock.lock();
|
||||
waiter.lock.lock();
|
||||
|
||||
while (waitq != waiter.waitq) {
|
||||
auto req = waiter.waitq;
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
waitq = req;
|
||||
waitq->lock.lock();
|
||||
waiter.lock.lock();
|
||||
}
|
||||
}
|
||||
|
||||
waiter.prev->next = waiter.next;
|
||||
waiter.next->prev = waiter.prev;
|
||||
|
||||
pthread_sigmask(SIG_SETMASK, &old_mask, NULL);
|
||||
|
||||
waiter.lock.unlock();
|
||||
waitq->lock.unlock();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
|
||||
@@ -34,7 +34,7 @@ package main
|
||||
},
|
||||
}, {// [2]
|
||||
src = `
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+build arm32, arm64
|
||||
package main
|
||||
`,
|
||||
@@ -45,7 +45,6 @@ package main
|
||||
{os = {.FreeBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.OpenBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.NetBSD}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
{os = {.Haiku}, arch = runtime.ALL_ODIN_ARCH_TYPES},
|
||||
parser.BUILD_KIND_NEWLINE_MARKER,
|
||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm32}},
|
||||
{os = runtime.ALL_ODIN_OS_TYPES, arch = {.arm64}},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
@@ -65,17 +65,8 @@ test_dirent :: proc(t: ^testing.T) {
|
||||
for entry in entries {
|
||||
defer posix.free(entry)
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
stat: posix.stat_t
|
||||
posix.stat(cstring(raw_data(entry.d_name[:])), &stat)
|
||||
|
||||
if !posix.S_ISREG(stat.st_mode) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
|
||||
name := string(cstring(raw_data(entry.d_name[:])))
|
||||
@@ -95,17 +86,8 @@ test_dirent :: proc(t: ^testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
when ODIN_OS == .Haiku {
|
||||
stat: posix.stat_t
|
||||
posix.stat(cstring(raw_data(entry.d_name[:])), &stat)
|
||||
|
||||
if !posix.S_ISREG(stat.st_mode) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
if entry.d_type != .REG {
|
||||
continue
|
||||
}
|
||||
|
||||
name := string(cstring(raw_data(entry.d_name[:])))
|
||||
@@ -165,8 +147,8 @@ test_libgen :: proc(t: ^testing.T) {
|
||||
{ "///", "/", "/" },
|
||||
{ "/usr/", "/", "usr" },
|
||||
{ "/usr/lib", "/usr", "lib" },
|
||||
{ "//usr//lib//", "//usr" + ("/" when ODIN_OS == .Haiku else ""), "lib" },
|
||||
{ "/home//dwc//test", "/home//dwc" + ("/" when ODIN_OS == .Haiku else ""), "test" },
|
||||
{ "//usr//lib//", "//usr", "lib" },
|
||||
{ "/home//dwc//test", "/home//dwc", "test" },
|
||||
}
|
||||
|
||||
for test in tests {
|
||||
@@ -259,4 +241,4 @@ open_permissions :: proc(t: ^testing.T) {
|
||||
stat: posix.stat_t
|
||||
res := posix.fstat(fd, &stat)
|
||||
testing.expectf(t, res == .OK, "failed to stat: %v", posix.strerror())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
#include <poll.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
@@ -31,9 +29,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
@@ -78,9 +74,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("passwd %zu %zu\n", sizeof(struct passwd), _Alignof(struct passwd));
|
||||
|
||||
#ifndef __HAIKU__
|
||||
printf("shmid_ds %zu %zu\n", sizeof(struct shmid_ds), _Alignof(struct shmid_ds));
|
||||
#endif
|
||||
|
||||
printf("ipc_perm %zu %zu\n", sizeof(struct ipc_perm), _Alignof(struct ipc_perm));
|
||||
printf("msqid_ds %zu %zu\n", sizeof(struct msqid_ds), _Alignof(struct msqid_ds));
|
||||
@@ -114,9 +108,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("utimbuf %zu %zu\n", sizeof(struct utimbuf), _Alignof(struct utimbuf));
|
||||
|
||||
#ifndef __HAIKU__
|
||||
printf("wordexp_t %zu %zu\n", sizeof(wordexp_t), _Alignof(wordexp_t));
|
||||
#endif
|
||||
|
||||
printf("time_t %zu %zu\n", sizeof(time_t), _Alignof(time_t));
|
||||
printf("timespec %zu %zu\n", sizeof(struct timespec), _Alignof(struct timespec));
|
||||
|
||||
@@ -45,9 +45,7 @@ main :: proc() {
|
||||
|
||||
fmt.println("passwd", size_of(posix.passwd), align_of(posix.passwd))
|
||||
|
||||
when ODIN_OS != .Haiku {
|
||||
fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds))
|
||||
}
|
||||
fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds))
|
||||
|
||||
fmt.println("ipc_perm", size_of(posix.ipc_perm), align_of(posix.ipc_perm))
|
||||
fmt.println("msqid_ds", size_of(posix.msqid_ds), align_of(posix.msqid_ds))
|
||||
@@ -81,9 +79,7 @@ main :: proc() {
|
||||
|
||||
fmt.println("utimbuf", size_of(posix.utimbuf), align_of(posix.utimbuf))
|
||||
|
||||
when ODIN_OS != .Haiku {
|
||||
fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t))
|
||||
}
|
||||
fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t))
|
||||
|
||||
fmt.println("time_t", size_of(posix.time_t), align_of(posix.time_t))
|
||||
fmt.println("timespec", size_of(posix.timespec), align_of(posix.timespec))
|
||||
|
||||
Reference in New Issue
Block a user