| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* METALICENSE: 2020 copyrights bumped to 2021. Added note
about SHA-256 routines from Colin Percival.
* LICENSE, LICENSE-CYG, 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, lex.yy.c.shipped,
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/copy-file.tl, share/txr/stdlib/debugger.tl,
share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl,
share/txr/stdlib/each-prod.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/quips.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, time.c, time.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,
y.tab.c.shipped: Copyright year bumped to 2021.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Three issues issues. The documentation is wrong about the
concept of a "leading bitfield" whose alignment matters.
The alignment of all named bitfields matters. Secondly,
the alignment of unnamed bitfields doesn't matter.
Thirdly, there is a flaw in the treatment of bitfields
in unions, from both alignment and sizing.
* ffi.c (make_ffi_type_struct): A bitfield member contributes
to alignment regardless of its offset within an allocation
unit: no bits_alloc == 0 check should be applied. Secondly, a
bitfield member that is unnamed has an alignment of 1,
otherwise the alignment of its declared type.
(make_ffi_type_union): The size and alignment of a bitfield
member is not simply that of its type. The size of a bitfield
is the number of bytes required to store all of the bits. The
alignment is 1 if it is unnamed, otherwise that of its type.
The sizing of bitfields now means that alignment can add
padding to a union. For instance, a uint32_t x : 17 bitfield
has size 3, but alignment 4, requiring one byte of alignment
padding in the union so that its size is 4. This means that we
must now do the padding alignment calculation for unions
to adjust the size, just like we do for structures.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct): Fix incorrect condition for
determining whether the zero-width bitfield allocates a unit
or not. We must take into account the bit_offs, because it's
possible that unit_offs and offs are the same, yet a previous
bitfield has allocated some bits into the current allocation
unit. For instance struct { char a : 1; uint32 : 0; char b }
has size 5, but the equivalent FFI struct type ends up
with size 1. After char a : 1, the byte offset is still
zero, so if we don't look at the bit offset of 1, it looks
like the allocation offset is aligned to the start of a uint32
cell, which then means that the zero-width bitfield is
ignored. What's worse, the char b is then also allocated
over top of the a : 1 bitfield.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_struct, make_ffi_type_union): Assign
tft->memb = memb after the loop which compiles the member
types, because memb is decremented in the case of the
zero-width bitfield. This hasn't cause an issue because the
extra members are all zero, so their slot symbol is nil, and
all the relevant operations skip a nil named member.
|
|
|
|
|
| |
* ffi.c (cptr_out): tft->out may be null, in which case
tft->put must be used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions are quite helpful in dealing with semi-opaque
types, like the xmlNode type of libxml2. Such types must be
treated as an opaque handle when passed to and returned from
the API, and not subject to any encoding or decoding, which
means that the appropriate representation for them is via the
cptr family of types. However, semi-opaque types also have
client-visible members that must be accessed directly. These
new functions provide for that access in a convenient way.
* ffi.c (ffi_type_lookup_checked): New static function.
(cptr_getobj, cptr_out): New static functions.
(ffi_init): Register cptr-get and cptr-out.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The c_num and c_unum functions now take a self argument for
identifying the calling function. This requires changes in a
large number of places.
In a few places, additional functions acquire a self
argument. The ffi module has the most extensive example of
this.
Some functions mention their name in a larger string, or have
scattered literals giving their name; with the introduction of
the self local variable, these are replaced by references to
self.
In the following changelog, the notation TS stands for "take
self argument", meaning that the functions acquires a new "val
self" argument. The notation DS means "define self": the functions
in question defines a self variable, which they pass down.
The notation PS means that the functions pass down an existing
self variable to functions that now require it.
* args.h (args_count): TS.
* arith.c (c_unum, c_num): TS.
(toint, exptv): DS.
* buf.c (buf_check_len, buf_check_alloc_size, buf_check_index,
buf_do_set_len, replace_buf, buf_put_buf, buf_put_i8,
buf_put_u8, buf_put_char, buf_put_uchar, buf_get_bytes,
buf_get_i8, buf_get_u8, buf_get_cptr,
buf_strm_get_byte_callback, buf_strm_unget_byte, buf_swap32,
str_buf, buf_int, buf_uint, int_buf, uint_buf): PS.
(make_duplicate_buf, buf_shrink, sub_buf, buf_print,
buf_pprint): DS.
* chskum.c (sha256_stream_impl, sha256_buf, crc32_buf,
md5_stream_impl, md5_buf): TS.
(chksum_ensure_buf, sha256_stream, sha256, sha256_hash,
md5_stream, md5, md5_hash): PS.
(crc32_stream): DS.
* combi.c (perm_while_fun, perm_gen_fun_common,
perm_str_gen_fun, rperm_gen_fun, comb_vec_gen_fun,
comb_str_gen_fun, rcomb_vec_gen_fun, rcomb_str_gen_fun): DS.
* diff.c (dbg_clear, dbg_set, dbg_restore): DS.
* eval.c (do_eval, gather_free_refs, maprodv, maprendv,
maprodo, do_args_apf, do_args_ipf): DS.
(op_dwim, me_op, map_common): PS.
(prod_common): TS.
* ffi.c (struct txr_ffi_type): release member TS.
(make_ffi_type_pointer): PS and release argument TS.
(ffi_varray_dynsize, ffi_array_in, ffi_array_put_common,
ffi_array_get_common, ffi_varray_in, ffi_varray_null_term): PS.
(ffi_simple_release, ffi_ptr_in_release, ffi_struct_release,
ffi_wchar_array_get, ffi_array_release_common,
ffi_array_release, ffi_varray_release): TS.
(ffi_float_put, double_put, ffi_be_i16_put, ffi_be_u16_put,
ffi_le_i16_put, ffi_le_u16_put, ffi_be_i32_put, ffi_be_u32_put,
ffi_le_i32_put, ffi_sbit_put, ffi_ubit_put, ffi_buf_d_put,
make_ffi_type_array, make_ffi_type_enum, ffi_type_compile,
make_ffi_type_desc, ffi_make_call_desc, ffi_call_wrap,
ffi_closure_dispatch_save, ffi_put_into, ffi_in, ffi_get,
ffi_put, carray_set_length, carray_blank, carray_buf,
carray_buf_sync, carray_cptr, carray_refset, carray_sub,
carray_replace, carray_uint, carray_int): PS.
(carray_vec, carray_list): DS.
* filter.c (url_encode, url_decode, base64_stream_enc_impl): DS.
* ftw.c (ftw_callback, ftw_wrap): DS.
* gc.c (mark_obj, gc_set_delta): DS.
* glob.c (glob_wrap): DS.
* hash.c (equal_hash, eql_hash, eq_hash, do_make_hash,
hash_equal, set_hash_traversal_limit, gen_hash_seed): DS.
* itypes.c (c_i8, c_u8, c_i16, c_u16, c_i32, c_u32, c_i64,
c_u64, c_short, c_ushort, c_int, c_uint, c_long, c_ulong): PS.
* lib.c (seq_iter_rewind): TS and becomes internal.
(seq_iter_init_with_info, seq_setpos, replace_str, less,
replace_vec, diff, isec, obj_print_impl): PS.
(nthcdr, equal, mkstring, mkustring, upcase_str, downcase_str,
search_str, sub_str, cat_str, scat2, scat3, fmt_join,
split_str_keep, split_str_set, trim_str, int_str, chr_int,
chr_str, chr_str_set, vector, vecref, vecref_l, list_vec,
copy_vec, sub_vec, cat_vec, lazy_str_put, lazy_str_gt,
length_str_ge, length_str_lt, length_str_le, cptr_size_hint,
cptr_int, out_lazy_str, out_quasi_str, time_string_local_time,
time_string_utc, time_fields_local_time, time_fields_utc,
time_struct_local, time_struct_utc, make_time, time_meth,
time_parse_meth): DS.
(init_str, cat_str_init, cat_str_measure, cat_str_append,
vscat, time_fields_to_tm, time_struct_to_tm, make_time_impl): TS.
* lib.h (seq_iter_rewind): Declaration removed.
(c_num, c_unum, init_str): Declarations updated.
* match.c (LOG_MISMATCH, LOG_MATCH): PS.
(h_skip, h_coll, do_output_line, do_output, v_skip, v_fuzz,
v_collect): DS.
* parser.c (parser, circ_backpatch, report_security_problem,
hist_save, repl, lino_fileno, lino_getch, lineno_getl,
lineno_gets, lineno_open): DS.
(parser_set_lineno, lisp_parse_impl): PS.
* parser.l (YY_INPUT): PS.
* rand.c (make_random_state): PS.
* regex.c (print_rec): DS.
(search_regex): PS.
* signal.c (kill_wrap, raise_wrap, get_sig_handler,
getitimer_wrap, setitimer_wrap): DS.
* socket.c (addrinfo_in, sockaddr_pack, fd_timeout,
to_connect, open_sockfd, sock_mark_connected,
sock_timeout): TS.
(getaddrinfo_wrap, dgram_set_sock_peer, sock_bind,
sock_connect, sock_listen, sock_accept, sock_shutdown,
sock_send_timeout, sock_recv_timeout, socketpair_wrap): DS.
* stream.c (generic_fill_buf, errno_to_string, stdio_truncate,
string_out_put_string, open_fileno, open_command, base_name,
dir-name): DS.
(unget_byte, put_buf, fill_buf, fill_buf_adjust,
get_line_as_buf, formatv, put_byte, test_set_indent_mode,
test_neq_set_indent_mode, set_indent_mode, set_indent,
inc_indent, set_max_length, set_max_depth, open_subprocess, run ): PS.
(fds_subst, fds_swizzle): TS.
* struct.c (make_struct_type, super, umethod_args_fun): PS.
(method_args_fun): DS.
* strudel.c (strudel_put_buf, strudel_fill_buf): DS.
* sysif.c (errno_wrap, exit_wrap, usleep_wrap, mkdir_wrap,
ensure_dir, makedev_wrap, minor_wrap, major_wrap, mknod_wrap,
mkfifo_wrap, wait_wrap, wifexited, wexitstatus, wifsignaled,
wtermsig, wcoredump, wifstopped, wstopsig, wifcontinued,
dup_wrap, close_wrap, exit_star_wrap, umask_wrap, setuid_wrap,
seteuid_wrap, setgid_wrap, setegid_wrap,
simulate_setuid_setgid, getpwuid_wrap, fnmatch_wrap,
dlopen_wrap): DS.
(chmod_wrap, do_chown, flock_pack, do_utimes, poll_wrap,
setgroups_wrap, setresuid_wrap, setresgid_wrap, getgrgid_wrap): PS.
(c_time): TS.
* sysif.h (c_time): Declaration updated.
* syslog.c (openlog_wrap, syslog_wrap): DS.
* termios.c (termios_pack): TS.
(tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap,
tcdrain_wrap, tcflush_wrap, tcflow_rap, encode_speeds,
decode_speeds): DS.
* txr.c (compato, array_dim, gc_delta): DS.
* unwind.c (uw_find_frames_by_mask): DS.
* vm.c (vm_make_desc): PS.
(vm_make_closure, vm_swtch): DS.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_i8_rput, ffi_i8_rget, ffi_u8_rput, ffi_u8_rget,
ffi_i16_rput, ffi_i16_rget, ffi_u16_rput, ffi_u16_rget,
ffi_i32_rput, ffi_i32_rget, ffi_u32_rput, ffi_u32_rget,
ffi_char_rput, ffi_char_rget, ffi_uchar_rput, ffi_uchar_rget,
ffi_bchar_rget, ffi_short_rput, ffi_short_rget,
ffi_ushort_rput, ffi_ushort_rget, ffi_int_rput, ffi_int_rget,
ffi_uint_rput, ffi_uint_rget, ffi_long_rput, ffi_long_rget,
ffi_ulong_rput, ffi_ulong_rget, ffi_wchar_rput,
ffi_wchar_rget, ffi_be_i16_rput): Add casts to suppress
warnings about unused tft and self.
|
|
|
|
|
|
|
| |
* ffi.c (carray_dup, carray_blank, carray_ref, carray_refset,
carray_replace, carray_pun): Refer to "carray" rather than
"array" in diagnostic messages, which is more accurate and
consistent with newer diagnostics added in previous patch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The carray type is hereby reviewed for and repaired of issues
related to the nelem member of struct carray using negative
values to indicate "unknown carray size".
* ffi.c (struct carray): The artype becomes a two-element
array of values, so a carray can have a cache of separate
null-terminated and non-null-terminated array type
descriptors. This way, we get rid of the dirty trick of
mutating one type.
(carray_mark_op): Mark the two-element artype.
(make_carray): Initialize two-element artype to nil.
(carray_set_length): Cache invalidation: reset both elements
of artype to nil, because the type includes length
information, which may now be wrong.
(copy_carray): Throw exception if asked to copy carray of
unknown length. This would happen in carray_dup anyway,
but at least the diagnostic refers to copy-carray.
(buf_carray): Avoid calling make_duplicate_buf with negative
bytes value when the carray has unknown length; diagnose.
(carray_ref, carray_refset): Don't translate negative index
values if the length is unknown.
(carray_sub, carray_replace): If the operation requires
use of the length, and it is unknown, throw an
exception.
(carray_ensure_artype): Take a null_term paramter that is 0
or 1, and use it as an array index into artype to set up the
correct type, with the correct value of the null_term
member that is henceforth not mutated.
(carray_get_common, carray_put_common): Pass the null_term
argument down to carray_ensure_artype.
Remove the mutation of the null_term member of the type
structure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the third round of an effort to enable GCC's -Wextra
option. Instances of signed/unsigned mismatch between
the branches of ternary conditionals are addressed.
* ffi.c (pad_retval): Add cast into the consequent of
the conditional so it yields size_t, like the alternative.
* lib.c (split_str_keep): Likewise.
(vector): Cast -1 to ucnum so it has the same type as the
alloc_plus opposite to it.
* parser.c (lino_getch): Add a cast to wint_t to match
return value and opposite WEOF operand.
* stream.c (generic_get_line): Likewise.
* sysif.c (c_time): Convert both consequent and alternative
to time_t to silence warning.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is the first round of an effort to enable GCC's -Wextra
option. All function parameters that are unused an that we
cannot eliminate are treated with a cast to void in the
function body.
* args.c (args_key_check_store): Cast unused param to void.
* combi.c (perm_list_gen_fill): Likewise.
* eval.c (op_error, op_meta_error, op_quote op_qquote_error,
op_unquote_error, op_load_time_lit, me_each, me_for,
me_quasilist, me_flet_labels, hash_min_max, me_ignerr,
me_whilet, me_iflet_whenlet, me_dotimes, me_mlet,
me_load_time, me_load_for): Likewise.
* ffi.c (ffi_void_put, ffi_fixed_dynsize, *ffi_fixed_alloc,
ffi_noop_free, ffi_void_get, ffi_simple_release, ffi_i8_put,
ffi_i8_get, ffi_u8_put, ffi_u8_get, ffi_i16_put, ffi_i16_get,
ffi_u16_put, ffi_u16_get, ffi_i32_put, ffi_i32_get,
ffi_u32_put, ffi_u32_get, ffi_i64_put, ffi_i64_get,
ffi_u64_put, ffi_u64_get, ffi_char_put, ffi_char_get,
ffi_uchar_put, ffi_uchar_get, ffi_bchar_get, ffi_short_put,
ffi_short_get, ffi_ushort_put, ffi_ushort_get, ffi_int_put,
ffi_int_get, ffi_uint_put, ffi_uint_get, ffi_long_put,
ffi_long_get, ffi_ulong_put, ffi_ulong_get, ffi_float_put,
ffi_float_get, ffi_double_put, ffi_double_get, ffi_val_put,
ffi_val_get, ffi_be_i16_put, ffi_be_i16_get, ffi_be_u16_put,
ffi_be_u16_get, ffi_le_i16_put, ffi_le_i16_get,
ffi_le_u16_put, ffi_le_u16_get, ffi_be_i32_put,
ffi_be_i32_get, ffi_be_u32_put, ffi_be_u32_get,
ffi_le_i32_put, ffi_le_i32_get, ffi_le_u32_put,
ffi_le_u32_get, ffi_be_i64_put, ffi_be_i64_get,
ffi_be_u64_put, ffi_be_u64_get, ffi_le_i64_put,
ffi_le_i64_get, ffi_le_u64_put, ffi_le_u64_get, ffi_wchar_put,
ffi_wchar_get, ffi_sbit_get, ffi_ubit_get, ffi_cptr_get,
ffi_str_in, ffi_str_put, ffi_str_get, ffi_str_d_get,
ffi_wstr_in, ffi_wstr_get, ffi_wstr_put, ffi_wstr_d_get,
ffi_bstr_in, ffi_bstr_put, ffi_bstr_get, ffi_bstr_d_get,
ffi_buf_in, ffi_buf_put, ffi_buf_get, ffi_buf_d_in,
ffi_buf_d_put, ffi_buf_d_get, ffi_closure_put, ffi_ptr_in_in,
ffi_ptr_in_d_in, ffi_ptr_in_out, ffi_ptr_out_in,
ffi_ptr_out_out, ffi_ptr_out_null_put, ffi_ptr_out_s_in,
ffi_flex_struct_in, ffi_carray_get, ffi_union_get,
make_ffi_type_builtin, make_ffi_type_array,
ffi_closure_dispatch, ffi_closure_dispatch_safe): Likewise.
* gc.c (cobj_destroy_stub_op, cobj_destroy_free_op, cobj_mark_op): Likewise.
* lib.c (seq_iter_get_nil, seq_iter_peek_nil): Likewise.
* linenoise/linenoise.c (sigwinch_handler): Likewise.
* parser.c (repl_intr, read_eval_ret_last, repl_warning,
is_balanced_line): Likewise.
* parser.y (yydebug_onoff): Likewise.
* socket.c (dgram_close): Likewise.
* stream.c (unimpl_put_string, unimpl_put_char,
unimpl_put_byte, unimpl_unget_char, unimpl_unget_byte,
unimpl_put_buf, unimpl_fill_buf, unimpl_seek, unimpl_truncate,
unimpl_set_sock_peer, null_put_string, null_put_char,
null_put_byte, null_get_line, null_get_char, null_get_byte,
null_close, null_flush, null_seek, null_set_prop,
null_get_error, null_get_error_str, null_clear_error,
null_get_fd, dir_close): Likewise.
* struct.c (struct_type_print): Likewise.
* unwind.c (me_defex): Likewise.
|
|
|
|
|
|
| |
* ffi.c (ffi_varray_alloc): Add cast to this conversion. The
idea here is we are checking for truncation when cnum is
converted to size_t.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The undimensioned (array <type>) and (zarray <type>) types are
not doing UTF-8 conversion when <type> is char or zchar,
or doing what they are supposed to with the FFI character
types, which is inconsistent from their dimensioned
counterparts.
* ffi.c (ffi_varray_dynsize): if the element type is marked
for character conversion, then do the size calculation for
char and zchar by measuring the UTF-8 coded size.
(ffi_varray_alloc): Call ffi_varray_dynsize to get the size,
to benefit from the char handling. Thus when FFI allocates
buffers for a variable length array, it will allocate correct
size required for the UTF-8 encoded string.
(ffi_varray_put, ffi_varray_in): Here we must call
ffi_varray_dynsize and divide by the element type to get the
proper numer of elements. Then we must check for character
conversion and handle the cases.
(ffi_varray_null_term_in): Check for character conversion
cases and route those through ffi_varray_in, which handles
null-terminated strings.
* tests/017/ffi-misc.tl: New file.
* tests/017/ffi-misc.expected: New file.
|
|
|
|
|
|
|
|
| |
This is cribbed from a patch by q66 <daniel@oct***rge.org>,
commited recently to the Void Linux distro.
* ffi.c (ffi_arg): Define this type when HAVE_FFI is not enabled.
Some big-endian-specific code refers to it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
| |
* ffi.c (ffi_array_out): Add missing zchar case.
|
|
|
|
|
|
| |
* ffi.c (ffi_array_put, ffi_array_out): Handle conv_none in the switch,
even though the whole switch is conditional on the value being other
than conv_none.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The zchar type, when used as an array element, specifies an
optionally null-terminated or padded field, which is subject
to UTF-8 conversion.
* ffi.c (zchar_s): New symbol variable.
(enum char_conv): New member, conv_zchar.
(ffi_zchar_array_get): New static function.
(ffi_array_in, ffi_array_get_common): Handle conv_zchar via
ffi_zchar_array_get.
(ffi_array_put): Handle conv_char together with conv_zchar.
(ffi_type_compile): Handle zchar array element type, mapping
to conv_zchar.
(ffi_init_types): Register zhar type.
(ffi_init): Initialize zchar_s symbol variable.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The three flags controlling character array conversion
semantics are mutually exclusive. Let's turn them into an
enumeration, so we can (1) test that a conversion is in effect
by testing a single value and (2) switch on the conversion
type instead of successively testing the flags and (3) assure
the aforementioned mutual exclusion.
* ffi.c (enum char_conv): New enum.
(struct txr_ffi_type): Members char_conv, wchar_conv and
bchar_conv gone, replaced by ch_conv.
(ffi_array_in, ffi_array_put, ffi_array_out,
ffi_array_get_common, ffi_array_release_common,
ffi_varray_null_term_get, ffi_type_compile,
carray_ensure_artype): Work with ch_conv instead of three
flags.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_memb_compile): Don't complain about
three-argument slot specifiers, only about longer ones.
(ffi_struct_init): New static function.
(ffi_type_compile): Deal with third element in the slot
syntax. If there are any non-nil initializing expressions,
then we when we call make_struct_type, we specify an initfun,
which will plant the values into the slots, using logic
similar to that of the initfun generated defstruct,
except that the init-forms are reduced to values up-front.
* txr.1: Specify optional init-form for slots in FFI
struct syntax.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_unum, carray_num, unum_carray, num_carray):
Functions renamed to carray_uint, carray_int, uint_carray,
int_carray.
(ffi_init): Functions registered under new names:
carray-uint, carray-int, uint-carray, int-carray. Compat
values of 227 or less provide the old old names.
* ffi.h (carray_unum, carray_num, unum_carray, num_carray):
Declarations renamed.
* txr.1: Updated to new names; compat note added.
|
|
|
|
|
| |
* ffi.c (carray_num): Use the correct name carray-num rather
than carray-unum in diagnostics.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes numerous instances of a safety hole which
involves the type of a COBJ object being tested to be of
a given class using logic that can be subverted by the
definition of a like-named struct.
Specifically logic like (typeof(obj) == hash_s) is broken,
because if a struct type called hash is defined, then the test
will yield true for instances of that struct type. Those
instances can then be passed into code that only works on COBJ
hashes, and relies on this test to reject invalid objects.
* ffi.c (make_carray): Replace fragile test with strong one,
using new cobjclassp function.
* hash.c (hashp): Likewise.
* lib.c (class_check): The expression used here for the type
test moves into the new function cobjclassp and so is replaced
by a call to that function.
(cobjclassp): New function.
* lib.h (cobjclassp): Declared.
* rand.c (random_state_p): Replace fragile test using
cobjclassp.
* regex.c (char_set_compile): Replace fragile typeof tests
for character type with is_chr.
(reg_derivative, regexp): Replace fragile test with cobjclassp.
* struct.c (struct_type_p): Replace fragile test with cobjclassp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_flex_struct_in): Use get_special_slot to obtain
length method.
* lib.c (nullify_s, from_list_s, lambda_set_s): Definitions
removed from here.
(seq_info, car, cdr, rplaca, rplacd, make_like, nullify,
replace_obj, length, empty, sub, ref, refset, dwim_set): Use
get_special_slot to obtain special method from object,
rather than maybe_slot.
(obj_init): Remove initializations of nullify_s, from_list_s
and lambda_set_s from here.
* struct.c (enum special_slot): Definition removed from here.
(nullify_s, from_list_s, lambda_set_s): Definitions moved here
from lib.c.
(special_sym): New static array.
(struct_init): Initializations of nullify_s, from_list_s
and lambda_set_s moved here from lib.c.
(get_special_slot): New function.
* struct.h (lambda_set_s): Declared.
(enum special_slot): Definition moved here.
(get_special_slot): Declared.
* txr.1: Added compat note, since get_special_slot behaves
like maybe_slot under 224 compatibility.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_type_compile, ffi_init_types): Fixed a number of
instances of make_ffi_type_builtin being passed the type
kind as the fourth rather than the third argument.
The strange fluke here is that FFI_KIND_NUM is 1, so this
actually made no difference in all the case in ffi_init_types!
However in ffi_type_compile, it would have set the type of
cptr-s to struct, and its size to 3. Anyway, we were saved
from a regression by the good pre-release habit of compiling
as C++!
|
|
|
|
|
|
|
|
|
|
|
| |
Recent work has introduced wrong-way assignments. When we
compile the slots after we have created the type object, the
slot types may be in a newer generation than the type object.
If we are reusing an old type object, it can be older than
the syntax, or the Lisp object being stored in it.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): add some
setcheck calls to handle anti-generational assignments.
|
|
|
|
|
|
|
|
|
| |
This is a bug in the prior commit's change.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): When
using an existing type, do not call cobj to make a new Lisp
object for the type structure; pull the existing one out
from tft->self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this commit, FFI a struct definitions can contain
references to the struct type being defined. It becomes
possible to pass a (non-circular) linked list of structures to
and from C foreign function.
* ffi.c (ffi_kind_t): New enum. We need some tag in the
txr_ffi_type struct to indicate type.
(ffi_struct_tag_hash): New static variable.
(struct txr_ffi_type): New members: kind and flexible.
(ffi_struct_in, ffi_struct_get): Use the new flexible bit as
an indicator that the struct has a flexible member, rather
than the incomplete bit.
(make_ffi_type_builtin): Take new argument indicating type
kind, and store it in the kind member.
(make_ffi_type_pointer): Initialize kind field.
(ffi_memb_compile): New static function.
(make_ffi_type_struct): No longer receives the list of slot
names and their compiled types as arguments. The compiling is
done in this function on-the-fly as the slots are initialized,
using the ffi_memb_compile function helper. If a same-named
struct/union type already exists, this is passed in; the
function will replace that type by freeing and reallocating
the member vector, clearing the existing struct type to all
zero and re-initializing it from scratch. The new kind field
is initialized. The incomplete flag is set initially and then
updated at the end, so during the processing of the member
types, the struct type is considered incomplete. If a struct
has no members, it is considered incomplete now. It is
flexible only if it ends in a flexible array. The struct type
is added to ffi_struct_tag_hash, keyed on its tag.
(make_ffi_type_union): Similar changes as in
make_ffi_type_struct.
(ffi_membs_compile): Function removed.
(ffi_type_compile): Change to struct compilation logic.
An empty struct definition now avoids creating a Lisp struct
type. If a FFI struct type already exists, that one is
returned, otherwise an empty one (considered incomplete) is
created. A struct definition with members replaces an existing
one. The new make_ffi_type_struct interface is used which
simplifies things here, since we just pass down the syntax and
the existing type, without having to compile the member types.
Not a big change for unions: just use the new
make_ffi_type_union interface, which requires the existing
type, and just the syntax now, rather than compiled slots.
For varrays, set the type kind to FFI_KIND_ARRAY, overriding
the FFI_KIND_PTR type that is already there due to varrays
being implemented as pointers. Perhaps varray should have its
own kind, but for now this approach serves fine.
For buffer types, set the kind to FFI_KIND_PTR, and for the
bitfields, set it to FFI_KIND_NUM.
(ffi_init_types): Pass an appropriately-valued kind argument
in ach call to the make_ffi_type_builtin constructor.
(ffi_init): GC-protect the ffi_struct_tag_hash variable, and
initialize it.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_ptr_in_in, ffi_ptr_in_d_in, ffi_ptr_out_in,
ffi_ptr_out_s_in): If the memory location which holds the
pointer to the C object is null, then just return nil.
If we don't do this, we then crash trying to extract
the object from a null pointer via the recursive tgtft->in or
tgtft->get call.
|
|
|
|
|
|
|
|
| |
* ffi.c (elemtype_s): New symbol variable.
(ffi_type_compile): Handle elemtype.
(ffi_init): Initialize elemtype_s.
* txr.1: Document elemtype.
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_elemsize, ffi_elemtype): Fix error messages to
include enum among possible argument types.
* txr.1: Extend documentation for ffi-elemsize and ffi-elemtype
to include base integer type of enumerations.
|
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): New case handling qref_s symbol.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
The get operation must use the flexible array's in virtual
function, because incomplete arrays have a no-op get function.
* ffi.c (ffi_flex_struct_in): return the value of the slot.
(ffi_struct_get): When processing the terminating slot of a
flexible struct, we invoke its in-semantics, using the updated
slot value as the object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit adds support for working with foreign structures
which use the C99 "flexible array member", or possibly the
old "C struct hack". Some improvements are made in the FFI
code the area of incomplete types and bitfields.
* ffi.c (struct txr_ffi_type): New flag members incomplete
and bitfield.
(ffi_varray_dynsize): Check incomplete type flag rather than
for zero size.
(ffi_flex_dynsize, ffi_flex_alloc, ffi_flex_struct_in): New static functions.
(ffi_struct_in): Call ffi_flex_struct_in when doing by-value
semantics on a flexible structure, just before converting last
member. This checks for the length method, calls it, and
adjusts the last member object as documented.
(ffi_struct_get): Likewise.
(bitfield_syntax_p): Static function removed; there is a
flag for this now in the type, so no need to parse its
syntax.
(make_ffi_type_pointer): Test bitfield flag rather than
using bitfield_syntax_p.
(make_ffi_type_struct): Take new argument indicating that the
struct is flexible. Wire in appropriate virtual functions
based on this flag, and set the type's incomplete flag
accordingly. Check bitfield flag rather than using
bitfield_syntax_p for detecting bitfield members.
Calculate the size of flexible struct differently: it is
the offset of the last member.
(make_ffi_type_union): Test bitfield flag rather than
using bitfield_syntax_p.
(ffi_struct_compile): Renamed to ffi_membs_compile.
(ffi_membs_compile): New pointer parameter for returning an
indication whether the member list specifies a flexible
struct. Test the incomplete flag of a member type rather than
size being zero.
(ffi_type_compile): Follow rename of ffi_struct_compile to
ffi_membs_compile. Pass down the flag obtained from
ffi_membs_compile into make_ffi_type_struct so that a flexible
struct type is created when necessary. Disallow arrays of
bitfields. Set bitfield flag on bitfield types.
(ffi_init_types): Set incomplete flag on void type.
(ffi_make_call_desc): Test for incomplete and bitfield types
using new flags.
(ffi_typedef, ffi_size, ffi_alignof): Test for bitfield type
using new bitfield flag.
(carray_elem_check): New static function.
(carray_buf, carray_pun, carray_unum, carray_num): Use new
carray_elem_check to check for bad array element type. This
uses the incomplete flag rather than checking for zero size,
and also disallows bitfields.
* lib.h (length_s): Declared.
* txr.1: Flexible structs documented in new section. Also
section on incomplete types. Description of sizeof operator
gives more detaild about incomplete types including flexible
structs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If sizeof is given an extra argument (an expression which
evaluates to an object), it can calculate the dynamic size of
the FFI type in relation to representing that object.
* ffi.c (dyn_size): New static function.
(ffi_init): Register sys:dyn-size intrinsic.
* share/txr/stdlib/ffi.tl (sizeof): Support additional
argument, avoiding run-time compilation of the type expression
with the help of load-time.
* txr.1: Update documentation for sizeof macro.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The motivating bug here is that
(ffi-put #(1 2 3 5) (ffi (array int)))
perpetrates a buffer overrun. The size of (array int) is zero,
and so a zero-length buffer is allocated. But then an array of
five ints is stored. This is made to work correctly:
allocating a buffer large enough.
A new virtual function is introduced into the txr_ffi_type
structure to calculate a type's dynamic size, from a prototype
Lisp object.
* ffi.c (struct txr_ffi_type): New function pointer member,
dynsize.
(ffi_fixed_dynsize, ffi_varray_dynsize): New static functions.
(make_ffi_type_builtin, make_ffi_type_pointer,
make_ffi_type_struct, make_ffi_type_union,
make_ffi_type_array): Initialize new dynsize member of type
structure with pointer to ffi_fixed_dynsize.
(ffi_type_compile): Initialize the dynsize pointer of variable
array types to ffi_varray_dynsize.
(ffi_put_into, ffi_put, ffi_in, ffi_out): Use dynsize to
calculate the real size required to store or extract the given
object.
* txr.1: Update doc for ffi-put, ffi-put-into and ffi-in.
Looks like we are missing ffi-out; it is not documented!
|
|
|
|
|
|
|
|
| |
* ffi.c (carray_replace): Use original fn < vn loop guard,
like in the original code that was replaced by the generic
sequence iteration loop. For instance, when we replace
a range like 1..1, fn == tn, and so the loop doesn't copy
anything.
|
|
|
|
|
| |
* ffi.c (carray_replace): Use generic sequence iteration for
range replacement instead of separate list/vector code.
|
|
|
|
|
|
| |
* ffi.c (carray_refset): Support negative indexing by adding
the length of the array to a negative index value.
This is already done in carray_ref.
|
|
|
|
|
| |
* ffi.c (carray_replace): add missing index list assignment
semantics required by documentation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The replace function now returns a list if a nil object's is
replaced with a range, rather than just returning the original
item sequence. This breaks the variable array in operation,
causing it to produce a list. We fix this sproblem, and also
the nonsense semantics of the operation also; the operation
should replace the original sequence, with the array,
similarly to how null terminated strings work.
* ffi.c (ffi_varray_null_term_in): If the original Lisp object
isn't nil, then assume it's a sequence and replace it with the
items gathered in the vector. Otherwise, replace it with the
vector.
* txr.1: Adjust documentation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This bug causes a problem particularly in FFI. THe conversion
of an integer to the FFI int type begins by conversion via
c_num to the cnum type, which is at least as wide as int.
Alas, the INT_MIN value (e.g. #x-80000000 on 32 bits) will
not convert!
Fixing this has a ripple effect. We alter the INT_PTR_MIN
constant to include this value. This causes the derived
NUM_MIN to also include the extra negative value, extending
the fixnum range by one value. Everything seems to be okay.
* configure: Decrease value of INT_PTR_MIN and
DOUBLE_INTPTR_MIN constants by one to include the most
negative two's complement value.
* ffi.c (make_ffi_type_enum): We must not subtract 1 from
INT_PTR_MIN here any more.
* mpi.c (mp_in_range): If the bignum is negative, then extend
the range check by one value, so that we don't reject the
most negative two's complement value.
|
|
|
|
|
|
|
|
|
| |
* arith.h (mod_s, bit_s): Add extern declarations.
* ffi.c (bit_s): Remove definition.
* match.c (mod_s): Remove definition. Include "arith.h" to
obtain declaration of mod_s.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (struct_s): Now defined here.
(eval_init): struct now interned here.
* eval.h (struct_s): Declared.
* ffi.c (struct_s): Definition removed.
(ffi_init) struct no longer interned here.
|
|
|
|
|
| |
* ffi.c (ffi_type_common_mark): We must mark tft->tag field
whih is used by the cptr type and is otherwise nil.
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_enum): Allocate the sym_num an num_sym
hashes before the type object. That ensures they are older,
and may be assigned into the object without setcheck.
Also, move those assignments earlier, before the loop which
populates the hashes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
What happens if a FFI closure intercepts an exception, returns
to the foreign code, but that caller does not return to Lisp
where the exception will continue? Suppose the caller invokes
another closure. In that situation, the lingering value of
the s_exit_point variable causes problems for FFI calls.
An example of this is callbacks from an event dispatching
framework such as a GUI. When these callback closures return,
control returns to the event loop, which itself doesn't
immediately return to Lisp code. Rather, it processes more
events and invokes more callbacks.
* ffi.c (ffi_closure_dispatch_safe): One thing we can do
is clear s_exit_point whenever we dispatch a closure.
|
|
|
|
|
|
|
| |
* ffi.c (ffi_closure_dispatch_safe): When initially clearing
a return value that has release semantics, use the padded
size, not the nominal size. Let's get calculate this once and
put it in a local.
|
|
|
|
| |
* ffi.c (pad_retval): If the size is zero, don't pad it.
|