summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Stop using C library setjmp/longjmp.Kaz Kylheku2015-10-2526-32/+270
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR is moving to custom assembly-language routines. This is mainly motivated by a very dubious thing done in the GNU C Library setjmp and longjmp in the name of security. Evidently, glibc's setjmp "mangles" certain pointer values which are stored into the jmp_buf buffer. It's been that way since 2005, evidently. This means that, firstly, all along, the use of setjmp in gc.c to get registers into a buffer so they can be scanned has not actually worked properly. More importantly, this pointer mangling in setjmp and longjmp is very hostile to a stack copying implementation of delimited continuations. The reason is that continuations contain jmp_buf buffers, which get relocated in the process of capturing and reviving a continuation. Any pointers in a jmp_buf which point into the captured stack segment have to be fixed up to point into the relocated location. Mangled pointers make this difficult, requiring hacks which are specific to glibc and the machine architecture. We might as well implement a clean, well-behaved setjmp and longjmp. * Makefile (jmp.o): New object file. (dbg/%.o, opt/%.o): New rules for .S prerequisites. * args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c, eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h> include. * gc.c: Switch to struct jmp and jmp_save, instead of jmp_buf and setjmp. * jmp.S: New source file. * signal.h (struct jmp): New struct type. (jmp_save, jmp_restore): New function declarations denoting assembly language routines in jmp.S. (extended_jmp_buf): Uses struct jmp instead of setjmp. (extended_setjmp): Use jmp_save instead of setjmp. (extended_longjmp): Use jmp_restore instead of longjmp.
* Reduce stack usage for args in a few places.Kaz Kylheku2015-10-242-5/+3
| | | | | | * eval.c (apply, do_eval): Use ARGS_MIN instead of ARGS_MAX. * unwind.c (uw_throw): Ditto, when invoking handler.
* Implementing truncate-stream.Kaz Kylheku2015-10-215-10/+104
| | | | | | | | | | | | | | | | | | | | | | | * configure: Test for ftruncate and chsize. * stream.c (unimpl_truncate): New static function. (fill_stream_ops): Default the truncate operation to unimpl_truncate. (null_ops): Initialize truncate to unimpl_truncate. (stdio_truncate): New static function. (stdio_ops, tail_ops): Initialize truncate to stdio_truncate. (pipe_ops, dir_ops, string_ops, byte_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Initialize truncate to null, so it gets defaulted by fill_stream_ops. (truncate_stream): New function. (stream_init): Register truncate-stream intrinsic. * stream.h (struct strm_ops): New member, truncate. (strm_ops_init): New truncate argument added to macro. (truncate_stream): Declared. *syslog.c (syslog_strm_ops): Initialize truncate to null. * txr.1: Documented.
* Correction in error message on unimplemented seek.Kaz Kylheku2015-10-211-1/+1
| | | | | * stream.c (unimpl_seek): Function should identify itself as seek-stream, not seek.
* Doc improvements in Structures.Kaz Kylheku2015-10-191-10/+16
| | | | | * txr.1: mention defmeth in Structures intro plus a number of wording changes and corrections.
* defmeth and with-objects formatting fix.Kaz Kylheku2015-10-191-1/+2
| | | | | * txr.1: Bad syntax formatting in defmeth. Missing .desc under with-objects.
* Version 120.txr-120Kaz Kylheku2015-10-186-374/+430
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Bugfix: unterminated format argument list in repl code.Kaz Kylheku2015-10-181-1/+1
| | | | | * parser.c (repl): Missing nao terminator in format call which computes expression name.
* Support binary specifier in format.Kaz Kylheku2015-10-172-5/+31
| | | | | | | | * stream.c (formatv): New 'b' case along side 'o', handling binary in straightforward way for bignums, and with binary formatting loop code for fixnums. * txr.1: Documented b.
* Use chk_manage_vec for static slots arrays.Kaz Kylheku2015-10-171-4/+7
| | | | | | | | * struct.c (make_struct_type): Use chk_manage_vec for initial allocation of static slot array. (static_slot_ensure): Use chk_manage_vec to grow the array when adding a slot. The function will automatically double the array in power of two step sizes.
* New function chk_manage_vec.Kaz Kylheku2015-10-172-0/+51
| | | | | | | | | | | | This function manages a dynamic array using only the filled size as input, while minimizing reallocations. The allocated size is implicitly always the next power of two at or above the filled size. * lib.c (next_pow_two): New static function. (chk_manage_vec): New function. * lib.h (chk_manage_vec): Declared.
* Fix overflow check using wrong variable.Kaz Kylheku2015-10-171-1/+1
| | | | | * lib.c (chk_grow_vec): It is newelems which must be compared against the no_oflow value, not bytes.
* New test case for handle and frame introspection.Kaz Kylheku2015-10-172-0/+19
| | | | | | * tests/012/except.tl: New file. * tests/012/except.expected: New file.
* Streamline handling of struct type arguments.Kaz Kylheku2015-10-172-98/+86
| | | | | | | | | | * struct.c (stype_handle): New static function. (make_struct_type, super, make_struct, static_slot, static_slot_set, static_slot_ensure, slotp, static_slot_p): Use stype_handle, * txr.1: Documented that static-slot and static-slot-set take type as a symbol.
* Fix formatting under caar, cadr, ...Kaz Kylheku2015-10-161-0/+1
| | | | * txr.1: .cblk with no closing .cble.
* Adding defmeth macro and static-slot-ensure.Kaz Kylheku2015-10-164-0/+135
| | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (defmeth): New macro. * struct.c (struct struct_type): New member, dvtypes. (struct_init): Register static-slot-ensure intrinsic. (make_struct_type): Initialize dvtypes of newly instantiated struct_type struct. If a super is specified, add new type to the super's dvtypes. (struct_type_mark): Mark st->dvtypes. (static_slot_ensure): New function. * struct.h (static_slot_ensure): Declared. * txr.1: Documented defmeth and static-slot-ensure.
* Remove use of the system function.Kaz Kylheku2015-10-162-19/+35
| | | | | | | | | | System depends on environment variables, and also causes SIGINT and SIGQUIT to be ignored. * stream.c (sh): Function rewritten in terms of sh, in two platform variants. * txr.1: Documented that sh doesn't use system as of TXR 120.
* Most uses of auto_str should be static_str.Kaz Kylheku2015-10-161-3/+3
| | | | | | | | | These functions do exactly same thing, but communicate something different to the reader of the code. An auto_str is on the stack, and so must not be passed somewhere where it will be retained. * txr.c (help, compat, txr_main): Use static_str on version.
* Renaming some functions for consistency.Kaz Kylheku2015-10-168-42/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * combi.c (perm_list, perm_str, rperm_list, reperm_gen_fun, rperm_vec, comb_vec, rcomb_list, rcomb_vec, rcomb_str): Follow rename of list_vector to list_vec. * eval.c (vector_list_s): Global variable renamed to vec_list_s. (expand_qquote): Follow vector_list_s to vec_list_s. (eval_init): Follow renames of all identifiers. Functions num-chr, chr-num, vector-list and list-vector are registered under new names, while remaining registered under old names. * eval.h (vector_list_s): Declaration renamed. * filter.c (url_encode): Follow chr_num to chr_int rename. * lib.c (make_like, interpose, shuffle): Follow vector_list to vec_list rename. (tolist, replace, replace_list): Follow list_vector to list_vec rename. (num_chr): Renamed to int_chr. (chr_num): Renamed to chr_int. (vector_list): Renamed to vec_list. (list_vector): Renamed to list_vec. * lib.h (num_chr, chr_num, list_vector, vector_list): * Declarations renamed. * parser.y (vector): Follow vector_list to vec_list rename. * txr.1: Updated documentation for num-chr, chr-num, list-vector and vector-list with new names, and notes about the old names being supported, but obsolescent.
* Adding find-frame function.Kaz Kylheku2015-10-154-2/+110
| | | | | | | | | | | | * unwind.c (uw_find_frame): New function. (uw_late_init): Registered find-frame intrinsic. * unwind.h (uw_find_frame): Declared. * lib.h (default_arg_strict): New inline function. Will not replace nil value with default. * txr.1: Documented find-frame.
* Introspection over catch and handle frames.Kaz Kylheku2015-10-153-1/+242
| | | | | | | | | | | | | | * unwind.c (types_s, jump_s): New symbol variables. (frame_type, catch_frame_type, handle_frame_type): New globals denoting struct types. (uw_get_frames, uw_invoke_catch): New functions. (uw_late_init): Initialize new global variables. Register get-frames and invoke-catch intrinsics. * unwind.h (uw_get_frames, uw_invoke_catch): Declared. * txr.1: Documented frame, catch-frame, handle-frame, get-frames and invoke-catch.
* List another limitation of listener.Kaz Kylheku2015-10-151-0/+6
| | | | * txr.1: suports only VT100.
* Slight section restructuring.Kaz Kylheku2015-10-141-1/+3
| | | | * txr.1: Object Type and Equivalence split into two.
* Adding typecase macro.Kaz Kylheku2015-10-143-0/+97
| | | | | | | | | | * lisplib.c (type_set_entries, type_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/type.tl: New file, providing typecase * txr.1: Documented typecase.
* New way of handling exceptions without unwinding.Kaz Kylheku2015-10-147-7/+350
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (handler_bind_s): New symbol variable. (op_handler_bind): New static function. (do_expand): Traverse handler-bind forms. (eval_init): Initialize handler_bind_s variable and register handler-bind operator. * lisplib.c (except_set_entries, except_instantiate): New functions. (lisplib_init): Register new functions in dl_table. * parser.c (intr_s): New symbol variable. (repl_intr): Throw exception of type intr, rather than error. This way we can interrupt accidental exception handling loops involving exceptions derived from error. (parse_init): Initialize intr_s. * share/txr/stdlib/except.tl: New file, defines handle macro. * unwind.c (uw_push_handler): New function. (invoke_handler): New static function. (uw_throw): Search loop looks for and processes handlers in addition to catches. * unwind.h (uw_frtype_t): New enum member, UW_HANDLE. (struct uw_catch): Move member visible so it is in the same position as in struct uw_handler. (struct uw_handler): New struct type. (union uw_frame): New member ha of type struct uw_handler. (uw_push_handler): Function declared. * txr.1: Added introductory paragraphs to Exception Handling section. Documented handler-bind and handle. Some minor errors corrected.
* Go into listener if no arguments are given.Kaz Kylheku2015-10-131-0/+24
| | | | | | | | * txr.c (help): Document the behavior. (banner): New static function. (txr_main): If listener support compiled in, show the banner and go to REPL instead of showing the usage hint and bailing.
* Capitalization in help text.Kaz Kylheku2015-10-131-3/+3
| | | | * txr.c (help): Capitalize TXR, Copyright and Usage.
* Hash table iterators exposed, with new macro.Kaz Kylheku2015-10-114-0/+141
| | | | | | | | | | | * eval.c (eval_init): Register hash-begin and hash-next intrinsics. * lisplib.c (hash_set_entries, hash_instantiate): New static functions. (lisplib_init): Register new tables in dl_table. * share/txr/stdlib/hash.tl: New file. * txr.1: Document with-hash-iter macro.
* Invoke finalizers if object initialization bails.Kaz Kylheku2015-10-102-0/+22
| | | | | | | | | | * struct.c (make_struct): Add unwind protection around the initialization of the struct object, which calls the partially initialized object's finalizers if initialization is abandoned by a non-local exit. * txr.1: Document the behavior, under make-struct and the new macro.
* Struct finalizers should be registered first.Kaz Kylheku2015-10-102-15/+15
| | | | | | | | | | | * share/txr/stdlib/struct.tl (defstruct): Rearrange the generated instance initialization function so that if a :fini block was specified, it is performed first. Thus if the remaining initialization code is abandoned, it is possible to intercept that and invoke the finalizer, which can clean up any mess left behind. * txr.1: Document changed order.
* defstruct bugfix: nonexistent function called.Kaz Kylheku2015-10-101-6/+6
| | | | | * share/txr/stdlib/struct.tl (defstruct): The nonexistent uw-throwf function was called instead of throw.
* Version 119.txr-119Kaz Kylheku2015-10-106-406/+479
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New macro: with-objects.Kaz Kylheku2015-10-103-1/+62
| | | | | | | | | | | * lisplib.c (with_resources_set_entries): "with-objects" added to name table. * share/txr/stdlib/with-resources.tl (with-objects): New macro. * txr.1: Documented with-objects. Added note to :fini specifier of defstruct pointing to call-finalizers and with-objects.
* Improve progn expansion.Kaz Kylheku2015-10-091-4/+13
| | | | | * eval.c (do_expand): Reduce (progn) to nil, and (progn single) to single.
* Tweaking expansions of when and until.Kaz Kylheku2015-10-092-6/+14
| | | | | | | * eval.c (me_when): Expand to if if there aren't multiple body forms. (me_unless): Simplify progn. * tests/012/struct.tl: Update string representation in struct test case.
* Add note to :init and :fini.Kaz Kylheku2015-10-091-0/+14
| | | | * txr.1: Unlike methods, these don't have an implicit block.
* Various stream-related with- macros introduced.Kaz Kylheku2015-10-083-0/+241
| | | | | | | | | | * lisplib.c (with_stream_set_entries, with_stream_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/with-stream.tl: New file. * txr.1: Documented new macros.
* Adding defex macro and related functions.Kaz Kylheku2015-10-082-0/+148
| | | | | | | | | | * eval.c (me_defex, register_exception_subtypes): New static functions. (eval_init): Registered new defex macro, and register-exception-subtype and exception-subtype-p intrinsic functions. * txr.1: Documented new macro and functions.
* Report objects with ~s in exception registration code.Kaz Kylheku2015-10-081-4/+4
| | | | | * unwind.c (uw_register_subtype): Error messages should print symbols with ~s, not the information-losing ~a.
* Add note to Limitations of interactive listener.Kaz Kylheku2015-10-081-0/+3
| | | | * txr.1: listener doesn't handle Unicode properly.
* Doc fixes: interactive listener section.Kaz Kylheku2015-10-071-3/+4
| | | | | * txr.1: spelling and grammar errors in various places in Interactive Listener section.
* Adding promisep function.Kaz Kylheku2015-10-072-0/+33
| | | | | | | * eval.c (promisep): New static function. (eval_init): Registered promisep intrinsic. * txr.1: Documented promisep.
* Better diagnostic for cramped floating literals.Kaz Kylheku2015-10-071-2/+7
| | | | | | * parser.l: Different text needed for ).1 and a.1 cases, because the insertion of a zero cannot fix the latter. Might as well make the messages more detailed.
* Vim: better indentation for some forms.Kaz Kylheku2015-10-071-1/+7
| | | | | * genvim.txr: Some operators should indent like functions. We don't want these in lispwords.
* New function: reset-struct.Kaz Kylheku2015-10-063-0/+50
| | | | | | | | | * struct.c (reset_struct): New function. (struct_init): Register reset_struct intrinsic. * struct.h (reset_struct): Declared. * txr.1: documented reset-struct.
* New function: replace-struct.Kaz Kylheku2015-10-063-0/+60
| | | | | | | | | * struct.c (replace_struct): New function. (struct_init): Register replace_struct intrinsic. * struct.h (replace_struct): Declared. * txr.1: documented replace-struct.
* New function: clear-struct.Kaz Kylheku2015-10-063-0/+34
| | | | | | | | | * struct.c (clear_struct): New function. (struct_init): Register clear-struct intrinsic. * struct.h (struct_init): Declared. * txr.1: documented clear-struct.
* New function: call-finalizers.Kaz Kylheku2015-10-063-0/+51
| | | | | | | | | * gc.c (gc_call_finalizers): New function. (gc_late_init): Register call-finalizers intrinsic. * gc.h (gc_call_finalizers): Declared. * txr.1: documented call-finalizers.
* Fix misleading documentation under if/iffi.Kaz Kylheku2015-10-061-4/+4
| | | | | | | | | | | * txr.1: Examples under iff and iffi had two issues: the false predicate function was used in a role which calls for a function that unconditionally returns nil. The correct function is nilf. Square brackets must be used, otherwise nilf and identity are unbound variables. Also the equivalence for [iff a] now indicates that it's equiavlent to a, showing that it's not useful to default both arguments.
* New function, expand-right.Kaz Kylheku2015-10-062-0/+101
| | | | | | | | * eval.c (expand_right_fun, expand_right): New static functions. (eval_init): Register expand-right intrinsic. * txr.1: Documented expand-right.