From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509 Date: Sun, 07 Jun 2009 19:24:56 +0200 Message-ID: References: <878wk577s2.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1244395976 31168 80.91.229.12 (7 Jun 2009 17:32:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 7 Jun 2009 17:32:56 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Jun 07 19:32:52 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MDMEl-0001Vr-DY for guile-devel@m.gmane.org; Sun, 07 Jun 2009 19:32:51 +0200 Original-Received: from localhost ([127.0.0.1]:43614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDMEk-0004yF-Rd for guile-devel@m.gmane.org; Sun, 07 Jun 2009 13:32:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDMEY-0004q9-Vj for guile-devel@gnu.org; Sun, 07 Jun 2009 13:32:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDMEU-0004ix-4y for guile-devel@gnu.org; Sun, 07 Jun 2009 13:32:38 -0400 Original-Received: from [199.232.76.173] (port=53348 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDMET-0004ie-US for guile-devel@gnu.org; Sun, 07 Jun 2009 13:32:33 -0400 Original-Received: from a-sasl-fastnet.sasl.smtp.pobox.com ([207.106.133.19]:57951 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDMER-0001XI-L8; Sun, 07 Jun 2009 13:32:31 -0400 Original-Received: from localhost.localdomain (unknown [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id 5DE83B9C5E; Sun, 7 Jun 2009 13:32:31 -0400 (EDT) Original-Received: from unquote (unknown [83.32.70.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 5BDC1B9C5D; Sun, 7 Jun 2009 13:32:28 -0400 (EDT) In-Reply-To: <878wk577s2.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Sat, 06 Jun 2009 16:31:57 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: 2DE8541A-5389-11DE-A80E-97731A10BFE7-02397024!a-sasl-fastnet.pobox.com X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:8644 Archived-At: Heya, On Sat 06 Jun 2009 16:31, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hello, > > "Andy Wingo" writes: > >> +SCM_DEFINE (scm_uniform_array_to_bytevector, "uniform-array->bytevector= ", >> + 1, 0, 0, (SCM array), >> + "Return a newly allocated bytevector whose contents\n" >> + "will be copied from the uniform array @var{array}.") >> +#define FUNC_NAME s_scm_uniform_array_to_bytevector >> +{ >> + SCM contents, ret; >> + size_t len; >> + scm_t_array_handle h; >> + const void *base; >> + size_t sz; >> +=20=20 >> + contents =3D scm_array_contents (array, SCM_BOOL_T); >> + if (scm_is_false (contents)) >> + scm_wrong_type_arg_msg (FUNC_NAME, 0, array, "uniform contiguous ar= ray"); >> + >> + scm_array_get_handle (contents, &h); >> + >> + base =3D scm_array_handle_uniform_elements (&h); >> + len =3D h.dims->inc * (h.dims->ubnd - h.dims->lbnd + 1); >> + sz =3D scm_array_handle_uniform_element_size (&h); >> + >> + ret =3D make_bytevector (len * sz); >> + memcpy (SCM_BYTEVECTOR_CONTENTS (ret), base, len * sz); > > Is this memcpy valid in the case of shared arrays? Looks like we end up > copying more elements than needed, but maybe it's better this way. I'm not entirely sure. I thought that scm_array_contents will give me a contiguous array, though trolling around in srfi-4.[ch] and unif.[ch] makes me grumpy ;) >> + uniform-array->bytevector > > I would not export it from `(rnrs bytevector)' given that it has nothing > to do with RnRS. No, but it does have to with bytevectors... Where would you put it? > Also, I would make the new C functions private, given that they are not > intended for general use AIUI. Dunno. I could imagine calling both of them from C. Would there be a problem with leaving them to be public? Cheers, Andy --=20 http://wingolog.org/