From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509
Date: Sun, 07 Jun 2009 19:24:56 +0200 [thread overview]
Message-ID: <m3ws7ovtw7.fsf@pobox.com> (raw)
In-Reply-To: <878wk577s2.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sat, 06 Jun 2009 16:31:57 +0200")
Heya,
On Sat 06 Jun 2009 16:31, ludo@gnu.org (Ludovic Courtès) writes:
> Hello,
>
> "Andy Wingo" <wingo@pobox.com> 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;
>> +
>> + contents = scm_array_contents (array, SCM_BOOL_T);
>> + if (scm_is_false (contents))
>> + scm_wrong_type_arg_msg (FUNC_NAME, 0, array, "uniform contiguous array");
>> +
>> + scm_array_get_handle (contents, &h);
>> +
>> + base = scm_array_handle_uniform_elements (&h);
>> + len = h.dims->inc * (h.dims->ubnd - h.dims->lbnd + 1);
>> + sz = scm_array_handle_uniform_element_size (&h);
>> +
>> + ret = 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
--
http://wingolog.org/
next prev parent reply other threads:[~2009-06-07 17:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1MCaTQ-0003wD-Sn@cvs.savannah.gnu.org>
2009-06-06 14:31 ` [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509 Ludovic Courtès
2009-06-07 17:24 ` Andy Wingo [this message]
2009-06-18 20:28 ` Ludovic Courtès
2009-06-19 7:50 ` Andy Wingo
2009-06-19 8:20 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3ws7ovtw7.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).