diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml index 82565c91..f2fc3733 100644 --- a/.builds/openbsd.yml +++ b/.builds/openbsd.yml @@ -5,27 +5,27 @@ packages: - gmake - meson tasks: -- build: | - cd janet # Makefile testing on BSD. +- gmake: | + cd janet gmake gmake test doas gmake install gmake test-install - doas gmake uninstall - rm -rf build # clean up - meson setup build --buildtype=release -Dsingle_threaded=true -Dnanbox=false -Ddynamic_modules=false -Ddocstrings=false -Dnet=false -Dsourcemaps=false -Dpeg=false -Dassembler=false -Dint_types=false -Dtyped_array=false -Dreduced_os=true # meson minimum build - cd build - ninja # will not pass tests but should build - cd .. - rm -rf build # clean up - meson setup build --buildtype=release -Dprf=true # meson (with prf) - cd build +- meson_min: | + cd janet + meson setup build_meson_min --buildtype=release -Dsingle_threaded=true -Dnanbox=false -Ddynamic_modules=false -Ddocstrings=false -Dnet=false -Dsourcemaps=false -Dpeg=false -Dassembler=false -Dint_types=false -Dtyped_array=false -Dreduced_os=true + cd build_meson_min + ninja +- meson_prf: | + cd janet + meson setup build_meson_prf --buildtype=release -Dprf=true + cd build_meson_prf ninja ninja test - cd .. - rm -rf build - meson setup build --buildtype=release # meson (default build) - cd build +- meson_default: | + cd janet + meson setup build_meson_default --buildtype=release + cd build_meson_default ninja ninja test doas ninja install diff --git a/src/mainclient/shell.c b/src/mainclient/shell.c index 47de7788..7282f270 100644 --- a/src/mainclient/shell.c +++ b/src/mainclient/shell.c @@ -126,28 +126,21 @@ https://github.com/antirez/linenoise/blob/master/linenoise.c #define JANET_LINE_MAX 1024 #define JANET_MATCH_MAX 256 #define JANET_HISTORY_MAX 100 -static int gbl_israwmode = 0; -static const char *gbl_prompt = "> "; -static int gbl_plen = 2; -static char gbl_buf[JANET_LINE_MAX]; -static int gbl_len = 0; -static int gbl_pos = 0; -static int gbl_cols = 80; -static char *gbl_history[JANET_HISTORY_MAX]; -static int gbl_history_count = 0; -static int gbl_historyi = 0; -static int gbl_sigint_flag = 0; -static struct termios gbl_termios_start; -static JanetByteView gbl_matches[JANET_MATCH_MAX]; -static int gbl_match_count = 0; -static int gbl_lines_below = 0; - -/* Put a lock around this global state so we don't screw up - * the terminal in a multithreaded situation */ -#ifndef JANET_SINGLE_THREADED -#include -static pthread_mutex_t gbl_lock = PTHREAD_MUTEX_INITIALIZER; -#endif +JANET_THREAD_LOCAL static int gbl_israwmode = 0; +JANET_THREAD_LOCAL static const char *gbl_prompt = "> "; +JANET_THREAD_LOCAL static int gbl_plen = 2; +JANET_THREAD_LOCAL static char gbl_buf[JANET_LINE_MAX]; +JANET_THREAD_LOCAL static int gbl_len = 0; +JANET_THREAD_LOCAL static int gbl_pos = 0; +JANET_THREAD_LOCAL static int gbl_cols = 80; +JANET_THREAD_LOCAL static char *gbl_history[JANET_HISTORY_MAX]; +JANET_THREAD_LOCAL static int gbl_history_count = 0; +JANET_THREAD_LOCAL static int gbl_historyi = 0; +JANET_THREAD_LOCAL static int gbl_sigint_flag = 0; +JANET_THREAD_LOCAL static struct termios gbl_termios_start; +JANET_THREAD_LOCAL static JanetByteView gbl_matches[JANET_MATCH_MAX]; +JANET_THREAD_LOCAL static int gbl_match_count = 0; +JANET_THREAD_LOCAL static int gbl_lines_below = 0; /* Unsupported terminal list from linenoise */ static const char *badterms[] = { @@ -169,9 +162,6 @@ static char *sdup(const char *s) { /* Ansi terminal raw mode */ static int rawmode(void) { struct termios t; -#ifndef JANET_SINGLE_THREADED - pthread_mutex_lock(&gbl_lock); -#endif if (!isatty(STDIN_FILENO)) goto fatal; if (tcgetattr(STDIN_FILENO, &gbl_termios_start) == -1) goto fatal; t = gbl_termios_start; @@ -185,9 +175,6 @@ static int rawmode(void) { return 0; fatal: errno = ENOTTY; -#ifndef JANET_SINGLE_THREADED - pthread_mutex_unlock(&gbl_lock); -#endif return -1; } @@ -195,9 +182,6 @@ fatal: static void norawmode(void) { if (gbl_israwmode && tcsetattr(STDIN_FILENO, TCSADRAIN, &gbl_termios_start) != -1) gbl_israwmode = 0; -#ifndef JANET_SINGLE_THREADED - pthread_mutex_unlock(&gbl_lock); -#endif } static int curpos(void) {