From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#14599: An option to make vector allocation aligned Date: Wed, 12 Jun 2013 22:37:40 +0200 Message-ID: <87mwqv83qj.fsf@pobox.com> References: <51B87998.9060402@email.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1371069549 10580 80.91.229.3 (12 Jun 2013 20:39:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Jun 2013 20:39:09 +0000 (UTC) Cc: 14599@debbugs.gnu.org To: Jan Schukat Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Jun 12 22:39:10 2013 Return-path: Envelope-to: guile-bugs@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 1Umroz-0004yf-HE for guile-bugs@m.gmane.org; Wed, 12 Jun 2013 22:39:09 +0200 Original-Received: from localhost ([::1]:37859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umroz-00041r-6O for guile-bugs@m.gmane.org; Wed, 12 Jun 2013 16:39:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umrov-00041l-EB for bug-guile@gnu.org; Wed, 12 Jun 2013 16:39:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Umros-0001vz-TG for bug-guile@gnu.org; Wed, 12 Jun 2013 16:39:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Umros-0001vt-O9 for bug-guile@gnu.org; Wed, 12 Jun 2013 16:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Umros-0007rK-9F for bug-guile@gnu.org; Wed, 12 Jun 2013 16:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 12 Jun 2013 20:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14599 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 14599-submit@debbugs.gnu.org id=B14599.137106949130083 (code B ref 14599); Wed, 12 Jun 2013 20:39:01 +0000 Original-Received: (at 14599) by debbugs.gnu.org; 12 Jun 2013 20:38:11 +0000 Original-Received: from localhost ([127.0.0.1]:59452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Umro2-0007p3-O1 for submit@debbugs.gnu.org; Wed, 12 Jun 2013 16:38:11 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:61141 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Umrny-0007ol-7K for 14599@debbugs.gnu.org; Wed, 12 Jun 2013 16:38:07 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 19D6BCEB1; Wed, 12 Jun 2013 16:38:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=J3cgGxl1CUO76TCaYm55OpsQRtQ=; b=igeg24 MIgwrwf46MQYQlNn3fHdAAPDum1UY0/Nf2a/55tEyx57MF1Q8iU+NZeqiu6JJ2o3 QP8ijjkU+ujKw9T78tsovuR5l5qpO3GyyBpoXR/DpTyHDSosQ2vkqWXMRxfKgotJ H9+I5Kkv8dnrS5S2cJoUHC8ROE7j++ZFLPAu0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=X+7tUD4OKkduIK3QSaMhqEi7rAvA6OHi N+Z9FCsnJJGY0sxHjXAWBJRCtBqVV10iKkU9huXNvaPm/5zL7MPh/KQMynA6rvQw tXERahTXFqhp3Lr8jL89bbXPySd48R9eIcTLzsSync8oudhb4aCsdKvsBMFMeXo2 aDZpKn5Ga2M= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 96D5BCEAE; Wed, 12 Jun 2013 16:37:46 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 14EE6CEAB; Wed, 12 Jun 2013 16:37:43 -0400 (EDT) In-Reply-To: <51B87998.9060402@email.de> (Jan Schukat's message of "Wed, 12 Jun 2013 15:37:28 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Pobox-Relay-ID: EF474BF8-D39F-11E2-A06E-9F710E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7170 Archived-At: On Wed 12 Jun 2013 15:37, Jan Schukat writes: > If you want to access native uniform vectors from c, sometimes you > really want guarantees about the alignment. 16 bytes I guess? Guile's uniforms are 8-byte-aligned by default, as you probably know. Just wondering if there is a better default. > +#ifdef SCM_VECTOR_ALIGN > + contents = scm_gc_malloc_pointerless (SCM_BYTEVECTOR_HEADER_BYTES > + c_len + SCM_VECTOR_ALIGN, > + SCM_GC_BYTEVECTOR); > + ret = PTR2SCM (contents); > + contents += SCM_BYTEVECTOR_HEADER_BYTES; > + contents += (addr + (SCM_VECTOR_ALIGN - 1)) & -SCM_VECTOR_ALIGN; > +#else > contents = scm_gc_malloc_pointerless (SCM_BYTEVECTOR_HEADER_BYTES > + c_len, > SCM_GC_BYTEVECTOR); > ret = PTR2SCM (contents); > contents += SCM_BYTEVECTOR_HEADER_BYTES; > +#endif This is somewhat dangerous, as you could lose the pointer to the start, and then the contents get collected. I guess this can be fixed in master, if you set the "holder" field on a bytevector to the actual memory that you allocate. Andy -- http://wingolog.org/