summaryrefslogtreecommitdiffstats
path: root/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* New: virtual machine with assembler.Kaz Kylheku2018-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is the start of compiler work to make TXR Lisp execute faster. In six days of part time work, we now have a register-style virtual machine with 32 instructions, handling exceptions, unwind-protect, lexical closures, and global environment access/mutation. We have a complete assembler and disassembler for this machine. The assembler supports labels with forward referencing with backpatching, and features pseudo-ops: for instance the (mov ...) pseudo-instruction chooses one of three kinds of specific move instruction based on the operands. * Makelfile (OBJS): Add vm.o. * eval.c (lookup_sym_lisp1): Static function becomes external; the virtual machine needs to use this to support that style of lookup. * genvmop.txr: New file. This is the generator for the "vmop.h" header. * lib.c (func_vm): New function. (generic_funcall): Handle the FVM function type via new vm_execute_closure function. In the variadic case, we want to avoid the argument copying which we do for the sake of C functions that get their fixed arguments directly, and then just the trailing arguments. Thus the code is restructured a bit in order to switch twice on the function type. (init): Call vm_init. * lib.h (functype_t): New enum member FVM. (struct func): New member in the .f union: vm_desc. (func_vm): Declared. * lisplib.c (set_dlt_entries_impl): New static function, formed from set_dlt_entries. (set_dlt_entries): Reduced to wrapper for set_dlt_entries_impl, passing in the user package. (set_dlt_entries_sys): New static function: like set_dlt_entries but targetting the sys package. (asm_instantiate, asm_set_entries): New static functions. (lisplib_init): Auto-load the sys:assembler class. * share/txr/stdlib/asm.tl: New file. * vm.c, vm.h, vmop.h: New files.
* Copyright year bump 2018.Kaz Kylheku2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.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, 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/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.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/txr-case.tl, share/txr/stdlib/type.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, win/cleansvg.txr: Extended Copyright line to 2018.
* New feature: structure delegate streams.Kaz Kylheku2017-12-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new kind of stream object which redirects its operations to the methods of a structure. * Makefile (OBJS): New object file, strudel.o. * lib.c (init): Call new strudel_init function. * lisplib.c (stream_wrap_set_entries, stream_wrap_instantiate): New static functions. (lisplib_init): Arrange for autloading of new stream-wrap.tl. * share/txr/stdlib/stream-wrap.tl: New file. * stream.c (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): New symbol variables. (stream_init): New symbol variables initialized. Numerous functions registered via these variables now rather than intern(...) expressions. * stream.h (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): Declared. * strudel.c, strudel.h: New files.
* Makefile: further improvement of tests.Kaz Kylheku2017-10-251-32/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that if a test is interrupted, it will not be re-run because the .ok stamp file depends only on an .out file, and that has been successfully created. We completely remove .out files from the rule tree. Quite simply, the output of a test is the .ok stamp. If that is out of date or doesn't exist, the test is run. Generation of the .out is just a side effect. * Makefile (TESTS_OK): Calculate this variable directly from the wildcard over .txr and .tl files..directly rather than from TESTS_OUT. (TESTS_OUT): Variable removed. (TXR_OPTS, TXR_ARGS): The target-specific assignments of these variables for specific tests is now done against .ok stamp file targets rather than .out targets. (TST_EXPECTED, TST_OUT): New helper variables for condensing repeated instances of some syntax. (tst/%.out): Both of these rules are turned into rules which target tst/%.ok. The .out files are just a side effect; the goal is to update the stamp. If an .out file is removed, the test won't be re-run; only if an .ok file is removed, or any of the real prerequisites change. (%.ok): This rule disappears, and its body containing the conditional stamp file touch is moved into both tst/%.ok rules.
* Makefile: fix silliness in "tests" target.Kaz Kylheku2017-10-251-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Last I addressed this, I didn't get it quite right. The problem is that the .out files are being removed when a test fails, which is annoying. The whole redirection of test results to a temp file which is then renamed is silly. Now, the .out files are preserved. Whether or not a test passed depends on whether or not the .ok stamp file is created or updated, so it doesn't matter whether an .out file exists or not. Also, tests are made dependent on the executable, and on the .expected files. If the executable is newer than the test outputs, all the tests will re-run. Also, if any .expected file is touched, the corresponding test will be re-run. * Makefile (clean): Do not remove $(TESTS_TMP). (TESTS_TMP): Variable removed. (tst/%.out): In both rules that run the test and make .out files simply redirect the output directly to the .out file represented as the $@ target. This is how it was before, once upon a time. (%.ok): Do not remove the .out file represdented by $< if the test fails; it is sufficient not to create/touch the .ok stamp file.
* Makefile: improve command abbreviation.Kaz Kylheku2017-10-251-4/+8
| | | | | | | | | | | | For all build steps other than linking, print only the leftmost prerequisite of the target. * Makefile (ABBREV): The macro references $< rather than $^, and hence longer needs the $(DEP_$@) filtering. (ABBREVN): New macro, identical to previous ABBREV, modulo a whitespace fix: removal of a stray tab character. (LINK_PROG): For linking, use ABBREVN so that all the object files are shown.
* Makefile: clean temporary file used in testing.Kaz Kylheku2017-09-281-0/+1
| | | | * Makefile (clean): Remove $(TESTS_TMP) if it exists.
* Makefile: print failing command in condensed mode.Kaz Kylheku2017-09-281-63/+82
| | | | | | | | | | | | | | | | | | When make output is condensed, showing a summary of each build step in the style "CC txr.c -> opt/txr.o", as is the case by default, the failing build command is now shown. Previously, a failed build had to be re-invoked with make VERBOSE=y to show the failing command. * Makefile (SH): New macro. (COMPILE_C, COMPILE_C_WITH_DEPS, LINK_PROG, WINDRES, INSTALL): These macros now invoke commands via SH rather than directly. (lex.yy.c, y.tab.h, y.tab.c, install-tests, %): Recipes for these targets use SH macro for executing shell commands rather than specifying them directly. (tst/%.out, %.ok, %.expected): These test-related pattern rules also use SH.
* configure: deal with non-standard libffi installations.Kaz Kylheku2017-07-041-0/+4
| | | | | | | | | | | | | | | | | This addresses a failure to build with libffi on Arch Linux, reported by Joe Eib. * Makefile (opt/ffi.o, dbg/ffi.o): Pull LIBFFI_CFLAGS into TXR_CFLAGS for just these object files. * configure (have_pkgconfig, libffi_cflags): New variables. (gen_config_make): Create new Makefile variable, LIBFFI_CFLAGS, from libffi_cflags. New configure test to detect pkg-config. Libffi test falls back on using pkg-config to test for existence of the library and to get the cflags and ldflags. Any needed cflags end up in LIBFFI_CFLAGS and are used only when compiling ffi.c.
* ffi: retain some functionality if libffi missing.Kaz Kylheku2017-06-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FFI module is more than just foreign calls and callbacks; it provides a type system and operations for working with binary data. None of it depends on libffi being present and so shouldn't be disabled if libffi is not available. * Makefile (ffi.o): Unconditionally link this object file, not subject to the have_libffi variable. * configure (have_libffi): Variable removed. (gen_config_make): Do not generate a have_libffi variable into config.make, since nothing needs it. * ffi.c (ffi_type): Fake ffi_type defined if libffi is missing. (FFI_TYPE_STRUCT): Fake macro. (ffi_type ffi_type_void, ffi_type_pointer, ffi_type_sint, ffi_type ffi_type_schar, ffi_type_uchar, ffi_type ffi_type_sshort, ffi_type_ushort, ffi_type ffi_type_sint, ffi_type_uint, ffi_type ffi_type_slong, ffi_type_ulong, ffi_type ffi_type_sint8, ffi_type_uint8, ffi_type ffi_type_sint16, ffi_type_uint16, ffi_type ffi_type_sint32, ffi_type_uint32, ffi_type ffi_type_sint64, ffi_type_uint64, ffi_type ffi_type_float, ffi_type_double): Fake libffi type objects, so that code which references these things will build without modification. (ffi_get_type): Function only defined if we have libffi. (ffi_type_struct_destroy_op, ffi_struct_clone, make_ffi_type_struct, ffi_array_clone, make_ffi_type_array): Don't work with ffi_type's element array if we don't have libffi; our fake ffi_type doesn't have such an array. (struct txr_ffi_closure): Type only defined if we have libffi. (ffi_closure_struct, ffi_closure_struct_checked, ffi_closure_print_op, ffi_closure_destroy_op, ffi_closure_mark_op, ffi_closure_put): Functions only defined if we have libffi. (ffi_closure_ops): Static structure only defined if we have libffi. (ffi_init_types): Don't register a closure type if we don't have libffi. (struct txr_ffi_call_desc): Don't define type if we don't have libffi. (ffi_call_desc, ffi_call_desc_checked, ffi_call_desc_print_op, ffi_call_desc_destroy_op, ffi_call_desc_mark_op, ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch, ffi_closure_dispatch_safe, ffi_make_closure, ffi_closure_get_fptr): Functions only defined if we have libffi. (ffi_call_desc_ops): Static structure only defined if we have libffi. (ffi_init): Only register ffi-make-call-desc, ffi-call, and ffi-make-closure if we have libffi. * lib.c: Include "ffi.h" header unconditionally. (generic_funcall, ref, refset, int): Remove #if HAVE_LIBFFI.
* make tests: remove failed .out.Kaz Kylheku2017-05-271-1/+4
| | | | | | | | * Makefile (%.ok): If the .out file differs from .expected, don't just fail this rule. Remove the .out file also, so that when "make tests" is repeated, the test is re-run to regenerate it. Otherwise "make tests" will only run diff again on the previously generated .out file.
* tests: first FFI regression test case.Kaz Kylheku2017-05-131-0/+1
| | | | | | | | | | | * tests/017/qsort.expected: New file. * tests/017/qsort.tl: New file. * tests/common.tl (libc): New function. * Makefile (tst/tests/017/%): Clear TXR_DBG_OPTS so the GC stress test isn't applied to tests in this directory.
* Start of FFI implementation based on libffi.Kaz Kylheku2017-04-241-0/+1
| | | | | | | | | | | | * Makefile (OBJS): Add ffi.o. * configure (have_libffi): New variable. (gen_config_make): Generate have_libffi make variable. New check for availability of libffi. * ffi.c, ffi.h: New files. * lib.c (init): Call ffi_init.
* Continuing implementation of buffers.Kaz Kylheku2017-04-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS): New objects itypes.o and buf.o. * buf.c, buf.h: New files. * itypes.c, itypes.h: New files. * lib.c (obj_print_impl): Handle BUF via buf_print and buf_pprint. (init): Call itypes_init and buf_init. * parser.h (end_of_buflit): Declared. * parser.l (BUFLIT): New exclusive state. (grammar): New rules for recognizing start of buffer literal and its interior. (end_of_buflit): New function. * parser.y (HASH_B_QUOTE): New token. (buflit, buflit_items, buflit_item): New nonterminals and corresponding grammar rules. (i_expr, n_expr): These symbols now generate a buflit; a buffer literal is a kind of expression. (yybadtoken): Handle HASH_B_QUOTE case.
* Makefile: detect when y.tab.h doesn't change.Kaz Kylheku2017-04-191-0/+5
| | | | | | | | | | | | | | | | When we touch the parser.y file, yacc regenerates y.tab.h. Then everything which depends on that is rebuilt. However, this is not necessary if the parser.y change doesn't actually modify the contents of y.tab.h. A build system based on file hashes wouldn't have this problem, but make works strictly with modification timestamps. * Makefile (y.tab.c): Preserve the old y.tab.h, if it exists, as y.tab.h.old. Then if the new y.tab.h is exactly the same according to cmp, restore the old y.tab.h in its place. (clean): Remove y.tab.h.old.
* Protect internal symbols from uninterning.Kaz Kylheku2017-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | Issue: TXR holds numerous symbol references in global variables, like list_s. These variables are not registered as root pointers with the garbage collector. This is normally okay because symbols are reachable via packages. However, if such a symbol is uninterned, that causes an integrity problem. Solution: protect those symbols from being removed from their packages. * Makefile (OBJS): Add protsym.o. * genprotsym.txr, protsym.c: New files. * lib.c (prot_sym_check): New static function. (use_sym, uintern, rehome_sym): Use prot_sym_check to implement a defense against internal symbols being booted out of their package.
* Get rid of config/ directory.Kaz Kylheku2017-03-311-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We revert back to config.h, config.make and config.log just being in the root of the build directory, rather than in a config/ subdirectory, like it was until mid 2014. That change was done for the sake of the tainting problem: a build directory picking up the wrong config.h from a source directory that is itself in the a configured state. * Makefile: Include config.make rather than config/config.make. (TXR_CFLAGS): Remove config directory from include file search path. (OBJS, EXTRA_OBJS, y.tab.c, y.tab.h, lex.yy.c): Dependencies on config.h and config.make adjusted to point to new location. (distclean): Use rm -f on config.*, not rm -rf; we don't expect there to be a directory matching that pattern. Remove config.h, config.make and config.log rather than config directory. Extend the generic distclean to remove opt and dbg, because this change will trigger its use and lingering .d files in opt and dbg will break the build. Remove txr-win.exe and txr-dbg-win.exe in generic distclean. * configure (conf_dir, config_h, config_make, config_log): Variables gone, replaced by hard-coded strings everywhere. Generate config.make, config.log and config.h in the current directory rather than a subdirectory. Do not generate a conf_dir variable into config.make.
* build: defend against $(top_srcdir) interference.Kaz Kylheku2017-03-311-0/+11
| | | | | | | | | | | * Makefile (tainted): New top target added in a situation when an out-of-tree build is tainted by a configuration in the original tree. The problem is that .c files which have an #include "y.tab.h" or #include "config.h" get these headers from the same directory where they reside. This is processed ahead of any -iquote directories. If a "config.h" exists in $(top_srcdir), files include that in spite of "-iquote ." on the compiler command line.
* Fix broken out-of-tree build.Kaz Kylheku2017-03-311-1/+2
| | | | | | | | | | | Reported by Marco Wahl. When building in a separate directory, the y.tab.h file isn't found because the current directory is not searched by the compiler. It searches only the original source tree and the local config directory. * Makefile (TXR_CFLAGS): We must have . in the include file search path otherwise files can only find y.tab.h when it's in the same directory where they are.
* Icon refresh.Kaz Kylheku2017-03-151-1/+1
| | | | | | | | | | | | | | | | | I lost the original vector graphic inputs that went into the icon. This is a superior re-make. Better artwork, better post-processing quality, more sizes. * Makefile (win/%.res): Add win/*.ico as a pattern prerequisite, so that the resource file is regenerated when the icon changes. * win/txr.ico: Updated icon, now in sizes 16, 32, 48, 64, 96, 128, 192 and 256. * win/txr.xcf: Updated GIMP file. * win/txr.svg: New file.
* Drop the annoying need for - for standard input.Kaz Kylheku2017-03-081-1/+1
| | | | | | | | | | | | | * match.c (open_data_source): If there is nothing in the files array and data is t (indicating a request to open a data source), then use standard input. Subject to the compatibility option. * Makefile (txr-manpage.html): Drop use of the txr - argument in rule recipe. * txr.1: Document that - isn't necessary. Added to compatibility notes.
* Bump copyright year to 2017.Kaz Kylheku2017-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, struct.c, struct.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, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Add 2017 to all copyright headers and strings.
* bugfix: make clean not removing txr-win.exeKaz Kylheku2016-12-221-0/+1
| | | | | | | * Makefile (clean): Remove txr-win an txr-win-dbg executables if they exist. Because of this issue, stale txr-win executables got packaged in some Windows installer releases.
* configure: move Darwin check into Makefile.Kaz Kylheku2016-11-201-0/+6
| | | | | | * Makefile (conftest.darwin): New phony target. * configure: Always do Darwin check via make conftest.darwin.
* Conform to standard Makefile conventions.Kaz Kylheku2016-11-201-29/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR's build should use the values of standard make variables: use the existing $(CC), $(CFLAGS), $(YACC), $(LDFLAGS) and such. * Makefile (TXR_CFLAGS): New variable. Initialized with the value of $(CFLAGS) and then customized. Used everywhere in place of CFLAGS. (CFLAGS): Now used only as the initial value of TXR_CFLAGS; no longer clobbered with the := assignment. Thus if a distribution of free software builds everything with certain CFLAGS, we incorporate those CFLAGS that it wants us to use. (TXR_LDFLAGS): New variable, initialized from $(LDFLAGS). Used in place of LDFLAGS. (LDFLAGS): Use only, do not modify. (NM): Replaced with TXR_NM. (YACC): Replaced with TXR_YACC. * configure (ccname): Default to $(CC) rather than gcc. (lex): Default name portion $(LEX) rather than flex; keep the optional prefixes. (gen_config_make): Generate TXR_CC, TXR_LEX, TXR_YACC and TXR_NM variables, rather than clobbering the standard ones CC, LEX and YACC. Also, in the rule that finds yacc, we now try '$(YACC)' first.
* New arithmetic tests.Kaz Kylheku2016-11-151-0/+1
| | | | | | | | | * Makefile (TXR_DBG_OPTS): Suppress for new directory tests/016. * tests/016/arith.tl: New file. * tests/016/arith.expected: New file.
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-011-16/+17
| | | | | | | | | | | | | | | | | | | | * Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.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, 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: Revert to verbatim 2-Clause BSD.
* Adding tests for split-str.Kaz Kylheku2016-09-171-0/+1
| | | | | | | | * Makefile (TXR_DBG_OPTS): Disable for tst/tests/015. * tests/common.tl (mtest): New macro. * tests/015/split.tl: New file.
* Fix multi-arch build issue for txr.res.Kaz Kylheku2016-08-061-1/+1
| | | | | | | | | | | | | When building in a separate directory, we can't just symlink the win directory, because the txr.res output file is architecture dependent and cannot be shared between 32 and 64 bit builds. * Makefile (%.res): Convert .rc -> .res rule to use the top_srcdir pattern, so the prerequisite will be found without the aid of the win/ directory symlink. * configure: Do not create win -> $source_dir/win symlink in the build directory.
* Fix issue in make dependency generation.Kaz Kylheku2016-08-061-1/+2
| | | | | | | * Makefile (DEPGEN): We must fold the backslash continuations before trying to delete the first dependency element, because if the target name is long, that first element may be on the following line, and we delete the backslash.
* The cmdwrap sh.exe hack is no longer needed.Kaz Kylheku2016-06-301-5/+0
| | | | | | | | | | | The Cygnal library uses cmd.exe for popen: problem solved. * Makefile (sh.exe): Target removed. * cmdwrap.c: File removed. * inst.nsi: Do not install sh.exe.
* Fix command spawning on Cygwin-based standalone image.Kaz Kylheku2016-06-291-0/+5
| | | | | | | | | | | | | | | | In the standalone image, we need a /bin/sh interpreter for the sh and open-command functions to work. The / path resolves to the installation directory, thanks to some sysrooting logic in the Cygwin DLL. Thus, we just need a sh.exe program in the bin directory, side by side with txr.exe. This sh.exe program can translate the "sh -c command" invocation to "cmd.exe /c command". * Makefile (sh.exe): New target, built from cmdwrap.c. * cmdwrap.c: New file. * inst.nsi: Install sh.exe.
* Eliminating the ! $ and - file-opening hacks.Kaz Kylheku2016-05-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Going forward, the "!command" and "$dir" are no longer recognized, except with the backward-compatibility -C option. The "-" string denoting standard input is only recognized from the command line, not in the @(next) directive; and "-" cannot be used in @(output) to denote standard output. The main problem is that these are hacks which intrude into the namespace. (What if a file is named "-", or begins with "!" or "$"?) Secondly, they are possible security holes. These prefixes are recognized even in computed strings, like "@(next var)" where var contains "!command". * Makefile (tst/tests/002/%): Run tests in this directory with the -C 142 option in TXR_OPTS, because they use the ! mechanism. * match.c (complex_open): New argument, from_cmdline, indicating whether the file name came from the command line or is internal. Function now only treats "-" as denoting standard input, if that came from the command line. The "!" and "$" prefixes are only recognized in compatibility with 142 or earlier. (v_next): Suppress old strategy of handling string sources by pushing them to the file list to let match_files open them. This is now done only under 142 compatibility. Instead, open directly, produce the list, and recurse into match_files with ready data. This is not only simpler, but also prevents "-" from being recognized in @(next), because complex_open is invoked directly, and the from_cmdline argument is specified as nil. (v_output): Don't rely on "-" denoting standard output; rather use the stream directly, which can be passed to complex_open. Pass nil to the new from_cmdline parameter of complex_open, so "-" isn't recognized. (open_data_source): Pass t for the from_cmdline parameter of complex_open, to have "-" recognized as denoting standard input. * txr.1: Removed documentation referring to !, and use of - in the @(next) and @(output) directives. Added notes to COMPATIBILITY section.
* Adding termios support.Kaz Kylheku2016-05-181-0/+1
| | | | | | | | | | | | | | | | * Makefile (termios.o): New object file. * lib.c (init): Call termios_init. * lisplib.c (termios_set_entries, termios_instantiate): New functions. (lisplib_init): Register new functions in autoload table. * share/txr/stdlib/termios.tl: New file. * termios.c, termios.h: New files. * txr.1: Documented termios.
* Some recent versions of flex contain // comment.Kaz Kylheku2016-05-061-1/+6
| | | | | | Makefile (lex.yy.c): Crudely and shamelessly filter lex.yy.c through sed to remove // commments, even if // occurs in a string literal or a /*...*/ comment which ends on that line.
* Adding manual page checker.Kaz Kylheku2016-04-261-1/+2
| | | | | | | * Makefile (txr-manpage.pdf): Invoke checkman.txr on the man page source. * checkman.txr: New file.
* Check man page for errors when generating PDF.Kaz Kylheku2016-04-261-1/+1
| | | | | | * Makefile (txr-manpage.pdf): Add -ww option to pdfroff to report all errors, such as uses of undefined macros.
* Adding ftw function.Kaz Kylheku2016-04-151-0/+1
| | | | | | | | | | | | | | * Makefile (ftw.o): Add to OBJS-y conditionally. * configure (have_ftw): New variable. New configure test for nftw. (gen_config_make): Set up have_ftw make variable. * ftw.c, ftw.h: New files. * lib.c (init): Call ftw_init, if compiled in. * txr.1: Documented.
* Basic regression test case for sockets.Kaz Kylheku2016-03-071-0/+1
| | | | | | | | | | * Makefile: suppress --gc-debug for tst/tests/014 directory. * tests/014/socket-basic.tl: New file. * tests/014/socket-basic.expected: New file. * tests/sock-common.tl: New file.
* Adding socket support: unix, ipv4, ipv6.Kaz Kylheku2016-02-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c, socket.h: New files. * Makefile: include new socket.o among objects if have_objects variable is defined to 'y'. * configure (have_sockets): New variable. New configure test for socket-related functionality. (HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration preprocessor symbols. Also, reordering the shell probing so that /usr/xpg4/bin/sh is the last fallback. On Solaris, it chokes on some code that is needed for Solaris. * lisplib.c (sock_set_entries, sock_instantiate): New static functions. (lisplib_init): Register new functions as autoload hooks. * share/txr/stdlib/socket.tl: New file. * stream.c (socket_error_s): New symbol variable. (struct stdio_handle): New members, family and type, helping stdio streams represent sockets too. (stdio_stream_mark): Mark new members of struct stdio_handle. (make_stdio_stream_common): Initialize new members. (make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): New functions. (stream_init): Initialize socket_error_s variable. Register sock-family, sock-type and open-socket intrinsic functions. Register socket-error subtype. * stream.h (socket_error_s, make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): Declared.
* Support extra linker flags.Kaz Kylheku2016-01-131-1/+1
| | | | | * Makefile (EXTRA_LDFLAGS): New variable, interpolated into LDFLAGS.
* Copyright year bump.Kaz Kylheku2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* Increase stack size on Windows.Kaz Kylheku2015-11-291-1/+1
| | | | | | | | | * Makefile: include CONF_LDFLAGS in LDFLAGS. * configure (conf_ldflags): New variable. (gen_config_make): Generate CONF_LDFLAGS make variable. New test which sets up conf_ldflags for a 16Mb stack size if we are on Cygwin or MinGW.
* Stop using C library setjmp/longjmp.Kaz Kylheku2015-10-251-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Reveal struct winsize on Solaris.Kaz Kylheku2015-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | On Solaris 10, we need __EXTENSIONS__ defined to make struct winsize appear out of <termios.h>. This commit adds detection for what preprocessor symbol needs to be defined for struct winsize to appear, if it appears at all. Then this symbol is defined on the compiler command line when compiling linenoise. * Makefile (CFLAGS): Add -D$(termios_define) for linenoise.o target. * configure (have_winsize, termios_define): New variables. Detect whether struct winsize is available, and what preprocessor symbol, if any, is required to reveal the feature. * linenoise/linenoise.c: Need to include TXR's "config.h" for HAVE_WINSIZE. (get_columns): Reorganized so that use of struct winsize is guarded by HAVE_WINSIZE and fallback code is used if either obtaining the size fails or the feature is completely unavailable.
* Basic REPL based on linenoise.Kaz Kylheku2015-09-051-1/+1
| | | | | | | | | | | | | | | | * Makefile (OBJS): Only include linenoise.o if have_termios is y. * configure: Adding test for termios. (have_termios): New configure and config.make variable. (gen_config_make): Generate have_termios variable. * parser.c (repl): New function. * parser.h (repl): Declared. * txr.c (help): Summarize new -i option. (txr_main): Implement -i repl.
* Compile and link linkenoise into txr; fix errors.Kaz Kylheku2015-09-041-0/+1
| | | | | | | | | | | * Makefile (OBJS): Add linenoise/linenoise.o. * linenoise/linenoise.c (linenoiseEditInsert, linenoiseEditMoveLeft, linenoiseEditMoveRight, linenoiseEditMoveEnd, linenoiseEditHistoryNext, linenoiseEditDelete, linenoiseEditBackspace, linenoiseEditDeletePrevWord): These de facto internal functions are switched from external to static.
* No need to point the compiler into the mpi directory.Kaz Kylheku2015-09-041-1/+0
| | | | | | * Makefile (CFLAGS): Remove -iquote $(top_srcdir)mpi * lib.h: include "mpi/mpi.h" instead of "mpi.h".
* Introducing structs.Kaz Kylheku2015-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.
* Add maze generation to test suite.Kaz Kylheku2015-08-241-0/+2
| | | | | | | | | * Makefile (tst/tests/013/maze.out): Add TXR_ARGS. Disable gc-debugging for tests in new directory. * tests/013/maze.expected: New file. * tests/013/maze.tl: New file.