From 0ca3142d069da5ce44d0bd4fce4b3a604beb1d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Mon, 16 Mar 2026 21:05:09 +0100 Subject: [PATCH] lwp: add smoke test --- lwp-smoke.lsp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 lwp-smoke.lsp diff --git a/lwp-smoke.lsp b/lwp-smoke.lsp new file mode 100644 index 000000000..5ac1e1380 --- /dev/null +++ b/lwp-smoke.lsp @@ -0,0 +1,50 @@ +(in-package "CL-USER") + +(format t "Hello world!~%") + +(format t "--- Creating accessors and entries~%") +(defun thread-continuation (o) + (check-type o si::thread) + (ffi:c-inline (o) (:object) + :object "#0->thread.cont" :one-liner t :side-effects nil)) + +(defun thread-function (o) + (check-type o si::thread) + (ffi:c-inline (o) (:object) + :object "#0->thread.fun" :one-liner t :side-effects nil)) + +(defun yield (thread) + (si:pass (thread-continuation thread))) + +(defun example-function (this-thread) + (format t "Example function!~%") + (yield this-thread) + (format t "Example function resumed!~%") + (yield this-thread)) + +(format t "--- Disabling Garbage Collector~%") +(let ((module (find "BDW-GC" (si::list-modules) :test #'string= + :key #'si::module-name))) + (ext:gc t) + (format t "disabling ~a~%" module) + (si::module-disable module)) + +(format t "-- Creating a continuation!~%") +(defparameter *cont* (si:make-continuation (si:make-thread #'example-function))) + +(format t "Running a continuation!~%") +(si:pass *cont*) +(format t "Continuation returned; again!~%") +(si:pass *cont*) +(format t "Continuation returned; OK!~%") + +(dotimes (v 3) (terpri)) + +(format t "Creating a lot of these, repeat 1024~%") +(dotimes (v (* 32 1024)) + (let ((cont (si:make-continuation (si:make-thread #'example-function)))) + (format t "run ~a ~a~%" v cont) + (si:pass cont) + (format t "res ~a ~a~%" v cont) + (si:pass cont) + (format t "qed ~a ~a~%" v cont)) )