Skip to content

Commit

Permalink
Try using GCC builtins on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-s committed Jun 24, 2024
1 parent 345170c commit ba8ed32
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/bindings.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,21 @@ defining an error map with a non-nil FATAL-ERROR is undefined.")
:if-exists :supersede)
(format stream "#define ~A~%~%" build-flag)
(format stream "#include ~s~%~%" header-name)
#-win32
(format stream "#include <setjmp.h>~%")
#+win32
(format stream "#include <stdint.h>~%")
(format stream "#include <stdio.h>~%~%")
#-win32
(format stream "__thread jmp_buf fatal_lisp_error_handler;~%~%")
#+win32
(format stream "__thread intptr_t fatal_lisp_error_handler[5];~%~%")
(when *non-static-lossage-handler*
(format stream "extern void (*lossage_handler)(void);~%~%"))
(format stream "extern void ldb_monitor(void);~%~%")
(format stream "int fatal_sbcl_error_occurred = 0;~%~%")
(format stream "void return_from_lisp(void) { fatal_sbcl_error_occurred = 1; fflush(stdout); fflush(stderr); longjmp(fatal_lisp_error_handler, 1); }~%~%")
(format stream "void return_from_lisp(void) { fatal_sbcl_error_occurred = 1; fflush(stdout); fflush(stderr); ~a(fatal_lisp_error_handler, 1); }~%~%"
#-win32 "longjmp" #+win32 "__builtin_longjmp")
(dolist (api (library-apis library))
(write-api-to-source api stream))
(unless omit-init-function
Expand Down
5 changes: 3 additions & 2 deletions src/function.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ cause a normal crash and not return control to this function."
(list "result"))))))
(format nil "~a {~%~a~%}~%"
header
(format nil " if (!setjmp(fatal_lisp_error_handler)) {
(format nil " if (!~a(fatal_lisp_error_handler)) {
~a
} else {
~a
}" call-statement (if (and error-map (error-map-fatal-code error-map))
}" #-win32 "setjmp" #+win32 "__builtin_setjmp"
call-statement (if (and error-map (error-map-fatal-code error-map))
(format nil "return ~d;" (error-map-fatal-code error-map))
(format nil "ldb_monitor();"))))))))

Expand Down

0 comments on commit ba8ed32

Please sign in to comment.