From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Thompson, David" Newsgroups: gmane.lisp.guile.devel Subject: Re: Attempting to unbox struct fields Date: Mon, 29 Feb 2016 09:26:26 -0500 Message-ID: References: <8737scubaj.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> <87h9gscgpt.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1456756002 1911 80.91.229.3 (29 Feb 2016 14:26:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Feb 2016 14:26:42 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Feb 29 15:26:42 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aaOmU-0005XL-SL for guile-devel@m.gmane.org; Mon, 29 Feb 2016 15:26:39 +0100 Original-Received: from localhost ([::1]:36967 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaOmR-0000zL-0w for guile-devel@m.gmane.org; Mon, 29 Feb 2016 09:26:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaOmN-0000yz-9Q for guile-devel@gnu.org; Mon, 29 Feb 2016 09:26:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aaOmJ-0001zo-8I for guile-devel@gnu.org; Mon, 29 Feb 2016 09:26:31 -0500 Original-Received: from mail-yw0-x22e.google.com ([2607:f8b0:4002:c05::22e]:34525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aaOmJ-0001zj-1H for guile-devel@gnu.org; Mon, 29 Feb 2016 09:26:27 -0500 Original-Received: by mail-yw0-x22e.google.com with SMTP id h129so121894891ywb.1 for ; Mon, 29 Feb 2016 06:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=worcester-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=BhXhxE+4GyvldcOxd3lNIy5aZ/OB6AsVFUYHX3ruWuU=; b=Ro/jDT8+ZMnnzrsJgZrLOYK9zI+hDNYDRLRGYlsANnPBn0LuZTcmUQIKwAZ7KLYL28 UbEVcipZLekyfki/aPTrWzPw6Lx9lx51HA214yUX9cMmIBemS4oP5oSMN82eN20D+Mgd +WJ3Zh0TELJQJIBr+q1xDY40nyPHMO/bt7RkjxVwda86ZvEjktZ5pIMFUmXaU38xpo72 hUlbUF9RwHNhk6XfF+Yu0BSPQS5r1m5yqIpyL1mdPkvCHt23xMfjniTYfVRqdWwumRGL gSk0hk8hw5BFKBaJOK1DO01fZZoczvK8PUT0QPjh0KO2p9M3UrAwNz6yIwBafM2G13J3 dNig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=BhXhxE+4GyvldcOxd3lNIy5aZ/OB6AsVFUYHX3ruWuU=; b=dGZpYHydYEEaUuZpPU2xo7+ardWnS61j7v3sl2JU4HnVbHA+FUTHz0aCd6T679A36Y xgcYJwwDFxoG+BVXknoeKqljsmu8e+r7DYBdUTJZxBeMfEKOG3mpvfDZDtwvp6jSmpoS hIAvGvCNC0+q7AXqKj7b6zwmNlN3g1aeycvk+wX05GfykmUciuWfHnTIDapin56qODdB xC5jHK38Khdg0J69WZOItHxhaR7vZe1qbjMoqqAsOMM54Ul0ux8oxSJkT2z7q0Eszl5p AsaA/C6ZWIeKoLypXWPk1RVBA/CTpJIwxkd4EcrTqg9TohkU4fSwlTdb5AqcLZpntYGS Anlg== X-Gm-Message-State: AD7BkJLeYKPe0qJRPTla6YAGXviEySlBh9WDbabVzl6XTKex/wdv54ZltiejKlkdma5XPWhc+RWD3WnCZcuOGw== X-Received: by 10.129.134.132 with SMTP id w126mr9735313ywf.137.1456755986456; Mon, 29 Feb 2016 06:26:26 -0800 (PST) Original-Received: by 10.37.25.86 with HTTP; Mon, 29 Feb 2016 06:26:26 -0800 (PST) In-Reply-To: <87h9gscgpt.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::22e X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:18199 Archived-At: Hi Mark, On Sun, Feb 28, 2016 at 10:56 PM, Mark H Weaver wrote: > Hi David, > > "Thompson, David" writes: >> Here's a patch I came up with to enable (and fix where necessary) the >> support for signed integer and double struct fields. > > Great, thanks for working on it! This is not a proper review, just a > couple of questions and comments. I'm not very knowledgeable in the finer points of writing portable C code or the Guile C API, so this feedback is very valuable. Thanks! >> Am I on the right track here? > > The first thing I noticed is that the patch assumes that doubles are the > same size as pointers. Obviously this is not the case on 32-bit > systems. What's the plan for those systems? Yeah, I just hacked this together on my x86_64 system and paid no mind to portability. I was hoping that you or Andy or Ludovic would have an idea for how to address portability issues. :) > The patch also currently assumes that longs and pointers are the same > size, and this turns out to be false on LLP64 systems such as 64-bit > Windows. See . However, it should be > straightforward to fix this issue. > >> + if ((prot != 'r' && prot != 'w') || inits_idx == n_inits) >> + *mem = 0.0; > > Note that 'mem' is of type scm_t_bits*, so the 0.0 will be converted to > the integer 0 and then stored as an integer, which I guess is not what > you meant. Note that in practice this works on IEEE 754 systems, where > 0.0 is represented as all zero bits, but the code is somewhat misleading > and less portable than it could be. D'oh! I forgot to cast here. Thanks for the explanation. It explains why I didn't notice the issue when testing. My current plan is to keep pressing onward and produce a proof-of-concept, hacky patch set that allows unboxed struct fields on x86_64. Then, with some help and guidance, I can sort out the portability issues, code style issues, unit tests, and documentation after confirmation that the prototype is on the right track. Thanks, - Dave