mirror of
https://github.com/janet-lang/janet
synced 2026-09-22 00:48:42 +00:00
Initial support for GNU Hurd.
Simply stubs out the operating system keywords. Many ifdefs for Linux can likely be adapted for GNU Hurd.
This commit is contained in:
+1
-1
@@ -37,7 +37,7 @@
|
||||
/* Create new userdata */
|
||||
void *janet_abstract_begin(const JanetAbstractType *atype, size_t size) {
|
||||
JanetAbstractHead *header = janet_gcalloc(JANET_MEMORY_NONE,
|
||||
sizeof(JanetAbstractHead) + size);
|
||||
sizeof(JanetAbstractHead) + size);
|
||||
header->size = size;
|
||||
header->type = atype;
|
||||
return (void *) & (header->data);
|
||||
|
||||
+4
-4
@@ -584,7 +584,7 @@ JanetAtomicInt janet_atomic_inc(JanetAtomicInt volatile *x) {
|
||||
#elif defined(JANET_USE_STDATOMIC)
|
||||
return atomic_fetch_add_explicit(x, 1, memory_order_relaxed) + 1;
|
||||
#elif defined(JANET_PLAN9)
|
||||
return aincl((void*)x, 1);
|
||||
return aincl((void *)x, 1);
|
||||
#else
|
||||
return __atomic_add_fetch(x, 1, __ATOMIC_RELAXED);
|
||||
#endif
|
||||
@@ -596,7 +596,7 @@ JanetAtomicInt janet_atomic_dec(JanetAtomicInt volatile *x) {
|
||||
#elif defined(JANET_USE_STDATOMIC)
|
||||
return atomic_fetch_add_explicit(x, -1, memory_order_acq_rel) - 1;
|
||||
#elif defined(JANET_PLAN9)
|
||||
return aincl((void*)x, -1);
|
||||
return aincl((void *)x, -1);
|
||||
#else
|
||||
return __atomic_add_fetch(x, -1, __ATOMIC_ACQ_REL);
|
||||
#endif
|
||||
@@ -606,7 +606,7 @@ JanetAtomicInt janet_atomic_load(JanetAtomicInt volatile *x) {
|
||||
#ifdef _MSC_VER
|
||||
return _InterlockedOr(x, 0);
|
||||
#elif defined(JANET_PLAN9)
|
||||
return agetl((void*)x);
|
||||
return agetl((void *)x);
|
||||
#elif defined(JANET_USE_STDATOMIC)
|
||||
return atomic_load_explicit(x, memory_order_acquire);
|
||||
#else
|
||||
@@ -618,7 +618,7 @@ JanetAtomicInt janet_atomic_load_relaxed(JanetAtomicInt volatile *x) {
|
||||
#ifdef _MSC_VER
|
||||
return _InterlockedOr(x, 0);
|
||||
#elif defined(JANET_PLAN9)
|
||||
return agetl((void*)x);
|
||||
return agetl((void *)x);
|
||||
#elif defined(JANET_USE_STDATOMIC)
|
||||
return atomic_load_explicit(x, memory_order_relaxed);
|
||||
#else
|
||||
|
||||
+1
-1
@@ -1553,7 +1553,7 @@ JanetFiber *janet_loop1(void) {
|
||||
} else if (sig == JANET_SIGNAL_OK || (task.fiber->flags & (1 << sig))) {
|
||||
JanetChannel *chan = janet_channel_unwrap(sv);
|
||||
janet_channel_push(chan, make_supervisor_event(janet_signal_names[sig],
|
||||
task.fiber, chan->is_threaded), 2);
|
||||
task.fiber, chan->is_threaded), 2);
|
||||
} else if (!is_suspended) {
|
||||
janet_stacktrace_ext(task.fiber, res, "");
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#ifdef __linux__
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#ifdef __gnu_hurd__
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -92,9 +92,9 @@ static uint32_t decode_watch_flags(const Janet *options, int32_t n) {
|
||||
}
|
||||
JanetKeyword keyw = janet_unwrap_keyword(options[i]);
|
||||
const JanetWatchFlagName *result = janet_strbinsearch(watcher_flags_linux,
|
||||
sizeof(watcher_flags_linux) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
sizeof(watcher_flags_linux) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
if (!result) {
|
||||
janet_panicf("unknown linux flag %v", options[i]);
|
||||
}
|
||||
@@ -316,9 +316,9 @@ static uint32_t decode_watch_flags(const Janet *options, int32_t n) {
|
||||
}
|
||||
JanetKeyword keyw = janet_unwrap_keyword(options[i]);
|
||||
const JanetWatchFlagName *result = janet_strbinsearch(watcher_flags_windows,
|
||||
sizeof(watcher_flags_windows) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
sizeof(watcher_flags_windows) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
if (!result) {
|
||||
janet_panicf("unknown windows filewatch flag %v", options[i]);
|
||||
}
|
||||
@@ -580,9 +580,9 @@ static uint32_t decode_watch_flags(const Janet *options, int32_t n) {
|
||||
}
|
||||
JanetKeyword keyw = janet_unwrap_keyword(options[i]);
|
||||
const JanetWatchFlagName *result = janet_strbinsearch(watcher_flags_kqueue,
|
||||
sizeof(watcher_flags_kqueue) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
sizeof(watcher_flags_kqueue) / sizeof(JanetWatchFlagName),
|
||||
sizeof(JanetWatchFlagName),
|
||||
keyw);
|
||||
if (!result) {
|
||||
janet_panicf("unknown bsd flag %v", options[i]);
|
||||
}
|
||||
|
||||
+3
-3
@@ -156,8 +156,8 @@ static LPFN_CONNECTEX lazy_get_connectex(JSock sock) {
|
||||
LPFN_CONNECTEX connect_ex_ptr = NULL;
|
||||
DWORD byte_len = 0;
|
||||
int success = WSAIoctl(sock, SIO_GET_EXTENSION_FUNCTION_POINTER,
|
||||
(void*)&guid, sizeof(guid),
|
||||
(void*)&connect_ex_ptr, sizeof(connect_ex_ptr),
|
||||
(void *)&guid, sizeof(guid),
|
||||
(void *)&connect_ex_ptr, sizeof(connect_ex_ptr),
|
||||
&byte_len, NULL, NULL);
|
||||
if (success) {
|
||||
janet_vm.connect_ex = connect_ex_ptr;
|
||||
@@ -746,7 +746,7 @@ static const char *serverify_socket(JSock sfd, int reuse_addr, int reuse_port) {
|
||||
}
|
||||
}
|
||||
if (reuse_port) {
|
||||
#ifdef SO_REUSEPORT
|
||||
#if defined(SO_REUSEPORT) && !JANET_GNU_HURD
|
||||
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEPORT, &enable, sizeof(int)) < 0) {
|
||||
return "setsockopt(SO_REUSEPORT) failed";
|
||||
}
|
||||
|
||||
+9
-1
@@ -50,6 +50,11 @@
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifdef JANET_GNU_HURD
|
||||
/* Ideally we would try to dynamically allocate */
|
||||
#define PATH_MAX 8192
|
||||
#endif
|
||||
|
||||
#ifdef JANET_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <direct.h>
|
||||
@@ -151,6 +156,7 @@ JANET_CORE_FN(os_which,
|
||||
"* :macos\n\n"
|
||||
"* :web - Web assembly (emscripten)\n\n"
|
||||
"* :linux\n\n"
|
||||
"* :hurd\n\n"
|
||||
"* :freebsd\n\n"
|
||||
"* :openbsd\n\n"
|
||||
"* :netbsd\n\n"
|
||||
@@ -177,6 +183,8 @@ JANET_CORE_FN(os_which,
|
||||
return janet_ckeywordv("web");
|
||||
#elif defined(JANET_LINUX)
|
||||
return janet_ckeywordv("linux");
|
||||
#elif defined(JANET_GNU_HURD)
|
||||
return janet_ckeywordv("hurd");
|
||||
#elif defined(__FreeBSD__)
|
||||
return janet_ckeywordv("freebsd");
|
||||
#elif defined(__NetBSD__)
|
||||
@@ -2250,7 +2258,7 @@ JANET_CORE_FN(os_readlink,
|
||||
(void) argv;
|
||||
janet_panic("not supported on Windows");
|
||||
#else
|
||||
static char buffer[PATH_MAX];
|
||||
char buffer[PATH_MAX];
|
||||
const char *path = janet_getcstring(argv, 0);
|
||||
ssize_t len = readlink(path, buffer, sizeof buffer);
|
||||
if (len < 0 || (size_t)len >= sizeof buffer)
|
||||
|
||||
@@ -67,6 +67,11 @@ extern "C" {
|
||||
#define JANET_LINUX 1
|
||||
#endif
|
||||
|
||||
/* Check for GNU Hurd */
|
||||
#ifdef __gnu_hurd__
|
||||
#define JANET_GNU_HURD 1
|
||||
#endif
|
||||
|
||||
/* Check for Android */
|
||||
#ifdef __ANDROID__
|
||||
#define JANET_ANDROID 1
|
||||
|
||||
Reference in New Issue
Block a user