mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 13:10:33 +02:00
serialization: Use ‘bytevector-slice’ from Guile >= 3.0.9.
* 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 <ludo@gnu.org> Merges: #4495
This commit is contained in:
@@ -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 <ludo@gnu.org>
|
||||
# Copyright © 2012-2021, 2022-2023, 2025 Ludovic Courtès <ludo@gnu.org>
|
||||
# Copyright © 2013, 2016 Mark H Weaver <mhw@netris.org>
|
||||
# Copyright © 2014-2016 Alex Kost <alezost@gmail.com>
|
||||
# Copyright © 2014-2016 David Thompson <davet@gnu.org>
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user