summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: usage note for compile-update-file.Kaz Kylheku2019-12-231-0/+16
| | | | | | * txr.1: Document how compile-update-file can be used together with load to ensure that the compiled version of a file is loaded without unnecessary recompiling.
* doc: redocument keyword argument description.Kaz Kylheku2019-12-231-15/+29
| | | | | | * txr.1: Under :key parameter macro, rewriting the description of what keyword arguments are. This was prompted by the strange wording "Arguments to keyword appear ...".
* doc: spurious blank line under build macro.Kaz Kylheku2019-12-231-1/+0
| | | | * txr.1: Remove spurious blank line.
* New function: compile-update-file.Kaz Kylheku2019-12-223-59/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | The new function only compiles a file if the output file doesn't exist or is out of date. In addition, both compile-file now deletes the output file if compilation fails, and has a documented return value. * lisplib.c (compiler_set_entries): Add autoload entry fro compile-update-file. (open-compile-streams): Accepts a third argument: a function to test the input stream against the output path. The output file is opened, and the streams are returned, only if that test function returns true. Also, a third element is returned: the output path. This lets the caller to know what to delete, if the output file must be deleted. (compile-file-conditionally): New internal function, formed from compile-file. Takes an extra argument, the test function to pass to open-compile-streams. Compilation is skipped if open-compile-streams returns nil. Internals reshuffled a bit. If compilation doesn't set the success flag, then the with-resources logic now removes the output file in addition to closing the output stream. Prior to setting the success flag, we flush the output stream. * txr.1: Documented new function, all return values, and deletion of output file on unsuccessful compilation.
* Version 230.txr-230Kaz Kylheku2019-12-204-5/+24
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* config: improve check for PIE-disabling flags.Kaz Kylheku2019-12-191-2/+2
| | | | | | | * configure: the logic must be cumulative; the test for the code generation flag (e.g. -fno-pie) needs to incorporate the previously detected linker flag (e.g. -no-pie). On x86_64, -fno-pie by itself without -no-pie fails with errors.
* configure: better check for missing make.Kaz Kylheku2019-12-191-2/+2
| | | | | | * configure: don't fail with a "unbound variable $3" error if make is not found; correctly print "missing" and quit cleanly.
* configure: disable building as PIE.Kaz Kylheku2019-12-181-0/+25
| | | | | | | | | | | | | | | | On some GNU/Linux distributions, the compiler is configured for PIE (position-independent executables). This is horrible garbage which causes our "make tests" to run more than 22% slower (e.g. 8.22 seconds versus 6.69) which is unacceptable. Worse, this was implicated in a crash in TXR's exception handling logic. The committed workaround for that problem stays in place for users who want to build TXR in the PIE style anyway. * configure: detect which, if any, of the known gcc and clang options are available for disabling PIE and add those to opt_flags (which turns into OPT_FLAGS in config.make).
* Move jmp-related stuff from signal.h to unwind.h.Kaz Kylheku2019-12-173-170/+177
| | | | | | | | | | | | | | | | | | * gc.c: Include "unwind.h" for jmp_buf. * signal.h (struct jmp): All versions removed from here. (jmp_save, jmp_restore): Declarations removed from here. (EJ_DBG_MEMB): Macro removed. (extended_jmp_buf): Struct type removed. (extended_setjmp, extended_longjmp): Macros removed. (extjmp_save, extjmp_restore): Declarations removed. * unwind.h (struct jmp): Declared here. (jmp_save, jmp_restore): Declared here. (EJ_DBG_MEMB): Macro moved here. (extended_jmp_buf): Struct type moved here. (extended_setjmp, extended_longjmp): Declared here. (extjmp_save, extjmp_restore): Declared here.
* bugfix: crash in extended_setjmp due to PIE.Kaz Kylheku2019-12-173-55/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A crash occurs on Ubuntu 18.04, 32 bit x86, when executing the test case tests/007/except-2.txr, whereby TXR segfaults in the v_try function. This is reminiscent of a January, 2016 report in the txr-users mailing list from Morit Barsnick, who also ran into a crash in the same test case. Background: it appears that the compiler in Ubuntu 18.04 enables PIE (position-independent executables) by default. Thus even simple executables that are not shared libraries reference their own global variables through an offset table, instead of direct addressing. To access globals, the compiler has to emit code that retrieves their addresses from a table, pulling them into a register, and then performing indirect memory accesses through the register. Sometimes the emitted code doesn't keep these addresses in a register. The address of a global variable accessed multiple times in a block of code may get spilled from a register into the stack, and then later retrieved from the stack again to access that same global. In our extended_setjmp logic, we save the values of a few global variables and restore them if the extended_longjmp takes place to return to that point. The problem is that when restoring some of the globals, the compiler is relying on retrieving the effective addresses from the temporary spill locations in the stack. However, those temporary locations have since been re-used for other purposes and the access to the globals therefore crashes or produces unpredictable results. Essentially, it's as if GCC did this around our code: { unsigned *debug_enable_addr = &debug_enable; /* save and restore logic here uses *debug_enable_addr * to refer to debug_enable */ if (extended_setjmp(...)) ... } /* Oops, debug_enable_addr is now garbage! * We are jumping back into the scope which will try to use * its value to restore the debug_enable global. */ extended_longjmp(...); I have experimented with a few approaches that did not work, and settled on moving the code which saves and restores the globals into functions. GCC will not cache the effective address calculation of a global variable access between calls to different external functions which access that variable. The mitigation in this commit gets the test cases to pass even if TXR is compiled with PIE. However, PIE should be disabled. Not only does it cause the above problem, but it has a huge performance impact: a more than 16% slowdown, which is quite unacceptable. * eval.h (dyn_env): Delare here. Some sources were depending on signal.h providing this, which is wrong. Now signal.h doesn't declare it any longer. * signal.h (EJ_DBG_SAVE, EJ_DBG_REST): Macros removed. (extended_setjmp): Greatly simplified. Extended restoring logic is now done in extended_longjmp, and the extended save for the globals is a function call. Just moving the restore into extended_longjmp probably would have fixed this issue. (extended_longjmp): Call extjmp_restore. (extjmp_save, extjmp_restore): Declared. * unwind.c (extjmp_save, extjmp_restore): New functions.
* ffi: bug: zchar not handled in array out semantics.Kaz Kylheku2019-12-161-0/+1
| | | | * ffi.c (ffi_array_out): Add missing zchar case.
* ffi: shut up gcc7 warnings about switch case.Kaz Kylheku2019-12-161-0/+7
| | | | | | * 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.
* Version 229.txr-229Kaz Kylheku2019-12-147-972/+1014
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* ffi: new type zcharKaz Kylheku2019-12-142-21/+126
| | | | | | | | | | | | | | | | | | | 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.
* ffi: turn char conversion flags into enum.Kaz Kylheku2019-12-141-52/+85
| | | | | | | | | | | | | | | | | | 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.
* listener: C++ enum issue.Kaz Kylheku2019-12-131-1/+1
| | | | | | * parser.c (is_balanced_line): don't initialize an "enum state" variable with 0, but with the equivalent enum constant.
* doc: doubled word in compat note.Kaz Kylheku2019-12-131-1/+1
| | | | | * txr.1: fix "invoked invoked" in compatibility note for compat value 151.
* doc: make-buf: document default value.Kaz Kylheku2019-12-131-2/+5
| | | | | * txr.1: documnt that the default value of the optional alloc-size parameter is taken from the len parameter.
* multiple-inheritance: test static-slot-home.Kaz Kylheku2019-12-132-1/+6
| | | | | | | * tests/012/oop-mi.tl: Add some coverage for static-slot-home function. * tests/012/oop-mi.expected: Updated.
* multiple-inheritance: super-method loose ends.Kaz Kylheku2019-12-134-41/+87
| | | | | | | | | | | | | | | | | * struct.c (do_super): New function. Now the common implementation for call_super_method, call_super_fun and super_method. (call_super_method, call_super_fun): Reduced to small wrappers around do_super. (super_method): Drill into the object to geet the struct_type handle, and then use do_super to get the method. * tests/012/oop-mi.tl: New tests for call-super-fun and call-super-method. * tests/012/oop-mi.expected: Updated. * txr.1: Updated.
* define-option-struct: use multiple inheritanceKaz Kylheku2019-12-131-14/+22
| | | | | | | | | | | | * share/txr/stdlib/getopts.tl (sys:option-base): New struct type, holding the boiler-plate methods and slots that were generated into the user-defined struct by define-option-struct. (define-option-struct): Inject the required properties by inheritance from sys:option-base, greatly reducing code bloat in the macro. The slot hash and opt-desc-list static slots have to be redefined in the derived structure so that type has its own instance of them.
* OOP: implementing multiple inheritance.Kaz Kylheku2019-12-117-94/+344
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple inheritance is too useful to ignore any longer. * lib.c (subtypep): Perform subtypep calculation between two struct types via the new struct_subtype_p function. It's too complicated now to do with ad hoc code outside of struct.c. * share/txr/stdlib/struct.tl (defstruct): This macro now needs to deal with the super argument being possibly a list of base types instead of a single one. * strut.c (struct struct_type): Member super and super_handle are removed. New member nsupers, supers, and sus. (struct_init): The super function re-registered; it has an optional argument. (call_stinitfun_chain): The compat code here must now access the supertype differently. We don't bother dealing with multiple inheritance in the compat case; programs requesting compatibility with TXR 151 shoudn't be trying to use multiple inheritance. (get_struct_handles, count_super_stslots, get_super_slots, find_super_for_slot): New static functions, to off-load some new complexity from make_struct_type. (make_struct_type): Handle the increased complexity due to multiple inheritance. (super): Takes an additional argument now, to request which supertype to retrieve. Defaults to zero: the first one. (struct_type_destroy): Free the sus array. (struct_type_mark): Mark the supers slot. (call_initfun_chain): Call init functions of all bases, in right-to-left order. (call_postinitfun_chain): Likewise for postinit functions. (call_super_method, call_super_fun, super_method): Use the first base as the supertype. This requirement feels bad; it needs to be revisited. (do_struct_subtype_p): New static function. (struct_subtype_p): New function. (ancestor_with_static_slot): New static function. (method_name): Revised for multiple inheritance; now relies on ancestor_with_static_slot to find the original ancestor that has brought in a method, so we can use that type in the method name. * struct.h (super): Declaration updated. (struct_subtype_p): Declared. * tests/012/oop-mi.expected: New file. * tests/012/oop-mi.tl: New test cases. * txr.1: Revised in order to document multiple inheritance.
* doc: clarify inheritance of static slot value.Kaz Kylheku2019-12-091-0/+31
| | | | | | | | | * txr.1: In relation of the previous bugfix, a certain situation is worth clarifying. A static slot does not inherit the value of a grandparent type's static slot of the same name, if the supertype has specified that slot as an instance slot. Inheritance of the static slot value is from the direct supertype only.
* structs: bugfix: crash in static slot inheritance.Kaz Kylheku2019-12-091-1/+1
| | | | | | | | | | | | | * struct.c (make_struct_type): When a struct defines a static slot that exists as an instancee slot in the supertype, there is a crash. This is because the code assumes that the supertype's slot is static. The index value m ends up negative due to subtracting STATIC_SLOT_BASE from an instance slot index, and so the code tries to copy the value of a negatively indexed static slot from the supertype into the new static slot. We can fix this by not doing the copy when a negative index has been calculated. That way we treat the situation as if the supertype didn't have that slot at all.
* New function: path-dir-empty.Kaz Kylheku2019-12-093-0/+38
| | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload entry for path-dir-empty. * share/txr/stdlib/path-test.tl (path-dir-empty): New function. * txr.1: Documented.
* Add hyperbolic functions: sinh, cosh, and others.Kaz Kylheku2019-12-074-0/+146
| | | | | | | | | | | | | | | | | | | | * 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.
* ffi: allow init-forms for slots.Kaz Kylheku2019-12-062-11/+80
| | | | | | | | | | | | | | | * 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.
* unwind: new function uw_warningf.Kaz Kylheku2019-12-062-0/+23
| | | | | | | | Convenience function for throwing warnings. * unwind.c (uw_warningf): New function. * unwind.h (uw_warningf): Declared.
* disassemble: d and t regs in decimal.Kaz Kylheku2019-11-291-2/+2
| | | | | | | | * share/txr/stdlib/asm.tl (operand-to-sym): Use decimal with no leading zeros for t and d registers. Only the v registers use hex, because that helps unravel their level structure. The data table is dumped with decimal numbering, so the d registers being decimal makes it easier to cross-ref.
* load: bug: source loc gathered for .tlo files.Kaz Kylheku2019-11-291-1/+3
| | | | | | | | | | | | Contrary to the belief expressed in the commit message of June 2018's 46480c25e62f60c761088c561d90b0f2f5a3143f, source location info is being recorded during the loading of compiled files. The reason is that the function used for processing the forms, lisp_parse_impl, overrides it. * parser.c (read_file_common): Use lisp_parse_impl directly, rather than lisp_parse. Specify that function's rlcp_p argument as false when processing compiled code.
* getopt: tweak multi-line literals in help textKaz Kylheku2019-11-291-26/+25
| | | | | | | | | * share/txr/stdlib/getopts.tl (opthelp): Use a different line breaking approach for literals: the escaped space is now at the end of the previous line, rather than at the start of the next line, which looks nicer. We don't do this for the option type legend, because that has some instances of leading space alignment, which requires a leading backslash.
* getopts: new define-option-struct macro.Kaz Kylheku2019-11-293-2/+159
| | | | | | | | | | | | This provides more streamlined option processing. * lisplib.c (getopts_set_entries): Add auto-load entry for define-option-struct. * share/txr/stdlib/getopts.tl (define-option-struct): New macro. * txr.1: Documented.
* doc: getopt: long and short options appear in index.Kaz Kylheku2019-11-291-0/+17
| | | | | | | | * txr.1: Document that in the parsed opts object returned by getopts, an option which has two names (long and short form) is indexed under both names if it has occurred in the command line, regardless of whether it has occurred under the short or long name.
* getopts: rename add method to add-opt.Kaz Kylheku2019-11-291-5/+5
| | | | | | | | | | | | | The reason for this rename is that add is a public symbol in the usr package, thanks to the build macro. This will interfere with an upcoming feature under which options appear directly as struct slots, defined by symbols. If a user defines an --add option using the symbol add, it will clash with the add method. But add-opt will be sys:add-opt. * share/txr/stdlib/getopts.tl (opts add): Rename to add-opt. (sys:opt-processor parse-long, sys:opt-processor parse-shorts): Follow rename.
* intern-fb: bugfix: optional argument handling.Kaz Kylheku2019-11-281-1/+1
| | | | | | | | | * lib.c (intern_fallback_intrinsic): The missing_ok parameter of get_package must be given a true argument, because package_in is optional. When it is missing, it is represented by the colon symbol, and if missing_ok is false, then get_package treats this colon symbol as the package name "" (the name of that symbol).
* intern-fb: use correct name in diagnostics.Kaz Kylheku2019-11-281-2/+2
| | | | | * lib.c (intern_fallback, intern_fallback_intrinsic): Use intern-fb name, not intern-fallback.
* getopts: move opts object into opt-processor.Kaz Kylheku2019-11-281-20/+24
| | | | | | | | | | | | | | | | | | | | | | | | | The methods of sys:opt-processor pass down an argument called out which is an opts instance that is created in parse-opts. In this patch, we move that argument into a new slot of the sys:opt-processor object, named opts. We instantiate the opts structure in the getopts function instead. The motivation here is that (meth sys:opt-processor parse-opts) doesn't know which type of opts object it is working with; its user is now responsible for instantiating the object and installing it as the opts slot. * share/txr/stdlib/getopts.tl (sys:opt-processor): New slot, opts. (sys:opt-processor (parse-long, parse-shorts): Drop out argument; refer to me.opts instead of it. (sys:opt-processor parse-opts): Don't instantiate opts object here, and don't pass it to parse-long and parse-shorts which no longer take that argument. Rather, rely on it already being installed into the opts slot. (getopts): Instantiate opts here, and specify it as the opts slot of the sys:opt-processor object also being instantiated here.
* getopts: remove unused opt-processor slot from opts.Kaz Kylheku2019-11-281-3/+2
| | | | | | | | * share/txr/stdlib/getopts.tl (opts): opt-processor slot removed. (sys:opt-processor parse-opts): When instantiating opts, do not initialize the opt-processor slot with a backpointer to self object. It is not referenced anywhere.
* getopts: print types in help without colon.Kaz Kylheku2019-11-281-2/+2
| | | | | | | | * share/txr/stdlib/getopts.tl (opthelp): Use symbol-name to get the string representation of type keywords instead of tostringp, so there is no leading colon. In the type legend, we don't have any colon. For instance --gravity=FLOAT rather than --gravity=:FLOAT.
* getopts: simplify build-hash.Kaz Kylheku2019-11-281-5/+3
| | | | | | share/txr/stdlib/getopts.tl (sys:opt-processor build-hash): Don't construct (list od.long od.short) twice and iterate through it twice; make just one and process it in one pass.
* doc: ffi-make-callback doesn't exist.Kaz Kylheku2019-11-251-1/+1
| | | | | * txr.1: Under deffi-cb, correcting a reference to nonexistent ff-make-callback to ffi-make-closure.
* listener: fix buggy balanced line check.Kaz Kylheku2019-11-241-2/+7
| | | | | | | | | | * parser.c (is_balanced_line): When handling the closing characters, we must look for the state type which matches the character type, not state[sp]. Of course state[sp] == match, since we initialized it that way, and so state[sp] != match is always false. We want match to be derived from the character ch, not from state[sp]. Also, the polarity in the match-not-found return case is wrong; we must return 0.
* buffers: support list operations.Kaz Kylheku2019-11-201-0/+18
| | | | | * lib.c (car, cdr, rplaca, rplacd, make_like): Handle BUF type.
* New function: buf-list.Kaz Kylheku2019-11-203-0/+39
| | | | | | | | | * buf.c (buf_list): New function. (buf_init): buf-list intrinsic registered. * buf.h (buf_list): Declared. * txr.1: Documented.
* parser: forgotten top-level .? cases.Kaz Kylheku2019-11-191-0/+8
| | | | | | * parser.y (hash_semi_or_n_expr, hash_semi_or_i_expr): We need to handle OREFDOT here so that .?sym can parse as a top-level expression. Issue reported by vapnik spaknik.
* parser: missing cases in yybadtoken.Kaz Kylheku2019-11-191-0/+3
| | | | | | * parser.y (yybadtoken): Add missing cases for UREFDOT, OREFDOT and UOREFDOT, so these don't fall through to being reported as a junk character.
* parser: merge cases in yybadtoken.Kaz Kylheku2019-11-191-1/+1
| | | | | * parser.y (yybadtoken): Merge CONSDOT and LAMBDOT cases since they have identical code.
* doc: macro-time update.Kaz Kylheku2019-11-191-23/+74
| | | | | | | * txr.1: Update outdated documentation. macro-date is not required any more in the indicated situations. But it can still be required sometimes, and has some interesting uses. More detail added.
* Version 228.txr-228Kaz Kylheku2019-11-187-1122/+1192
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* identity*: fix wrong argument index type.Kaz Kylheku2019-11-181-1/+1
| | | | | * lib.c (identity_star): The args_more function requires an index which is a cnum, not int.