Received: (at 27782) by debbugs.gnu.org; 25 Nov 2017 16:17:20 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 11:17:19 2017 Received: from localhost ([127.0.0.1]:58071 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1eId8p-0004EL-Nw for submit <at> debbugs.gnu.org; Sat, 25 Nov 2017 11:17:19 -0500 Received: from mail-yb0-f182.google.com ([209.85.213.182]:46256) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <nalaginrut@HIDDEN>) id 1eId8o-0004E5-Ji for 27782 <at> debbugs.gnu.org; Sat, 25 Nov 2017 11:17:18 -0500 Received: by mail-yb0-f182.google.com with SMTP id 188so9172351ybd.13 for <27782 <at> debbugs.gnu.org>; Sat, 25 Nov 2017 08:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NHOzK0j8hlT/jzVuIsjgBOgyUClJ+UXobU6BRM9CIGY=; b=NMlyw4Q5FTKVrOuLvKom/o7sMw5PVGxIPmiVDhFCaVt8CP2RdE/gtXe75V6oiVikrN VDcbuCt1LhPVn20dINxsdYlSXXEHUj7jSJXuUjqYJB6AJl2s+BO3Xm1l2JRLfRYYKJR0 uO2bjrg5lUduO4y3bdrGIY/2io3hn4Lsn1xGPevCXhARyeohW/724fpWf+WnWaJeUyuV breft0WI34fk5+YKU/sN4VER+KmeJjT87j2+dgQipCua0bqWdDuSYOQ4cHKVJC1hgMwP Xz4iAgHblPPQBthB0xTupxR+IIPV01ZrDZ/pw6+PifrZKmgTYNJcyEbBHwtu0a6SyU8B n63A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NHOzK0j8hlT/jzVuIsjgBOgyUClJ+UXobU6BRM9CIGY=; b=qMZmd/elSLhS7GDTD+QbcUr9FoV32/HR+4LGxB44cAkIJu72iVQP/U1k8LHc0acR5t QKI1GNaM3/TA/2T10Ta8cXbEEW5/mLKyxPBBVtAgvL/8drSD8W4nkiCktQI8gQsMKaLA 9hDSnz6nbA3ETBLNumjhat4TKB+L5z8q2Ztgy6PgMugxgVAM7ThItLcUnDH3/BNOGuH6 uw/l6rsEGVelgy99hpWd2NDiFCOkD6yU03GHRfg9EQ8kS3T6p9CaSn3W32205QtJAdYl TXkrD/4wKQ7b9+JnEW+sx0sn9br7VPP8/EaYEtu9bXDSy+2AvzWc2MXm6DALbJv6qvDN upiA== X-Gm-Message-State: AJaThX4yYU+3MhpLmrxuU9RNfG2Av/7oVxyLBI/fCFZai9QCwKKcshYN wrSs2SJEZrqzETGY1bFQ+AA3wOZbVQkWJ6yfvls= X-Google-Smtp-Source: AGs4zMZdNb8zl195qSmR+BsiNw7aUN5ySNpSbUPJPZ5P9MBigoRvZ/X/K/NPp6DXNCvsmqOGnzkSAEQV9mKAMC1jpcE= X-Received: by 10.37.193.7 with SMTP id r7mr19741467ybf.205.1511626632441; Sat, 25 Nov 2017 08:17:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.45.94 with HTTP; Sat, 25 Nov 2017 08:17:11 -0800 (PST) Received: by 10.37.45.94 with HTTP; Sat, 25 Nov 2017 08:17:11 -0800 (PST) In-Reply-To: <3F4AACD7-3278-4C4B-90D4-56BCDE5043F6@HIDDEN> References: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> <CAPjoZoeWyRx5_eTogzhuUbARZyPtp4OsbCjtGnkp_TGvYfkfag@HIDDEN> <D32D387D-D1B1-433D-B791-ACDB6859E38D@HIDDEN> <3F4AACD7-3278-4C4B-90D4-56BCDE5043F6@HIDDEN> From: Nala Ginrut <nalaginrut@HIDDEN> Date: Sun, 26 Nov 2017 00:17:11 +0800 Message-ID: <CAPjoZoeQ-zdwkogw=b9=rZrjOxcWZqBeNuGpgSRmQZmD6_QM-w@HIDDEN> Subject: Re: bug#27782: mmap for guile To: Matt Wette <matt.wette@HIDDEN> Content-Type: multipart/alternative; boundary="94eb2c05528275b515055ed100e2" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 27782 Cc: 27782 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --94eb2c05528275b515055ed100e2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Actually I've been using a FFI version of mmap in my working code, with my previous patch to Guile it's very easy to handle errno. Just few lines code is enough to bind mmap. I am not sure if C version binding is still the best option to maintain. 2017=E5=B9=B411=E6=9C=8825=E6=97=A5 22:42=EF=BC=8C"Matt Wette" <matt.wette@= gmail.com>=E5=86=99=E9=81=93=EF=BC=9A > here is a start on test-suite/tests/mmap.test > > +;;;; mmap.test --- test suite for Guile's mmap functions -*- scheme -*- > +;;;; > + > +(define-module (test-mmap) > + #:use-module (test-suite lib)) > + > +(use-modules (rnrs bytevectors)) > + > +(with-test-prefix "mmap" > + > + (pass-if "basics" > + (let* ((siz #x10000) > + (reg (mmap 0 siz))) > + (and (eqv? (bytevector-length reg) siz) > + (begin (bytevector-u8-set! reg 0 99) > + (eqv? (bytevector-u8-ref reg 0) 99)) > + (begin (bytevector-u8-set! reg (1- siz) 98) > + (eqv? (bytevector-u8-ref reg (1- siz)) 98)) > + #t))) > + > + ) > + > +;;;; --- last line --- > > > > > --94eb2c05528275b515055ed100e2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">Actually I've been using a FFI version of mmap in my = working code, with my previous patch to Guile it's very easy to handle = errno. Just few lines code is enough to bind mmap.<div dir=3D"auto">I am no= t sure if C version binding is still the best option to maintain.</div></di= v><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2017=E5=B9=B411= =E6=9C=8825=E6=97=A5 22:42=EF=BC=8C"Matt Wette" <<a href=3D"ma= ilto:matt.wette@HIDDEN">matt.wette@HIDDEN</a>>=E5=86=99=E9=81=93= =EF=BC=9A<br type=3D"attribution"><blockquote class=3D"gmail_quote" style= =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">here is = a start on test-suite/tests/mmap.test<br> <br> +;;;; mmap.test --- test suite for Guile's mmap functions=C2=A0 -*- sch= eme -*-<br> +;;;;<br> +<br> +(define-module (test-mmap)<br> +=C2=A0 #:use-module (test-suite lib))<br> +<br> +(use-modules (rnrs bytevectors))<br> +<br> +(with-test-prefix "mmap"<br> +<br> +=C2=A0 (pass-if "basics"<br> +=C2=A0 =C2=A0 (let* ((siz #x10000)<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (reg (mmap 0 siz)))<br> +=C2=A0 =C2=A0 =C2=A0 (and (eqv? (bytevector-length reg) siz)<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (begin (bytevector-u8-set! reg 0 99)<br= > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(eqv? (bytev= ector-u8-ref reg 0) 99))<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (begin (bytevector-u8-set! reg (1- siz)= 98)<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(eqv? (bytev= ector-u8-ref reg (1- siz)) 98))<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #t)))<br> +<br> +=C2=A0 )<br> +<br> +;;;; --- last line ---<br> <br> <br> <br> <br> </blockquote></div></div> --94eb2c05528275b515055ed100e2--
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 25 Nov 2017 14:41:27 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 09:41:27 2017 Received: from localhost ([127.0.0.1]:56854 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1eIbe3-0001bi-G1 for submit <at> debbugs.gnu.org; Sat, 25 Nov 2017 09:41:27 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:37341) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1eIbe2-0001bT-6W for 27782 <at> debbugs.gnu.org; Sat, 25 Nov 2017 09:41:26 -0500 Received: by mail-pg0-f51.google.com with SMTP id m4so6889811pgc.4 for <27782 <at> debbugs.gnu.org>; Sat, 25 Nov 2017 06:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=50IpS0zXCaueIIG4d8jUtXLPD8HLM/XxmrpezXDvf3I=; b=vXjHblRmgKhxteY36yVYogM6nEY11tHVoBZhoK2sUVQOsUbA3NZyBrqPUwAA3OIZkB dWIA3IE4MyrVwk5UHTr5Fqt4F2mgAOHrVYHprnUCpND05YwHDIGUS2PvO4joQYDBW4Ch aj5oGrz0pNIn8hz/0XRnAywvZZWiyoL76RH8wa+SJegU8z2s//pfJKKwNnPyaE3YmCSO uSbAVEVNTDQ35BZcoiOCxN1/nzz9TMpIxOvlspAL302Jlxq4cPkF326iI0HutSbqTbe4 XAG3pKnQfNK9TMeWamypF1ABqyfkT1df1Rh8/bjbd4eT8X5xh5/LsiXBntiMuNrpk074 Y99Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=50IpS0zXCaueIIG4d8jUtXLPD8HLM/XxmrpezXDvf3I=; b=ragMjboZ45+kkzmddLS8fwCKylRw3LEcw30MRHSvlbeVp2uEBBjJV18V6JXgJ/eitM GFfNpr5+dWNtgTMsn0aTBue/bH+s0jST4XcKhnKnuRiZk6OsF9L7cQpOUTo45ffmbQ+0 Qn+6BIYVFCuC/gbZD8jcy2i4Z0HzuRR4Yp2wNuBIF4Hiq6ZpIduLhNTMNYQHtUkGUQzk twJG4osJxv+umGTvJmjQz2iyUJRqHv4vi+ha+Gasm5WBgKp3IoUXtsQ6507E4VPOPVPZ Haw3T50VYRhoMzADT9POOrDP350Nr2JWGP7tTKPZpsJX5UpVuophuTncOtRPZ/R5uNDF T8YQ== X-Gm-Message-State: AJaThX7YftxeAKzOusHj1i2h6VXdFSAA9TReUmuz6z7jvuhSrH4m8Q59 HABt1q0xNn30uWhMLMgk7STfatvv X-Google-Smtp-Source: AGs4zMYqPYHc3a4BVVI0Au+OUgMmgsxJGvhSYhsYAg3fH5btMmw+mQvlXWiNLPkyUtB0XftkzXPRZQ== X-Received: by 10.98.144.141 with SMTP id q13mr12544526pfk.140.1511620879896; Sat, 25 Nov 2017 06:41:19 -0800 (PST) Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id z86sm46398318pff.4.2017.11.25.06.41.19 for <27782 <at> debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Nov 2017 06:41:19 -0800 (PST) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: bug#27782: mmap for guile Date: Sat, 25 Nov 2017 06:41:17 -0800 References: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> <CAPjoZoeWyRx5_eTogzhuUbARZyPtp4OsbCjtGnkp_TGvYfkfag@HIDDEN> <D32D387D-D1B1-433D-B791-ACDB6859E38D@HIDDEN> To: 27782 <at> debbugs.gnu.org In-Reply-To: <D32D387D-D1B1-433D-B791-ACDB6859E38D@HIDDEN> Message-Id: <3F4AACD7-3278-4C4B-90D4-56BCDE5043F6@HIDDEN> X-Mailer: Apple Mail (2.3273) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 27782 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) here is a start on test-suite/tests/mmap.test +;;;; mmap.test --- test suite for Guile's mmap functions -*- scheme -*- +;;;; + +(define-module (test-mmap) + #:use-module (test-suite lib)) + +(use-modules (rnrs bytevectors)) + +(with-test-prefix "mmap" + + (pass-if "basics" + (let* ((siz #x10000) + (reg (mmap 0 siz))) + (and (eqv? (bytevector-length reg) siz) + (begin (bytevector-u8-set! reg 0 99) + (eqv? (bytevector-u8-ref reg 0) 99)) + (begin (bytevector-u8-set! reg (1- siz) 98) + (eqv? (bytevector-u8-ref reg (1- siz)) 98)) + #t))) + + ) + +;;;; --- last line ---
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 24 Nov 2017 17:09:44 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 12:09:44 2017 Received: from localhost ([127.0.0.1]:56238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1eIHTz-0004Rf-PL for submit <at> debbugs.gnu.org; Fri, 24 Nov 2017 12:09:44 -0500 Received: from mail-pg0-f52.google.com ([74.125.83.52]:43201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1eIHTx-0004RP-Kf for 27782 <at> debbugs.gnu.org; Fri, 24 Nov 2017 12:09:42 -0500 Received: by mail-pg0-f52.google.com with SMTP id r12so15666463pgu.10 for <27782 <at> debbugs.gnu.org>; Fri, 24 Nov 2017 09:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=3x9ftzPvouWiFDG9/Sp1S9Dt4Yx4DFpMGHCcvIRfb64=; b=b1HLjTEcU0GP229FQ/GtzaegTB6X9Ju7APQKbBDzHDDL5ghCc51WopYQCWmyF16voz KOMfcrjgjJ4eIC7CcIl+Wwfy6sC53bphRUOh+rCNQ7UIXiU9mMzKAApHrXOB1vu+mWTp quxg/btxhTuNdwc09BJOxMJAfc3EqokgmfnVrP/AEw6LozCND92u5ttuETVLD0CcpTG7 QE02fnvtRs98MaCLuol9coeQi8h5NpAEDmI/R+pb1bdegsHA5bMJxvqwp5jm24KFj/Us I9ItpM7zob9Sidd6QYSksO46oO7GDHSkUxlFtsBrYi753MI5FCowGSKn/1OhmbwpEatU 0peg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=3x9ftzPvouWiFDG9/Sp1S9Dt4Yx4DFpMGHCcvIRfb64=; b=iuq3yjBr29MezrRbu8HiK9bXH4UnSxyIluTPtglWqTbx0d7cOeJHP4a5kU+F7YZjKu DwKz5FU/iugTNCkjNHZ9/uglzk5b1U0c1a/0MFa4SVruLZQnVi8RGd2IeAb4ukv0l2SP ejbiOjhjEjQ1Dskimu2mR2LMeFDCqTnCYY1RktpOVAYq+kWsjN29Zm2kJBQG/z51Fw0N WkWD8z+pSdGQ6LPRRGTkumUzzjgbcvj62YIbwq7ctyCz5AznQnyMAFMhgjiq5w2Cbzfe QDig3dGNSnpw7Ctz4zYwRhJHsUE8N72U/xLeR/WBjb6URnt0uRdR0igz3XI3WE7POqwQ kFTA== X-Gm-Message-State: AJaThX755fCZpC69fui65Fp19oR5HMMQZj/2NIrcjMHGyxshOKF/bWbx fhv55XmYS+rg7QEr+NFNV9U= X-Google-Smtp-Source: AGs4zMZyU2SN2669cuswEeADZ0DWQcwWtG6oz08ubjByOtXisgKtqx0ojxmo37sTEQKdQQ+1f4ShOQ== X-Received: by 10.99.114.30 with SMTP id n30mr28526846pgc.129.1511543375703; Fri, 24 Nov 2017 09:09:35 -0800 (PST) Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id m87sm27843812pfi.88.2017.11.24.09.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 09:09:34 -0800 (PST) From: Matt Wette <matt.wette@HIDDEN> Message-Id: <D32D387D-D1B1-433D-B791-ACDB6859E38D@HIDDEN> Content-Type: multipart/alternative; boundary="Apple-Mail=_705C18C9-0341-466A-9392-6E7A4A94B270" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: bug#27782: mmap for guile Date: Fri, 24 Nov 2017 09:09:33 -0800 In-Reply-To: <CAPjoZoeWyRx5_eTogzhuUbARZyPtp4OsbCjtGnkp_TGvYfkfag@HIDDEN> To: Nala Ginrut <nalaginrut@HIDDEN> References: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> <CAPjoZoeWyRx5_eTogzhuUbARZyPtp4OsbCjtGnkp_TGvYfkfag@HIDDEN> X-Mailer: Apple Mail (2.3273) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 27782 Cc: 27782 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) --Apple-Mail=_705C18C9-0341-466A-9392-6E7A4A94B270 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 got it. > On Nov 24, 2017, at 8:22 AM, Nala Ginrut <nalaginrut@HIDDEN> wrote: >=20 > Thanks for the work! Could you please add MAP_POPULATE too? >=20 > 2017=E5=B9=B411=E6=9C=8824=E6=97=A5 =E4=B8=8B=E5=8D=8811:55=EF=BC=8C"Mat= t Wette" <matt.wette@HIDDEN <mailto:matt.wette@HIDDEN>>=E5=86=99=E9=81= =93=EF=BC=9A >=20 >=20 >=20 >=20 >=20 > I did a little more on this. Here is the latest. > It provides mmap (not searched) and mmap/search (searched for pointers = to GC). >=20 >=20 > --- libguile/filesys.c.orig 2017-03-01 10:54:31.000000000 -0800 > +++ libguile/filesys.c 2017-10-28 10:05:10.000000000 -0700 > @@ -1828,9 +1828,14 @@ >=20 >=20 >=20 > +#include "mman.c" > + > void > scm_init_filesys () > { > +#ifdef HAVE_SYS_MMAN_H > + init_mman(); > +#endif > #ifdef HAVE_POSIX > scm_tc16_dir =3D scm_make_smob_type ("directory", 0); > scm_set_smob_free (scm_tc16_dir, scm_dir_free); > --- libguile/mman.c.orig 2017-10-28 10:05:10.000000000 -0700 > +++ libguile/mman.c 2017-11-04 09:23:35.000000000 -0700 > @@ -0,0 +1,199 @@ > +// mman.c - v171104a > +#ifdef HAVE_CONFIG_H > +# include <config.h> > +#endif > + > +#ifdef HAVE_SYS_MMAN_H > +# include <sys/mman.h> > +# include <errno.h> > +#endif > + > +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) > + > +#include "libguile/_scm.h" > +#include "libguile/smob.h" > +#include "libguile/fdes-finalizers.h" > +#include "libguile/feature.h" > + > +SCM_API SCM scm_mmap_search (SCM addr, SCM len, SCM prot, SCM flags, = SCM fd, > + SCM offset); > +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, > + SCM offset); > +SCM_API SCM scm_munmap (SCM bvec); > +void init_mman(void); > +static void mmap_finalizer (void *ptr, void *data); > + > +SCM_DEFINE (scm_mmap_search, "mmap/search", 2, 4, 0, > + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), > + "mmap addr len [prot [flags [fd [offset]]]]" > + "See the unix man page for mmap. Returns a bytevector." > + "Note that the region allocated will be searched by the = garbage" > + "collector for pointers. \n" > + " Defaults:\n" > + " PROT (logior PROT_READ PROT_WRITE)\n" > + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" > + " FD -1\n" > + " OFFSET 0\n" > + "@example\n(define reg (mmap/search %null-pointer = #x1000)\n" > + "@end example" > + ) > +#define FUNC_NAME s_scm_mmap_search > +{ > + void *c_mem, *c_addr; > + size_t c_len; > + int c_prot, c_flags, c_fd; > + scm_t_off c_offset; > + SCM pointer, bvec; > + > + if (SCM_POINTER_P (addr)) > + c_addr =3D SCM_POINTER_VALUE (addr); > + else if (scm_is_integer (addr)) > + c_addr =3D (void*) scm_to_uintptr_t (addr); > + else > + SCM_MISC_ERROR("bad addr", addr); > + > + c_len =3D scm_to_size_t (len); > + > + if (SCM_UNBNDP (prot)) > + c_prot =3D PROT_READ | PROT_WRITE; > + else > + c_prot =3D scm_to_int (prot); > + > + if (SCM_UNBNDP (flags)) > + c_flags =3D MAP_ANON | MAP_PRIVATE; > + else > + c_flags =3D scm_to_int (flags); > + > + if (SCM_UNBNDP (fd)) > + c_fd =3D -1; > + else > + c_fd =3D scm_to_int (fd); > + > + if (SCM_UNBNDP (fd)) > + c_offset =3D 0; > + else > + c_offset =3D scm_to_off_t (offset); > + > + c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); > + if (c_mem =3D=3D MAP_FAILED) > + SCM_SYSERROR; /* errno set */ > + > + pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem); > + bvec =3D scm_c_take_typed_bytevector((signed char *) c_mem + = c_offset, c_len, > + SCM_ARRAY_ELEMENT_TYPE_VU8, = pointer); > + /* if sizeof(void*) < sizeof(size_t) we are in trouble: */ > + scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) = c_len); > + return bvec; > +} > +#undef FUNC_NAME > + > +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0, > + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), > + "mmap addr len [prot [flags [fd [offset]]]]" > + "See the man page. Returns a bytevector." > + "Note that the region returned by mmap will NOT be = searched " > + "by the garbage collector for pointers.\n" > + "Defaults:\n" > + " PROT (logior PROT_READ PROT_WRITE)\n" > + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" > + " FD -1\n" > + " OFFSET 0\n" > + "@example\n" > + "(define bvec-1MB (mmap 0 #x100000)\n" > + "@end example" > + ) > +#define FUNC_NAME s_scm_mmap > +{ > + SCM bvec; > + void *c_mem; > + size_t c_len; > + > + bvec =3D scm_mmap_search(addr, len, prot, flags, fd, offset); > + c_mem =3D SCM_BYTEVECTOR_CONTENTS(bvec); > + c_len =3D SCM_BYTEVECTOR_LENGTH(bvec); > + > + /* tell GC not to scan for pointers */ > + GC_exclude_static_roots(c_mem, (char*) c_mem + c_len); > + > + return bvec; > +} > +static void > +mmap_finalizer (void *ptr, void *data) > +{ > + void *c_addr; > + intptr_t c_len; > + int res; > + > + c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER (ptr)); > + c_len =3D (intptr_t) data; > + res =3D munmap(c_addr, c_len); > + if (res !=3D 0) SCM_SYSERROR; > +} > +#undef FUNC_NAME > + > +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0, > + (SCM bvec), > + "See the man page. Given bytevector unmap." > + ) > +#define FUNC_NAME s_scm_munmap > +{ > + void *c_addr; > + size_t c_len; > + int c_res; > + > + SCM_VALIDATE_BYTEVECTOR (1, bvec); > + > + c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec); > + c_len =3D SCM_BYTEVECTOR_LENGTH (bvec); > + > + c_res =3D munmap(c_addr, c_len); > + if (c_res =3D=3D -1) > + SCM_SYSERROR; /* errno set */ > + > + // TODO: clean up bytevector > + return SCM_UNSPECIFIED; > +} > +#undef FUNC_NAME > + > +void init_mman(void) { > +#ifdef PROT_NONE > + scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); > +#endif > + > +#ifdef MAP_ANONYMOUS > + scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); > +#endif > +#ifdef MAP_ANON > + scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON)); > +#endif > +#ifdef MAP_FILE > + scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE)); > +#endif > +#ifdef MAP_FIXED > + scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED)); > +#endif > +#ifdef MAP_HASSEMAPHORE > + scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSEMAPHORE)); > +#endif > +#ifdef MAP_PRIVATE > + scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE)); > +#endif > +#ifdef MAP_SHARED > + scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED)); > +#endif > +#ifdef MAP_NOCACHE > + scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE)); > +#endif > + scm_c_define ("PAGE_SIZE", scm_from_int (getpagesize())); > +} > + > +#endif /* HAVE_SYS_MMAN_H */ >=20 >=20 >=20 >=20 --Apple-Mail=_705C18C9-0341-466A-9392-6E7A4A94B270 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = class=3D"">got it.<div class=3D""><br class=3D""><div><blockquote = type=3D"cite" class=3D""><div class=3D"">On Nov 24, 2017, at 8:22 AM, = Nala Ginrut <<a href=3D"mailto:nalaginrut@HIDDEN" = class=3D"">nalaginrut@HIDDEN</a>> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""><div dir=3D"auto" = class=3D"">Thanks for the work! Could you please add <span = style=3D"color:rgb(85,85,85);font-family:verdana,"bitstream vera = sans",tahoma,helvetica,sans-serif;font-size:21.5951px;background-colo= r:rgb(255,255,255)" class=3D"">MAP_POPULATE too?</span></div><div = class=3D"gmail_extra"><br class=3D""><div = class=3D"gmail_quote">2017=E5=B9=B411=E6=9C=8824=E6=97=A5 = =E4=B8=8B=E5=8D=8811:55=EF=BC=8C"Matt Wette" <<a = href=3D"mailto:matt.wette@HIDDEN" = class=3D"">matt.wette@HIDDEN</a>>=E5=86=99=E9=81=93=EF=BC=9A<br = type=3D"attribution" class=3D""><blockquote class=3D"gmail_quote" = style=3D"margin:0 0 0 .8ex;border-left:1px #ccc = solid;padding-left:1ex"><br class=3D""> <br class=3D""> <br class=3D""> <br class=3D""> <br class=3D""> I did a little more on this. Here is the latest.<br class=3D""> It provides mmap (not searched) and mmap/search (searched for pointers = to GC).<br class=3D""> <br class=3D""> <br class=3D""> --- libguile/filesys.c.orig 2017-03-01 = 10:54:31.000000000 -0800<br class=3D""> +++ libguile/filesys.c 2017-10-28 10:05:10.000000000 -0700<br = class=3D""> @@ -1828,9 +1828,14 @@<br class=3D""> <br class=3D""> <br class=3D""> <br class=3D""> +#include "mman.c"<br class=3D""> +<br class=3D""> void<br class=3D""> scm_init_filesys ()<br class=3D""> {<br class=3D""> +#ifdef HAVE_SYS_MMAN_H<br class=3D""> + init_mman();<br class=3D""> +#endif<br class=3D""> #ifdef HAVE_POSIX<br class=3D""> scm_tc16_dir =3D scm_make_smob_type ("directory", 0);<br = class=3D""> scm_set_smob_free (scm_tc16_dir, scm_dir_free);<br = class=3D""> --- libguile/mman.c.orig 2017-10-28 = 10:05:10.000000000 -0700<br class=3D""> +++ libguile/mman.c 2017-11-04 09:23:35.000000000 = -0700<br class=3D""> @@ -0,0 +1,199 @@<br class=3D""> +// mman.c - v171104a<br class=3D""> +#ifdef HAVE_CONFIG_H<br class=3D""> +# include <config.h><br class=3D""> +#endif<br class=3D""> +<br class=3D""> +#ifdef HAVE_SYS_MMAN_H<br class=3D""> +# include <sys/mman.h><br class=3D""> +# include <errno.h><br class=3D""> +#endif<br class=3D""> +<br class=3D""> +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS)<br = class=3D""> +<br class=3D""> +#include "libguile/_scm.h"<br class=3D""> +#include "libguile/smob.h"<br class=3D""> +#include "libguile/fdes-finalizers.h"<br class=3D""> +#include "libguile/feature.h"<br class=3D""> +<br class=3D""> +SCM_API SCM scm_mmap_search (SCM addr, SCM len, SCM prot, SCM flags, = SCM fd,<br class=3D""> + = SCM offset);<br class=3D""> +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM = fd,<br class=3D""> + = SCM offset);<br class=3D""> +SCM_API SCM scm_munmap (SCM bvec);<br class=3D""> +void init_mman(void);<br class=3D""> +static void mmap_finalizer (void *ptr, void *data);<br class=3D""> +<br class=3D""> +SCM_DEFINE (scm_mmap_search, "mmap/search", 2, 4, 0,<br class=3D""> + (SCM addr, SCM len, SCM prot, = SCM flags, SCM fd, SCM offset),<br class=3D""> + "mmap addr len [prot [flags = [fd [offset]]]]"<br class=3D""> + "See the unix man page for = mmap. Returns a bytevector."<br class=3D""> + "Note that the region = allocated will be searched by the garbage"<br class=3D""> + "collector for pointers. = \n"<br class=3D""> + " Defaults:\n"<br class=3D""> + " PROT = (logior PROT_READ PROT_WRITE)\n"<br class=3D""> + " FLAGS (logior = MAP_ANON MAP_PRIVATE)\n"<br class=3D""> + " FD = -1\n"<br class=3D""> + " OFFSET 0\n"<br = class=3D""> + "@example\n(define reg = (mmap/search %null-pointer #x1000)\n"<br class=3D""> + "@end example"<br class=3D""> + )<br class=3D""> +#define FUNC_NAME s_scm_mmap_search<br class=3D""> +{<br class=3D""> + void *c_mem, *c_addr;<br class=3D""> + size_t c_len;<br class=3D""> + int c_prot, c_flags, c_fd;<br class=3D""> + scm_t_off c_offset;<br class=3D""> + SCM pointer, bvec;<br class=3D""> +<br class=3D""> + if (SCM_POINTER_P (addr))<br class=3D""> + c_addr =3D SCM_POINTER_VALUE (addr);<br class=3D""> + else if (scm_is_integer (addr))<br class=3D""> + c_addr =3D (void*) scm_to_uintptr_t (addr);<br class=3D""> + else<br class=3D""> + SCM_MISC_ERROR("bad addr", addr);<br class=3D""> +<br class=3D""> + c_len =3D scm_to_size_t (len);<br class=3D""> +<br class=3D""> + if (SCM_UNBNDP (prot))<br class=3D""> + c_prot =3D PROT_READ | PROT_WRITE;<br class=3D""> + else<br class=3D""> + c_prot =3D scm_to_int (prot);<br class=3D""> +<br class=3D""> + if (SCM_UNBNDP (flags))<br class=3D""> + c_flags =3D MAP_ANON | MAP_PRIVATE;<br class=3D""> + else<br class=3D""> + c_flags =3D scm_to_int (flags);<br class=3D""> +<br class=3D""> + if (SCM_UNBNDP (fd))<br class=3D""> + c_fd =3D -1;<br class=3D""> + else<br class=3D""> + c_fd =3D scm_to_int (fd);<br class=3D""> +<br class=3D""> + if (SCM_UNBNDP (fd))<br class=3D""> + c_offset =3D 0;<br class=3D""> + else<br class=3D""> + c_offset =3D scm_to_off_t (offset);<br class=3D""> +<br class=3D""> + c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, = c_offset);<br class=3D""> + if (c_mem =3D=3D MAP_FAILED)<br class=3D""> + SCM_SYSERROR; = /* errno set */<br class=3D""> +<br class=3D""> + pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem);<br = class=3D""> + bvec =3D scm_c_take_typed_bytevector((<wbr class=3D"">signed = char *) c_mem + c_offset, c_len,<br class=3D""> + = = SCM_ARRAY_ELEMENT_TYPE_VU8, pointer);<br class=3D""> + /* if sizeof(void*) < sizeof(size_t) we are in trouble: */<br = class=3D""> + scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) = c_len);<br class=3D""> + return bvec;<br class=3D""> +}<br class=3D""> +#undef FUNC_NAME<br class=3D""> +<br class=3D""> +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0,<br class=3D""> + (SCM addr, SCM len, SCM prot, = SCM flags, SCM fd, SCM offset),<br class=3D""> + "mmap addr len [prot [flags = [fd [offset]]]]"<br class=3D""> + "See the man page. = Returns a bytevector."<br class=3D""> + "Note that the region returned = by mmap will NOT be searched "<br class=3D""> + "by the garbage collector for = pointers.\n"<br class=3D""> + "Defaults:\n"<br class=3D""> + " PROT = (logior PROT_READ PROT_WRITE)\n"<br class=3D""> + " FLAGS (logior = MAP_ANON MAP_PRIVATE)\n"<br class=3D""> + " FD = -1\n"<br class=3D""> + " OFFSET 0\n"<br = class=3D""> + "@example\n"<br class=3D""> + "(define bvec-1MB (mmap 0 = #x100000)\n"<br class=3D""> + "@end example"<br class=3D""> + )<br class=3D""> +#define FUNC_NAME s_scm_mmap<br class=3D""> +{<br class=3D""> + SCM bvec;<br class=3D""> + void *c_mem;<br class=3D""> + size_t c_len;<br class=3D""> +<br class=3D""> + bvec =3D scm_mmap_search(addr, len, prot, flags, fd, offset);<br = class=3D""> + c_mem =3D SCM_BYTEVECTOR_CONTENTS(bvec);<br class=3D""> + c_len =3D SCM_BYTEVECTOR_LENGTH(bvec);<br class=3D""> +<br class=3D""> + /* tell GC not to scan for pointers */<br class=3D""> + GC_exclude_static_roots(c_mem, (char*) c_mem + c_len);<br = class=3D""> +<br class=3D""> + return bvec;<br class=3D""> +}<br class=3D""> +static void<br class=3D""> +mmap_finalizer (void *ptr, void *data)<br class=3D""> +{<br class=3D""> + void *c_addr;<br class=3D""> + intptr_t c_len;<br class=3D""> + int res;<br class=3D""> +<br class=3D""> + c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER = (ptr));<br class=3D""> + c_len =3D (intptr_t) data;<br class=3D""> + res =3D munmap(c_addr, c_len);<br class=3D""> + if (res !=3D 0) SCM_SYSERROR;<br class=3D""> +}<br class=3D""> +#undef FUNC_NAME<br class=3D""> +<br class=3D""> +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0,<br class=3D""> + (SCM bvec),<br class=3D""> + "See the man page. Given = bytevector unmap."<br class=3D""> + )<br class=3D""> +#define FUNC_NAME s_scm_munmap<br class=3D""> +{<br class=3D""> + void *c_addr;<br class=3D""> + size_t c_len;<br class=3D""> + int c_res;<br class=3D""> +<br class=3D""> + SCM_VALIDATE_BYTEVECTOR (1, bvec);<br class=3D""> +<br class=3D""> + c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec);<br class=3D"">= + c_len =3D SCM_BYTEVECTOR_LENGTH (bvec);<br class=3D""> +<br class=3D""> + c_res =3D munmap(c_addr, c_len);<br class=3D""> + if (c_res =3D=3D -1)<br class=3D""> + SCM_SYSERROR; = /* errno set */<br class=3D""> +<br class=3D""> + // TODO: clean up bytevector<br class=3D""> + return SCM_UNSPECIFIED;<br class=3D""> +}<br class=3D""> +#undef FUNC_NAME<br class=3D""> +<br class=3D""> +void init_mman(void) {<br class=3D""> +#ifdef PROT_NONE<br class=3D""> + scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE));<br = class=3D""> +#endif<br class=3D""> +#ifdef PROT_<br class=3D""> + scm_c_define ("PROT_READ", scm_from_int (PROT_READ));<br = class=3D""> +#endif<br class=3D""> +#ifdef PROT_<br class=3D""> + scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE));<br = class=3D""> +#endif<br class=3D""> +#ifdef PROT_<br class=3D""> + scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC));<br = class=3D""> +#endif<br class=3D""> +<br class=3D""> +#ifdef MAP_ANONYMOUS<br class=3D""> + scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS));<br = class=3D""> +#endif<br class=3D""> +#ifdef MAP_ANON<br class=3D""> + scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON));<br class=3D"">= +#endif<br class=3D""> +#ifdef MAP_FILE<br class=3D""> + scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE));<br class=3D"">= +#endif<br class=3D""> +#ifdef MAP_FIXED<br class=3D""> + scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED));<br = class=3D""> +#endif<br class=3D""> +#ifdef MAP_HASSEMAPHORE<br class=3D""> + scm_c_define ("MAP_HASSEMAPHORE", scm_from_int = (MAP_HASSEMAPHORE));<br class=3D""> +#endif<br class=3D""> +#ifdef MAP_PRIVATE<br class=3D""> + scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE));<br = class=3D""> +#endif<br class=3D""> +#ifdef MAP_SHARED<br class=3D""> + scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED));<br = class=3D""> +#endif<br class=3D""> +#ifdef MAP_NOCACHE<br class=3D""> + scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE));<br = class=3D""> +#endif<br class=3D""> + scm_c_define ("PAGE_SIZE", scm_from_int (getpagesize()));<br = class=3D""> +}<br class=3D""> +<br class=3D""> +#endif /* HAVE_SYS_MMAN_H */<br class=3D""> <br class=3D""> <br class=3D""> <br class=3D""> <br class=3D""> </blockquote></div></div> </div></blockquote></div><br class=3D""></div></body></html>= --Apple-Mail=_705C18C9-0341-466A-9392-6E7A4A94B270--
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 24 Nov 2017 16:22:23 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 11:22:23 2017 Received: from localhost ([127.0.0.1]:56157 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1eIGkA-0003Bs-KB for submit <at> debbugs.gnu.org; Fri, 24 Nov 2017 11:22:23 -0500 Received: from mail-yb0-f176.google.com ([209.85.213.176]:34521) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <nalaginrut@HIDDEN>) id 1eIGk8-0003Bg-Uq for 27782 <at> debbugs.gnu.org; Fri, 24 Nov 2017 11:22:21 -0500 Received: by mail-yb0-f176.google.com with SMTP id k40so8430722ybj.1 for <27782 <at> debbugs.gnu.org>; Fri, 24 Nov 2017 08:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=V4cNgaurF9cbLgMRZmHUoQM3RX8Y/QYV84MN32xzCsg=; b=JF6Z0JXdPdLp1Q/h0DbzxezfuaVWKxWWL9CNto/+dsXm0bFuF/CveYxUqDZ3tf7fgY xnqvHFplgJhQheWEzgy5s6fQR1ZssK5ZHKKi+j7HQFvF4le8Ihjz98MX/TW3xDEKjegJ K5LwCREhVjOdrPAc7IslTFSLqfyNVX/bzQBrhfnE1ecKih3QwZ5TGlY0rY6QXHyLC02C PbuSryUJcGU7h5VIx8UWOdNMYERNNSWabl0i9X3jEibe/k4TycA3DH19tz5Fu9yF4Q2d YWLXDO8ZbZozqj1NFw0fZp4v5slejLOpwi2MNj2IsG1HuPUQ5nIfevpOncEunobqSX9W 9bLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=V4cNgaurF9cbLgMRZmHUoQM3RX8Y/QYV84MN32xzCsg=; b=rtLFBL53x64mbJSImLw+/zn20sD4aIv9tOQxR1w/pL7zetuPIGxriHZHLWQF1BYAD6 E9/fEXAt5a0R70tcYrv+7sndWUTz0rkBaAT3T1sWTGygWIMFZl4c+6Jq7P6OCPvtLfex LbHQD99PFyd+d/R3/QPXRyCzX7nBYCnv5DuulDHMWp/5u1ggKXjCtOuaX6ndb/XxtK/S hhtiC/+7zt8Fd77qLMrh3kdW3JEZeN6K/rT4tOHg23EgVRoV8vV3rN3huhEtee2K6fzZ 5WTD0vgoN1oW5olEgoV5ZwCpA/Mb80v45EhI79nz+fIyp1OrqHAhy3JazoHTQL33Y8c5 zMtw== X-Gm-Message-State: AJaThX4AoQCqh33kISUfW0lB+POTmort75K0QOcZBpPfEndLIlaUQK4i God0CAlFy5W+ZrSFA9jOY1uErIx9XMhtLiRfIb4= X-Google-Smtp-Source: AGs4zMbCRjNdA9OtECYp6MNvDlHrXJtASZYja55UYJ+XS9LvRKi2ce+vlQkPhvTVh6ZWUDb/r5aTwoQ+7ASamgUAXTk= X-Received: by 10.37.216.137 with SMTP id p131mr17613971ybg.397.1511540535249; Fri, 24 Nov 2017 08:22:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.45.94 with HTTP; Fri, 24 Nov 2017 08:22:14 -0800 (PST) Received: by 10.37.45.94 with HTTP; Fri, 24 Nov 2017 08:22:14 -0800 (PST) In-Reply-To: <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> References: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> From: Nala Ginrut <nalaginrut@HIDDEN> Date: Sat, 25 Nov 2017 00:22:14 +0800 Message-ID: <CAPjoZoeWyRx5_eTogzhuUbARZyPtp4OsbCjtGnkp_TGvYfkfag@HIDDEN> Subject: Re: bug#27782: mmap for guile To: Matt Wette <matt.wette@HIDDEN> Content-Type: multipart/alternative; boundary="94eb2c061e16aad101055ebcf4cd" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 27782 Cc: 27782 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) --94eb2c061e16aad101055ebcf4cd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the work! Could you please add MAP_POPULATE too? 2017=E5=B9=B411=E6=9C=8824=E6=97=A5 =E4=B8=8B=E5=8D=8811:55=EF=BC=8C"Matt W= ette" <matt.wette@HIDDEN>=E5=86=99=E9=81=93=EF=BC=9A > > > > > > I did a little more on this. Here is the latest. > It provides mmap (not searched) and mmap/search (searched for pointers to > GC). > > > --- libguile/filesys.c.orig 2017-03-01 10:54:31.000000000 -0800 > +++ libguile/filesys.c 2017-10-28 10:05:10.000000000 -0700 > @@ -1828,9 +1828,14 @@ > > > > +#include "mman.c" > + > void > scm_init_filesys () > { > +#ifdef HAVE_SYS_MMAN_H > + init_mman(); > +#endif > #ifdef HAVE_POSIX > scm_tc16_dir =3D scm_make_smob_type ("directory", 0); > scm_set_smob_free (scm_tc16_dir, scm_dir_free); > --- libguile/mman.c.orig 2017-10-28 10:05:10.000000000 -0700 > +++ libguile/mman.c 2017-11-04 09:23:35.000000000 -0700 > @@ -0,0 +1,199 @@ > +// mman.c - v171104a > +#ifdef HAVE_CONFIG_H > +# include <config.h> > +#endif > + > +#ifdef HAVE_SYS_MMAN_H > +# include <sys/mman.h> > +# include <errno.h> > +#endif > + > +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) > + > +#include "libguile/_scm.h" > +#include "libguile/smob.h" > +#include "libguile/fdes-finalizers.h" > +#include "libguile/feature.h" > + > +SCM_API SCM scm_mmap_search (SCM addr, SCM len, SCM prot, SCM flags, SCM > fd, > + SCM offset); > +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, > + SCM offset); > +SCM_API SCM scm_munmap (SCM bvec); > +void init_mman(void); > +static void mmap_finalizer (void *ptr, void *data); > + > +SCM_DEFINE (scm_mmap_search, "mmap/search", 2, 4, 0, > + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM offset)= , > + "mmap addr len [prot [flags [fd [offset]]]]" > + "See the unix man page for mmap. Returns a bytevector." > + "Note that the region allocated will be searched by the > garbage" > + "collector for pointers. \n" > + " Defaults:\n" > + " PROT (logior PROT_READ PROT_WRITE)\n" > + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" > + " FD -1\n" > + " OFFSET 0\n" > + "@example\n(define reg (mmap/search %null-pointer #x1000)\n" > + "@end example" > + ) > +#define FUNC_NAME s_scm_mmap_search > +{ > + void *c_mem, *c_addr; > + size_t c_len; > + int c_prot, c_flags, c_fd; > + scm_t_off c_offset; > + SCM pointer, bvec; > + > + if (SCM_POINTER_P (addr)) > + c_addr =3D SCM_POINTER_VALUE (addr); > + else if (scm_is_integer (addr)) > + c_addr =3D (void*) scm_to_uintptr_t (addr); > + else > + SCM_MISC_ERROR("bad addr", addr); > + > + c_len =3D scm_to_size_t (len); > + > + if (SCM_UNBNDP (prot)) > + c_prot =3D PROT_READ | PROT_WRITE; > + else > + c_prot =3D scm_to_int (prot); > + > + if (SCM_UNBNDP (flags)) > + c_flags =3D MAP_ANON | MAP_PRIVATE; > + else > + c_flags =3D scm_to_int (flags); > + > + if (SCM_UNBNDP (fd)) > + c_fd =3D -1; > + else > + c_fd =3D scm_to_int (fd); > + > + if (SCM_UNBNDP (fd)) > + c_offset =3D 0; > + else > + c_offset =3D scm_to_off_t (offset); > + > + c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); > + if (c_mem =3D=3D MAP_FAILED) > + SCM_SYSERROR; /* errno set */ > + > + pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem); > + bvec =3D scm_c_take_typed_bytevector((signed char *) c_mem + c_offset, > c_len, > + SCM_ARRAY_ELEMENT_TYPE_VU8, pointer)= ; > + /* if sizeof(void*) < sizeof(size_t) we are in trouble: */ > + scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) c_len); > + return bvec; > +} > +#undef FUNC_NAME > + > +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0, > + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM offset)= , > + "mmap addr len [prot [flags [fd [offset]]]]" > + "See the man page. Returns a bytevector." > + "Note that the region returned by mmap will NOT be searched " > + "by the garbage collector for pointers.\n" > + "Defaults:\n" > + " PROT (logior PROT_READ PROT_WRITE)\n" > + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" > + " FD -1\n" > + " OFFSET 0\n" > + "@example\n" > + "(define bvec-1MB (mmap 0 #x100000)\n" > + "@end example" > + ) > +#define FUNC_NAME s_scm_mmap > +{ > + SCM bvec; > + void *c_mem; > + size_t c_len; > + > + bvec =3D scm_mmap_search(addr, len, prot, flags, fd, offset); > + c_mem =3D SCM_BYTEVECTOR_CONTENTS(bvec); > + c_len =3D SCM_BYTEVECTOR_LENGTH(bvec); > + > + /* tell GC not to scan for pointers */ > + GC_exclude_static_roots(c_mem, (char*) c_mem + c_len); > + > + return bvec; > +} > +static void > +mmap_finalizer (void *ptr, void *data) > +{ > + void *c_addr; > + intptr_t c_len; > + int res; > + > + c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER (ptr)); > + c_len =3D (intptr_t) data; > + res =3D munmap(c_addr, c_len); > + if (res !=3D 0) SCM_SYSERROR; > +} > +#undef FUNC_NAME > + > +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0, > + (SCM bvec), > + "See the man page. Given bytevector unmap." > + ) > +#define FUNC_NAME s_scm_munmap > +{ > + void *c_addr; > + size_t c_len; > + int c_res; > + > + SCM_VALIDATE_BYTEVECTOR (1, bvec); > + > + c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec); > + c_len =3D SCM_BYTEVECTOR_LENGTH (bvec); > + > + c_res =3D munmap(c_addr, c_len); > + if (c_res =3D=3D -1) > + SCM_SYSERROR; /* errno set */ > + > + // TODO: clean up bytevector > + return SCM_UNSPECIFIED; > +} > +#undef FUNC_NAME > + > +void init_mman(void) { > +#ifdef PROT_NONE > + scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); > +#endif > +#ifdef PROT_ > + scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); > +#endif > + > +#ifdef MAP_ANONYMOUS > + scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); > +#endif > +#ifdef MAP_ANON > + scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON)); > +#endif > +#ifdef MAP_FILE > + scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE)); > +#endif > +#ifdef MAP_FIXED > + scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED)); > +#endif > +#ifdef MAP_HASSEMAPHORE > + scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSEMAPHORE)); > +#endif > +#ifdef MAP_PRIVATE > + scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE)); > +#endif > +#ifdef MAP_SHARED > + scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED)); > +#endif > +#ifdef MAP_NOCACHE > + scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE)); > +#endif > + scm_c_define ("PAGE_SIZE", scm_from_int (getpagesize())); > +} > + > +#endif /* HAVE_SYS_MMAN_H */ > > > > > --94eb2c061e16aad101055ebcf4cd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto">Thanks for the work! Could you please add=C2=A0<span styl= e=3D"color:rgb(85,85,85);font-family:verdana,"bitstream vera sans"= ;,tahoma,helvetica,sans-serif;font-size:21.5951px;background-color:rgb(255,= 255,255)">MAP_POPULATE too?</span></div><div class=3D"gmail_extra"><br><div= class=3D"gmail_quote">2017=E5=B9=B411=E6=9C=8824=E6=97=A5 =E4=B8=8B=E5=8D= =8811:55=EF=BC=8C"Matt Wette" <<a href=3D"mailto:matt.wette@gm= ail.com">matt.wette@HIDDEN</a>>=E5=86=99=E9=81=93=EF=BC=9A<br type=3D= "attribution"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;= border-left:1px #ccc solid;padding-left:1ex"><br> <br> <br> <br> <br> I did a little more on this.=C2=A0 Here is the latest.<br> It provides mmap (not searched) and mmap/search (searched for pointers to G= C).<br> <br> <br> --- libguile/filesys.c.orig=C2=A0 =C2=A0 =C2=A02017-03-01 10:54:31.00000000= 0 -0800<br> +++ libguile/filesys.c=C2=A0 2017-10-28 10:05:10.000000000 -0700<br> @@ -1828,9 +1828,14 @@<br> <br> <br> <br> +#include "mman.c"<br> +<br> =C2=A0void<br> =C2=A0scm_init_filesys ()<br> =C2=A0{<br> +#ifdef HAVE_SYS_MMAN_H<br> +=C2=A0 init_mman();<br> +#endif<br> =C2=A0#ifdef HAVE_POSIX<br> =C2=A0 =C2=A0scm_tc16_dir =3D scm_make_smob_type ("directory", 0)= ;<br> =C2=A0 =C2=A0scm_set_smob_free (scm_tc16_dir, scm_dir_free);<br> --- libguile/mman.c.orig=C2=A0 =C2=A0 =C2=A0 =C2=A0 2017-10-28 10:05:10.000= 000000 -0700<br> +++ libguile/mman.c=C2=A0 =C2=A0 =C2=A02017-11-04 09:23:35.000000000 -0700<= br> @@ -0,0 +1,199 @@<br> +// mman.c - v171104a<br> +#ifdef HAVE_CONFIG_H<br> +#=C2=A0 include <config.h><br> +#endif<br> +<br> +#ifdef HAVE_SYS_MMAN_H<br> +#=C2=A0 include <sys/mman.h><br> +#=C2=A0 include <errno.h><br> +#endif<br> +<br> +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS)<br> +<br> +#include "libguile/_scm.h"<br> +#include "libguile/smob.h"<br> +#include "libguile/fdes-finalizers.h"<br> +#include "libguile/feature.h"<br> +<br> +SCM_API SCM scm_mmap_search (SCM addr, SCM len, SCM prot, SCM flags, SCM f= d,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 SCM offset);<br> +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0SCM offset);<br> +SCM_API SCM scm_munmap (SCM bvec);<br> +void init_mman(void);<br> +static void mmap_finalizer (void *ptr, void *data);<br> +<br> +SCM_DEFINE (scm_mmap_search, "mmap/search", 2, 4, 0,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (SCM addr, SCM len, SCM prot, SC= M flags, SCM fd, SCM offset),<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"mmap addr len [prot [flags = [fd [offset]]]]"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"See the unix man page for m= map.=C2=A0 Returns a bytevector."<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Note that the region alloca= ted will be searched by the garbage"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"collector for pointers.=C2= =A0 \n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0" Defaults:\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 PROT=C2=A0 =C2=A0(lo= gior PROT_READ PROT_WRITE)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 FLAGS=C2=A0 (logior = MAP_ANON MAP_PRIVATE)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 FD=C2=A0 =C2=A0 =C2= =A0-1\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 OFFSET 0\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"@example\n(define reg (mmap= /search %null-pointer #x1000)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"@end example"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)<br> +#define FUNC_NAME s_scm_mmap_search<br> +{<br> +=C2=A0 void *c_mem, *c_addr;<br> +=C2=A0 size_t c_len;<br> +=C2=A0 int c_prot, c_flags, c_fd;<br> +=C2=A0 scm_t_off c_offset;<br> +=C2=A0 SCM pointer, bvec;<br> +<br> +=C2=A0 if (SCM_POINTER_P (addr))<br> +=C2=A0 =C2=A0 c_addr =3D SCM_POINTER_VALUE (addr);<br> +=C2=A0 else if (scm_is_integer (addr))<br> +=C2=A0 =C2=A0 c_addr =3D (void*) scm_to_uintptr_t (addr);<br> +=C2=A0 else<br> +=C2=A0 =C2=A0 SCM_MISC_ERROR("bad addr", addr);<br> +<br> +=C2=A0 c_len =3D scm_to_size_t (len);<br> +<br> +=C2=A0 if (SCM_UNBNDP (prot))<br> +=C2=A0 =C2=A0 c_prot =3D PROT_READ | PROT_WRITE;<br> +=C2=A0 else<br> +=C2=A0 =C2=A0 c_prot =3D scm_to_int (prot);<br> +<br> +=C2=A0 if (SCM_UNBNDP (flags))<br> +=C2=A0 =C2=A0 c_flags =3D MAP_ANON | MAP_PRIVATE;<br> +=C2=A0 else<br> +=C2=A0 =C2=A0 c_flags =3D scm_to_int (flags);<br> +<br> +=C2=A0 if (SCM_UNBNDP (fd))<br> +=C2=A0 =C2=A0 c_fd =3D -1;<br> +=C2=A0 else<br> +=C2=A0 =C2=A0 c_fd =3D scm_to_int (fd);<br> +<br> +=C2=A0 if (SCM_UNBNDP (fd))<br> +=C2=A0 =C2=A0 c_offset =3D 0;<br> +=C2=A0 else<br> +=C2=A0 =C2=A0 c_offset =3D scm_to_off_t (offset);<br> +<br> +=C2=A0 c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset);<br> +=C2=A0 if (c_mem =3D=3D MAP_FAILED)<br> +=C2=A0 =C2=A0 SCM_SYSERROR;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* errno set */<br> +<br> +=C2=A0 pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem);<br> +=C2=A0 bvec =3D scm_c_take_typed_bytevector((<wbr>signed char *) c_mem + c= _offset, c_len,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SCM_ARRAY_ELEMENT_TYPE= _VU8, pointer);<br> +=C2=A0 /* if sizeof(void*) < sizeof(size_t) we are in trouble: */<br> +=C2=A0 scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) c_len)= ;<br> +=C2=A0 return bvec;<br> +}<br> +#undef FUNC_NAME<br> +<br> +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (SCM addr, SCM len, SCM prot, SC= M flags, SCM fd, SCM offset),<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"mmap addr len [prot [flags = [fd [offset]]]]"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"See the man page.=C2=A0 Ret= urns a bytevector."<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Note that the region return= ed by mmap will NOT be searched "<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"by the garbage collector fo= r pointers.\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Defaults:\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 PROT=C2=A0 =C2=A0(lo= gior PROT_READ PROT_WRITE)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 FLAGS=C2=A0 (logior = MAP_ANON MAP_PRIVATE)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 FD=C2=A0 =C2=A0 =C2= =A0-1\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"=C2=A0 OFFSET 0\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"@example\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"(define bvec-1MB (mmap 0 #x= 100000)\n"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"@end example"<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)<br> +#define FUNC_NAME s_scm_mmap<br> +{<br> +=C2=A0 SCM bvec;<br> +=C2=A0 void *c_mem;<br> +=C2=A0 size_t c_len;<br> +<br> +=C2=A0 bvec =3D scm_mmap_search(addr, len, prot, flags, fd, offset);<br> +=C2=A0 c_mem =3D SCM_BYTEVECTOR_CONTENTS(bvec);<br> +=C2=A0 c_len =3D SCM_BYTEVECTOR_LENGTH(bvec);<br> +<br> +=C2=A0 /* tell GC not to scan for pointers */<br> +=C2=A0 GC_exclude_static_roots(c_mem, (char*) c_mem + c_len);<br> +<br> +=C2=A0 return bvec;<br> +}<br> +static void<br> +mmap_finalizer (void *ptr, void *data)<br> +{<br> +=C2=A0 void *c_addr;<br> +=C2=A0 intptr_t c_len;<br> +=C2=A0 int res;<br> +<br> +=C2=A0 c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER (ptr));<br> +=C2=A0 c_len =3D (intptr_t) data;<br> +=C2=A0 res =3D munmap(c_addr, c_len);<br> +=C2=A0 if (res !=3D 0) SCM_SYSERROR;<br> +}<br> +#undef FUNC_NAME<br> +<br> +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0,<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (SCM bvec),<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"See the man page. Given byt= evector unmap."<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0)<br> +#define FUNC_NAME s_scm_munmap<br> +{<br> +=C2=A0 void *c_addr;<br> +=C2=A0 size_t c_len;<br> +=C2=A0 int c_res;<br> +<br> +=C2=A0 SCM_VALIDATE_BYTEVECTOR (1, bvec);<br> +<br> +=C2=A0 c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec);<br> +=C2=A0 c_len =3D SCM_BYTEVECTOR_LENGTH (bvec);<br> +<br> +=C2=A0 c_res =3D munmap(c_addr, c_len);<br> +=C2=A0 if (c_res =3D=3D -1)<br> +=C2=A0 =C2=A0 SCM_SYSERROR;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* errno set */<br> +<br> +=C2=A0 // TODO: clean up bytevector<br> +=C2=A0 return SCM_UNSPECIFIED;<br> +}<br> +#undef FUNC_NAME<br> +<br> +void init_mman(void) {<br> +#ifdef PROT_NONE<br> +=C2=A0 scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE));<br> +#endif<br> +#ifdef PROT_<br> +=C2=A0 scm_c_define ("PROT_READ", scm_from_int (PROT_READ));<br> +#endif<br> +#ifdef PROT_<br> +=C2=A0 scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE));<b= r> +#endif<br> +#ifdef PROT_<br> +=C2=A0 scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC));<br> +#endif<br> +<br> +#ifdef MAP_ANONYMOUS<br> +=C2=A0 scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOU= S));<br> +#endif<br> +#ifdef MAP_ANON<br> +=C2=A0 scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON));<br> +#endif<br> +#ifdef MAP_FILE<br> +=C2=A0 scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE));<br> +#endif<br> +#ifdef MAP_FIXED<br> +=C2=A0 scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED));<br> +#endif<br> +#ifdef MAP_HASSEMAPHORE<br> +=C2=A0 scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSE= MAPHORE));<br> +#endif<br> +#ifdef MAP_PRIVATE<br> +=C2=A0 scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE));= <br> +#endif<br> +#ifdef MAP_SHARED<br> +=C2=A0 scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED));<b= r> +#endif<br> +#ifdef MAP_NOCACHE<br> +=C2=A0 scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE));= <br> +#endif<br> +=C2=A0 scm_c_define ("PAGE_SIZE", scm_from_int (getpagesize()));= <br> +}<br> +<br> +#endif /* HAVE_SYS_MMAN_H */<br> <br> <br> <br> <br> </blockquote></div></div> --94eb2c061e16aad101055ebcf4cd--
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 24 Nov 2017 15:54:20 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 10:54:20 2017 Received: from localhost ([127.0.0.1]:56132 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1eIGJ1-0002W2-Kt for submit <at> debbugs.gnu.org; Fri, 24 Nov 2017 10:54:19 -0500 Received: from mail-pg0-f43.google.com ([74.125.83.43]:39085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1eIGIz-0002Vp-BA for 27782 <at> debbugs.gnu.org; Fri, 24 Nov 2017 10:54:18 -0500 Received: by mail-pg0-f43.google.com with SMTP id 70so15541114pgf.6 for <27782 <at> debbugs.gnu.org>; Fri, 24 Nov 2017 07:54:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=8CHxkERYU2lWrfMn+NcDkTlhedhgfy/Ic7K4vFtOPKs=; b=Nbl6qMAawI4/uH4kSScN++r/lHLtIOeKIm8ZN/D+BpNmFQXXTK0xDR6QDnfJmnJWUo xvAfJbbedQfp3rSVtBC0mAfl5fyv3IX0OBQV0TAn3AbW22C+8nQZ5joC3BG1MHnWhlJ1 RvzeELZ5mWChPkwB1KkzkgIbdcsgh/bwh22D2usTvwdWoxiL0Njj8q9szTjH+2FhQKTO W1zVzBhGddJoKmJwxz0NmeochlHsv/nF2ZNtR2gMaIPobWLEhd23nKj4nEASFwT4J2HG DMU3aEl6anACoxtoutTzJx+bXVcWcT4OYjwNTCOKuE0IqI6xyDvxRZx5AnPtf00WVUJI 1OlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=8CHxkERYU2lWrfMn+NcDkTlhedhgfy/Ic7K4vFtOPKs=; b=l2Ux4mnLjNwnxdmDUokSs1XfZyr9E0VW1yaHT5t1rYekT6XVNK2liNkKhxbtbjGcxG hiFbYFVQ/mF1y5xd2DMoOv06Xs+swtPwYRW/kSckqbphM3NsuB/NNyas3/d9VT9+MBSy dGJk3mvwvyG4uPtrH+F1Fzv26TRE5H8f0GyvjOmUcpq8LaLyJp6GBap4CninE1AMeHjs H275lAMWfYhN5Og7MFnctbDFoZM7j5PPEZ59HVd8uDXqLjBTCs5hwkfSvdDWKe+EgGXc +Iexw6vs1sN7Vubuwph8c173wqJAUepNXEkLPc+oolGg3Xw1OG2czL7ImQPPjFytr8fp LrSQ== X-Gm-Message-State: AJaThX6qDRYTUUxp4dS3+qHFIb1/B8ZRigeXUfO/+6gwTfEAD/UvRAec 5OJg6CzSUVpT2/GCREFjtmiChR4W X-Google-Smtp-Source: AGs4zMbJgjTMh1nC15dtg9hMREjx7r7t7+PjrNIEvGmh/cXF0PgMPXpSxQcX/krxY+PJrPGRwyeucA== X-Received: by 10.101.80.8 with SMTP id f8mr8436813pgo.24.1511538850652; Fri, 24 Nov 2017 07:54:10 -0800 (PST) Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id o10sm25364361pgq.89.2017.11.24.07.54.09 for <27782 <at> debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 07:54:10 -0800 (PST) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: mmap for guile Message-Id: <D6FB4C4A-D4AB-421F-ADD5-CA8ECDA8F37E@HIDDEN> Date: Fri, 24 Nov 2017 07:54:07 -0800 To: 27782 <at> debbugs.gnu.org X-Mailer: Apple Mail (2.3273) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 27782 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.0 (/) I did a little more on this. Here is the latest. It provides mmap (not searched) and mmap/search (searched for pointers = to GC). --- libguile/filesys.c.orig 2017-03-01 10:54:31.000000000 -0800 +++ libguile/filesys.c 2017-10-28 10:05:10.000000000 -0700 @@ -1828,9 +1828,14 @@ =20 =0C =20 +#include "mman.c" + void scm_init_filesys () { +#ifdef HAVE_SYS_MMAN_H + init_mman(); +#endif #ifdef HAVE_POSIX scm_tc16_dir =3D scm_make_smob_type ("directory", 0); scm_set_smob_free (scm_tc16_dir, scm_dir_free); --- libguile/mman.c.orig 2017-10-28 10:05:10.000000000 -0700 +++ libguile/mman.c 2017-11-04 09:23:35.000000000 -0700 @@ -0,0 +1,199 @@ +// mman.c - v171104a +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_SYS_MMAN_H +# include <sys/mman.h> +# include <errno.h> +#endif + +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) + +#include "libguile/_scm.h" +#include "libguile/smob.h" +#include "libguile/fdes-finalizers.h" +#include "libguile/feature.h" + +SCM_API SCM scm_mmap_search (SCM addr, SCM len, SCM prot, SCM flags, = SCM fd, + SCM offset); +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, + SCM offset); +SCM_API SCM scm_munmap (SCM bvec); +void init_mman(void); +static void mmap_finalizer (void *ptr, void *data); + +SCM_DEFINE (scm_mmap_search, "mmap/search", 2, 4, 0,=20 + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), + "mmap addr len [prot [flags [fd [offset]]]]" + "See the unix man page for mmap. Returns a bytevector." + "Note that the region allocated will be searched by the = garbage" + "collector for pointers. \n" + " Defaults:\n" + " PROT (logior PROT_READ PROT_WRITE)\n" + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" + " FD -1\n" + " OFFSET 0\n" + "@example\n(define reg (mmap/search %null-pointer #x1000)\n" + "@end example" + ) +#define FUNC_NAME s_scm_mmap_search +{ + void *c_mem, *c_addr; + size_t c_len; + int c_prot, c_flags, c_fd; + scm_t_off c_offset; + SCM pointer, bvec; + + if (SCM_POINTER_P (addr)) + c_addr =3D SCM_POINTER_VALUE (addr); + else if (scm_is_integer (addr)) + c_addr =3D (void*) scm_to_uintptr_t (addr); + else + SCM_MISC_ERROR("bad addr", addr); + + c_len =3D scm_to_size_t (len); + =20 + if (SCM_UNBNDP (prot)) + c_prot =3D PROT_READ | PROT_WRITE; + else=20 + c_prot =3D scm_to_int (prot); + + if (SCM_UNBNDP (flags)) + c_flags =3D MAP_ANON | MAP_PRIVATE; + else + c_flags =3D scm_to_int (flags); + + if (SCM_UNBNDP (fd)) + c_fd =3D -1; + else + c_fd =3D scm_to_int (fd); + + if (SCM_UNBNDP (fd)) + c_offset =3D 0; + else + c_offset =3D scm_to_off_t (offset); + + c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); + if (c_mem =3D=3D MAP_FAILED) + SCM_SYSERROR; /* errno set */ + + pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem); + bvec =3D scm_c_take_typed_bytevector((signed char *) c_mem + = c_offset, c_len, + SCM_ARRAY_ELEMENT_TYPE_VU8, = pointer); + /* if sizeof(void*) < sizeof(size_t) we are in trouble: */ + scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) c_len); + return bvec; +} +#undef FUNC_NAME + +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0,=20 + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), + "mmap addr len [prot [flags [fd [offset]]]]" + "See the man page. Returns a bytevector." + "Note that the region returned by mmap will NOT be searched = " + "by the garbage collector for pointers.\n" + "Defaults:\n" + " PROT (logior PROT_READ PROT_WRITE)\n" + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" + " FD -1\n" + " OFFSET 0\n" + "@example\n" + "(define bvec-1MB (mmap 0 #x100000)\n" + "@end example" + ) +#define FUNC_NAME s_scm_mmap +{ + SCM bvec; + void *c_mem; + size_t c_len; + + bvec =3D scm_mmap_search(addr, len, prot, flags, fd, offset); + c_mem =3D SCM_BYTEVECTOR_CONTENTS(bvec); + c_len =3D SCM_BYTEVECTOR_LENGTH(bvec); + + /* tell GC not to scan for pointers */ + GC_exclude_static_roots(c_mem, (char*) c_mem + c_len); + + return bvec; +} +static void +mmap_finalizer (void *ptr, void *data) +{ + void *c_addr; + intptr_t c_len; + int res; + + c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER (ptr)); + c_len =3D (intptr_t) data; + res =3D munmap(c_addr, c_len); + if (res !=3D 0) SCM_SYSERROR; +} +#undef FUNC_NAME + +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0,=20 + (SCM bvec), + "See the man page. Given bytevector unmap." + ) +#define FUNC_NAME s_scm_munmap +{ + void *c_addr; + size_t c_len; + int c_res; + + SCM_VALIDATE_BYTEVECTOR (1, bvec); + =20 + c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec); + c_len =3D SCM_BYTEVECTOR_LENGTH (bvec); + + c_res =3D munmap(c_addr, c_len); + if (c_res =3D=3D -1) + SCM_SYSERROR; /* errno set */ + + // TODO: clean up bytevector + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME + +void init_mman(void) { +#ifdef PROT_NONE + scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); +#endif + +#ifdef MAP_ANONYMOUS + scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); +#endif +#ifdef MAP_ANON + scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON)); +#endif +#ifdef MAP_FILE + scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE)); +#endif +#ifdef MAP_FIXED + scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED)); +#endif +#ifdef MAP_HASSEMAPHORE + scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSEMAPHORE)); +#endif +#ifdef MAP_PRIVATE + scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE)); +#endif +#ifdef MAP_SHARED + scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED)); +#endif +#ifdef MAP_NOCACHE + scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE)); +#endif + scm_c_define ("PAGE_SIZE", scm_from_int (getpagesize())); +} + +#endif /* HAVE_SYS_MMAN_H */
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 28 Oct 2017 17:10:02 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 28 13:10:02 2017 Received: from localhost ([127.0.0.1]:39418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1e8UcT-0001HI-EK for submit <at> debbugs.gnu.org; Sat, 28 Oct 2017 13:10:02 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:48554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1e8UcR-0001H6-CA for 27782 <at> debbugs.gnu.org; Sat, 28 Oct 2017 13:09:59 -0400 Received: by mail-pg0-f49.google.com with SMTP id v78so7720578pgb.5 for <27782 <at> debbugs.gnu.org>; Sat, 28 Oct 2017 10:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=vrWA8FdyGEhjvlvR6CMPIZYqnbqc+an9Q5n0Fcq4H6k=; b=Fq6iZDvXdO9LfV5RdHzFoJGfozjT76//msK8upmZuZ3LrppiwNQkgnLL0p4Zz6roYy Ioqr/67r9FBsJl1AxlSxgfwblrzM3d4hYBUfU9hYxKCQBrWimwfPBiAwxIrVKQd0VthA ftkHudYSB1Kl4b/iPyInVnLfmjoxORmaXPaMJ4XsjMX2mtBZpxIx7vq40Nb87OAlvr/f p8QSD9y3xKsI+NLoUfVFiHQlCN89O0lLZCoAcuppqjiryAAZKwEt0wh/Isr72iZjt7x+ TpMtnsGs7xlsgw3Mb2YiO0B032YW0yjleCNfcKLIu2jBtyhLaE4iEHlKiU6rF7j1z7N4 8UhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=vrWA8FdyGEhjvlvR6CMPIZYqnbqc+an9Q5n0Fcq4H6k=; b=fOWE9EBJK6v2O/0vlDqqOiClck4Jm58t6KWRzHAiUJoXG8o5DaICBDxNMuWJVizYGA lFZfWYeP6xnFEIrVQe/hkVrDsd1KKKsU2OO8RwZlrx1bNoijzv+wcFIgHpo4kANKvuA2 s81AUuDnbUP06MTLfcb4S6rmyENx/9b0Q6HsyYH4gE81yrKXM4LnmGuCQQm+WtiYEEP9 RT0BBeUS7zm+A5bleW2MG5rYnhkMngPDTfoIxWuwJUuHD6oXs8ZudhlLu4REDHE7R68G W9Ujfudo/jAB07iVUWebOOAn73qILSV9nAmtMM/GOT0OJlEfh+9MoVJghptYdc4KqDH/ 2NWw== X-Gm-Message-State: AMCzsaX8O1ZezFjlcYFEJhZUnEW3r/sN1KlaiggPbmTcUu9JX6+sAejX etcouVUlUK51ug3hwwAFuKw6iYQT X-Google-Smtp-Source: ABhQp+RTomTqV0G7ZNRkLwaI3mLsiL+0r2z4cZ2RrAJ1obrYjP5sNp6G1/8BIEOiA2vxDR3af4GLcA== X-Received: by 10.98.80.69 with SMTP id e66mr3840485pfb.112.1509210593173; Sat, 28 Oct 2017 10:09:53 -0700 (PDT) Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id l22sm21413493pfk.45.2017.10.28.10.09.52 for <27782 <at> debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Oct 2017 10:09:52 -0700 (PDT) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: mmap for guile 2.2.2 Date: Sat, 28 Oct 2017 10:09:51 -0700 References: <68E9A19E-CC14-4FEF-96C3-4FCB6F6AD74A@HIDDEN> To: 27782 <at> debbugs.gnu.org In-Reply-To: <68E9A19E-CC14-4FEF-96C3-4FCB6F6AD74A@HIDDEN> Message-Id: <A6DBC060-D85F-44B8-ADE7-04075AE00033@HIDDEN> X-Mailer: Apple Mail (2.3273) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 27782 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.0 (/) I located GC_exclude_static_roots() call for the collector. Now mmap/search will run allocate a bytevector as in the previously = provided patch. And mmap will call mmap/search and then apply GC_exclude_static_roots() = to the mmap'd region.
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 28 Oct 2017 15:25:37 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 28 11:25:37 2017 Received: from localhost ([127.0.0.1]:39355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1e8SzR-000767-GV for submit <at> debbugs.gnu.org; Sat, 28 Oct 2017 11:25:37 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:48109) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1e8SzQ-00075u-AA for 27782 <at> debbugs.gnu.org; Sat, 28 Oct 2017 11:25:36 -0400 Received: by mail-pf0-f170.google.com with SMTP id z11so7131267pfk.4 for <27782 <at> debbugs.gnu.org>; Sat, 28 Oct 2017 08:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=cVZJG3tyGqFNaJMiho1SoCxe3qumfUS0KPdbm7l6hL8=; b=DqHxEKPan31ItFHmd9mLSTFXTLx/YefHGQzo2oztsb6K8+TiVEWmnaSJbKBRF4R/L0 7v+thzNbUj1vcGNI776HHtF13UR2NbKD2wQoiHA9fqQDe/K8EYPYz0qQyxXgR6tmb2c6 uTREHpE51OeSkI8VDqlVfRnpbJkV+6YtNzAr3OJchMxhU2PQvBL4jC0TOmGsdCOMBZ7r moRQtrJGF9x+7MvlQ6LUmUFUjJUqM3k0PRbAyfXoUyqIc5VRvEVYglZhV65Qbs6cjkJQ de5goxscS8A440YBu5CsxLsaSkwJfY0IqLjVkfb6ODs2TOu3jLyIyOMlQ8QcKG1tWVpn lvqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=cVZJG3tyGqFNaJMiho1SoCxe3qumfUS0KPdbm7l6hL8=; b=PcHNFI22Odn9Q07sO92q6tszhBBMBDFuyrzRHu8OAsyxxN/NBuyljNu/pd8FZMTXu1 7tQKyJB7nVlk91EtHh5+8WJvvUqvTlR1afu6GDDl0bIDcy926PF1KLdKSyn5ergAarBB DMtG3c+NEtKtOnqD4JTEdBlO40rJU3kXfn/xMZh8YmifRukudGBD3YEbXvjZ3WfqOFgL RnO46+WyeydFypjmXzAgD8CjxZEBdk6/DDPXPa2nzP0YHe9srNhJ+8NiHas8bpMnRYao GuKIVwXXnEU7wYeQE9lwZHXIwUFYA5k6G6jFfYLdYLEDRT2PqE/o/nZNcs31LVDv77ar QaDw== X-Gm-Message-State: AMCzsaVQjqFpmHZxdwRj4VHNHGmeWiMNForISeid8/rU4alURqdGTTKJ RoVQk1thMZERlI8MR1P96Ov9fZ+F X-Google-Smtp-Source: ABhQp+QtKd0JdSxYVtRnT7RHCOtVbdFA9rqYH78uvcYzuuIQs/phMI+UaqP6GUNUHpFrwg/05j8rfg== X-Received: by 10.98.34.22 with SMTP id i22mr3685367pfi.340.1509204329940; Sat, 28 Oct 2017 08:25:29 -0700 (PDT) Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id u7sm17899657pfh.142.2017.10.28.08.25.28 for <27782 <at> debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Oct 2017 08:25:29 -0700 (PDT) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: mmap for guile 2.2.2 Message-Id: <68E9A19E-CC14-4FEF-96C3-4FCB6F6AD74A@HIDDEN> Date: Sat, 28 Oct 2017 08:25:27 -0700 To: 27782 <at> debbugs.gnu.org X-Mailer: Apple Mail (2.3273) X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 27782 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.8 (--) I worked on the code a bit more. It is currently implemented as a = #include "mman.c" in filesys.c=20 and another file "mman.c". I believe this needs to be reviewed by someone who understands the = constraints on foriegn pointers=20 and finalization better than I do. Also, there is a comment to add a = procedure mmap/no-search to=20 guarantee that the allocated region is not searched by the GC for = pointers. The following patch is against guile-2.2.2: --- libguile/filesys.c.orig 2017-07-21 06:14:18.000000000 -0700 +++ libguile/filesys.c 2017-10-27 15:40:04.000000000 -0700 @@ -1828,9 +1828,14 @@ =20 =0C =20 +#include "mman.c" + void scm_init_filesys () { +#ifdef HAVE_SYS_MMAN_H + init_mman(); +#endif #ifdef HAVE_POSIX scm_tc16_dir =3D scm_make_smob_type ("directory", 0); scm_set_smob_free (scm_tc16_dir, scm_dir_free); --- libguile/mman.c.orig 2017-07-20 17:06:55.000000000 -0700 +++ libguile/mman.c 2017-10-28 08:12:46.000000000 -0700 @@ -0,0 +1,165 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_SYS_MMAN_H +# include <sys/mman.h> +# include <errno.h> +#endif + +#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) + +#include "libguile/_scm.h" +#include "libguile/smob.h" +#include "libguile/fdes-finalizers.h" +#include "libguile/feature.h" + +SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, + SCM offset); +SCM_API SCM scm_munmap (SCM bvec); +void init_mman(void); +static void mmap_finalizer (void *ptr, void *data); + + +SCM_DEFINE (scm_mmap, "mmap", 2, 4, 0,=20 + (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), + "mmap addr len [prot [flags [fd [offset]]]]" + "See the man page. Returns a bytevector." + "ordinarily convert to bytevector using pointer->bytevector. = " + "Note that the region returned by mmap is not (?) searched " + "by the garbage collector. Defaults:\n" + " PROT (logior PROT_READ PROT_WRITE)\n" + " FLAGS (logior MAP_ANON MAP_PRIVATE)\n" + " FD -1\n" + " OFFSET 0\n" + "@example\n(define reg (mmap %null-pointer #x1000)\n" + "@end example" + ) +#define FUNC_NAME s_scm_mmap +{ + void *c_mem, *c_addr; + size_t c_len; + int c_prot, c_flags, c_fd; + scm_t_off c_offset; + SCM pointer, bvec; + + if (SCM_POINTER_P (addr)) + c_addr =3D SCM_POINTER_VALUE (addr); + else if (scm_is_integer (addr)) + c_addr =3D (void*) scm_to_uintptr_t (addr); + else + SCM_MISC_ERROR("bad addr", addr); + + c_len =3D scm_to_size_t (len); + =20 + if (SCM_UNBNDP (prot)) + c_prot =3D PROT_READ | PROT_WRITE; + else=20 + c_prot =3D scm_to_int (prot); + + if (SCM_UNBNDP (flags)) + c_flags =3D MAP_ANON | MAP_PRIVATE; + else + c_flags =3D scm_to_int (flags); + + if (SCM_UNBNDP (fd)) + c_fd =3D -1; + else + c_fd =3D scm_to_int (fd); + + if (SCM_UNBNDP (fd)) + c_offset =3D 0; + else + c_offset =3D scm_to_off_t (offset); + + c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); + if (c_mem =3D=3D MAP_FAILED) + SCM_SYSERROR; /* errno set */ + + pointer =3D scm_cell (scm_tc7_pointer, (scm_t_bits) c_mem); + bvec =3D scm_c_take_typed_bytevector((signed char *) c_mem + = c_offset, c_len, + SCM_ARRAY_ELEMENT_TYPE_VU8, = pointer); + /* if sizeof(void*) < sizeof(size_t) we are in trouble: */ + scm_i_set_finalizer (SCM2PTR (bvec), mmap_finalizer, (void*) c_len); + return bvec; +} +static void +mmap_finalizer (void *ptr, void *data) +{ + void *c_addr; + intptr_t c_len; + int res; + + c_addr =3D (void *) SCM_POINTER_VALUE (SCM_PACK_POINTER (ptr)); + c_len =3D (intptr_t) data; + res =3D munmap(c_addr, c_len); + if (res !=3D 0) SCM_SYSERROR; +} +#undef FUNC_NAME + +SCM_DEFINE (scm_munmap, "munmap", 1, 0, 0,=20 + (SCM bvec), + "See the man page. Given bytevector unmap." + ) +#define FUNC_NAME s_scm_munmap +{ + void *c_addr; + size_t c_len; + int c_res; + + SCM_VALIDATE_BYTEVECTOR (1, bvec); + =20 + c_addr =3D (void *) SCM_BYTEVECTOR_CONTENTS (bvec); + c_len =3D SCM_BYTEVECTOR_LENGTH (bvec); + + c_res =3D munmap(c_addr, c_len); + if (c_res =3D=3D -1) + SCM_SYSERROR; /* errno set */ + + // TODO: clean up bytevector + return SCM_UNSPECIFIED; +} +#undef FUNC_NAME + +void init_mman(void) { +#ifdef PROT_NONE + scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); +#endif +#ifdef PROT_ + scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); +#endif + +#ifdef MAP_ANONYMOUS + scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); +#endif +#ifdef MAP_ANON + scm_c_define ("MAP_ANO=
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at 27782) by debbugs.gnu.org; 21 Jul 2017 14:35:42 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 21 10:35:42 2017 Received: from localhost ([127.0.0.1]:51345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dYZ1p-00088b-Sd for submit <at> debbugs.gnu.org; Fri, 21 Jul 2017 10:35:42 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1dYZ1o-00088P-30 for 27782 <at> debbugs.gnu.org; Fri, 21 Jul 2017 10:35:40 -0400 Received: by mail-pf0-f170.google.com with SMTP id q85so24886604pfq.1 for <27782 <at> debbugs.gnu.org>; Fri, 21 Jul 2017 07:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=tndBSRmlKBtcRNG/2KZbAu8xymotB4VCxVwliIg0WaU=; b=lJnCg6kwv9TamVwdzkXrCjZ8VBnh1uRJQTE2yz3a4HNcqTF23YuR+IjqvKQKJJzhfm W3p4er3Q3gG3kdY35r74yJvzgJ/Pgb2F2r9Fje88oDv+7S4kAEpdn6CTDzSgtZUcspI8 0VBL9R2S5Y2YFUSOzgUyo8a1kCjg6SKdDi3yU8xUU8sZOTqg5Wl2STNAhKKFphJ/FqUV k5npjDpIJLEgTLmrag+KIaE7qo3054AIRNJoqllyT9QxBbhq8ik771EyUZf+aYXeDP/Q 1cgTnnBNfLgnxCd/neF/neSd5VJhCXSVJsU3cOQ1PYPCk+9Z5IhKqJJ5NG+zZ7qQfA8x S/0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=tndBSRmlKBtcRNG/2KZbAu8xymotB4VCxVwliIg0WaU=; b=jPyMPCFtmQ9dTvzTq8BEsgw2ekYELsbTQMFi/WzDGdGtuK28ljKNJ9Mj/w+MDNa/vJ sgiZ+u4523tQ5GzdKckslyQiRh8Dm/HqweDOb6DcLwEASuAgfyz9HS98k+WIa4wMjoqv cw/NU+HWVYTPyIAi/sjBE0XhYHzzb+UnF9M+Hcmn3OMh0u14TsI/O/pIjRE2MqFg3/1J XCvl5IyhUP7nTYFldwfPj1Kaf9UbmfegpT4GknLR126L3MAlrJhwRCrUDLPXMxCxa1XZ DK84k/DzifCUGINVZ4qAKRpHNzoy9H8KVq8xi7JbJFy8k9SIOe4/B//5qMSdJ00HB2xu 2i6Q== X-Gm-Message-State: AIVw113axFwVtaIy+QHSQENAGZnW/9ZwBL5IX14/IGY5iY4CHfMiqR3u TlpEvTDuJeOlTl6ZBuY= X-Received: by 10.84.149.197 with SMTP id a5mr8360951plh.3.1500647733442; Fri, 21 Jul 2017 07:35:33 -0700 (PDT) Received: from nautilus.championbroadband.com (216-165-236-44.championbroadband.com. [216.165.236.44]) by smtp.gmail.com with ESMTPSA id v18sm9730043pfg.164.2017.07.21.07.35.32 for <27782 <at> debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 07:35:32 -0700 (PDT) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: bug#27782: Acknowledgement ([wishlist] scheme level mmap) Date: Fri, 21 Jul 2017 07:35:31 -0700 References: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> <handler.27782.B.150064439025677.ack <at> debbugs.gnu.org> To: 27782 <at> debbugs.gnu.org In-Reply-To: <handler.27782.B.150064439025677.ack <at> debbugs.gnu.org> Message-Id: <417DAD59-E2A0-43D3-9364-41660CFCD31B@HIDDEN> X-Mailer: Apple Mail (2.3273) X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 27782 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.8 (--) Works on guile-2.2.2: > (use-modules (system foreign)) > (define raw (mmap %null-pointer #x1000 (logior PROT_READ PROT_WRITE) (logior MAP_ANON MAP_PRIVATE) -1 0)) > (munmap raw #x1000) $ diff filesys.c.orig filesys.c + #include "mmap.c" + void scm_init_filesys () { + MMAP_DEFS; #ifdef HAVE_POSIX scm_tc16_dir = scm_make_smob_type ("directory", 0); scm_set_smob_free (scm_tc16_dir, scm_dir_free); mmap.c-post2: #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef HAVE_SYS_MMAN_H # include <sys/mman.h> # include <errno.h> #endif #include "libguile/_scm.h" #include "libguile/smob.h" #include "libguile/fdes-finalizers.h" #include "libguile/feature.h" SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM offset); SCM_API SCM scm_munmap (SCM addr, SCM len); #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) // python mmap makes the last four args optional // should use fd=-1 default on mac // The following works: // > (use-modules (system foreign)) // > (define raw (mmap %null-pointer #x1000 (logior PROT_READ PROT_WRITE) // (logior MAP_ANON MAP_PRIVATE) -1 0)) // > (munmap raw #x1000) SCM_DEFINE (scm_mmap, "mmap", 6, 0, 0, (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM offset), "See the man page. returns a foreign pointer which one would" "ordinarily convert to bytevector using pointer->bytevector. " "Note that the region returned by mmap is not (?) searched " "by the garbage collector." "@example\n(define reg\n (pointer->bytevector\n " "(mmap %null-pointer #x10000 (logior PROT_READ PROT_WRITE) " "(logior MAP_ANON MAP_PRIVATE) -1 0) #x1000))" "@end example" ) #define FUNC_NAME s_scm_mmap { void *c_mem, *c_addr; size_t c_len; int c_prot, c_flags, c_fd; scm_t_off c_offset; SCM_VALIDATE_POINTER (1, addr); c_addr = (void *) SCM_POINTER_VALUE (addr); c_len = scm_to_size_t (len); c_prot = scm_to_int (prot); c_flags = scm_to_int (flags); c_fd = scm_to_int (fd); c_offset = SCM_UNBNDP (offset) ? 0: scm_to_off_t (offset); c_mem = mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); if (c_mem == MAP_FAILED) SCM_SYSERROR; /* errno set */ else return scm_from_pointer (c_mem, NULL); } #undef FUNC_NAME SCM_DEFINE (scm_munmap, "munmap", 2, 0, 0, (SCM addr, SCM len), "See the man page. Given foreign pointer unmap." ) #define FUNC_NAME s_scm_munmap { void *c_addr; size_t c_len; int c_res; SCM_VALIDATE_POINTER (1, addr); c_addr = (void *) SCM_POINTER_VALUE (addr); c_len = scm_to_size_t (len); c_res = munmap(c_addr, c_len); if (c_res == -1) SCM_SYSERROR; /* errno set */ else return scm_from_int (c_res); } #endif /* HAVE_SYS_MMAN_H */ #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) #define MMAP_DEFS \ scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); \ scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); \ scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); \ scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); \ \ scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); \ scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON)); \ scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE)); \ scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED)); \ scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSEMAPHORE)); \ scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE)); \ scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED)); \ scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE)) #else #define MMAP_DEFS /* */ #endif /* HAVE_SYS_MMAN_H */
bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.Received: (at submit) by debbugs.gnu.org; 21 Jul 2017 13:39:50 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jul 21 09:39:50 2017 Received: from localhost ([127.0.0.1]:50487 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1dYY9m-0006g5-5c for submit <at> debbugs.gnu.org; Fri, 21 Jul 2017 09:39:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <matt.wette@HIDDEN>) id 1dYY9k-0006fs-Ub for submit <at> debbugs.gnu.org; Fri, 21 Jul 2017 09:39:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <matt.wette@HIDDEN>) id 1dYY9e-0005Cs-UR for submit <at> debbugs.gnu.org; Fri, 21 Jul 2017 09:39:43 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:38566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <matt.wette@HIDDEN>) id 1dYY9e-0005Ck-QS for submit <at> debbugs.gnu.org; Fri, 21 Jul 2017 09:39:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <matt.wette@HIDDEN>) id 1dYY9d-0008Tg-J2 for bug-guile@HIDDEN; Fri, 21 Jul 2017 09:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <matt.wette@HIDDEN>) id 1dYY9Z-0005A4-K0 for bug-guile@HIDDEN; Fri, 21 Jul 2017 09:39:41 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:35948) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <matt.wette@HIDDEN>) id 1dYY9Z-000591-CK for bug-guile@HIDDEN; Fri, 21 Jul 2017 09:39:37 -0400 Received: by mail-pf0-x232.google.com with SMTP id o88so24324277pfk.3 for <bug-guile@HIDDEN>; Fri, 21 Jul 2017 06:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=sS7KkSIiDloap3/Fngj0RzmWpbNZ8GCPRUC9HvT4Zpo=; b=N/INHmNM5v6UlTpvTPfdc11AgQ4huLTsHGIQLBHhcspHYWcLKV34O7Y+Cty52uso9K vY6NZyGHxqm1m+YnTThOi+oYs1fhyoQ6fKfPNQyx4P6LpN5/kegxx5CB/cI/q9v1al1b NN3q55iFe8l3PBCbJLwhBjvrYoqx8Rq3wTvMKCZQ+Bl+d7iCEBqqMlaNOsg7jKVL2Ty8 Cp2HkZed+ojaW6uRZOfp4J3ke0OSjAVEYEpMAGJKzP1Ho0oWRNJGiFuLMlgQiecAN05T dJBS2ss9IiNqQV1nmpDxD+2hA829Z4v5ZAwOWItvQzr7lz3ZfO1xLi2OX+trx7Wc9Ec+ HhcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=sS7KkSIiDloap3/Fngj0RzmWpbNZ8GCPRUC9HvT4Zpo=; b=CcoqbF0kWJeR7kbyIAKbzlLsh57RfGx6YhpYed8OyHqqKIqpkpw9RSd5K0L2vsDRWb wmpS9n6SPJHUKCdZ0vTsKf8CoD18icFBtkPOYpRJ2sC5OdxBmJsJip6sHJ8eH/yD/EWv 6NMcsQyaYxpOlLoV2hq+j7KGTv2jOxb17FmkbcDExYL6NZo6aHbTLJMgg6taqkbXED9c AwUaqJBzSrz7zLQryfWE9N38KTq5wJrsGtbEXq3n3Ikratc5TlzC2vx+xv1tmvhyGzVI Jbxdt9RgVsmDXKUi810fuUKoL4YjR8pN4HMKhxyNiMsVUWKqdm5vOChy2MGScN6kbUVH +7NA== X-Gm-Message-State: AIVw110eA2yIPSGlyuYmidiMXpSBYrp1TvV/sQtk2vE1CctVKCwH+iws Y83QBfgDGRr5mG0UGcc= X-Received: by 10.99.152.66 with SMTP id l2mr7251123pgo.93.1500644374140; Fri, 21 Jul 2017 06:39:34 -0700 (PDT) Received: from nautilus.championbroadband.com (216-165-236-44.championbroadband.com. [216.165.236.44]) by smtp.gmail.com with ESMTPSA id v9sm6634161pfi.115.2017.07.21.06.39.33 for <bug-guile@HIDDEN> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 06:39:33 -0700 (PDT) From: Matt Wette <matt.wette@HIDDEN> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [wishlist] scheme level mmap Message-Id: <CD68D357-0F0F-471C-BEC1-EB601844A04E@HIDDEN> Date: Fri, 21 Jul 2017 06:39:32 -0700 To: bug-guile@HIDDEN X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -4.0 (----) There was an implicit request on the user-guile mailing list (20 Jul = 2017) to provide a scheme language call to mmap. I am working on a prototype and will post when I get a simple case = working. Here is non-working code so far: Currently I have this in a file =E2=80=9Cmmap.c=E2=80=9D and #including = into filesys.c. #ifdef HAVE_CONFIG_H # include <config.h> #endif #ifdef HAVE_SYS_MMAN_H # include <sys/mman.h> #endif #include "libguile/_scm.h" #include "libguile/smob.h" #include "libguile/fdes-finalizers.h" #include "libguile/feature.h" SCM_API SCM scm_mmap (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM offset); SCM_API SCM scm_munmap (SCM addr, SCM len); #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) // python mmap makes the last four args optional // should use fd=3D-1 default on mac SCM_DEFINE (scm_mmap, "mmap", 6, 0, 0,=20 (SCM addr, SCM len, SCM prot, SCM flags, SCM fd, SCM = offset), "See the man page. returns a foreign pointer which one = would" "ordinarily convert to bytevector using pointer->bytevector. = " "Note that the region returned by mmap is not (?) searched " "by the garbage collector." "@example\n(define reg\n (pointer->bytevector\n " "(mmap %void-pointer #x10000 (logior PROT_READ PROT_WRITE) " "MAP_ANON -1 0) #x1000))" "@end example" ) #define FUNC_NAME s_scm_mmap { void *c_mem, *c_addr; size_t c_len; int c_prot, c_flags, c_fd; scm_t_off c_offset; SCM ret; SCM_VALIDATE_POINTER (1, addr); =20 c_addr =3D (void *) SCM_POINTER_VALUE (addr); c_len =3D scm_to_size_t (len); c_prot =3D scm_to_int (prot); c_flags =3D scm_to_int (flags); c_fd =3D scm_to_int (fd); c_offset =3D SCM_UNBNDP (offset) ? 0: scm_to_off_t (offset); =20 c_mem =3D mmap(c_addr, c_len, c_prot, c_flags, c_fd, c_offset); ret =3D scm_from_pointer (c_mem, NULL); return ret; } #undef FUNC_NAME SCM_DEFINE (scm_munmap, "munmap", 2, 0, 0,=20 (SCM addr, SCM len), "See the man page. Given foreign pointer unmap." ) #define FUNC_NAME s_scm_munmap { void *c_addr; size_t c_len; int c_res; SCM res; SCM_VALIDATE_POINTER (1, addr); =20 c_addr =3D (void *) SCM_POINTER_VALUE (addr); c_len =3D scm_to_size_t (len); c_res =3D munmap(c_addr, c_len); res =3D scm_from_int (c_res); return res; } #endif /* HAVE_SYS_MMAN_H */ #if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MAP_ANONYMOUS) #define MMAP_DEFS \ scm_c_define ("PROT_NONE", scm_from_int (PROT_NONE)); \ scm_c_define ("PROT_READ", scm_from_int (PROT_READ)); \ scm_c_define ("PROT_WRITE", scm_from_int (PROT_WRITE)); \ scm_c_define ("PROT_EXEC", scm_from_int (PROT_EXEC)); \ \ scm_c_define ("MAP_ANONYMOUS", scm_from_int (MAP_ANONYMOUS)); \ scm_c_define ("MAP_ANON", scm_from_int (MAP_ANON)); \ scm_c_define ("MAP_FILE", scm_from_int (MAP_FILE)); \ scm_c_define ("MAP_FIXED", scm_from_int (MAP_FIXED)); \ scm_c_define ("MAP_HASSEMAPHORE", scm_from_int (MAP_HASSEMAPHORE)); \ scm_c_define ("MAP_PRIVATE", scm_from_int (MAP_PRIVATE)); \ scm_c_define ("MAP_SHARED", scm_from_int (MAP_SHARED)); \ scm_c_define ("MAP_NOCACHE", scm_from_int (MAP_NOCACHE)) #else #define MMAP_DEFS /* */ #endif /* HAVE_SYS_MMAN_H */
Matt Wette <matt.wette@HIDDEN>
:bug-guile@HIDDEN
.
Full text available.bug-guile@HIDDEN
:bug#27782
; Package guile
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.