diff -uNr a/gscm/README b/gscm/README --- a/gscm/README 8720f7781977ed40fdd336e72f85d75bae99ee1cd913c358235d03671cf81e276ccc227904f7c601efb5e14547d122a07de7ecd26a58f85ccdc270ebac89a89b +++ b/gscm/README 3011289ba281008dd6f314718348b5f2de6ebe54841ed89136c02273d322b69aad4e514d18bfdf13416dec27ddfa8ebb0525dcd04aace16a7d79cace0cd5410b @@ -20,11 +20,11 @@ 1. Create the top-level /package directory if necessary and place the tree at its fully version-qualified path: mkdir -p /package - cp -r /YOUR/PATH/TO/gscm /package/gscm-0.40.6 + cp -r /YOUR/PATH/TO/gscm /package/gscm-0.40.7 2. Run the install script from the above directory: - cd /package/gscm-0.40.6 + cd /package/gscm-0.40.7 sh package/install 3. Run the test suite if you like: diff -uNr a/gscm/doc/CHANGES b/gscm/doc/CHANGES --- a/gscm/doc/CHANGES cafdad5da765193b577cf00a3b6db06d690db1b48acad383330d2bbc6a3d4d215175083b1aa9f6230b633642527a5c4cde0f19b406390ceee355a2507c881505 +++ b/gscm/doc/CHANGES d251315af73a4670c7a857eb55909c7b6f7cd4e1f4af5529bdc2e1ff1b473c5e7e2078e712feb25699c03c7dc462dea966e1de9cfa1b7fcfb0292122d29c6655 @@ -776,3 +776,12 @@ Documentation: - README moved from 'package' subdir to top level and massaged a bit. + +March 2023: + +40.maint7. + +Core: +- Improve portability to glibc systems by defining the minimal required feature test macros and directly declaring some newer syscalls. +- Add a HAVE_PIPE2 configurable, instead of commenting out the fallback code. +- Expand related comments. diff -uNr a/gscm/manifest b/gscm/manifest --- a/gscm/manifest c872822ff26ad91e1140762a25c317e1be2fa8331e75ec85f979a1a254e81f356f13b463c61318edba685a8c932227c997537cd2f344539db1292d81f8f7b7b0 +++ b/gscm/manifest edb1d0e644b513e646ce663bb78f1ed64a4557e4a64e12632a4eaa5b6e17d9c24da7991e2b2b23b6f63a9797826e875d5b0c638796181d1af24c5f80586f5617 @@ -2,3 +2,4 @@ 648629 gscm_fix_m_whitespace_package_install jfw The -m argument to set heap memory allocation was broken; the control characters allowed as whitespace by the lexer were inconsistent; package installation was broken in the case of an existing version. 654058 gscm_immutable_fill jfw The string-fill! and vector-fill! builtins failed to catch the errors of operating on immutable strings or vectors respectively. 711740 gscm_usrbin jfw Change command symlink from /command/gscm to /usr/bin/gscm (see CHANGES for rationale) and update README. +781987 gscm_glibc_build_fix jfw Improve portability to glibc systems and add a HAVE_PIPE2 configurable. diff -uNr a/gscm/package/install b/gscm/package/install --- a/gscm/package/install 38938de1d08dcfcb833b6adf3f35af18f37ea1283eb08e02b53d19f2952155374543d326215e076e5a14a00215727e3f854b8d4f7283442f47feb94472974d48 +++ b/gscm/package/install 2f0f4c18ba8498f8325a61aae566d521c12aa791b368a02d1c9a4e4d27e3d88a680e6242380810ba123878ecfcf84bcbe8f15832681d92b96821eb26256e2447 @@ -2,7 +2,7 @@ set -e P=gscm -V=0.40.6 +V=0.40.7 cd /package/$P-$V # Versioned path duplicated in: diff -uNr a/gscm/src/Makefile b/gscm/src/Makefile --- a/gscm/src/Makefile 34dfec1e7baa7169fa4508ccfc9f277a803e50aa1b7bcece5719c9d75cdefb33a716cb8e2c68bf169dfc1a178516183cfc25bef7941462cebe0837ea45244266 +++ b/gscm/src/Makefile 6f71e198e552d8927c66a2c7c7f6cac5cb54973070575d7e85ba6177b679f62f18e0a5aee98108898b87bd9cc96bd1316f02280957688201815e9df04e812402 @@ -1,4 +1,4 @@ -PREFIX := /package/gscm-0.40.6 +PREFIX := /package/gscm-0.40.7 ASM_ARCH := x86_64 CFLAGS := -std=c99 -pedantic -Wall -Wextra -Winit-self -Wstrict-aliasing=1 -g -O2 diff -uNr a/gscm/src/gscm.c b/gscm/src/gscm.c --- a/gscm/src/gscm.c 27041dc8a3fa1511bb10b6bd122fa21ae975857c5aba2e16081d74c6d0e9713bec0620677f61f2200230219591747e2d145f4a5e7b07935c7ecf71c4604e6b37 +++ b/gscm/src/gscm.c a1d87138bf0faaa75b4dfb9c9a03d1da9baa4ba4dc9daae671bfb4de2cf23dc3f8af08799af25e738f41ebcb248f74ec4b3e4f43a37d059ba22ec417c84ce8bc @@ -5,9 +5,17 @@ * artificial restrictions, and R5RS compliance with strict error checking. * * J. Welsh - * January 2017 - April 2018 + * January 2017 - March 2023 */ +/* Define this if your system supports pipe2 and the O_CLOEXEC flag. Currently this is manually switched because I want to find out if there are any relevant systems that don't. (In other words - if you have to remove this to build, please let me know!) */ +#define HAVE_PIPE2 + +/* make glibc define MAP_ANONYMOUS */ +#define _BSD_SOURCE +/* make glibc 2.12+ define O_CLOEXEC */ +#define _POSIX_C_SOURCE 200809L + #include #include #include @@ -27,14 +35,23 @@ #define MAP_ANON MAP_ANONYMOUS #endif +/* stdio.h dependencies listed explicitly */ int snprintf(char *, size_t, const char *, ...); /* to be replaced */ + +/* stdlib.h dependencies listed explicitly */ void abort(void); + +/* string.h dependencies listed explicitly */ size_t strlen(const char *); char *strerror(int); void *memcpy(void *, const void *, size_t); void *memset(void *, int, size_t); int memcmp(const void *, const void *, size_t); + +/* Newer syscalls which glibc is cranky about declaring: let's not play along with its feature test macro games more than strictly necessary. */ pid_t vfork(void); +int fdatasync(int); +int pipe2(int[2], int); #include "gscm.h" @@ -217,22 +234,26 @@ */ static int open_cloexec(const char *path, int flags) { +#ifdef HAVE_PIPE2 return open(path, flags | O_CLOEXEC, 0666); - /* Non-atomic version for systems lacking O_CLOEXEC +#else + /* Non-atomic version for systems lacking O_CLOEXEC. This doesn't currently matter, but if we go multi-threaded, we'll need locking for this and any exec family calls. And exec locking would be hard to enforce if this were linkable into larger programs. So basically there's a choice between portability or support for complexity. */ int fd = open(path, flags, 0666); if (fd != -1) fcntl(fd, F_SETFD, FD_CLOEXEC); return fd; - */ +#endif } static int pipe_cloexec(int pipefd[2]) { +#ifdef HAVE_PIPE2 return pipe2(pipefd, O_CLOEXEC); - /* Non-atomic version for systems lacking pipe2 +#else + /* Non-atomic version for systems lacking pipe2 (see O_CLOEXEC comments above). */ if (pipe(pipefd) == -1) return -1; fcntl(pipefd[0], F_SETFD, FD_CLOEXEC); fcntl(pipefd[1], F_SETFD, FD_CLOEXEC); return 0; - */ +#endif } /* Reliably catching close errors is NOT POSSIBLE on Linux and others. The call