| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the second round of an effort to enable GCC's -Wextra
option. All function parameters that are unused and
are removable are removed. They are eliminated from the
function defintions, declarations, callers, and any related
function pointer variables or structure members.
* arith.c (nary_simple_op): Remove unused self parameter.
See lib.c: maxv, minv.
* chksum.c (crc32_buf, crc32_str): Remove unused self
parameter.
(crc32): Don't pass self to the above functions.
* eval.c (copy_env_handler, copy_bh_env_handler): Remove
unused parent parameter. See unwind.c.
(supplement_op_syms): Remove unused max parameter.
(me_op): Don't pass max to supplement_op_syms.
* lib.c (seq_iter_rewind): Remove unused self parameter.
(lazy_flatten_func): Remove unused env parameter.
(lazy_flatten): Use func_n1 to create non-environment-carrying
funtion out of lazy_flatten_func.
(maxv, minv): Don't pass self parameter to nary_simple_op.
(middle_pivot): Remove unused lessfun param.
(quicksort): Don't pass lessfun to middle_pivot.
(diff, isec): Don't pass self to seq_iter_rewind.
* lib.h (seq_iter_rewind, nary_simple_op): Declarations
updated.
* struct.c (get_super_slots): Remove unused self parameteer.
(make_struct_type): Don't pass self to get_super_slots.
* sysif.c (flock_unpack): Remove unused self parameter.
(fcntl_wrap): Don't pass self to flock_unpack.
* unwind.c (uw_push_cont_copy): Remove parent parameter from
function pointer parameter. See eval.c: copy_env_handler.
(call_copy_handlers): Remove parent parameter and don't
pass that argument to the indirect call via pointer
to the copy handler function.
(revive_cont, capture_cont): Don't pass 0 value to
removed parent parameter of call_copy_handlers.
* unwind.h (struct uw_cont_copy): Function pointer member copy
loses parent parameter.
(uw_push_cont_copy): Declaration updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c,
args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h,
chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c,
ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c,
glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c,
lib.h, linenoise/linenoise.c, linenoise/linenoise.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c,
regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl,
share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl,
share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl,
share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl,
share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl,
share/txr/stdlib/package.tl, share/txr/stdlib/param.tl,
share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl,
share/txr/stdlib/pmac.tl, share/txr/stdlib/save-exe.tl,
share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl,
share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/vm-param.tl,
share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, socket.c, socket.h, stream.c, stream.h,
struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h,
syslog.c, syslog.h, termios.c, termios.h, tree.c, tree.h,
txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c,
vm.h, vmop.h, win/cleansvg.txr: Extended copyright notices
to 2020.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (sinh_s, cosh_s, tanh_s, asinh_s, acosh_s, atanh_s):
New symbol variables.
(sinh, cosh, tanh, asinh, acosh, atanh): New static functions.
(sineh, cosih, tangh, asineh, acosih, atangh): New functions.
(arith_init): Register sinh, cosh, tanh, asinh, acosh and
atanh intrinsic functions, and initialize the new symbol
variables.
* configure: Detect availability of hyperbolic functions in
math library and defne HAVE_HYPERBOLICS as 1 in config.h
accordingly.
* lib.h (sineh, cosih, tangh, asineh, acosih, atangh):
Declared.
* txr.1: Documented new hyperbolic functions and their method
counterparts that a numeric struct can implement.
|
|
|
|
|
|
|
| |
* arith.c (digcommon): Improved termination test in the second
loop to avoid wasteful pop when the list of powers is empty.
Use rcyc_pop to recycle these conses; they will be immediately
reused for building the output list.
|
|
|
|
|
|
| |
* arith.c (digcommon): Fix off-by-one test causing incorrect
results for radix powers like (digits 10) (digits 100) ...
and analogously in other radices. Reported by vapnik spaknik.
|
|
|
|
|
| |
* arith.c (digcommon): Fix wrong test that allows base 1 to be
admitted, resulting in infinitely looping behavior.
|
|
|
|
|
|
|
|
|
| |
* arith.c (ash): Introduce smaller scopes and move variable
initializations close to their use. The NUM case of argument
a no longer falls through to the BGNUM case, and doesn't
cons up a bignum object. Rather, a temporary mp_int is
allocated, used and freed. The gc_hint added in the previous
commit is now gone.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On 32 bit x86 Solaris 10, with gcc 4.9.0, this issue caused a
miscompilation of the pset macro, due to ash abruptly
returning zero, causing the op-code field of an instruction to
be NOOP rather than GCALL.
I'm committing this fix just for reference; I will immediately
replace it with a refactoring of the function.
* arith.c (ash): Add a gc_hint to prevent the a bignum from
being reclaimed if the b = make_bignum() triggers gc.
This happens in the case when the previous case computes
a = make_bignum() and falls through.
|
|
|
|
|
|
|
| |
* arith.c (logcount): NUM case doesn't have a return statement
in 64 bit build, statement causing fall-through to BGNUM case
where the integer object is treated as a bignum. This bug has
existed in the function ab initio.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (bitset_s): New symbol variable.
(bitset): New function.
(arith_init): bitset_s initialized, bitset intrinsic
registered.
* lib.h (bitset): Declared.
* txr.1: Documented bitset function and method.
|
|
|
|
|
| |
* arith.c (int_flo): Don't subtract one from INT_PTR_MIN any
more, since it is now the most negative integer already.
|
|
|
|
|
|
| |
* arith.c: we need to include "alloca.h" since we have moved
some functions into here from lib.c which use "args.h" macros.
This shows up on Cygwin and some other platforms.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (r_ceil_s, r_round_s): New symbol variables.
(ceildiv, roundiv): Route binary cases involving struts
directly to binary methods so the object is responsible for
the complete implementation.
(arith_init): Initialize r_ceil_s and r_round_s.
* tests/016/ud-arith.tl (numbase): Binary methods added for
ceil and round. Test cases added.
* txr.1: Descriptions for binary ceil and round methods added;
Notes about non-existence of binary methods removed from unary
ceil and round removed.
|
|
|
|
|
| |
* arith.c (plus, minus, mul, mod, floordiv): Dispatch reverse
operaton for PTR/COBJ combination.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* tests/016/ud-arith.expected b/tests/016/ud-arith.tl:
New file.
* tests/016/ud-arith.expected b/tests/016/ud-arith.expected:
New file.
* arith.c (divi): Bugfix: wrong argument tested for being
a COBJ.
(logtrunc): Fix incorrect method call: calling r-logtrunc-s
for the object-in-left-position case.
(sign_extend): Fix semantics not following documentation:
dispatch method with original arguments.
(divv): When there is just one argument, take advantage of the
hitherto unused unary case of divi rather than giving it both
arguments. The object dispatch is in that unary case, so we
need it now.
(arith_init): Fix wrong name of r_lognot_s symbol.
* txr.1: Fix atan2 being documented as atan.
Fix misspelling of r-lognot as lognot-r.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most of the library now accepts struct objects as
arguments, relying on them to implement methods.
* arith.c (minus_s, inv_minus_s, neg_s, abs_s, signum_s,
mul_s, div_s, recip_s, inv_div_s, trunc1_s, trunc_s,
r_trunc_s, mod_s, r_mod_s, zerop_s, plusp_s, minusp_s,
evenp_s, oddp_s, gt_s, lt_s, ge_s, le_s, numeq_s, expt_s,
r_expt_s, exptmod_s, isqrt_s, square_s, floor_s, floor1_s,
r_floor_s, ceil_s, ceil1_s, round_s, round1_s, sin_s, cos_s,
tan_s, asin_s, acos_s, atan_s, atan2_s, r_atan2_s, log_s,
log2_s, log10_s, exp_s, sqrt_s, logand_s, logior_s, logxor_s,
lognot1_s, lognot_s, r_lognot_s, logtrunc_s, r_logtrunc_s,
sign_extend_s, ash_s, bit_s, width_s, logcount_s): New symbol
variables.
(not_struct_error, method_error, do_unary_method,
do_binary_method, do_ternary_method): New static functions.
(plus, minus, neg, abso, signum, mul, trunc1, trunc, mod,
floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp,
oddp, gt, lt, ge, le, numeq, expt, exptmod, isqrt, square,
floorf, ceili, since, cosi, tang, asine, atang, atang2, loga,
logten, logtwo, expo, sqroot, logand, logior, logxor,
comp_trunc, lognot, sign_extend, ash, bit, logcount, width,
bits, unary_num, unary_arith): Support struct arguments.
(plusv, minusv, mulv, divv, sumv, prodv, gtv, ltv, gev, lev,
numeqv, exptv, logandv, logiorv): Use symbol for self instead
of string lit.
(arith_init): Initialize new symbol variables. Replace
existing intern calls in function registrations with
references to some of these symbol variables.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* arith.c (plus): Add missing break statements to two switch
cases. One is at the end, where it is not strictly necessary.
The other omission is harmless also and may have been
deliberate, though not commented by a /* fallthrough */.
The other functions with this same pattern, namely minus,
has the breaks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c, lib.c (num, c_num, c_fixnum, bad_float, flo, c_flo, fixnump, bignump,
integerp, floatp, numberp nary_op, nary_simple_op, plusv,
minusv, mulv, divv, logandv, logiorv, gtv, ltv, gev, lev,
numeqv, numneqv, sumv, prod, exptv, gcdv, lcmv): Function
definitions moved from lib.c to arith.c.
(nary_op_keyfun, unary_num, unary_arith, unary_int, sumv,
prodv, rexpt, abso_self): Static functions moved from
libmoved from lib.c to arith.c.
(max): New macro in arith.c.
(arith_init): Registrations moved from eval.c.
* eval.c (eval_init): Registrations moved to arith.c
|
|
|
|
|
|
|
|
| |
* arith.c (plus_s): Definition moved here.
(arith_init): Register numerous math intrinsics here.
* eval.c (plus_s): Definition removed.
(eval_init): Numerous math function registrations removed.
|
|
|
|
|
|
|
|
|
| |
* arith.c (expt): The function overhauled. Raising integers to
negative integers now works. Raising zero to a negative is
diagnosed as a division by zero for operands of all kinds.
* txr.1: Documentation updated for expt, and also division by
zero error is documented for the / function.
|
|
|
|
|
|
| |
* arith.c (highest_bit): On GCC, use __builtin_clz.
* mpi/mpi.c (s_highest_bit): Likewise.
|
|
|
|
|
|
| |
* arith.c (mul): In code that is only compiled when
HAVE_DOUBLE_INTPTR_T is missing/zero, we need to test the
return value of MPI's mp_mul.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We support an unsigned version of the type, and add functions
for converting between Lisp values and both types.
* arith.c (bignum_dbl_uipt): New function, unsigned companion
to existing bignum_dbl_ipt.
(c_dbl_num, c_dbl_unum): New functions.
* arith.h (bignum_dbl_uipt, c_dbl_num, c_dbl_unum): Declared.
* configure (superulong_t, SIZEOF_DOUBLE_INTPTR,
DOUBLE_INTPTR_MAX, DOUBLE_INTPTR_MIN, DOUBLE_UINTPTR_MAX,
double_uintptr_t): New definitions going into config.h.
* lib.h (dbl_cnum, dbl_ucnum): New typedefs: double-sized
analogs of cnum and ucnum.
* mpi/mpi.c (mp_set_double_uintptr, mp_get_double_uintptr,
mp_get_double_intptr): New functions.
(s_mp_in_big_range): New static function.
(mp_in_double_intptr_range, mp_in_double_uintptr_range): New
functions.
* mpi/mpi.h (mp_set_double_uintptr,
mp_get_double_intptr, mp_get_double_uintptr,
mp_in_double_intptr_range, mp_in_double_uintptr_range):
Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* mpi/mpi.c (mp_in_range, mp_in_intptr_range,
mp_in_uintptr_range): New functions.
* mpi/mpi.h (mp_in_range, mp_in_intptr_range,
mp_in_uintptr_range): Declared.
* arith.c (NUM_MAX_MP, INT_PTR_MAX_MP, UINT_PTR_MAX_MP,
INT_PTR_MAX_SUCC_MP): Static variables removed. Note that
INT_PTR_MAX_MP was not used at all!
(normalize): Use mp_in_range instead magnitude comparison to
NUM_MAX_MP.
(in_int_ptr_range, in_uint_ptr_range): Static functions removed.
(c_unum): Use mp_in_uintptr_range instead of
in_uint_ptr_range.
(arith_init): Remove initializations of removed variables.
(arith_free_all): Remove cleanup of removed variables, leaving
function empty.
* lib.c (c_num): Use mp_in_intptr_range instead of
in_int_ptr_range.
|
|
|
|
|
|
|
|
| |
* arith.c (c_unum): Fix misleading error message, and instead
specify the range that was violated.
* lib.c (c_num): Similar change: don't refer to a 'cnum range'
which means nothing to the user.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* hash.c (equal_hash, eql_hash, cobj_eq_hash_op,
hash_hash_op): Multiply object size by CHAR_BIT and switch on
number of bits, rather than bytes.
* sysif.c (off_t_num): Likewise.
* arith.c, ffi.c, itypes.c, rand.c: In numerous #if directive,
fix size tests from bytes to bits.
* configure: in the test that detects integer types, and in
the test for enabling large file offsets, detect one more
variable from the system: the value of CHAR_BIT. This
turns into SIZEOF_BYTE. We use that value instead of a
hard-coded 8.
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (bignum_dbl_ipt): Change internal function to
external linkage.
* arith.h (bignum_dbl_ipt): Conditionally declared.
* sysif.c (num_off_t): Use bignum_dbl_ipt instead of
open-coding exactly the same thing that bignum_dbl_ipt does.
Abort is changed to same internal_error as in off_t_num.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* mpi/mpi.h (mp_sign, mp_isneg, mp_used, mp_alloc, mp_digits,
mp_digit): New macros, based on renaming SIGN, ISNEG, USED,
ALLOC, DIGITS and DIGIT.
(mp_set_prec): Use mp_digits instead of DIGITS.
* mpi/mpi.c (SIGN, ISNEG, USED, ALLOC, DIGITS, DIGIT): Macros
defined here now, as local aliases for their namespaced
counterparts.
* arith.c (signum, floordiv): Replace ISNEG with mp_isneg.
* rand.c (random): Replace ISNEG with mp_isneg.
* sysif.c (off_t_num): Replace USED, DIGITS and ISNEG with
mp_used, mp_digits and mp_isneg.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The flaw in the rand function caused by mp_count_ones is
serious. For instance calls to (rand 3000000000) are expected
to produce evenly distributed values in the range zero
to one less than 3 billion. Due to this flaw, only values
in the range [0, 2147483648) are produced. The function is
wrongly informed that 3000000000 is a power of two, and
so it subtracts one from the number of bits needed for the
clamping bit mask, causing raw random values to be clamped
to 31 bits instead of 32.
* arith.c (logcount): Use mp_err to capture return value from
mp_count_ones, rather than mp_size. If the result is less than
zero, throw an internal error. (The only non-internal error
indication that could come from this function is a memory
allocation, and we already use chk_malloc under MPI).
* mpi/mpi.c (mp_count_ones): Switch return type to mp_err,
because this function returns error codes, which are negative.
(mp_is_pow_two): Fix broken test that is always true.
This affects our random number module; it's used in the random
function for bignum moduli.
(mp_toradix_case): Use unsigned char temporary for exchanging
two unsigned chars, rather than a char temporary.
(s_mp_div_d): Assert that the partial quotient t and
remainder w, of mp_word_type, have values that fit into the
mp_digit variables to which they are being assigned.
(s_mp_ispow2d): The result of s_highest_bit(d) is unsigned,
so if we subtract 1 from 0, we create a large value which
likely converts to -1. Let's ensure that clearly with a cast
to (int) of the return value.
* mpi/mpi.h (mp_count_ones): Declaration updated.
* mpi/mplogic.c (mpl_rsh, mpl_lsh): Fix two places where we
shift the constant 1 (of type int) left by a number of bits
that can exceed the type int. Note, that these functions are
currently not called anywhere in TXR.
|
|
|
|
|
|
|
|
| |
* arith.c (int_flo): If the floating point value is in the
ucnum range, we can convert to integer by way of that type;
we gain a little bit of range. For instance on 32 bits,
floating values in the range 2147483648.0 to 4294967295.0
can be converted via the fast path.
|
|
|
|
|
|
|
|
| |
* arith.c (int_flo): Fix reversed inequality tests which
cause the test to be always false. This always false test
prevents use of the faster code path for converting
floating-point point values that are in range of the cptr
type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h,
arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c,
ffi.h, filter.c, filter.h, ftw.h, gc.c, gc.h, glob.c, glob.h,
hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h,
lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h,
parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c,
regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl,
share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl,
share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl,
share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl,
share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl,
share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl,
share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl,
share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl,
share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl,
share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl,
share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl,
signal.c, signal.h, socket.c, socket.h, stream.c, stream.h,
struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h,
syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h,
unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h,
win/cleansvg.txr: Extended Copyright line to 2018.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The square function calulates (* x x) but is faster for bignum
integers by taking advantage of mp_sqr.
* arith.c (square): New function.
* eval.c (eval_init): Register square as intrinsic.
* lib.h (square): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (nzerop): New function.
* eval.c (eval_init): Register nzerop intrinsic.
* lib.h (nzerop): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* arith.c (zerop, plusp, minusp): style: if2(expr, t) should
be using tnil(expr).
|
|
|
|
| |
* arith.c (plusp): plusp wrongly reports itself as zerop.
|
|
|
|
|
|
|
|
| |
* arith.c (logand, logior): Remove wasteful zerop tests which
involve a type check. Also don't check for a == b equivalence
in CHR and NUM cases; this is a rare case that just adds to
the cycles and instruction count. Blindly copying and pasting
this code is what led to the bug in logxor.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reported by Guillaume le Vaillant.
* arith.c (logxor): Fix broken behavior when the arguments are
the same nonzero fixnum, or the same bignum object.
(logxor_old): New function: verbatim copy of previous logxor.
* eval.c (eval_init): Register logxor intrinsic to the broken
function if compatibility is 202 or less.
* txr.1: Compat note added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (arith_init): Register functions in the sys package:
b<, b>, b<=, b=, b+, b-, b*, b/ and neg.
* share/txr/stdlib/compiler.tl (%nary-ops%, %bin-ops%,
%bin-op%): New global variables.
(compiler comp-fun-form): Transform two-argument calls to any
of the variadic functions in %nary-ops% functions into calls
to their binary counterpart. These calls are faster, since
they bypass the wrapper which deals with the variable argument
list. Also, we detect unary - and map it to the new sys:neg
function, and reduce the one-argument cases of certain
functions to noops.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (plus, minus, neg, abso, signum, mul, trunc, mod,
floordiv, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq,
expt, exptmod, isqrt, gcd, flo_int, logand, logior, logxor,
comp_trunc, lognot, logtrunc, sign_extend, ash, bit, logcount,
tofloat, toint, width, poly, rpoly): Use the unchecked c_n
rather than c_num on quantities that are known to be of NUM
and CHR type.
* lib.h (c_n): New inline function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (flo_int): Pass down name to type_check.
* eval.c (copy_env, env_fbind, env_vbind, env_vb_to_fb,
func_get_name, lexical_var_p, lexical_fun_p,
lexical_lisp1_binding, squash_menv_deleting_range, op_upenv):
Pass relevant Lisp function name to type_check.
(lookup_global_var, lookup_sym_lisp1, lookup_fun, lookup_mac,
lookup_symac, lookup_symac_lisp1): For these widely used
functions, pass situational prefix in place of function name.
They may get a funtion name argument in the future.
* gc.c (gc_finalize): Pass function name to type_check.
* lib.c (throw_mismatch): Take function nme argument,
incorporate into mesage.
(lcons_fun, c_flo, string_extend, symbol_name, symbol_package,
get_package, package_name, func_get_form, func_get_env,
func_set_env, vec_set_length, length_vec, size_vec, list_vec,
lay_str_force, lay_str_force_upto, lazy_str_get_trailing_list,
from, too, set_from, set_to): Pass relevant Lisp function name
to type_check.
(symbol_setname, symbol_visible): Pass indication of internal
error into type_check, since this doesn't pertain to any Lisp
function being wrong.
* lib.h (throw_mismatch): Declaration updated.
(type_check): Take new parameter and pass down to
throw_mismatch.
* signal.c (set_sig_handler): Pass name down to type_check.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
More streamlined code, better identification of functions.
* arith.c (not_number, not_integer, invalid_ops, invalid_op,
divzero): New static functions.
(num_to_buffer, bugnum_len, plus, minus, neg, abso, signum,
mul, trunc1, mod, floordiv, round1, roundiv, divi, zerop,
plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt,
exptmod, floorf, ceili, sine, cosi, tang, asine, acosi, atang,
loga, logten, logtwo, expo, sqroot, int_flo, flo_int,
cum_norm_dist, inv_cum_norm): Establish function's Lisp name as
self variable. Use new static functions for reporting common
errors. Pass function name to new argument of c_flo function.
* buf.c (buf_put_float, buf_put_double): Pass function's Lisp
name to c_flo function.
* ffi.c (ffi_float_put, ffi_double_put): Likewise.
* lib.c (c_flo): Takes new argument, name of calling function.
* lib.h (c_flo): Declaration updated.
* stream.c (formatv): Pass function name to c_flo.
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (arith_init): Do not define *flo-dig*, *flo-max*,
*flo-min*, *flo-epsilon*, *pi* and *e* unless compatibility
with TXR 199 or earlier is requested.
* txr.c (txr_main): Likewise for *self-path*.
* txr.1: Compat note added.
|
|
|
|
|
|
|
| |
arith.c (signum): New function.
(arith_init): signum intrinsic registered.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (flo_get_round_mode, flo_set_round_mode): New
functions.
(arith_init): Register global lexical variables flo-near,
flo-down, flo-up and flo-zero.
Register flo-get-round-mode and flo-set-round-mode intrinsic
functions.
* configure: Test for fesetround and fegetround variables,
and the associated constants, prpoducing a HAVE_ROUNDING_CTL_H
variable in config.h.
* txr.1: Documented new variables and functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is in ANSI CL; potentially useful and hard to
implement efficiently in user code.
* arith.c (logcount): New function.
* eval.c (eval_init): Register logcount intrinsic.
* lib.h (logcount): Declared.
* mpi/mi.c (s_mp_count_ones): New static function.
(mp_count_ones): New function.
* mpi/mpi.h (mp_count_ones): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* arith.c (width): Fix incorrect name in type error
diagnostic. There is no such function as integer-length.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The INT_PTR_MIN value isn't the smallest value actually
representable in cnum, because it is just the additive
inverse of INT_PTR_MAX. In two's complement, the INT_PTR_MIN-1
value is still representable. But we are excluding it.
If a Lisp integer has the value INT_PTR_MIN-1, the c_num
function will fail to convert it to a cnum.
This situation occurs in FFI, where code may expect that the
Lisp value #x-80000000 can convert to an external 32 bit
integer type. This will be done by way of a conversion to
cnum first via c_num (see ffi_i32_put for instance, which
calls c_i32 which relies on c_num).
* arith.c (INT_PTR_MAX_SUCC_MP): New static variable.
This holds a bignum equivalent to INT_PTR_MAX + 1.
(in_int_ptr_range): We now check whether the value
against the range [-(INT_PTR_MAX + 1), (INT_PTR_MAX + 1)]
and then check all possible return values. The MP_LT
case is clearly in range, and MP_GT is out of the range.
The interesting situation is MP_EQ: in that case
we just test the sign to see whether we are looking
at -(INT_PTR_MAX + 1).
(int_flo): INT_PTR_MIN is referenced in this function, so
we use INT_PTR_MIN - 1 instead. This allows that value
to be handled via the simple bignum(n) case.
(arith_init): Initialize INT_PTR_MAX_SUCC_MP. We cannot
initialize it to INT_PTR_MAX + 1 directly because that
expression overflows: insted we use INT_PTR_MIN - 1 and
then flip the resulting bignum's sign.
(arith_free_all): Call mp_clear on the new variable to
release its digit buffer.
* ffi.c (make_ffi_type_enum): Use INT_PTR_MIN - 1 as the
initial value of the highest variable, to accurately
calculate the range of the enum values if they contain
INT_PTR_MIN - 1.
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (c_unum): Add fallthrough comment.
(minus): Add missing break after case that handles char minus
heap object.. This luckily isn't a bug because type(anum)
isn't RNG, and so when it falls through, the next case also
falls through.
* lib.c (car): Add missing fallthrough comment.
|
|
|
|
|
|
|
|
|
| |
* arith.c (bignum_len): Wew function.
(arith_init): Register bignum-len intrinsic.
* arith.h (bignum_len): Declared.
* txr.1: Documented.
|