summaryrefslogtreecommitdiffstats
path: root/HACKING
Commit message (Collapse)AuthorAgeFilesLines
* Eliminate declaration-after-statement everywhere.Kaz Kylheku2021-12-291-39/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The use of -ansi doesn't by itself diagnose instances of some constructs we don't want in the project, like mixed declarations and statements. * configure (diag_flags): Add -Werror=declaration-after-statement. This is C only, so filter it out for C++. Also add -Werror=vla. * HACKING: Update inaccurate statements about what dialect we are using. TXR isn't pure C90: some GCC extensions are used. We even use long long if the configure script detects it as working, and some C99 library features. * buf.c (replace_buf, buf_list): Fix by reordering. * eval.c (op_dohash, op_load_time_lit): Fix by reordering. * ffi.c (ffi_simple_release): Fix by reordering. (align_sw_get): Fix empty macro to expand to dummy declaration so a semicolon after it isn't interpreted as a statement. On platforms with alignment, remove a semicolon from the macro so that it requires one. (ffi_i8_put, ffi_u8_put): Fix by reordering. * gc.c (gc_init): Fix with extra braces. * hash.c (hash_init): Fix by reordering. * lib.c (list_collect_revappend, sub_iter, replace_str, replace_vec, mapcar_listout, mappend, mapdo, window_map_list, subst): Fix by reordering. (gensym, find, rfind, pos, rpos, in, search_common): Fix by renaming optional argument and using declaration instead of assignment. * linenoise/linenoise.c (edit_in_editor): Fix by reordering. * parser.c (is_balanced_line): Fix by reordering. * regex.c (nfa_count_one, print_rec): Fix by reordering. * signal.c (sig_mask): Fix by reordering. * stream.c (get_string): Fix by renaming optional argument and using declaration instead of assignment. * struct.c (lookup_static_slot_desc): Fix by turning mutated variable into block local. (umethod_args_fun): Fix by reordering. (get_special_slot): Fix by new scope via braces. * sysif.c (usleep_wrap): Fix by new scope via braces. (setrlimit_wrap): Fix by new scope via braces. * time.c (time_string_meth, time_parse_meth): Fix by reordering. * tree.c (tr_do_delete_spec): Fix by new scope via braces. * unwind.h (uw_block_beg): New macro which doesn't define RESULTVAR but expects it to refers to an existing one. (uw_block_begin): Replace do while (0) with enum trick so that we have a declaration that requires a semicolon, rather than a statement, allowing declarations to follow. (uw_match_env_begin): Now opens a scope and features the same enum trick as in uw_block_begin. This fixes a declaration-follows-statement issue in the v_output function in match.c. (uw_match_env_end): Closes scope opened by uw_match_env_begin. * unwind.c (revive_cont): Fix by introducing variable, and using new uw_block_beg macro. * vm.c (vm_execute_closure): Fix using combination of local variable and reordering.
* Revert bogus LIT_ALIGN commit from 2015.Kaz Kylheku2021-04-201-47/+37
| | | | | | | | | | | | | | | | This reverts commit 0343c6f32c5bd8335e88595cb9d23506625b2586. I don't see evidence that the claim in the commit is true: that wide literals are not four-byte-aligned on Darwin in spite of sizeof(wchar_t) being 4. Not even with the old clang in my old VM where I first thought I discovered this. * configure: do not set up LIT_ALIGN == 2 for Darwin. * lib.h (litptr): Remove LIT_ALIGN < 4 && SIZEOF_WCHAR_T == 4 case. * HACKING: Undocument bogus claim.
* HACKING: typoReini Urban2016-05-051-1/+1
|
* Fix incorrect example and add one more approach.Kaz Kylheku2015-09-021-12/+38
| | | | | | | | HACKING: Fix wrong make_foo example which violates Rule One, by registering an uninitialized struct as a cobj handle, thereby making garbage traversable by gc. Also show alternative solution to the problem based on extending variable liveness via gc_hint.
* Correction to COBJ initialization pattern.Kaz Kylheku2015-07-301-42/+69
| | | | | | | | | | | | | In fact, the previosuly documented process is not correct and still leaves a corruption problem under generational GC (which has been the default for some time). * HACKING: Document flaw in the initialization pattern previously thought to be correct, and show fix. * hash.c (copy_hash): Fix instance of incorrect pattern. * regex.c (regex_compile): Likewise.
* * HACKING: Restore accidentally deleted document title.Kaz Kylheku2015-07-301-0/+5
|
* Fix for LLVM wchar_t literals not being four byteKaz Kylheku2015-01-121-26/+31
| | | | | | | | | | | | | | | | | aligned, affecting OS X port. * configure: Detect a SIZEOF_WCHAR_T when detecting integer type that will hold a pointer. In the lit_align test, if we are on Apple Mac OSX, use a lit_align of 2, so the logic kicks in for padding literals and handling misalignment. * lib.h (litptr): Add a case for LIT_ALIGN < 4 and SIZEOF_WCHAR_T == 4. In this case we do the arithmetic on the pointer using short *, and then convert to wchar_t. * HACKING: New section 2.4.3 about new wchar_t hack.
* Implementing finalization hooks.Kaz Kylheku2014-10-301-47/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | * gc.c (struct fin_reg): New struct type. (final_list, final_tail, mark_makefresh): New static variables. (mark_obj): Under generational GC, if make_makefresh is in effect, set the generation to -1 on all marked objects. (sweep_one): In an EXTRA_DEBUGGING build, call breakpt if the object being swept is the one in break_obj. Under generational GC, place reachable objects that are in generation -1 the freshobj nursery and assign them to generation 0, rather than sticking them into the mature generation 1. (sweep): Under generational gc, reset the freshobj_idx variable here, so that sweep_one has an empty nursery in which to place the generation -1 objects. (prepare_finals, call_finals): New static functions. (gc): Call prepare_finals before sweep, and call call_finals just before re-enabling GC and returning. Do not reset freshobj_idx to zero; this was done in sweep, which may have added entries into it. (gc_finalize): New function. (gc_late_init): Register gc_finalize as intrinsic function finalize. * txr.1: Documented finalize. * HACKING: Documented finalization, described the additional meaning of the -1 generation, and added a section on debugging with break_obj and breakpt.
* * HACKING: New section Type Safety.Kaz Kylheku2014-10-171-35/+81
| | | | | | Table of contents regenerated with line numbers. * HACKING-toc.txr: New file.
* * HACKING: Updating generational GC notes in light of changes.Kaz Kylheku2014-03-291-34/+43
|
* Fix a bug arising from putting generation 1 objects into theKaz Kylheku2014-03-271-15/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | checkobj array (via the mut macro that expands to gc_mutated). The garbage collector assumes that checkobj has only generation 0 objects, which all exist in the freshobj array, which is subject to a sweep. So gen 1 objects in checkobj are never cleaned up properly: they do not have their REACHABLE flag reset, or their generation restored to 1. To fix this, a new array for these objects is introduced separate from checkobj. * gc.c (MUTOBJ_VEC_SIZE): New preprocessor symbol. (mutobj, mutobj_idx): New static array and integer. (mark_obj): Check for REACHABLE flag before checking the full_gc flag and generation, since those cost additional memory accesses. (mark): Mark the objects in the new mutobj array. (sweep): Sweep the objects in the mutobj array. (gc): Reset mutobx_idx to zero after gc. (gc_set): Rearrange logic. In the case that the checkobj array is full and a gc is done to make room, there is no point in adding to the array: the gc pass moves all babies to generation 1, so the object that was passed into the function is no longer a baby. (gc_mutated): Rewrite in terms of mutobj rather than checkobj, fixing the bug. * HACKING: Improved documentation of GC. Describe mut macro and mutobj array.
* Fixed occurrences of "garbage allocator". :)Kaz Kylheku2013-12-101-4/+5
|
* Spellcheck.Kaz Kylheku2013-12-051-17/+17
|
* * HACKING: Added notes on generational garbage collection.Kaz Kylheku2012-04-141-0/+110
|
* * configure: Switch from _POSIX_C_SOURCE=2 to _XOPEN_SOURCE.Kaz Kylheku2012-04-101-4/+4
| | | | | | | | We will be relying on the gettimeofday function which only came into POSIX in 2001, but was in Unix long before then. * HACKING: Replace notes about -D_POSIX_C_SOURCE which are not true any more.
* * HACKING: Added note about register save areas, which can contributeKaz Kylheku2012-02-121-1/+3
| | | | to spurious retention.
* * HACKING: Grammar fixes. Expanded on lazy strings a little bit.Kaz Kylheku2011-10-291-35/+68
| | | | | Added something about mem_t *, and a few extra words here and there, including a blurb about a Valgrind debugging caveat.
* Fix section numbering mixup.Kaz Kylheku2011-10-101-2/+2
|
* * HACKING: Documented portability hacks for narrow wchar_t.Kaz Kylheku2011-10-101-1/+59
|
* * HACKING: Formatting.Kaz Kylheku2011-10-081-8/+10
|
* HACKING: Clarified that --vg-debug is also needed to turn on onKaz Kylheku2011-10-011-2/+4
| | | | the Valgrind support at run-time, in addition to building it in.
* * HACKING: Updated with debugging hints.Kaz Kylheku2011-09-301-4/+210
|
* Spelling.Kaz Kylheku2011-09-201-2/+2
|
* This should be under version control.Kaz Kylheku2011-09-011-0/+516