| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (copy_carray): New function
(ffi_init): Register copy-carray intrinsic.
* ffi.h (copy_carray): Declared.
* lib.c (copy): Call copy_array for carray objects.
* txr.1: Documented copy-carray and updated
copy description.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (put_carray, fill_carray): New functions.
(ffi_init): put-carray and fill-carray intrinsics
registered.
* ffi.h (put_carray, fill_carray): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_unum, carray_num, unum_carray, num_carray):
New functions.
(ffi_init): New intrinsics registered: carray-unum,
carray-num, unum-carray, num-carray.
* ffi.h (carray_unum, carray_num, unum_carray, num_carray):
Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (sign_extend): After taking the two's complement
which works at the granularity of digits, not the exact
number of bits, we must truncate the number to the
exact number of bits before negating. Otherwise we end up
with an excessively large value. For instance if a bignum
like #x80... is sign extended tightly to the upper
1 bit, the resulting value is something like #-xFFFF80...,
rather than #x-80... as it should be. There are extra
1 bits padding up to the bignum digit. These must be
chopped away.
|
|
|
|
|
|
|
|
| |
* mpi/logtab.h, mpi/mpi-config.h mpi/mpi-types.h mpi/mpi.c,
mpi/mpi.h mpi/mplogic.c mpi/mplogic.h: Reformatted comments.
Removed useless comments. Removed superfluous blank lines and
whitespace. Added space between C keywords if, for, while,
sizeof and opening parens. Removed #if 0 blocks. Tabs to spaces.
|
|
|
|
| |
* txr.c (banner): Text updated.
|
|
|
|
|
| |
* linenoise/linenoise.c (show_help): New static function.
(edit): Call show_help on Ctrl-X ?.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (ffi_set_entries): Register carray-sub
for autoload.
* share/txr/stdlib/ffi.tl (carray-sub): New place
macro, aliases to sub. This is not 100% correct since
that means it will admit non-carray objects, but
the alternative is to clone the entire sub expander
with a few changes, or else factor out sub expansion
into a shared routine. Bleh ...
* txr.1: Documented. We don't cover up the ruse we
perpetrated, and reveal that it's just a place macro
targetting sub.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TXR Lisp doesn't autoload the definition of places.
For instance if a (set (foo x) y) appears out of the
blue and foo is keyed for autoload, it doesn't happen.
The right place to fix this is to do the autload check
in the place macro expander, since every place form is
tried as a macro.
We need to expose the lisplib_try_load function as a Lisp
intrinsic.
* lisplib.c (lisplib_init): Register sys:try-load
intrinsic, mapped to lisplib_try_load.
* share/txr/stdlib/place.tl (sys:get-place-macro):
New function.
(sys:pl-expand): Use sys:get-place-macro instead of
direct lookup in *place-macro* hash. The new function
tries to autoload the symbol if it finds no place
macro for it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): When there is no room in the
current bitfield, two mistakes are made. When bit_offs is
reset to zero in this case, the dependent variable bits_alloc
that was calculated from it (bits allocated to current unit)
must also be reset. The subsequent shift depends on it.
Secondly, when we establish the memb[i].offs field, that
must come from offs, not from unit_offs, because unit_offs
is always the base offset of the existing cell (which doesn't
have room for the new bitfield in this case); the main offset
variable offs is what gets gets adjusted to the cell which has
room for the new bitfield.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_generic_sbit_put, fi_generic_sbit_get,
ffi_generic_ubit_put, fi_generic_ubit_get): Add needed
coerce from zalloca to mem_t *.
(make_ffi_type_struct): Fix signed/unsigned comparison.
* lib.c (vector): Fix signed/unsigned comparison.
|
|
|
|
|
| |
* genprotsym.txr: Sort groups so that the protsym.c
deltas, going forward, are more stable.
|
|
|
|
|
|
| |
* genprotsym.txr: use @(first) directive trick to
eliminate leading blank lines in front of items
that are not controlled by a preprocessor symbol.
|
|
|
|
|
|
|
|
|
| |
* buf.c (bufp): New function.
(buf_init): Registered bufp intrisic.
* buf.h (bufp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/conv.tl (sys:conv-let): New
local functions c and cz, using the new #\c
radix conversion.
* txr.1: Documented new extension under the fconv
awk macro. Also fixed a typo here; the b conversion
was exemplified as (c str).
|
|
|
|
|
|
|
|
|
| |
* lib.c (int_str): Support #\c base, recognizing
0x as hex and leading 0 as octal. We don't rely on
the wcstol function's ability to do this conversion,
but scan it ourselves.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Put carray and buf cases into the description of
the indexing notation under the dwim operator.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): Use chk_xalloc instead of
chk_malloc.
(make_ffi_type_array): Use chk_xalloc. Since there are
multiple callers, take a self argument to pass down to
chk_xalloc.
(ffi_type_compile): Pass self down to make_ffi_type_array.
(ffi_make_call_desc): Use chk_xalloc.
(carray_ensure_artype): Take a self argument and pass down to
make_ffi_type_array.
(carray_get_common, carray_put_common): Pass self down to
carray_ensure_artype.
|
|
|
|
|
|
|
|
|
| |
* stream.c (open_process): Check that manipulations of nargs
do not overflow int type. Use chk_xalloc. Allocation is
done before pipe so we have no file descriptors to clean up
if chk_xalloc throws.
(run): In both versions of run, check that manipulations of
nargs don't overflow int and use chk_xalloc.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* sysif.c (excec_wrap): Check that our nargs manipulation
doesn't exceed INT_MAX. Use chk_xalloc to allocate the
argument vector, providing an overflow check. Use self
variable in place function name embedded in literal.
(getgroups_wrap): Use chk_xalloc instead of chk_malloc,
so multiplication overflow is checked. Use self variable
in place function name embedded in literal.
(setgroups_wrap): Revamp existing overflow check. Use
ucnum for the size, check that it can convert to size_t
and back without loss of value, and use chk_xalloc
instead of chk_malloc.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (vector): Bugfix: we are checking whether
length + 2 is negative, not length. Check the original
value, and simplify everything using check_mulloc.
(list_vec, sub_vec): Use chk_xalloc just in case. There
shouldn't be any overflow if the vector was constructed and
manipulated properly.
(replace_vec): Replace division-based oveflow check with
a simple test that total + 2 doesn't overflow; then
rely on chk_xalloc to do the multiplication overflow
check.
|
|
|
|
|
| |
* lib.c (chk_wmalloc): Drop the incorrect multiplication
overflow test, and just call chk_xalloc.
|
|
|
|
|
|
|
|
|
| |
This will simplify code that allocates an array-like
object whose size is the product of two numbers.
* lib.c (chk_xalloc): New function.
* lib.h (chk_xalloc): Declared.
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_dup): Do size multiplication using unsigned
type, then coerce back to signed. Check for overflow correctly
by first testing result for negative, then doing division check.
(carray_replace): Add check for negative size, which confirms
overflow.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carrayp): New function.
(ffi_init): Register carrayp intrinsic.
* ffi.h (carrayp): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thanks to this (set [ca from..to] list) works.
* ffi.c (carray_replace): New function.
(ffi_init): Register carray-replace intrinsic.
* ffi.h (carray_replace): Declared.
* ffi.c (replace): Hook in carray_replace.
* txr.1: Mention carray under replace, and document
carray-replace.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_pun): New function.
(ffi_init): Registered carray-pun intrinsic.
* ffi.h (carray_pun): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thus, [ca 3..5] syntax works for slice extraction.
However, this works referentially, not by making a copy.
The extracted subarray points to the original memory,
until carray-dup is invoked on it.
* ffi.c (carray_sub): New function.
(ffi_init): carray-sub intrinsic registered.
* ffi.h (carray_sub): Declared.
* lib.c (sub): Handle carray via carray_sub.
* txr.1: Documented changes in sub.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Thus (select ca '(0 3 4 ...)) works and so does the
sytnax [ca '(0 3 4 ...)]. This is inefficiently implemented.
The selected elements are extracted to a list which is then
converted to a carray of the same kind agan.
* ffi.c (carray_list): New function.
(ffi_init): Register carray-list intrinsic.
* ffi.h (carray_list): Declared.
* lib.c (make_like): Add carray case, so we can turn
a list into a carray based on an example carray.
This uses carray_list, with the type pulled from the
original carray. The target isn't null terminated.
(sel): Handle carray via vector case.
* txr.1: Document changes in select and make-like.
|
|
|
|
| |
* lib.c (generic_funcall, ref, refset): Handle BUF.
|
|
|
|
|
|
| |
* lib.c (length): Handle COBJ of carray type.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Restructure the length documentation to use
definition-style paragraphs, and add buf.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (struct carray): New member, artype.
(carray_mark_op): Mark artype member.
(make_carray): Initialize artype to nil.
(carray_ensure_artype, carray_get_common, carray_put_common):
New static functions.
(carray_get, carray_getz, carray_put, carray_putz): New
functions.
(ffi_init): Register intrinsics carray-get, carray-getz,
carray-put, carray-putz.
* ffi.h (carray_get, carray_getz, carray_put, carray_putz):
Declared.
* txr.1: Documented new functions.
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_get): Renamed to carray_ptr.
(ffi_carray_put): Follow rename.
* ffi.h (carray_get): Declaration removed.
(carray_put): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The FFI module is more than just foreign calls and callbacks;
it provides a type system and operations for working with
binary data. None of it depends on libffi being present and so
shouldn't be disabled if libffi is not available.
* Makefile (ffi.o): Unconditionally link this object file,
not subject to the have_libffi variable.
* configure (have_libffi): Variable removed.
(gen_config_make): Do not generate a have_libffi
variable into config.make, since nothing needs it.
* ffi.c (ffi_type): Fake ffi_type defined if libffi is
missing.
(FFI_TYPE_STRUCT): Fake macro.
(ffi_type ffi_type_void, ffi_type_pointer, ffi_type_sint,
ffi_type ffi_type_schar, ffi_type_uchar, ffi_type
ffi_type_sshort, ffi_type_ushort, ffi_type ffi_type_sint,
ffi_type_uint, ffi_type ffi_type_slong, ffi_type_ulong,
ffi_type ffi_type_sint8, ffi_type_uint8, ffi_type
ffi_type_sint16, ffi_type_uint16, ffi_type ffi_type_sint32,
ffi_type_uint32, ffi_type ffi_type_sint64, ffi_type_uint64,
ffi_type ffi_type_float, ffi_type_double): Fake libffi type
objects, so that code which references these things will
build without modification.
(ffi_get_type): Function only defined if we have libffi.
(ffi_type_struct_destroy_op, ffi_struct_clone,
make_ffi_type_struct, ffi_array_clone, make_ffi_type_array):
Don't work with ffi_type's element array if we don't have
libffi; our fake ffi_type doesn't have such an array.
(struct txr_ffi_closure): Type only defined if we have libffi.
(ffi_closure_struct, ffi_closure_struct_checked,
ffi_closure_print_op, ffi_closure_destroy_op,
ffi_closure_mark_op, ffi_closure_put): Functions only defined
if we have libffi.
(ffi_closure_ops): Static structure only defined if we have
libffi.
(ffi_init_types): Don't register a closure type if we don't
have libffi.
(struct txr_ffi_call_desc): Don't define type if we don't have
libffi.
(ffi_call_desc, ffi_call_desc_checked, ffi_call_desc_print_op,
ffi_call_desc_destroy_op, ffi_call_desc_mark_op,
ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch,
ffi_closure_dispatch_safe, ffi_make_closure,
ffi_closure_get_fptr): Functions only defined if we have
libffi.
(ffi_call_desc_ops): Static structure only defined if we have
libffi.
(ffi_init): Only register ffi-make-call-desc, ffi-call, and
ffi-make-closure if we have libffi.
* lib.c: Include "ffi.h" header unconditionally.
(generic_funcall, ref, refset, int): Remove #if HAVE_LIBFFI.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that the get semantics (zarray char)
produces a vector of characters, not a string. Ditto for
bchar and wchar.
* ffi.c (ffi_varray_null_term_in): Check for the char_conv,
wchar_conv or bchar_conv flag and delegate to
ffi_array_get_common.
(ffi_type_compile): Set char_conv, wchar_conv or bchar_conv
flag for incomplete zarray.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that if we have a typedef like (typedef x char)
then (array 256 x) will not do string conversion in the manner
of (array 256 char). This is because the raw syntax is checked
for the symbol char, rather than inspecting the type object.
* ffi.c (ffi_type_compile): When checking whether the array
element is a char, bchar or wchar, look at the syntax in
the compiled type object, not the raw syntax. The compiled
type object is the original type pulled from behind the
typedef alias and has the symbol char, bchar or wchar as
its syntax.
|
|
|
|
|
| |
* txr.1: forgotten documentation added: the carray-own
function can't be used on a carray which references a buf.
|
|
|
|
|
|
|
|
|
| |
* lib.c (generic_funcall): Handle carray object via
the same cas that handles vectors, lists and strings.
That in turn works via ref and other lower-level
functions (not all of which support carray yet).
(ref): Handle carray object via carray_ref.
(refset): Handle carray_object via carray_refset.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Bug: rng fails to activate when the to and from condition
are true for the same record.
* share/txr/stdlib/awk.tl (sys:awk-mac-let): Rename the flag-new
gensym holder to flag-act, since it indicates whether the range
is active, either from before or due to being activated by
the current record. A new gensym is added to indicate whether
the range is being deactivated in this record. The inclusive
rng range refers to this variable rather than flag-old.
But a bug emulation is provided to refer to the wrong variable.
* txr.1: Added compatibility note.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
| |
The way bitfields are laid out must be changed. The
requirements were reverse-engineered by experimentation.
* ffi.c (make_ffi_type_struct): Member allocation loop
substantially rewritten.
* txr.1: Documentation rewritten. Description of the
bitfield allocation algorithm moved to a separate paragraph.
|
|
|
|
|
|
| |
* arith.c (c_unum): When the input value is negative, complain
about that, not about uint_ptr_t, which means nothing in
TXR Lisp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (bit_s): New symbol variable.
(ffi_generic_sbit_put, ffi_generic_sbit_get,
ffi_generic_ubit_put, ffi_generic_ubit_get): New static
functions.
(bitfield_syntax_p): Include bit symbol in the check.
(make_ffi_type_pointer): Zero size is no longer an early
rejection test for bitfields; don't rely on it.
(make_ffi_type_struct): Revise the member calculating loop
to handle bitfields of various sizes. If a bitfield
follows one of a different size, it starts a new cell
even if the previous one has room, et cetera.
The masking and shifting is set up to work on cells of
int size; however, the new ffi_generic_s?bit_{put,get}
functions use a temporary buffer and transfer just the
right number of bytes to and from the actual buffer.
(ffi_struct_compile): The check against incomplete type
members only needs to test size zero; bitfields have nonzero
size now, which is the true size of the underlying storage
unit. They also have true alignment, which is used in
make_ffi_type_struct rather than hard-coding to alignof (int).
New syntax (bit width type) is now handled, where type can
be any of the signed and unsigned integral types up to int32
and int. The endian types are not supported for now.
(ffi_typedef, ffi_size, ffi_alignof): Zero size is no longer
an early rejection test for bitfields; don't rely on it.
(ffi_init): Initialize bit_s.
* ffi.h (bit_s): Declared.
* txr.1: Documented.
|
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Give the bitfield type
the evaluated syntax where the width expression
is reduced to an integer value.
|
|
|
|
|
|
|
|
|
| |
* configure: test for clockid_t type refers to
CLOCK_REALTIME macro also, which comes from <time.h>.
But that header isn't included. Since we only care
about whether or not we have the type, for the sake of
defining it in FFI, and don't use the CLOCK_REALTIME
macro anywhere, let's replace it with a 0 constant.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Old style casts have crept into the code base.
* buf.c (make_buf, buf_grow, buf_get_i8, buf_get_u8): Replace
old style cast with macro.
* ffi.c (align_sw_get, align_sw_put, ffi_be_i32_get,
ffi_be_u32_get, ffi_le_i32_put, ffi_le_i32_get,
ffi_le_u32_get, ffi_be_i64_put, ffi_be_i64_get,
ffi_be_u64_get, ffi_le_i64_put, ffi_le_i64_get,
ffi_le_u64_get, ffi_sbit_put, ffi_sbit_get,
ffi_init_extra_types): Likewise.
* hash.c (hash_buf): Likewise.
* itypes.c (c_i32, c_i64, c_u64): Likewise.
* stream.c (stdio_put_buf, stdio_fill_buf): Likewise.
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_sbit_put, make_ffi_type_struct): Fix
signed/unsigned comparison warning from g++.
(pad_retval): Likewise.
* stream.c (stdio_put_buf, stdio_fill_buf): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.h (struct strm_ops): put_buf and fill_buf function
pointers get third argument to indicate starting position
of read and write.
(put_buf, fill_buf): Declarations updated.
* stream.c (unimpl_put_buf, unimpl_fill_buf): Third argument
added.
(generic_put_buf, generic_fill_buf, stdio_put_buf,
stdio_fill_buf): Implement position
argument.
(delegate_put_buf, delegate_fill_buf): Take third argument,
pass it down.
(put_buf, fill_buf): New position argument in second position.
Defaulted to zero. Passed down.
(stream_init): Updated registration of put-buf and fill-buf.
* txr.1: Updated documentation.
|