From e8bd9b83cdcc319fdbc560a12658edd34d0cfaf4 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 11 Jun 2019 07:02:51 -0600 Subject: [PATCH] repair {Free,Open,Net}BSD build Use OSSP UUID on {Free,Open}BSD and native UUID on NetBSD. Building on OpenBSD requires a filesystem mounted with wxneeded. original commit: e964d7d01a6d115e469c01626896b683d421d599 --- c/Mf-a6ob | 2 +- c/Mf-i3ob | 4 ++-- c/Mf-ta6fb | 2 +- c/Mf-ta6nb | 1 + c/Mf-ta6ob | 4 ++-- c/Mf-ti3fb | 2 +- c/Mf-ti3ob | 4 ++-- c/expeditor.c | 13 ++++++++++++- c/stats.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- c/thread.c | 4 ++++ c/version.h | 4 ++++ s/a6nb.def | 2 +- s/ta6nb.def | 2 +- s/ta6ob.def | 2 +- s/update-revision | 2 +- 15 files changed, 78 insertions(+), 15 deletions(-) diff --git a/c/Mf-a6ob b/c/Mf-a6ob index a413a9b829..521a5aac8d 100644 --- a/c/Mf-a6ob +++ b/c/Mf-a6ob @@ -35,7 +35,7 @@ ${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} ${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-i3ob b/c/Mf-i3ob index f651eadaea..4bd211f9f4 100644 --- a/c/Mf-i3ob +++ b/c/Mf-i3ob @@ -17,7 +17,7 @@ m = i3ob Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) +mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O ${CFLAGS} o = o mdsrc = i3le.c @@ -35,7 +35,7 @@ ${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} ${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/Mf-ta6fb b/c/Mf-ta6fb index f4ed1a8ec1..899bc59d8e 100644 --- a/c/Mf-ta6fb +++ b/c/Mf-ta6fb @@ -17,7 +17,7 @@ m = ta6fb Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread +mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c diff --git a/c/Mf-ta6nb b/c/Mf-ta6nb index 168c97103e..98a1f7a196 100644 --- a/c/Mf-ta6nb +++ b/c/Mf-ta6nb @@ -36,6 +36,7 @@ ${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} ${Scheme}: ${Kernel} ${Main} $C -rdynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} + paxctl +m ${Scheme} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ta6ob b/c/Mf-ta6ob index 35c81fcd88..c435ffec1d 100644 --- a/c/Mf-ta6ob +++ b/c/Mf-ta6ob @@ -17,7 +17,7 @@ m = ta6ob Cpu = X86_64 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread +mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -35,7 +35,7 @@ ${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} ${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m64" ./configure --64) diff --git a/c/Mf-ti3fb b/c/Mf-ti3fb index b985c44d5e..fc58a55d96 100644 --- a/c/Mf-ti3fb +++ b/c/Mf-ti3fb @@ -17,7 +17,7 @@ m = ti3fb Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread +mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Wextra -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c diff --git a/c/Mf-ti3ob b/c/Mf-ti3ob index 52aa7c6489..560959164a 100644 --- a/c/Mf-ti3ob +++ b/c/Mf-ti3ob @@ -17,7 +17,7 @@ m = ti3ob Cpu = I386 mdinclude = -I/usr/local/include -I/usr/X11R6/include -mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread +mdclib = -L/usr/local/lib -liconv -lm $(LIBNCURSES) -lpthread -lossp-uuid C = ${CC} ${CPPFLAGS} -Wpointer-arith -Werror -O2 -D_REENTRANT -pthread ${CFLAGS} o = o mdsrc = i3le.c @@ -35,7 +35,7 @@ ${Kernel}: ${kernelobj} ${zlibDep} ${LZ4Dep} ld -r -X -o ${Kernel} ${kernelobj} ${zlibLib} ${LZ4Lib} ${Scheme}: ${Kernel} ${Main} - $C -rdynamic -Wl,--export-dynamic -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} + $C -rdynamic -Wl,--export-dynamic -Wl,-zwxneeded -o ${Scheme} ${Kernel} ${Main} ${mdclib} ${LDFLAGS} ../zlib/configure.log: (cd ../zlib; CFLAGS="${CFLAGS} -m32" ./configure) diff --git a/c/expeditor.c b/c/expeditor.c index b56dc0a76c..5a6a50788c 100644 --- a/c/expeditor.c +++ b/c/expeditor.c @@ -549,7 +549,7 @@ static void s_ee_write_char(wchar_t c) { #include #include #include -#ifndef __GLIBC__ +#if !defined(__GLIBC__) && !defined(__OpenBSD__) && !defined(__NetBSD__) #include #endif @@ -557,6 +557,17 @@ static void s_ee_write_char(wchar_t c) { #define HANDLE_SIGWINCH #endif +#ifdef USE_MBRTOWC_L +static locale_t the_locale; +static locale_t uselocale_alt(locale_t l) { + locale_t old = the_locale; + the_locale = l; + return old; +} +# define uselocale(v) uselocale_alt(v) +# define mbrtowc(pwc, s, n, ps) mbrtowc_l(pwc, s, n, ps, the_locale) +#endif + /* locally defined functions */ static int eeputc(tputsputcchar c); #ifdef HANDLE_SIGWINCH diff --git a/c/stats.c b/c/stats.c index ae5640a0df..93415ecd9b 100644 --- a/c/stats.c +++ b/c/stats.c @@ -65,7 +65,50 @@ ptr S_unique_id() { Sunsigned32(u.foo[3])))); } -#else /* WIN32 */ +#elif defined(USE_OSSP_UUID) /* WIN32 */ + +#include + +ptr S_unique_id() { + uuid_t *uuid; + U32 bin[4]; + void *bin_ptr = &bin; + size_t bin_len = sizeof(bin); + + uuid_create(&uuid); + uuid_make(uuid, UUID_MAKE_V4); + uuid_export(uuid, UUID_FMT_BIN, &bin_ptr, &bin_len); + uuid_destroy(uuid); + + return S_add(S_ash(Sunsigned32(bin[0]), Sinteger(8*3*sizeof(U32))), + S_add(S_ash(Sunsigned32(bin[1]), Sinteger(8*2*sizeof(U32))), + S_add(S_ash(Sunsigned32(bin[2]), Sinteger(8*sizeof(U32))), + Sunsigned32(bin[3])))); +} + +#elif defined(USE_NETBSD_UUID) /* USE_OSSP_UUID */ + +#include + +ptr S_unique_id() { + uuid_t uuid; + uint32_t status; + unsigned char bin[16]; + ptr n; + unsigned int i; + + uuid_create(&uuid, &status); + uuid_enc_le(bin, &uuid); + + n = Sinteger(0); + for (i = 0; i < sizeof(bin); i++) { + n = S_add(n, S_ash(Sinteger(bin[i]), Sinteger(8*i))); + } + + return n; +} + +#else /* USE_NETBSD_UUID */ #include diff --git a/c/thread.c b/c/thread.c index faa7f2c92e..3c4ed42f27 100644 --- a/c/thread.c +++ b/c/thread.c @@ -434,6 +434,10 @@ IBOOL S_condition_wait(c, m, t) s_thread_cond_t *c; scheme_mutex_t *m; ptr t; { typeno = Sinteger32_value(Srecord_ref(t,0)); sec = Sinteger32_value(Scar(Srecord_ref(t,1))); nsec = Sinteger32_value(Scdr(Srecord_ref(t,1))); + } else { + typeno = 0; + sec = 0; + nsec = 0; } if (c == &S_collect_cond || DISABLECOUNT(tc) == 0) { diff --git a/c/version.h b/c/version.h index 9caf0e02a8..7c6a9c140b 100644 --- a/c/version.h +++ b/c/version.h @@ -152,6 +152,7 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE char ** #define UNUSED __attribute__((__unused__)) +#define USE_OSSP_UUID #endif #if (machine_type == machine_type_i3nb || machine_type == machine_type_ti3nb || machine_type == machine_type_a6nb || machine_type == machine_type_ta6nb) @@ -185,6 +186,8 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE const char ** #define UNUSED __attribute__((__unused__)) +#define USE_NETBSD_UUID +#define USE_MBRTOWC_L #endif #if (machine_type == machine_type_i3nt || machine_type == machine_type_ti3nt || machine_type == machine_type_a6nt || machine_type == machine_type_ta6nt) @@ -281,6 +284,7 @@ typedef int tputsputcchar; #define NSECMTIME(sb) (sb).st_mtimespec.tv_nsec #define ICONV_INBUF_TYPE char ** #define UNUSED __attribute__((__unused__)) +#define USE_OSSP_UUID #endif #if (machine_type == machine_type_i3osx || machine_type == machine_type_ti3osx || machine_type == machine_type_a6osx || machine_type == machine_type_ta6osx) diff --git a/s/a6nb.def b/s/a6nb.def index a2dbd9506b..0ba4e358e4 100644 --- a/s/a6nb.def +++ b/s/a6nb.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/ta6nb.def b/s/ta6nb.def index 50bd30b6d2..309fb6c547 100644 --- a/s/ta6nb.def +++ b/s/ta6nb.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/ta6ob.def b/s/ta6ob.def index 8ff3fbba73..ae40a2b509 100644 --- a/s/ta6ob.def +++ b/s/ta6ob.def @@ -24,7 +24,7 @@ (define-constant size_t-bits 64) (define-constant ptrdiff_t-bits 64) (define-constant wchar-bits 32) -(define-constant time-t-bits 32) +(define-constant time-t-bits 64) (define-constant max-float-alignment 8) (define-constant max-integer-alignment 8) (define-constant asm-arg-reg-max 5) diff --git a/s/update-revision b/s/update-revision index 0b6e3f6ed0..8f1250f5dc 100755 --- a/s/update-revision +++ b/s/update-revision @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if [ -d ../../.git ]; then git describe --always --exclude='*' --abbrev=40 --dirty echo 'git'