From: ludo@gnu.org (Ludovic Courtès)
To: "Andy Wingo" <wingo@pobox.com>
Cc: guile-devel@gnu.org
Subject: Re: [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509
Date: Sat, 06 Jun 2009 16:31:57 +0200 [thread overview]
Message-ID: <878wk577s2.fsf@gnu.org> (raw)
In-Reply-To: <E1MCaTQ-0003wD-Sn@cvs.savannah.gnu.org> (Andy Wingo's message of "Fri, 05 Jun 2009 14:32:50 +0000")
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.
> + uniform-array->bytevector
I would not export it from `(rnrs bytevector)' given that it has nothing
to do with RnRS.
Also, I would make the new C functions private, given that they are not
intended for general use AIUI.
What d'ya think?
Thanks,
Ludo'.
next parent reply other threads:[~2009-06-06 14:31 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 ` Ludovic Courtès [this message]
2009-06-07 17:24 ` [Guile-commits] GNU Guile branch, master, updated. 782a82eed13abb64393f7acad92758ae191ce509 Andy Wingo
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=878wk577s2.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/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).