summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-12-17 22:52:00 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-12-17 22:52:00 -0800
commit0dd3cd6260ff9ddcd678f2e58ddf5ab506fd636c (patch)
tree4348a650c990ac40078471cabce6e1cc9befe234
parent1325adcc2219a2052bb646deea2080f1d76364d9 (diff)
downloadtxr-0dd3cd6260ff9ddcd678f2e58ddf5ab506fd636c.tar.gz
txr-0dd3cd6260ff9ddcd678f2e58ddf5ab506fd636c.tar.bz2
txr-0dd3cd6260ff9ddcd678f2e58ddf5ab506fd636c.zip
Move jmp-related stuff from signal.h to unwind.h.
* 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.
-rw-r--r--gc.c1
-rw-r--r--signal.h170
-rw-r--r--unwind.h176
3 files changed, 177 insertions, 170 deletions
diff --git a/gc.c b/gc.c
index 3460fb27..2d86c830 100644
--- a/gc.c
+++ b/gc.c
@@ -42,6 +42,7 @@
#include "eval.h"
#include "gc.h"
#include "signal.h"
+#include "unwind.h"
#define PROT_STACK_SIZE 1024
#define HEAP_SIZE 16384
diff --git a/signal.h b/signal.h
index 863bbf68..2b998297 100644
--- a/signal.h
+++ b/signal.h
@@ -25,146 +25,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#if __i386__
-
-struct jmp {
- unsigned eip;
- unsigned esp;
- unsigned ebp;
- unsigned ebx;
- unsigned esi;
- unsigned edi;
-};
-
-#elif __x86_64__
-
-struct jmp {
- unsigned long rip;
- unsigned long rsp;
- unsigned long rbp;
- unsigned long rbx;
- unsigned long r12;
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
-#if __CYGWIN__
- unsigned long rsi;
- unsigned long rdi;
-#endif
-};
-
-#elif __arm__ && !__thumb__
-
-struct jmp {
- unsigned long r4;
- unsigned long r5;
- unsigned long r6;
- unsigned long r7;
- unsigned long r8;
- unsigned long r9;
- unsigned long r10;
- unsigned long fp;
- unsigned long sp;
- unsigned long lr;
-};
-
-#elif __arm__ && __thumb__
-
-struct jmp {
- unsigned long lr;
- unsigned long r4;
- unsigned long r5;
- unsigned long r6;
- unsigned long r7;
- unsigned long r8;
- unsigned long r9;
- unsigned long r10;
- unsigned long fp;
- unsigned long sp;
-};
-
-#elif __PPC64__
-
-struct jmp {
- unsigned long r1;
- unsigned long r2;
- unsigned long r11;
- unsigned long r12;
- unsigned long r13;
- unsigned long r14;
- unsigned long r15;
- unsigned long r16;
- unsigned long r17;
- unsigned long r18;
- unsigned long r19;
- unsigned long r20;
- unsigned long r21;
- unsigned long r22;
- unsigned long r23;
- unsigned long r24;
- unsigned long r25;
- unsigned long r26;
- unsigned long r27;
- unsigned long r28;
- unsigned long r29;
- unsigned long r30;
- unsigned long r31;
-};
-
-#elif __aarch64__
-
-struct jmp {
- unsigned long x19;
- unsigned long x20;
- unsigned long x21;
- unsigned long x22;
- unsigned long x23;
- unsigned long x24;
- unsigned long x25;
- unsigned long x26;
- unsigned long x27;
- unsigned long x28;
- unsigned long x29;
- unsigned long x30;
- unsigned long d8;
- unsigned long d9;
- unsigned long d10;
- unsigned long d11;
- unsigned long d12;
- unsigned long d13;
- unsigned long d14;
- unsigned long d15;
- unsigned long x16;
-};
-
-/* Jump buffer contains:
- x19-x28, x29(fp), x30(lr), (x31)sp, d8-d15. Other registers are not
- saved. */
-
-#else
-#error port me!
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int jmp_save(struct jmp *);
-void jmp_restore(struct jmp *, int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#if CONFIG_DEBUG_SUPPORT
-#define EJ_DBG_MEMB int ds;
-#else
-#define EJ_DBG_MEMB
-#endif
-
-#define EJ_OPT_MEMB EJ_DBG_MEMB
-
#if HAVE_POSIX_SIGS
typedef struct {
@@ -209,17 +69,6 @@ INLINE val sig_check_fast(void)
return if2(sig_deferred, sig_check());
}
-typedef struct {
- struct jmp jb;
- volatile sig_atomic_t se;
- volatile small_sigset_t blocked;
- volatile val de;
- volatile int gc;
- val **volatile gc_pt;
- EJ_OPT_MEMB
- volatile int rv;
-} extended_jmp_buf;
-
extern volatile sig_atomic_t async_sig_enabled;
#else
@@ -232,29 +81,10 @@ extern volatile sig_atomic_t async_sig_enabled;
#define sig_check_fast() ((void) 0)
-typedef struct {
- struct jmp jb;
- volatile val de;
- volatile int gc;
- val **volatile gc_pt;
- EJ_OPT_MEMB
- volatile int rv;
-} extended_jmp_buf;
-
extern int async_sig_enabled;
#endif
-#define extended_setjmp(EJB) \
- (jmp_save(&(EJB).jb) \
- ? ((EJB).rv) \
- : (extjmp_save(&(EJB)), 0))
-
-#define extended_longjmp(EJB, ARG) \
- ((EJB).rv = (ARG), extjmp_restore(&(EJB)), jmp_restore(&(EJB).jb, 1))
-
-void extjmp_save(extended_jmp_buf *ejb);
-void extjmp_restore(extended_jmp_buf *);
void sig_init(void);
val set_sig_handler(val signo, val lambda);
val get_sig_handler(val signo);
diff --git a/unwind.h b/unwind.h
index 64f21a02..9bea72bb 100644
--- a/unwind.h
+++ b/unwind.h
@@ -25,6 +25,182 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if __i386__
+
+struct jmp {
+ unsigned eip;
+ unsigned esp;
+ unsigned ebp;
+ unsigned ebx;
+ unsigned esi;
+ unsigned edi;
+};
+
+#elif __x86_64__
+
+struct jmp {
+ unsigned long rip;
+ unsigned long rsp;
+ unsigned long rbp;
+ unsigned long rbx;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+#if __CYGWIN__
+ unsigned long rsi;
+ unsigned long rdi;
+#endif
+};
+
+#elif __arm__ && !__thumb__
+
+struct jmp {
+ unsigned long r4;
+ unsigned long r5;
+ unsigned long r6;
+ unsigned long r7;
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long fp;
+ unsigned long sp;
+ unsigned long lr;
+};
+
+#elif __arm__ && __thumb__
+
+struct jmp {
+ unsigned long lr;
+ unsigned long r4;
+ unsigned long r5;
+ unsigned long r6;
+ unsigned long r7;
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long fp;
+ unsigned long sp;
+};
+
+#elif __PPC64__
+
+struct jmp {
+ unsigned long r1;
+ unsigned long r2;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long r16;
+ unsigned long r17;
+ unsigned long r18;
+ unsigned long r19;
+ unsigned long r20;
+ unsigned long r21;
+ unsigned long r22;
+ unsigned long r23;
+ unsigned long r24;
+ unsigned long r25;
+ unsigned long r26;
+ unsigned long r27;
+ unsigned long r28;
+ unsigned long r29;
+ unsigned long r30;
+ unsigned long r31;
+};
+
+#elif __aarch64__
+
+struct jmp {
+ unsigned long x19;
+ unsigned long x20;
+ unsigned long x21;
+ unsigned long x22;
+ unsigned long x23;
+ unsigned long x24;
+ unsigned long x25;
+ unsigned long x26;
+ unsigned long x27;
+ unsigned long x28;
+ unsigned long x29;
+ unsigned long x30;
+ unsigned long d8;
+ unsigned long d9;
+ unsigned long d10;
+ unsigned long d11;
+ unsigned long d12;
+ unsigned long d13;
+ unsigned long d14;
+ unsigned long d15;
+ unsigned long x16;
+};
+
+/* Jump buffer contains:
+ x19-x28, x29(fp), x30(lr), (x31)sp, d8-d15. Other registers are not
+ saved. */
+
+#else
+#error port me!
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int jmp_save(struct jmp *);
+void jmp_restore(struct jmp *, int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#if CONFIG_DEBUG_SUPPORT
+#define EJ_DBG_MEMB int ds;
+#else
+#define EJ_DBG_MEMB
+#endif
+
+#define EJ_OPT_MEMB EJ_DBG_MEMB
+
+#if HAVE_POSIX_SIGS
+
+typedef struct {
+ struct jmp jb;
+ volatile sig_atomic_t se;
+ volatile small_sigset_t blocked;
+ volatile val de;
+ volatile int gc;
+ val **volatile gc_pt;
+ EJ_OPT_MEMB
+ volatile int rv;
+} extended_jmp_buf;
+
+#else
+
+typedef struct {
+ struct jmp jb;
+ volatile val de;
+ volatile int gc;
+ val **volatile gc_pt;
+ EJ_OPT_MEMB
+ volatile int rv;
+} extended_jmp_buf;
+
+#endif
+
+#define extended_setjmp(EJB) \
+ (jmp_save(&(EJB).jb) \
+ ? ((EJB).rv) \
+ : (extjmp_save(&(EJB)), 0))
+
+#define extended_longjmp(EJB, ARG) \
+ ((EJB).rv = (ARG), extjmp_restore(&(EJB)), jmp_restore(&(EJB).jb, 1))
+
+void extjmp_save(extended_jmp_buf *ejb);
+void extjmp_restore(extended_jmp_buf *);
+
typedef union uw_frame uw_frame_t;
typedef enum uw_frtype {
UW_BLOCK, UW_CAPTURED_BLOCK, UW_MENV, UW_CATCH, UW_HANDLE,