summaryrefslogtreecommitdiffstats
path: root/rand.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-25 11:33:21 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-25 11:33:21 -0700
commit09f172c98f79f52a6e5c0e4ec87918a6e74aaccf (patch)
treebadd09ef01db2cfd8ce77fd6e86ada747319aa8f /rand.c
parent329318ae4f9c180ed68ec484bb5e1acdcb3dec44 (diff)
downloadtxr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.tar.gz
txr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.tar.bz2
txr-09f172c98f79f52a6e5c0e4ec87918a6e74aaccf.zip
Stop using C library setjmp/longjmp.
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.
Diffstat (limited to 'rand.c')
-rw-r--r--rand.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/rand.c b/rand.c
index b127dae0..04c161be 100644
--- a/rand.c
+++ b/rand.c
@@ -31,7 +31,6 @@
#include <limits.h>
#include <stdarg.h>
#include <dirent.h>
-#include <setjmp.h>
#include <wchar.h>
#include <limits.h>
#include <time.h>