mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 08:30:26 +00:00
Start cleaning up defines in janet.h
This commit is contained in:
parent
58ff7f0788
commit
b8004555ea
@ -155,7 +155,8 @@ ninja -C build install
|
|||||||
Janet can be hacked on with pretty much any environment you like, but for IDE
|
Janet can be hacked on with pretty much any environment you like, but for IDE
|
||||||
lovers, [Gnome Builder](https://wiki.gnome.org/Apps/Builder) is probably the
|
lovers, [Gnome Builder](https://wiki.gnome.org/Apps/Builder) is probably the
|
||||||
best option, as it has excellent meson integration. It also offers code completion
|
best option, as it has excellent meson integration. It also offers code completion
|
||||||
for Janet's C API right out of the box, which is very useful for exploring.
|
for Janet's C API right out of the box, which is very useful for exploring. VSCode, Vim,
|
||||||
|
Emacs, and Atom will have syntax packages for the Janet language, though.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -20,18 +20,14 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Compiler feature test macros for things */
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#define _BSD_SOURCE
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifndef JANET_AMALG
|
#ifndef JANET_AMALG
|
||||||
#include <janet.h>
|
#include <janet.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#ifndef JANET_WINDOWS
|
#ifndef JANET_WINDOWS
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,11 +75,11 @@ static Janet os_which(int32_t argc, Janet *argv) {
|
|||||||
return janet_ckeywordv(janet_stringify(JANET_OS_NAME));
|
return janet_ckeywordv(janet_stringify(JANET_OS_NAME));
|
||||||
#elif defined(JANET_WINDOWS)
|
#elif defined(JANET_WINDOWS)
|
||||||
return janet_ckeywordv("windows");
|
return janet_ckeywordv("windows");
|
||||||
#elif defined(__APPLE__)
|
#elif defined(JANET_APPLE)
|
||||||
return janet_ckeywordv("macos");
|
return janet_ckeywordv("macos");
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
return janet_ckeywordv("web");
|
return janet_ckeywordv("web");
|
||||||
#elif defined(__linux__)
|
#elif defined(JANET_LINUX)
|
||||||
return janet_ckeywordv("linux");
|
return janet_ckeywordv("linux");
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
return janet_ckeywordv("freebsd");
|
return janet_ckeywordv("freebsd");
|
||||||
@ -87,6 +87,8 @@ static Janet os_which(int32_t argc, Janet *argv) {
|
|||||||
return janet_ckeywordv("netbsd");
|
return janet_ckeywordv("netbsd");
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
return janet_ckeywordv("openbsd");
|
return janet_ckeywordv("openbsd");
|
||||||
|
#elif defined(JANET_BSD)
|
||||||
|
return janet_ckeywordv("bsd");
|
||||||
#else
|
#else
|
||||||
return janet_ckeywordv("posix");
|
return janet_ckeywordv("posix");
|
||||||
#endif
|
#endif
|
||||||
@ -527,11 +529,9 @@ static Janet os_cryptorand(int32_t argc, Janet *argv) {
|
|||||||
v = v >> 8;
|
v = v >> 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
#elif defined(JANET_LINUX)
|
||||||
/* We should be able to call getrandom on linux, but it doesn't seem
|
/* We should be able to call getrandom on linux, but it doesn't seem
|
||||||
to be uniformly supported on linux distros. Macos may support
|
to be uniformly supported on linux distros.
|
||||||
arc4random_buf, but it needs investigation.
|
|
||||||
|
|
||||||
In both cases, use this fallback path for now... */
|
In both cases, use this fallback path for now... */
|
||||||
int rc;
|
int rc;
|
||||||
int randfd;
|
int randfd;
|
||||||
@ -549,9 +549,12 @@ static Janet os_cryptorand(int32_t argc, Janet *argv) {
|
|||||||
n -= nread;
|
n -= nread;
|
||||||
}
|
}
|
||||||
RETRY_EINTR(rc, close(randfd));
|
RETRY_EINTR(rc, close(randfd));
|
||||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
#elif defined(JANET_BSD) || define(JANET_APPLE)
|
||||||
|
(void) genericerr;
|
||||||
|
|
||||||
arc4random_buf(buffer->data + offset, n);
|
arc4random_buf(buffer->data + offset, n);
|
||||||
#else
|
#else
|
||||||
|
(void) genericerr;
|
||||||
janet_panic("cryptorand currently unsupported on this platform");
|
janet_panic("cryptorand currently unsupported on this platform");
|
||||||
#endif
|
#endif
|
||||||
return janet_wrap_buffer(buffer);
|
return janet_wrap_buffer(buffer);
|
||||||
|
@ -45,6 +45,23 @@ extern "C" {
|
|||||||
* detection for unsupported platforms
|
* detection for unsupported platforms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Check for any flavor of BSD (except apple) */
|
||||||
|
#if defined(__FreeBSD__) || defined(__DragonFly__) || \
|
||||||
|
defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
#define JANET_BSD 1
|
||||||
|
#define _BSD_SOURCE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Check for Mac */
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define JANET_APPLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Check for Linux */
|
||||||
|
#ifdef __linux__
|
||||||
|
#define JANET_LINUX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check Unix */
|
/* Check Unix */
|
||||||
#if defined(_AIX) \
|
#if defined(_AIX) \
|
||||||
|| defined(__APPLE__) /* Darwin */ \
|
|| defined(__APPLE__) /* Darwin */ \
|
||||||
@ -58,11 +75,8 @@ extern "C" {
|
|||||||
|| defined(__QNXNTO__) \
|
|| defined(__QNXNTO__) \
|
||||||
|| defined(sun) || defined(__sun) /* Solaris */ \
|
|| defined(sun) || defined(__sun) /* Solaris */ \
|
||||||
|| defined(unix) || defined(__unix) || defined(__unix__)
|
|| defined(unix) || defined(__unix) || defined(__unix__)
|
||||||
#define JANET_UNIX 1
|
#define JANET_POSIX 1
|
||||||
/* Enable certain posix features */
|
|
||||||
#ifndef _POSIX_C_SOURCE
|
|
||||||
#define _POSIX_C_SOURCE 200112L
|
#define _POSIX_C_SOURCE 200112L
|
||||||
#endif
|
|
||||||
#elif defined(__EMSCRIPTEN__)
|
#elif defined(__EMSCRIPTEN__)
|
||||||
#define JANET_WEB 1
|
#define JANET_WEB 1
|
||||||
#elif defined(WIN32) || defined(_WIN32)
|
#elif defined(WIN32) || defined(_WIN32)
|
||||||
@ -71,7 +85,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Check 64-bit vs 32-bit */
|
/* Check 64-bit vs 32-bit */
|
||||||
#if ((defined(__x86_64__) || defined(_M_X64)) \
|
#if ((defined(__x86_64__) || defined(_M_X64)) \
|
||||||
&& (defined(JANET_UNIX) || defined(JANET_WINDOWS))) \
|
&& (defined(JANET_POSIX) || defined(JANET_WINDOWS))) \
|
||||||
|| (defined(_WIN64)) /* Windows 64 bit */ \
|
|| (defined(_WIN64)) /* Windows 64 bit */ \
|
||||||
|| (defined(__ia64__) && defined(__LP64__)) /* Itanium in LP64 mode */ \
|
|| (defined(__ia64__) && defined(__LP64__)) /* Itanium in LP64 mode */ \
|
||||||
|| defined(__alpha__) /* DEC Alpha */ \
|
|| defined(__alpha__) /* DEC Alpha */ \
|
||||||
|
Loading…
Reference in New Issue
Block a user