Skip to content

Commit

Permalink
SBCL: implement THREAD-ATTRIBUTES only for Linux
Browse files Browse the repository at this point in the history
SBCL defines SB-THREAD:THREAD-OS-TID only for Linux, and accessing it
from MacOS or Windows will result in a symbol not found error:

    ; caught ERROR:
    ;   READ error during COMPILE-FILE:
    ;
    ;     Symbol "THREAD-OS-TID" not found in the SB-THREAD package.
    ;
    ;       Line: 1716, Column: 40, File-Position: 69208
    ;
    ;       Stream: #<SB-INT:FORM-TRACKING-STREAM for "file /Users/matteolandi/my-env/opt/slime/swank/sbcl.lisp" {1001ECFC23}>
    ;;
    ;; Error compiling /Users/matteolandi/my-env/opt/slime/swank/sbcl.lisp:
    ;;   COMPILE-FILE returned NIL.
    ;;
  • Loading branch information
iamFIREcracker authored and phmarek committed Sep 11, 2023
1 parent addc589 commit 2760bfc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion swank/sbcl.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,10 +1720,10 @@ stack."
;; sometimes the name is not a string (e.g. NIL)
(princ-to-string (sb-thread:thread-name thread)))

#+linux
(defimplementation thread-attributes (thread)
(let* ((tid (sb-thread:thread-os-tid thread))
(cpu-time
#+linux
(ignore-errors
(with-open-file (s (format nil "/proc/self/task/~d/schedstat" tid))
(* (parse-integer (read-line s nil nil) :junk-allowed t)
Expand Down

0 comments on commit 2760bfc

Please sign in to comment.