notify.lisp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (in-package :hurd)
  2. ;; Types of callbacks for a notify server.
  3. (defcenum notify-routine-code
  4. :do-mach-notify-port-deleted
  5. :do-mach-notify-msg-accepted
  6. :do-mach-notify-port-destroyed
  7. :do-mach-notify-no-senders
  8. :do-mach-notify-send-once
  9. :do-mach-notify-dead-name)
  10. (defcfun ("set_notify_routine" %set-notify-routine) :void
  11. (what notify-routine-code)
  12. (fun :pointer))
  13. (defun set-notify-routine (what fun)
  14. "Sets a function to be run on 'what' events."
  15. (declare (type symbol what))
  16. (%set-notify-routine what fun))
  17. (defsetf notify-routine set-notify-routine)
  18. ;; For debugging purposes
  19. (defcfun ("get_notify_info" %get-notify-info) :void)
  20. (defcfun ("lisp_notify_server" %lisp-notify-server) :boolean
  21. (in :pointer)
  22. (out :pointer))
  23. (defun notify-server (in out)
  24. "Notify server."
  25. (%lisp-notify-server in out))
  26. (defmacro def-notify-interface (name params &body body)
  27. "Defines a new notify callback."
  28. (with-gensyms (result)
  29. `(define-hurd-interface notify-routine ,name ,params
  30. ,(remove-declare body)
  31. (let ((,result (progn ,@body)))
  32. (if (null ,result)
  33. :operation-not-supported
  34. ,result)))))