diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-28 06:02:33 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-28 06:02:33 -0700 |
commit | 6b7a88b83ff5f3574e05a7677c65a232d667d52c (patch) | |
tree | 03d568143299772cbf101ff0966108cfd16928f7 /ffi.c | |
parent | 7155d82316305b4280511f11236eec5f8e8582be (diff) | |
download | txr-6b7a88b83ff5f3574e05a7677c65a232d667d52c.tar.gz txr-6b7a88b83ff5f3574e05a7677c65a232d667d52c.tar.bz2 txr-6b7a88b83ff5f3574e05a7677c65a232d667d52c.zip |
ffi: buf type doesn't need fill function.
The fill function is useless, because the object is already filled
directly. It's just performing an exactly overlapping memcpy.
* ffi.c (ffi_buf_alloc): Function removed.
(ffi_type_compile): We can't use the presence or absence of
the fill function as the test whether a type can be passed
by ptr-in-out or ptr-out, since buf can be passed that way
and has no fill. A better criterion is "has no fill and
use the fixed size allocation". Removing the assignment
statements which set up the fill function for buffers.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -625,13 +625,6 @@ static mem_t *ffi_buf_alloc(struct txr_ffi_type *tft, val buf, val self) return buf_get(buf, self); } -static void ffi_buf_fill(struct txr_ffi_type *tft, mem_t *src, - val buf, val self) -{ - (void) tft; - buf_fill(buf, src, self); -} - static void ffi_ptr_in_in(struct txr_ffi_type *tft, val obj, val self) { val tgttype = tft->mtypes; @@ -1051,7 +1044,7 @@ val ffi_type_compile(val syntax) } else if (sym == ptr_out_s) { val target_type = ffi_type_compile(cadr(syntax)); struct txr_ffi_type *tft = ffi_type_struct(target_type); - if (tft->fill == 0) + if (tft->fill == 0 && tft->alloc == ffi_fixed_alloc) uw_throwf(error_s, lit("~a: ~s cannot be ptr-out target"), self, cadr(syntax), nao); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), @@ -1061,7 +1054,7 @@ val ffi_type_compile(val syntax) } else if (sym == ptr_in_out_s) { val target_type = ffi_type_compile(cadr(syntax)); struct txr_ffi_type *tft = ffi_type_struct(target_type); - if (tft->fill == 0) + if (tft->fill == 0 && tft->alloc == ffi_fixed_alloc) uw_throwf(error_s, lit("~a: ~s cannot be ptr-in-out target"), self, cadr(syntax), nao); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), @@ -1076,7 +1069,6 @@ val ffi_type_compile(val syntax) struct txr_ffi_type *tft = ffi_type_struct(type); tft->alloc = ffi_buf_alloc; tft->free = ffi_noop_free; - tft->fill = ffi_buf_fill; tft->nelem = nelem; return type; } @@ -1185,7 +1177,6 @@ val ffi_type_compile(val syntax) struct txr_ffi_type *tft = ffi_type_struct(type); tft->alloc = ffi_buf_alloc; tft->free = ffi_noop_free; - tft->fill = ffi_buf_fill; return type; } else if (syntax == void_s) { return make_ffi_type_builtin(syntax, nil, 0, &ffi_type_void, |