msg-server.lisp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (in-package :mach)
  2. (defcfun ("mach_msg_server_timeout" %mach-msg-server-timeout)
  3. err
  4. (demuxer :pointer)
  5. (max-size msg-size)
  6. (port-set port)
  7. (options msg-option)
  8. (timeout msg-timeout))
  9. (defmacro msg-server-timeout (demuxer port-set &optional timeout max-size)
  10. "Receive RPC request messages on port-set and pass them to function demuxer with a timeout."
  11. (let ((callback-name (first (generate-temporaries '(a)))))
  12. #`(progn
  13. (defcallback #,callback-name :boolean ((in :pointer) (out :pointer))
  14. (funcall #,demuxer in out))
  15. (let ((timeout-val ,(if (null timeout) 0 timeout)))
  16. (%mach-msg-server-timeout (callback #,callback-name)
  17. #,(if (null max-size) 0 max-size)
  18. #,port-set
  19. (if (plusp timeout-val) '(:rcv-timeout) '())
  20. timeout-val)))))
  21. (defcfun ("mach_msg_server" %mach-msg-server)
  22. err
  23. (demuxer :pointer)
  24. (max-size msg-size)
  25. (rcv-name port))
  26. (defmacro msg-server (demuxer port-set &optional max-size)
  27. "Receive RPC request messages on port-set and pass them to function demuxer."
  28. (let ((callback-name (first (generate-temporaries '(a)))))
  29. #`(progn
  30. (defcallback #,callback-name :boolean ((in :pointer) (out :pointer))
  31. (funcall #,demuxer in out))
  32. (%mach-msg-server (callback #,callback-name)
  33. #,(if (null max-size)
  34. 0
  35. max-size)
  36. #,port-set))))