diff --git a/CHANGELOG.md b/CHANGELOG.md index ff7bd556..d730fa00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - ??? - Silence warnings in some compilers. +- Add `index-of` to core library. ## 1.11.1 - 2020-07-25 - Fix jpm and git with multiple git installs on Windows diff --git a/Makefile b/Makefile index 169f653c..4651165d 100644 --- a/Makefile +++ b/Makefile @@ -41,10 +41,10 @@ SONAME_SETTER=-Wl,-soname, # For cross compilation HOSTCC?=$(CC) HOSTAR?=$(AR) -CFLAGS?=-fPIC -O2 +CFLAGS?=-O2 LDFLAGS?=-rdynamic -COMMON_CFLAGS:=-std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden +COMMON_CFLAGS:=-std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC BOOT_CFLAGS:=-DJANET_BOOTSTRAP -DJANET_BUILD=$(JANET_BUILD) -O0 -g $(COMMON_CFLAGS) BUILD_CFLAGS:=$(CFLAGS) $(COMMON_CFLAGS) diff --git a/README.md b/README.md index 55b4fe71..7ae129b0 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,11 @@ gmake test gmake repl ``` +### NetBSD + +NetBSD build instructions are the same as the FreeBSD build instuctions. +Alternatively, install directly from packages, using `pkgin install janet`. + ### Windows 1. Install [Visual Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=15#) or [Visual Studio Build Tools](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15#) diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 3c6f5720..4767d9e5 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -957,6 +957,18 @@ (def i (find-index pred ind)) (if (= i nil) nil (in ind i))) +(defn index-of + "Find the first key associated with a value x in a data structure, acting like a reverse lookup. + Will not look at table prototypes. + Returns dflt if not found." + [x ind &opt dflt] + (var k (next ind nil)) + (var ret dflt) + (while (not= nil k) + (when (= (in ind k) x) (set ret k) (break)) + (set k (next ind k))) + ret) + (defn take "Take first n elements in an indexed type. Returns new indexed instance." [n ind] @@ -1212,7 +1224,7 @@ res) (defn any? - "Returns the first truthy valye in ind, otherwise nil. + "Returns the first truthy value in ind, otherwise nil. falsey value." [ind] (var res nil) diff --git a/src/core/features.h b/src/core/features.h index c594c1fc..ef9a0aea 100644 --- a/src/core/features.h +++ b/src/core/features.h @@ -38,4 +38,11 @@ #define _XOPEN_SOURCE 500 #endif +/* Needed for timegm and other extensions when building with -std=c99. + * It also defines realpath, etc, which would normally require + * _XOPEN_SOURCE >= 500. */ +#if !defined(_NETBSD_SOURCE) && defined(__NetBSD__) +#define _NETBSD_SOURCE +#endif + #endif diff --git a/src/include/janet.h b/src/include/janet.h index a1a5d05c..8efeec40 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -230,6 +230,11 @@ extern "C" { * To turn of nanboxing, for debugging purposes or for certain * architectures (Nanboxing only tested on x86 and x64), comment out * the JANET_NANBOX define.*/ + +#if defined(_M_ARM64) || defined(_M_ARM) || defined(__aarch64__) +#define JANET_NO_NANBOX +#endif + #ifndef JANET_NO_NANBOX #ifdef JANET_32 #define JANET_NANBOX_32