port-rights.lisp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. (defcfun ("mach_port_mod_refs" %mach-port-mod-refs)
  2. err
  3. (task ipc-space)
  4. (port-name port)
  5. (right port-right)
  6. (delta port-delta))
  7. (defun port-mod-refs! (port right
  8. &optional
  9. (delta -1) ; drop 1 ref by default
  10. (task (task-self)))
  11. "Modify the specified port right's count of user references."
  12. (%mach-port-mod-refs task port right delta))
  13. (defcfun ("mach_port_get_refs" %mach-port-get-refs)
  14. err
  15. (task ipc-space)
  16. (name port)
  17. (right port-right)
  18. (refs #:pointer))
  19. (defun port-get-refs (port-name right &optional (task (task-self)))
  20. "Get number of references of a specific right in a port name."
  21. (with-foreign-pointer (refs (foreign-type-size 'port-urefs))
  22. (let ((return-code
  23. (%mach-port-get-refs task
  24. port-name
  25. right
  26. refs)))
  27. (select-error return-code
  28. (mem-ref refs 'port-urefs)))))