port-receive-rights.lisp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. (defcfun ("mach_port_get_receive_status" %mach-port-get-receive-status)
  2. err
  3. (task ipc-space)
  4. (name port)
  5. (status #:pointer))
  6. (defun port-get-receive-status (name &optional (task (task-self)))
  7. "Returns the current status of the specified receive right."
  8. (with-foreign-pointer (status (foreign-type-size #:pointer))
  9. (let ((return-code
  10. (%mach-port-get-receive-status task
  11. name
  12. status)))
  13. (select-error return-code
  14. (make-port-status status)))))
  15. (defcfun ("mach_port_set_mscount" %mach-port-set-mscount)
  16. err
  17. (task ipc-space)
  18. (name port)
  19. (mscount port-mscount))
  20. (defun port-set-mscount! (port count &optional (task (task-self)))
  21. (assert (fixnum? count))
  22. (%mach-port-set-mscount task
  23. port
  24. count))
  25. (defcfun ("mach_port_set_qlimit" %mach-port-set-qlimit!)
  26. err
  27. (task ipc-space)
  28. (name port)
  29. (qlimit port-msgcount))
  30. (defconstant +qlimit-default+ 5 "Queue default size.")
  31. (defconstant +qlimit-min+ 0 "Queue minimum value.")
  32. (defconstant +qlimit-max+ 16 "Queue maximum size.")
  33. (defun port-set-qlimit! (port &optional (limit +qlimit-default+) (task (task-self)))
  34. "Changes the queue limit task's receive right named name to qlimit."
  35. (assert (exact-integer? limit))
  36. (assert (and (>= limit +qlimit-min+) (<= limit +qlimit-max+)))
  37. (%mach-port-set-qlimit! task port limit))
  38. (defcfun ("mach_port_set_seqno" %mach-port-set-seqno!)
  39. err
  40. (task ipc-space)
  41. (name port)
  42. (seqno port-seqno))
  43. (defun port-set-seqno! (port seqno &optional (task (task-self)))
  44. "Changes the sequence number task's receive right named port to seqno."
  45. (assert (exact-integer? seqno))
  46. (assert (fixnum? seqno))
  47. (%mach-port-set-seqno! task port seqno))