| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_be_i64_get, ffi_le_i64_get): The code here for 32
bit platforms is fishy: it is using the signed cnum type for
the low 32 bits, when that should be ucnum. We are actually
okay because ths code would only be executed on a platform
where cnum is 32 bits. We are saved by the fact that we are
doing left shifts (no sign extension), that shifting a 1 into
a sign bit is harmless on two's complement machines, and that
the lo32 value is ultimately passed to unum whereby it is
coerced to a ucnum argument type (which preserves the bit
representation) and prevents logior from seeing a negative
value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
| |
* sysif.c (off_t_num): Retarget to just use c_i32 or c_i64
from ctypes.c, depending on which of these types is the same
width as off_t.
(stdio_fseek): Pass identifying "self" string to off_t_num.
Don't use off_t_num for fseek's offset argument which is of
type long; for that we can use c_long from ctypes.c.
* sysif.h (off_t_num): Declaration updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
| |
* txr.1: eval mistakenly referred to instead of compile-file
under Compile File. Spurious pluralization of literals fixed.
New "Bound symbols in dwim" heading to separate text from
discussion of unbound symbols in dwim. Clarifying text added
about compile-toplevel's treatment of form.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
| |
* mpi/mpi.c (s_mp_2expt, mp_trunc_comp, mp_trunc, mp_bit):
Arguments that give a number of bits or bit position should be
mp_size; they are not related to digit values.
* mpi/mpi.h (mp_trunc_comp, mp_trunc, mp_bit): Declaration
updated.
|
|
|
|
| |
* Makefile (MPI_OBJ_BASE): remove mplogic.o.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* mpi/mpi.c (mp_read_radix): Take const wchar_t * string
rather than unsigned char *.
(s_mp_tovalue): Take character argument as wchar_t rather
than int.
* mpi/mpi.h (mp_read_radix): Declaration updated.
* lib.c (int_str): Avoid a malloc/free and UTF-8 conversion by
passing the original wide string to mp_read_radix.
This removes a TODO dating back to December 2011.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: We remove the uintptr variable and do not
generate the HAVE_UINTPTR_T constant in config.h. This is
always 1, and not actually tested anywhere. In situations when
uintptr is not established, intptr is also not established and
the configure script fails. We simply assume that for whatever
type we detect as inptr_t, we can derive the unsigned type.
(INT_PTR_MAX): We define this a bit differently; instead of
interpolating into the expression the underlying C type, we
use the int_ptr_t typedef that the previous lines of config.h
establish.
(UINT_PTR_MAX): New constant introduced in config.h.
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Sigh; this is a continuation of the same topic that was
addressed in November 14, 2016: "Fix bug in bignum addition".
Commit SHA: c30a96120f53b960db56bc05a7ce6310bb2528f5.
Though I fixed s_mp_add, s_mp_add_d has the same problem. Two
digit-sized quantities are added together in the digit-sized
type, and so the CARRYOUT(w) from the result is always zero.
This bug causes the following consequences (using behavior
under 32 bit as an example):
1. Wrong arithmetic:
(succ (pred (expt 2 32)) -> 0
2. Wrong conversion from decimal:
4294967296 -> 0
4294967297 -> 1
4294967298 -> 2
4294967299 -> 3
As well as all values that begin with the above digit
sequences.
4. Wrong conversion from floating-point.
(toint 4294967296.0) -> 0
* mpi/mpi.c (s_mp_add_d): Add missing cast to the initial
addition that adds the incoming digit d to the least
significant limb of the bignum, so that the addition is done
in the wider mp_word type, allowing CARRYOUT(w) to calculate a
nonzero k value.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If a zero-length carray is converted with vec-carray or
list-carray and the null-term-p argument is t, there is an
exception about a negative index. An empty vector or list
should be returned in this case, and the documentation says
exactly that.
Also, if a carray of unknown length is converted, there is
an exception from vec-carray, as documented, but it's
an uninformative one that is incidentally produced when -1
is passed to the vec function. The list-carray just returns
nil, contravening the documentation.
* ffi.c (vec_carray, list_carray): Fix the problems described
above.
* txr.1: Reviewing the documentation for these functions, an
improperly terminated sentence was found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
| |
* txr.1: with-dyn-lib relates not only to deffi but also
deffi-var and deffi-sym.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the programmer writes a deffi, deffi-sym or deffi-var that
makes simple references, and that macro is not wrapped in
with-dyn-lib, an unhelpful error message results about
sys:ffi-lib being unbound. We can detect this situation and
provide a warning.
* share/txr/stdlib/ffi.tl (sys:with-dyn-lib-check,
sys:expand-sym-ref): New functions.
(deffi, deffi-sym, deffi-var): Capture environment parameter.
Common code replaced by call to sys:expand-sym-ref, where the
missing sys:ffi-lib situation is diagnosed. This is only done
in cases when the simple reference syntax occurs.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (min): New macro.
(ffi_array_put_common): Tolerate sequences which are shorter
than the array. Use seq_info to classify the sequence and use
separate code for the vector and list case, avoiding taking
the length of the list.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_char_array_put): The char array put operation
should only null terminate when the null_term flag is set;
i.e. it's a zarray type. The bug here is that when a Lisp
string of length > N is put into an (array N char), the
C array gets null terminated, which is wrong. Only in the case
when the string is exactly of length N is there no null
termination. In all cases when the length >= N, we want
truncation without null termination.
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_array): Remove a useless loop that
was left behind when the essential part of its body was
removed.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/asm.tl (parse-compound-operand): The index
of a (v <lev> <index>) operand must be compard to the maximum
index constant, not to the maximum level constant.
This bug will prevent compiling frames that have more than 64
variables, which is a serious limitation from 1024.
|
|
|
|
|
|
| |
* share/txr/stdlib/asm.tl (op-frame): Check the level of the
operand against %max-v-lev%, not %max-lev-idx%, which
gives the maximum index within a level.
|
|
|
|
|
|
| |
* share/txr/stdlib/vm-param.tl (%max-lev-idx%): The maximum
index within a level is one less than the maximum level
size, not two less. Use pred rather than ppred to derive it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/vm-param.tl (%max-sm-lev-idx%): This
constant is named inconsistently relative to %max-lev-idx%.
It is providing the maximum level (encodable in a small
operand), whereas %max-lev-idx% provides the maximum index
within a level. It is hereby renamed to %max-sm-lev%.
The %max-sm-lev-idx% name is re-used to denote the quantity
which it suggests: the maximum index within a level
(encodable in a small operand), which is 63.
* share/txr/stdlib/asm.tl (small-op-p): Use the new
%max-sm-lev-idx% in place of %sm-lev-size%, getting rid of the
funny range starting with -1. Replace the original
%max-sm-lev-idx% with its new name, %max-sm-lev%.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: Instead of generating a definition of ALLOCA_H,
generate the variable HAVE_ALLOCA_<name> with a value of 1,
where <name> is one of stdlib, alloca or malloc.
* alloca.h: New header.
* args.c, eval.c, ffi.c ffi.c, ftw.c, hash.c, lib.c, match.c,
parser.c, parser.y, regex.c, socket.c, stream.c, struct.c,
sysif.c, syslog.c, termios.c, unwind.c, vm.c: Include
"alloca.h" instead of ALLOCA_H.
|
|
|
|
|
|
|
|
|
|
| |
* configure: try <stdlib.h> first for alloca. This should fix
a build issue which happens on the Musl library and perhaps
elsewhere. The problem on Musl is that #include <stdlib.h>
already includes <alloca.h>. That header contains an alloca
macro which interfers with our subsequent #include ALLOCA_H
directive: ALLOCA_H expands to <alloca.h> and the alloca token
gets further expanded.
|
|
|
|
|
| |
* configure: don't define HAVE_ALLOCA in config.h. It is not
used anywhere. Moreover, alloca isn't optional.
|
|
|
|
|
|
| |
* txr.1: Closing quote didn't come out in .codn; we must use
the \(dq code in this context. Let's make the opening quote
\(dq also for consistency.
|
|
|
|
|
| |
* txr.1: Wrong tense/person of "to expect"; spurious
occurrence of foo identifier deleted.
|
|
|
|
| |
* txr.1: .meti should be used to typeset code inline.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
| |
utf8.c (utf8_decode): The wch_min value is set incorrectly for
the four byte case due to an extra zero; it should be only
0x10000. Code points encoded to four utf8 bytes start at this value.
The consequence of this error is that utf8-encoded characters
in this range are treated as invalid bytes after being decoded
due to failing the range test.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following situation can occur:
(defvar v expr) ;; expr throws!
What happens is that the internal hash table of global
variables ends up with an entry that has a nil value,
instead of the expected (v . <value>) cons cell.
The hash table entry is created when the table is probed
for the existence of v, but then is never populated
with a binding because expr throws.
The consequence then is that (boundp v) returns nil, yet
subsequent (defvar v ...) expressions think that v exists, and
refuse to define it. (defparm v ...) also fails; it relies on
(defvar ...) which fails to define the variable, and then
tries to assign to it, which throws.
* eval.c (rt_defvarl): If the hash table exists, but has a nil
value, treat that as an undefined variable. Thus, define the
variable not only if the hash cell is newly made, but also if
it already exists, with a null cdr.
|
|
|
|
|
|
| |
* share/txr/stdlib/compiler.tl (assumed-fun): This variable
shouldn't be the first item in the compiler. It is moved after
the definitions of structs and important constants.
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
* configure: Add some help text for variables controllinig the
compiler command. Mention that CFLAGS and LDFLAGS are honored
from the environment or make command line on top of any of the
flags settable here.
|
|
|
|
|
|
|
| |
* configure (opt_flags): Add -fno-stack-protector to disable
this feature that is on by default in some toolchains/distros.
As a result, I'm seeing an over 5% VM speedup on a loop
benchmark.
|
|
|
|
|
| |
* Makefile (TXR_LDFLAGS): Fix use of wrong assignment operator
which clobbers the previous assignment of $(LDFLAGS).
|
|
|
|
|
|
|
|
|
|
| |
* hash.c: Don't include "cadr.h".
* stream.c: Don't include "struct.h".
* strudel.c: No <syslog.h>, ALLOCA_H, "args.h" or "utf8.h".
* vm.c: No "hash.h".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The <dirent.h> header is included all over the place because
it is needed by a single declaration in stream.h. That
declaration is for a function that is only called within
stream.c, so we make it internal. Now only stream.c has
to include <dirent.h>.
* buf.c, debug.c, eval.c, ffi.c, filter.c, gc.c, gencadr.txr,
hash.c, lib.c, lisplib.c, match.c, parser.c, regex.c, socket.c,
struct.c, strudel.c, sysif.c, syslog.c, termios.c, txr.c,
unwind.c, vm.c: Remove #include <dirent.h>.
* cadr.c: Regenerated.
* stream.c (make_dir_stream): Make external function static.
* stream.h (make_dir_stream): Declaration updated.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
| |
* txr.1: Fix .code macro occurring in middle of line.
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register in-range and in-range*
intrinsics.
* lib.c (in_range, in_range_star): New functions.
* lib.h (in_range, in_range_star): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* eval.c: Fix incorrect treatment of cases like
(caseql* ((a b) ...)). The check for evaluation must come
before we do the keys = car(keys) transformation. Also,
hash_keys must be updated to the evaluated keys, otherwise if
the hash table optimization is used, the table will contain
the original expressions as the keys, not their values.
|