port-sets.lisp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (in-package :mach)
  2. (defcfun ("mach_port_get_set_status" %mach-port-get-set-status)
  3. err
  4. (task ipc-space)
  5. (name port)
  6. (members :pointer)
  7. (count :pointer))
  8. (defun port-get-set-status (port &optional (task (task-self)))
  9. "Returns the members of a port set."
  10. (with-foreign-pointer (members (foreign-type-size :pointer))
  11. (with-foreign-pointer (count (foreign-type-size 'msg-type-number))
  12. (let ((return-code
  13. (%mach-port-get-set-status task
  14. port
  15. members
  16. count)))
  17. (select-error return-code
  18. (with-cleanup (munmap (mem-ref members :pointer)
  19. (* (mem-ref count 'msg-type-number)
  20. (foreign-type-size 'port)))
  21. (%foreign-port-array-to-list
  22. (mem-ref members :pointer)
  23. (mem-ref count 'msg-type-number))))))))
  24. (defun %foreign-port-array-to-list (ptr cnt)
  25. "Converts a port array to a list."
  26. (loop for i from 0 below cnt
  27. collect (mem-aref ptr 'port i)))
  28. (defcfun ("mach_port_move_member" %mach-port-move-member)
  29. err
  30. (task ipc-space)
  31. (before port)
  32. (after port))
  33. (defun port-move-member! (before after &optional (task (task-self)))
  34. "Move the specified receive right into or out of the specified port set."
  35. (%mach-port-move-member task before after))