| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
* txr.1: New section "Editing Help" under "Interactive
Listener" describing Ctrl-X ?
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): Fix incorrect shift
calculations, which are still being done from the
unit_offs byte rather than the correct offs byte where
the bitfield is actually placed. It is bit_offs which
has the correct bit offset of the bitfield relative
to offs.
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_union): Two arguments added. These
are optional.
(ffi_init): Update registration of make-union as
three-parameter function, with one required arg.
* ffi.h (make_union): Declaration updated.
* txr.1: Documented.
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Syntax for union type wrongly
using struct symbol rather than union.
|
|
|
|
|
| |
* txr.1: Split mapcar "zipper" example into two lines to
prevent wrapping and add missing -> between form and output.
|
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Assign full bool syntax to
cloned type, rather than just the argument syntax denoting the
base type.
|
|
|
|
|
| |
* ffi.c (ffi_make_call_desc): Throw error if argument or
return value is a bitfield.
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Check for too few or too many
arguments in a compound form.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (prod_common): New static function.
(maprodv, maprendv): New functions.
(eval_init): Registered maprod and maprend intrinsics.
* eval.h (maprodv, maprendv): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (enumed_s): New symbol variable.
(ffi_type_compile): New case for enumed type op.
(ffi_init): Initialize enumed_s.
* ffi.h (enumed_s): Declared.
* txr.1: enumed documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This lays the groundwork for enumerations based off types
other than int. All we need to do is implement the
syntax for this.
* ffi.c (ffi_enum_put, ffi_enum_get, ffi_enum_rput,
ffi_enum_rget): Retrieve the element type descriptor
and recurse into its put, get, rput and rget operation,
respectively, instead of hard-coded calls to the int
operations.
(make_ffi_type_enum): New argument, base_type.
Numerous properties of the enum type are taken from base_type:
the FFI type, the alignment, size, and alloc, free and
clone operations. The base type is installed as eltype.
(ffi_type_lookup): Static function relocated.
(ffi_type_compile): In the enum case, resolve the int type
and pass to make_ffi_type_enum.
|
|
|
|
|
|
| |
* ffi.c (ffi_enum_put, ffi_enum_rput): Fix function name
appearing in quotes in error diagnostic. Fix nonexistent
member being wrongly reported as nil.
|
|
|
|
|
|
|
|
|
|
|
|
| |
We either mishandle return values, or crash due to
a null rput/rget function pointers on aggregate types
and bools.
* ffi.c (ffi_bool_rput, ffi_bool_rget): New static functions.
(make_ffi_type_pointer, make_ffi_type_struct,
make_ffi_type_union, make_ffi_type_array): Fill in rput and rget.
(ffi_type_compile): Fill in rget and rput for bool with new
functions.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_varray_null_term_in): Rewrite nonsensical
code that refers to the newly created empty output array
as input. We must perform the in semantics on all the
original elements. Then get semantics on any new elements
if the array was extended, and the copy flag is true
(by-ref nuance).
|
|
|
|
|
|
|
|
| |
* lisplib.c (ffi_set_entries): Add deffi-sym to autload list.
* share/txr/stdlib/ffi.tl (deffi-sym): New macro.
* txr.1: Documented.
|
|
|
|
|
|
| |
* txr.1: Provide the correct description of the syntax
allowed for var-expr; i.e. that deffi-var can be put into
a with-dyn-lib form and all that.
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register new intrinsics cptr-cast and
int-cptr.
* lib.c (cptr_cast, int_cptr): New functions.
* lib.h (cptr_cast, int_cptr): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* txr.1: Fix syntax block under cptr-obj giving
function name as cptr-int.
|
|
|
|
| |
* ffi.c (ffi_varray_alloc): Add tft->null_term to length.
|
|
|
|
|
|
| |
* ffi.c (ffi_varray_null_term_in): Pass zero to replace
rather than 0, which corresponds to nil and is interpreted
as a list by replace.
|
|
|
|
| |
* txr.1: Fix date to 2017-06-25.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_union): Create cobj with correct
cobj_ops structure: ffi_type_struct_ops, not
ffi_type_enum_ops.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can't use the eltype field of the type structure
to store the cptr tag symbol, because that is expected
to be a type object and not a symbol.
* ffi.c (struct txr_ffi_type): New member, tag.
(ffi_cptr_put, ffi_cptr_get, ffi_cptr_alloc): Refer to
tag rather than eltype.
(ffi_type_compile): Handle the compound cptr type
using the same code as the simple one in ffi_init_types: use
make_ffi_type_builtin rather than make_ffi_type_pointer.
Install the tag into the tag field. Also set up the forgotten
alloc and free routines.
(ffi_init_types): For cptr, explicitly initialize the tag
to nil. This is not necessary since the structure is calloced,
and we rely on that for nil all over the place, but here it
serves as a reminder that cptr has a tag.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The recent commit "ffi: elide useless by-value in calls."
neglects to mark a few types with the by_value_in flag.
The string types need it because their in action performs
memory freeing, which must be done regardless of the
by-value or by-pointer semantics.
* ffi.c (ffi_init_types): set by_value_in to 1 for str,
bstr and wstr. In general, if the type needs a release
function, it needs by_value_in to be set.
|
|
|
|
| |
* txr.1: Fix "out operation" that should be "in operation.
|
|
|
|
|
|
|
| |
* txr.1: the actions argument of tcsetattr is
optional and its defaulting is correctly described.
Fix the syntax synopsis which wrongly indicates that
it is required.
|
|
|
|
|
| |
* txr.1: In the Dialect Notes, one of the notes is
confusingly split into two paragraphs.
|
|
|
|
|
| |
* txr.1: A symbol is not "returned" by the reader; drop that
text. Use the terminology that a token is interned.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can avoid calling in methods in the by-value nuance
(copy == 0) on types known not to have by-value in semantics.
Basic types have no by-value in.
Pointers inherently have by-value in.
An aggregate has by-value in semantics if any of one
of its members does, otherwise not.
* ffi.c (struct txr_ffi_type): New bitfield member,
by_value_in.
(ffi_ptr_in_in, ffi_ptr_in_d_in): Elite in call if target
type's by_value_in flag is clear.
(ffi_struct_in): Short-circuit to a return if doing by-value,
and the FFI struct type has no by-value semantics.
(ffi_array_in_common): Likewise. In this code change, we
just have to replace the test whether the element type has
an in method with a test of its by_value_in flag.
(make_ffi_type_pointer): Set by_value_in flag to 1, since
pointers have by value in semantics. This is true also of
ptr-in, because a structure passed as an in parameter to a
function via ptr-in could itself contain ptr or ptr-out
elements.
(make_ffi_type_struct): Set the type's by_value_in if
any element type's by_value_in is true.
(make_ffi_type_array): Propagate the by_value_in flag from
the element type to the array type.
(ffi_call_wrap): Calculate the in_pass_needed local flag
from the by_value_in flags of the arguments, not from whether
or not they have an in function. Only call the in function
for arguments which have the flag set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The theme here is that if a struct or array is
being subject to a by-value in operation, there
is nothing to do for that aggregate itself. So
if there is no corresponding Lisp object, we
should not create one. The caller isn't expecting
it and will throw it away. If it is known that no
element of an aggregate supports by-value semantics,
then the operation should short-circuit, and not
perform a useless loop.
* ffi.c (ffi_struct_in): If the strct parameter is nil,
don't unconditionally make a new structure; do so only
when the copy flag is asserted (by reference semantics).
If there is no Lisp struct object and by value semantics is
in effect, there is no point in doing anything; just
short-circuit to a nil return.
(ffi_array_in_common): If doing by value semantics, and
there is no vector object or the structure element type
has no by value in semantics (such as a basic type),
then short circuit to an early return.
(ffi_array_in): Only do the special string decoding when
reference semantics is in effect; there is no point
in extracting strings back from a by-value struct.
If by-value semantics is in effect, we fall through to
the ffi_array_in_common call even for character types;
but since those types have no by-value in semantics,
that function will just short-circuit, which is what we want.
(ffi_varray_in): If there is no vec, bail out with nil,
regardless of whether this is by value or not.
Just return vec if by-value semantics is in effect; don't
try to update it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (union_s): New symbol variable.
(ffi_find_memb, ffi_memb_not_found): New static functions.
(ffi_union_in, ffi_union_put, ffi_union_get): New static
functions.
(make_ffi_type_union): New static function.
(ffi_struct_compile): Handle union syntax using
ffi_struct_compile to compile the member definitions to types,
and make_ffi_type_union to produce the type node.
(struct uni): New struct type.
(uni_struct, uni_struct_checked): New static functions.
(union_destroy_op, union_mark_op): New static functions.
(union_ops): New static struct.
(make_union_common, make_union_tft): New static functions.
(union_get_ptr, make_union, union_members, union_get,
union_put, union_in, union_out): New functions.
(ffi_init): Initialize union_s. Register intrinsics
make-union, union-members, union-get, union-put, union-in,
union-out.
* ffi.h (union_s, union_get_ptr, make_union, union_members,
union_get, union_put, union_in, union_out): Declared.
* txr.1: Documented unions.
|
|
|
|
|
|
|
|
|
|
|
| |
Upcoming work is going to benefit from a pointer for
navigating from the txr_ffi_type structure to the Lisp object
whose implementation is that structure.
* ffi.c (struct txr_ffi_type): New member, self.
(make_ffi_type_builtin, make_ffi_type_pointer,
make_ffi_type_struct, make_ffi_type_array,
make_ffi_type_enum): Initialize self pointer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't bother creating and filling the ffi_type elements[]
array for a structs or array. Let's punch in the size and
alignment fields with the values we calculate ourselves
already, and set up a dummy elements[] array that contains
only a null terminator.
* ffi.c (struct txr_ffi_type): New member, elements:
one element dummy array that holds a null pointer.
(ffi_type_struct_destroy_op): Do not free ft->elements,
since it isn't dynamically allocated any more.
(ffi_struct_clone, ffi_array_clone): Don't copy the elements
array; just set up a dummy elements array in the copied type.
(make_ffi_type_struct, make_ffi_type_array): Eliminate the
dynamic allocation of the elements array. Point ft->elements
to the dummy array. Set up the ft->size and ft->alignment.
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_float_put): Fix silly range check:
FLT_MIN and FLT_MAX are, of course, both positive.
Also, fix num being used as an argument in the error
diagnostic. It's the address of a C function, not
an object.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (bool_s): New symbol variable.
(ffi_bool_put, ffi_bool_get): New static functions.
(ffi_type_compile): Handle (bool <type>) parametrized type.
(ffi_init_types): Register bool typedef for (bool uchar).
(ffi_init): Initialize bool_s.
* ffi.h (bool_s): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Update registration of cptr-int and
cptr-obj with one optional argument.
* lib.c (cptr_int): New type symbol argument, defaulting
to nil. Also, don't bother defaulting the integer argument;
the function isn't registered for that being optional.
(cptr_obj): New type symbol argument, defaulting to nil.
* lib.h (cptr_int, cptr_obj): Declarations updated.
* txr.1: Documented cptr-int and cptr-obj function changes.
Added discussion of type tag to introductory paragraph.
Also added neglected documentation of the FFI cptr type,
both unparametrized and parametrized.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem here is that ensure-stream ignores the mode
argument and decides between "r" and "w". That is incorrect;
the mode could be "a" for append.
The second problem is that the ignored mode strings are
also wrong. For an input pipe, "w" is specified rather than
"r".
* share/txr/stdlib/awk.tl (sys:awk-state ensure-stream): Use
the mode argument. The cases consolidate, because all that
need be distinguished here is file versus pipe.
(sys:awk-mac-let): for the <! redirection (input from pipe),
the mode must be "r", not "w".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the case when the :output clause of the awk macro opens a
stream, it isn't closing it. Why don't we treat such a stream
uniformly with redirections.
* share/txr/stdlib/awk.tl (sys:awk-state :postinit):
If a file is opened for output, then don't just install
this file as self.output. Also place it into the self.streams
hash, identified by using the key (:outf <name>), just
like a (-> "name") redirection. This ensures that it will
be closed when the awk macro terminates. It's also potentially
useful in that output redirections referring to the name will
use the same stream.
* txr.1: Documented that streams opened by :output are
closed, and that they are treated uniformly with redirections.
|
|
|
|
|
|
|
| |
* match.c (h_trailer): Prevent LOG_MATCH call from
being evaluated in failed case, when the position is nil.
This situation triggers an exception, because LOG_MATCH
prints the position as an integer using ~d.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim, protsym.c: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (do_mp_error): New function.
(num_from_buffer, plus, minus, mul, floordiv, expt, exptmod,
logtrunc, sign_extend, ash, bit): Handle errors from select
MPI functions: those that have the mp_ign attribute.
* ffi.c (unum_carray, num_carray): Likewise.
* rand.c (random): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Using a feature of GCC, we mark some functions with the
warn_unused_result attribute. Specifically, those functions
which could return the MP_TOOBIG overflow error.
* mpi/mpi.h (mp_nign): New macro.
(mp_init_size, mp_add_d, mp_sub_d, mp_mul_d, mp_mul_2,
mp_div_d, mp_div_2, mp_expt_d, mp_add, mp_sub, mp_mul,
mp_mul_2d, mp_sqr, mp_expt, mp_2expt, mp_sqrt, mp_addmod,
mp_submod, mp_mulmod, mp_sqrmod, mp_exptmod, mp_exptmod_d,
mp_lcm, mp_xgcd, mp_invmod, mp_trunc_comp, mp_trunc, mp_shift,
mp_to_double, mp_read_signed_bin, mp_read_unsigned_bin,
mp_read_radix): Functions attributed with unused result
warning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The main purpose of this patch is to prevent two cases of
numeric overflow.
One is when an arithmetic operation produces a result which
would have more digits than can be represented by mp_size. The
calculation for the digits in the result operand will simply
overflow, resulting in an undersized buffer that is then
overrun.
Another overflow is in calculations which work with bit
indexing. Even if the digits is in range of mp_size, the bit
number is eight times larger and can be out of range.
We can address both problems by clamping integers to have only
so many digits, that every bit has an offset that fits into
mp_size. If mp_size is 32 bits, that means we can still have
bignums that are half a gigabyte, which seems reasonable for
nearly any conceivable application of bignums.
After this patch, we must adjust the code in arith.c and
other places to detect errors, at least out of the functions
that can produce larger integers than their inputs.
* mpi/mpi-types.h (MP_MAX_BITS, MP_MAX_DIGITS): New macro.
* mpi/mpi.c (mp_err_string): New entry corresponding to the
new MP_TOOBIG error.
(mp_init_size, s_mp_grow): Reject, with the MP_TOOBIG error,
attemps to create or grow an mp_int mp_int such that it would
have more digits than MP_MAX_DIGITS.
* mpi/mpi.h (MP_TOOBIG): New macro code.
(MP_LAST_CODE): Redefined to MP_TOOBIG.
|
|
|
|
|
|
|
|
|
|
|
| |
* mpi.c (s_mp_cmp): Rewrite loop as a for with
a bottom test, and the increments in the usual place.
ap and bp aren't decremented if the index is zero.
Ironic to fix this, given that we march through the
stack in the garbage collector.
(s_mp_ispow2): Similar restructuring, with an additional
guard around ix being set up to descend from the
second-to-last digit.
|
|
|
|
| |
* mpi/mpi-config.h (MP_DEFPREC): Change from 16 to 8.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
MPI has a mp_size type for sizing of the digit arrays and some
other uses. It is not consistently used. Moreover, it is
typedef'd as a signed type. The type int is used for
iterating over digits, instead of the matching mpi_size type.
The int type is used as a size argument in some functions,
and in functions that return the number of bits.
This patch makes mp_size unsigned and replaces most uses of
int with a more appropriate type.
Because mp_size is now used for indexing, and is unsigned,
some downward loop termination tests have to be changed;
the always true condition ix >= 0 cannot be used.
* arith.c (width): Use mp_size for local variable which
iterates over digits inside mpi_int object, and for bit
count. Use unum to convert bit count to Lisp integer:
mp_size could be out of range of cnum.
* mpi/mpi-types.h (mp_size): Typedef to unsigned.
(MP_SIZE_MAX): New macro.
(MP_DIGIT_BIT, MP_WORD_BIT): Cast the value to mp_size rather
than to int.
* mpi/mpi.c (s_mp_defprec): Declare variable as mp_size.
(s_mp_setz, s_mp_copy, mp_size, s_highest_bit_mp,
s_mp_set_bit, s_mp_ispow2, s_mp_outlen, mp_set_int,
mp_set_uintptr, mp_set_double_intptr, mp_expt, mp_sqrt,
mp_exptmod, mp_hash, mp_gcd, mp_shift, mp_bit, mp_to_double,
mp_print, mp_read_signed_bin, mp_signed_bin_size,
mp_read_unsigned_bin, mp_unsigned_bin_size,
mp_to_unsigned_bin, mp_to_unsigned_buf, mp_count_bits,
mp_is_pow_two, mp_read_radix, mp_radix_size,
mp_value_radix_size, mp_toradix_case, s_mp_setz, s_mp_copy,
mp_size, s_highest_bit_mp, s_mp_set_bit, s_mp_mul_2,
s_mp_mod_2d, s_mp_div_2d, s_mp_div_d, s_mp_sqr, s_mp_sqr,
s_mp_div, s_mp_cmp, s_mp_cmp_d, s_mp_ispow2, s_mp_outlen): In
all these functions, use size_t for external size, mp_size for
number of digits and bits, in return values, arguments and
local variables. Tests in descending loops are adjusted for
unsigned logic.
* mpi/mpi.h (mp_get_prec, mp_set_prec, mp_read_signed_bin,
mp_signed_bin_size, mp_read_unsigned_bin,
mp_unsigned_bin_size, mp_to_unsigned_buf, mp_count_bits,
mp_is_pow_two, mp_radix_size, mp_value_radix_size):
Declarations updated.
* mpi/mplogic.c (mpl_not, mpl_and, mpl_or, mpl_xor, mpl_rsh,
mpl_lsh, mpl_num_set, mpl_num_clear, mpl_parity): Just like
in mpi.c
* rand.c (make_random_state): Use mp_size and ucnum for local
variables holding digit and bit counts.
* sysif.c (off_t_num): Use mp_size for digit count.
|
|
|
|
|
|
|
|
|
| |
mp_shift takes an int argument, but we decode bits to
a cnum, leaving possible room for overflow, such as
when cnum is 64 bits and int is 32. If the value
* arith.c (ash): Check that the value is in the range
of INT_MIN to INT_MAX.
|
|
|
|
|
| |
* arith.c (ash): Refer to ash in error messages rather than
ashift.
|