types.scm 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. (define-module (mach types)
  2. #:use-module (mach ffi)
  3. #:use-module (ice-9 format))
  4. ;;
  5. ;; In this file we put foreign types that are so
  6. ;; simple that they don't deserve a single file.
  7. ;;
  8. ;; A port name.
  9. ;;
  10. ;; In practice, this often refers to a port within the
  11. ;; local task @code{(task-self)}, but in principle it could refer
  12. ;; to a port within some other task (e.g., when using
  13. ;; @code{port-extract-right!} or @code{port-insert-right!}). Context
  14. ;; is required!
  15. ;;
  16. ;; This seems to be the same situation as with *nix file descriptors.
  17. (define-public ffi:mach-port ffi:unsigned-int)
  18. (define-public %wrap-mach-port identity)
  19. (define-public %unwrap-mach-port identity)
  20. (define-syntax-rule (define-port-type ffi:t %wrap-t %unwrap-t)
  21. (begin
  22. (define-public ffi:t ffi:mach-port)
  23. (define-public %wrap-t %wrap-mach-port)
  24. (define-public %unwrap-t %unwrap-mach-port)))
  25. (define-port-type ffi:task %wrap-task %unwrap-task)
  26. (define-port-type ffi:ipc-space %wrap-ipc-space %unwrap-ipc-space)
  27. (define-port-type ffi:vm-task %wrap-vm-task %unwrap-vm-task)
  28. #;(defctype port-mscount :unsigned-int "mach_port_msgcount_t type")
  29. #;
  30. (defctype msg-seqno :unsigned-int "mach_msg_seqno_t type")
  31. #;
  32. (defctype port-delta :int "mach_port_delta_t type")
  33. #;
  34. (defctype msg-type-number :unsigned-int "mach_msg_type_number_t type")
  35. ;; For addresses that might be outside our own address space.
  36. ;; If we know we're working in our own address space, use ffi:pointer
  37. ;; instead.
  38. (define-public vm-address ffi:unsigned-int)
  39. ;; Length of a virtual memory region.
  40. (define-public vm-size ffi:unsigned-int)
  41. (define-public vm-offset ffi:unsigned-int)
  42. #;
  43. (defctype msg-timeout :unsigned-int "mach_msg_timeout_t type")
  44. #;
  45. (defctype port-urefs :unsigned-int "mach_port_urefs_t type")
  46. #;
  47. (defctype port-msgcount :unsigned-int "mach_port_msgcount_t type")
  48. #;
  49. (defctype port-rights :unsigned-int "mach_port_rights_t type")
  50. ;; XXX what's the difference with ffi:msg-seqno?
  51. (define-public ffi:port-seqno ffi:unsigned-int)
  52. ;; Message size.
  53. (define-public ffi:msg-size ffi:unsigned-int)
  54. ;; Message bits. (XXX where are they defined?)
  55. (define-public ffi:msg-bits ffi:unsigned-int)
  56. ;; Message ID. (XXX what does this mean exactly?)
  57. (define-public ffi:msg-id ffi:int)