port-creation.lisp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ;;
  2. ;; This file contains functions to deal with port creation.
  3. ;;
  4. (defcfun ("mach_port_allocate" %mach-port-allocate)
  5. err
  6. (task ipc-space)
  7. (right port-right)
  8. (ret-port port-pointer))
  9. (defun port-allocate (right &optional (task (task-self)))
  10. "Creates a new right in the specified task."
  11. (with-foreign-object (port-name 'port)
  12. (let ((return-code
  13. (%mach-port-allocate task right port-name)))
  14. (select-error return-code (mem-ref port-name 'port)))))
  15. (defcfun ("mach_reply_port" %mach-reply-port) port)
  16. (defun reply-port ()
  17. "Creates a reply port in the calling task."
  18. (%mach-reply-port))
  19. (defcfun ("mach_port_allocate_name" %mach-port-allocate-name)
  20. err
  21. (task ipc-space)
  22. (right-type port-right)
  23. (name port))
  24. (defun port-allocate-name (right-type port-name &optional (task (task-self)))
  25. "Creates a new right in the specified task, with a specified name for the new right. name must not already be in use for some right, and it can't be the reserved values nil or :dead. On success the port-name is returned."
  26. (let ((return-code
  27. (%mach-port-allocate-name task right-type port-name)))
  28. (select-error return-code
  29. port-name)))