From ee450bcd77ae4c349c7e42aa4837f060cdd213e1 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Tue, 21 Jul 2020 13:40:23 -0500 Subject: [PATCH 1/8] Fix jpm on windows with multiple git binaries. --- jpm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpm b/jpm index 9dcb66c7..219f4019 100755 --- a/jpm +++ b/jpm @@ -688,7 +688,7 @@ int main(int argc, const char **argv) { (if stored-git-path (break stored-git-path)) (set stored-git-path (if is-win - (or (os/getenv "JANET_GIT") (pslurp "where git")) + (or (os/getenv "JANET_GIT") (first (string/split "\n" (pslurp "where git")))) (os/getenv "JANET_GIT" "git")))) (defn uninstall From 43438d3824ce553997f743d4cc0ca23751911842 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 24 Jul 2020 07:01:34 -0500 Subject: [PATCH 2/8] Allow getting typed arrays from byte sequences. Fix native importing for .so files in current directory. --- CHANGELOG.md | 5 +++++ meson.build | 2 +- src/conf/janetconf.h | 6 +++--- src/core/corelib.c | 21 ++++++++++++++++++++- src/core/typedarray.c | 36 ++++++++++++++++++++++-------------- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ece21574..5b2977a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## ??? - Unreleased +- Fix jpm and git with multiple git installs on Windows +- Fix importing a .so file in the current directory +- Allow passing byte sequence types directly to typed-array constructors. + ## 1.11.0 - 2020-07-18 - Add `forever` macro. - Add `any?` predicate to core. diff --git a/meson.build b/meson.build index cec15317..b2518693 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ project('janet', 'c', default_options : ['c_std=c99', 'b_lundef=false', 'default_library=both'], - version : '1.11.0') + version : '1.11.1') # Global settings janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') diff --git a/src/conf/janetconf.h b/src/conf/janetconf.h index 5f2b4a64..39a79f50 100644 --- a/src/conf/janetconf.h +++ b/src/conf/janetconf.h @@ -28,9 +28,9 @@ #define JANET_VERSION_MAJOR 1 #define JANET_VERSION_MINOR 11 -#define JANET_VERSION_PATCH 0 -#define JANET_VERSION_EXTRA "" -#define JANET_VERSION "1.11.0" +#define JANET_VERSION_PATCH 1 +#define JANET_VERSION_EXTRA "-dev" +#define JANET_VERSION "1.11.1-dev" /* #define JANET_BUILD "local" */ diff --git a/src/core/corelib.c b/src/core/corelib.c index da90bb2b..2af0ab38 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -63,10 +63,29 @@ typedef void *Clib; #define error_clib() dlerror() #endif +static char *get_processed_name(const char *name) { + if (name[0] == '.') return (char *) name; + const char *c; + for (c = name; *c; c++) { + if (*c == '/') return (char *) name; + } + size_t l = (size_t)(c - name); + char *ret = malloc(l + 3); + if (NULL == ret) { + JANET_OUT_OF_MEMORY; + } + ret[0] = '.'; + ret[1] = '/'; + memcpy(ret + 2, name, l + 3); + return ret; +} + JanetModule janet_native(const char *name, const uint8_t **error) { - Clib lib = load_clib(name); + char *processed_name = get_processed_name(name); + Clib lib = load_clib(processed_name); JanetModule init; JanetModconf getter; + if (name != processed_name) free(processed_name); if (!lib) { *error = janet_cstring(error_clib()); return NULL; diff --git a/src/core/typedarray.c b/src/core/typedarray.c index 0e29ed09..649e3397 100644 --- a/src/core/typedarray.c +++ b/src/core/typedarray.c @@ -376,21 +376,29 @@ static Janet cfun_typed_array_new(int32_t argc, Janet *argv) { if (argc > 3) offset = janet_getsize(argv, 3); if (argc > 4) { - if (!janet_checktype(argv[4], JANET_ABSTRACT)) { - janet_panicf("bad slot #%d, expected ta/view|ta/buffer, got %v", - 4, argv[4]); - } - void *p = janet_unwrap_abstract(argv[4]); - if (janet_abstract_type(p) == &janet_ta_view_type) { - JanetTArrayView *view = (JanetTArrayView *)p; - offset = (view->buffer->data - view->as.u8) + offset * ta_type_sizes[view->type]; - stride *= view->stride; - buffer = view->buffer; - } else if (janet_abstract_type(p) == &janet_ta_buffer_type) { - buffer = p; + int32_t blen; + const uint8_t *bytes; + if (janet_bytes_view(argv[4], &bytes, &blen)) { + buffer = janet_abstract(&janet_ta_buffer_type, sizeof(JanetTArrayBuffer)); + ta_buffer_init(buffer, (size_t) blen); + memcpy(buffer->data, bytes, blen); } else { - janet_panicf("bad slot #%d, expected ta/view|ta/buffer, got %v", - 4, argv[4]); + if (!janet_checktype(argv[4], JANET_ABSTRACT)) { + janet_panicf("bad slot #%d, expected ta/view|ta/buffer, got %v", + 4, argv[4]); + } + void *p = janet_unwrap_abstract(argv[4]); + if (janet_abstract_type(p) == &janet_ta_view_type) { + JanetTArrayView *view = (JanetTArrayView *)p; + offset = (view->buffer->data - view->as.u8) + offset * ta_type_sizes[view->type]; + stride *= view->stride; + buffer = view->buffer; + } else if (janet_abstract_type(p) == &janet_ta_buffer_type) { + buffer = p; + } else { + janet_panicf("bad slot #%d, expected ta/view|ta/buffer, got %v", + 4, argv[4]); + } } } JanetTArrayView *view = janet_tarray_view(type, size, stride, offset, buffer); From 02e5e49de2f7528ec9ffe64d0592c06dd4de5853 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 24 Jul 2020 07:04:32 -0500 Subject: [PATCH 3/8] Fix buffer overflow. --- src/core/corelib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/corelib.c b/src/core/corelib.c index 2af0ab38..be38cbf2 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -76,7 +76,7 @@ static char *get_processed_name(const char *name) { } ret[0] = '.'; ret[1] = '/'; - memcpy(ret + 2, name, l + 3); + memcpy(ret + 2, name, l + 1); return ret; } From 3e5e9e57e9463d2a65d36d189f14f041494d6e75 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 24 Jul 2020 12:29:31 -0500 Subject: [PATCH 4/8] Fix sourcehut builds yml file. --- .builds/meson.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.builds/meson.yml b/.builds/meson.yml index 889decd7..5643979d 100644 --- a/.builds/meson.yml +++ b/.builds/meson.yml @@ -11,4 +11,4 @@ tasks: ninja ninja test mkdir modpath - jpm --verbose --modpath=./modpath install https://github.com/bakpakin/x43bot.git + jpm --verbose --modpath=./modpath install https://github.com/bakpakin/x43bot.git From 1ba3f72e4c81dd2235e0159535523ac20518d10c Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 24 Jul 2020 13:03:10 -0500 Subject: [PATCH 5/8] Update meson build. --- .builds/meson.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.builds/meson.yml b/.builds/meson.yml index 5643979d..a3a6324f 100644 --- a/.builds/meson.yml +++ b/.builds/meson.yml @@ -10,5 +10,5 @@ tasks: cd build ninja ninja test - mkdir modpath - jpm --verbose --modpath=./modpath install https://github.com/bakpakin/x43bot.git + doas ninja install + doas jpm --verbose install circlet From 409a8a3a430e9b2e5f95d41a8f285bb692901970 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 Jul 2020 08:09:22 -0500 Subject: [PATCH 6/8] Fix #452 - Bad file marshal We forgot a call to janet_marshal_abstract, which corrupted the output. --- src/core/io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/io.c b/src/core/io.c index 4dbcee58..2b2c1c1b 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -339,6 +339,7 @@ static int io_file_get(void *p, Janet key, Janet *out) { static void io_file_marshal(void *p, JanetMarshalContext *ctx) { JanetFile *iof = (JanetFile *)p; if (ctx->flags & JANET_MARSHAL_UNSAFE) { + janet_marshal_abstract(ctx, p); #ifdef JANET_WINDOWS janet_marshal_int(ctx, _fileno(iof->file)); #else From 04ac9b8e32df5c030f251c4b8e983b08c30d126d Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 Jul 2020 10:14:11 -0500 Subject: [PATCH 7/8] Update README.md --- CHANGELOG.md | 1 + README.md | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b2977a6..184e826b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. - Fix jpm and git with multiple git installs on Windows - Fix importing a .so file in the current directory - Allow passing byte sequence types directly to typed-array constructors. +- Fix bug sending files between threads. ## 1.11.0 - 2020-07-18 - Add `forever` macro. diff --git a/README.md b/README.md index 5be52330..55b4fe71 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@   [![Appveyor Status](https://ci.appveyor.com/api/projects/status/bjraxrxexmt3sxyv/branch/master?svg=true)](https://ci.appveyor.com/project/bakpakin/janet/branch/master) [![Build Status](https://travis-ci.org/janet-lang/janet.svg?branch=master)](https://travis-ci.org/janet-lang/janet) -[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/freebsd.yml.svg)](https://builds.sr.ht/~bakpakin/janet/freebsd.yml?) -[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/openbsd.yml.svg)](https://builds.sr.ht/~bakpakin/janet/openbsd.yml?) -[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/meson.yml.svg)](https://builds.sr.ht/~bakpakin/janet/meson.yml?) -[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/meson_min.yml.svg)](https://builds.sr.ht/~bakpakin/janet/meson_min.yml?) +[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/freebsd.yml.svg)](https://builds.sr.ht/~bakpakin/janet/commits/freebsd.yml?) +[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/openbsd.yml.svg)](https://builds.sr.ht/~bakpakin/janet/commits/openbsd.yml?) +[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/meson.yml.svg)](https://builds.sr.ht/~bakpakin/janet/commits/meson.yml?) +[![builds.sr.ht status](https://builds.sr.ht/~bakpakin/janet/meson_min.yml.svg)](https://builds.sr.ht/~bakpakin/janet/commits/meson_min.yml?) Janet logo From 5be5e5b58fafff02745f5912b3f4820e1e58e745 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 Jul 2020 13:11:52 -0500 Subject: [PATCH 8/8] Update soname. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e9c02b4f..1e3f49ed 100644 --- a/Makefile +++ b/Makefile @@ -155,7 +155,7 @@ build/janet.c: build/janet_boot src/boot/boot.janet ##### Amalgamation ##### ######################## -SONAME=libjanet.so.1.10 +SONAME=libjanet.so.1.11 build/shell.c: src/mainclient/shell.c cp $< $@