From 40c24a92af2ead4379ea0755304c00fd09c806bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 26 Nov 2025 10:07:55 +0100 Subject: [PATCH] =?UTF-8?q?serialization:=20Use=20=E2=80=98bytevector-slic?= =?UTF-8?q?e=E2=80=99=20from=20Guile=20>=3D=203.0.9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/serialization.scm (sub-bytevector): Remove. (read-byte-string): Use ‘bytevector-slice’. * configure.ac: Require Guile 3.0.9. * doc/contributing.texi (Requirements): Adjust accordingly. Change-Id: I7aa11a2182530ea5131be591db03b17efb6847a4 Signed-off-by: Ludovic Courtès Merges: #4495 --- configure.ac | 5 +++-- doc/contributing.texi | 2 +- guix/serialization.scm | 15 ++------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 80d8e025b8..f72ca2f54c 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. # # GNU Guix --- Functional package management for GNU -# Copyright © 2012-2021, 2022-2023 Ludovic Courtès +# Copyright © 2012-2021, 2022-2023, 2025 Ludovic Courtès # Copyright © 2013, 2016 Mark H Weaver # Copyright © 2014-2016 Alex Kost # Copyright © 2014-2016 David Thompson @@ -130,7 +130,8 @@ if test "x$GUILD" = "x"; then fi dnl (guix ui), notably, requires 'default-optimization-level' added in 3.0.3. -PKG_CHECK_MODULES([GUILE], [guile-3.0 >= 3.0.3]) +dnl (guix serialization) requires 'bytevector-slice' added in 3.0.9. +PKG_CHECK_MODULES([GUILE], [guile-3.0 >= 3.0.9]) dnl Get CFLAGS and LDFLAGS for libguile. GUILE_FLAGS diff --git a/doc/contributing.texi b/doc/contributing.texi index c0a426db8a..06b4883baa 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -66,7 +66,7 @@ GNU Guix depends on the following packages: @itemize @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x, -version 3.0.3 or later; +version 3.0.9 or later; @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version 0.1.0 or later; @item diff --git a/guix/serialization.scm b/guix/serialization.scm index dfeb7a9bf1..0be97e4ff2 100644 --- a/guix/serialization.scm +++ b/guix/serialization.scm @@ -20,6 +20,7 @@ #:autoload (guix base16) (base16-string->bytevector bytevector->base16-string) #:use-module (rnrs bytevectors) + #:autoload (rnrs bytevectors gnu) (bytevector-slice) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) @@ -29,7 +30,6 @@ #:use-module ((ice-9 rdelim) #:prefix rdelim:) #:use-module (ice-9 match) #:use-module (ice-9 ftw) - #:use-module (system foreign) #:export (write-value read-value write-bytevector @@ -106,17 +106,6 @@ (port port))))) bv)) -(define (sub-bytevector bv len) - "Return a bytevector that aliases the first LEN bytes of BV." - (define max (bytevector-length bv)) - (cond ((= len max) bv) - ((< len max) - ;; Yes, this is safe because the result of each conversion procedure - ;; has its life cycle synchronized with that of its argument. - (pointer->bytevector (bytevector->pointer bv) len)) - (else - (error "sub-bytevector called to get a super bytevector")))) - (define (write-int n p) (let ((b (make-bytevector 8 0))) (bytevector-u32-set! b 0 n (endianness little)) @@ -164,7 +153,7 @@ (m (modulo len 8)) (pad (if (zero? m) 0 (- 8 m))) (bv (get-bytevector-n* p (+ len pad)))) - (sub-bytevector bv len))) + (bytevector-slice bv 0 len))) (define (read-string p) (utf8->string (read-byte-string p)))