bug#27782: patch for mmap and friends

Matt Wette <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <7a83fb6e-7f9c-b5fd-5b9f-aac81fade548__36356.2972097256$1673658149$gmane$org@gmail.com>
On 1/13/23 4:49 PM, Matt Wette wrote:
> Please consider this patch for adding mmap(), munmap() and msync()
>  to libguile/filesys.c.  Included is update for posix.texi and test 
> file mman.test.
> Once included, feature 'mman should be #t.
>
> Matt
Please add the attached file: test-suite/tests/mman.test.

I thought it was included in the patch.  It's the thought that counts, 
right?

Matt
mman.test (text/plain, 1.5 KB)
;;;; mman.test --- Tests for mmap API.    -*- scheme -*-
;;;;
;;;; Copyright 2022 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 3 of the License, or (at your option) any later version.
;;;;
;;;; This library is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

(define-module (test-mman)
  #:use-module (test-suite lib)
  #:use-module (test-suite guile-test)
  #:use-module (rnrs bytevectors)
  #:declarative? #f
  )

(define (mmap-test-file)
  (data-file-name "foo.txt"))

(define mmap-test-string "hello, world")

(define (gen-mmap-test-file)
  (with-output-to-file (mmap-test-file)
    (lambda () (display mmap-test-string))))

(when (provided? 'mman)

  (gen-mmap-test-file)

  (with-test-prefix "mman"

    (pass-if "mman 1"
      (let ((bv (mmap 0 #x100)))
        (bytevector-u8-set! bv 0 34)
        (= (bytevector-u8-ref bv 0) 34)))

    ))

;; --- last line ---
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.