ipc_mqueue.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Mach Operating System
  3. * Copyright (c) 1991,1990,1989 Carnegie Mellon University
  4. * All Rights Reserved.
  5. *
  6. * Permission to use, copy, modify and distribute this software and its
  7. * documentation is hereby granted, provided that both the copyright
  8. * notice and this permission notice appear in all copies of the
  9. * software, derivative works or modified versions, and any portions
  10. * thereof, and that both notices appear in supporting documentation.
  11. *
  12. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15. *
  16. * Carnegie Mellon requests users of this software to return to
  17. *
  18. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  19. * School of Computer Science
  20. * Carnegie Mellon University
  21. * Pittsburgh PA 15213-3890
  22. *
  23. * any improvements or extensions that they make and grant Carnegie Mellon
  24. * the rights to redistribute these changes.
  25. */
  26. /*
  27. * File: ipc/ipc_mqueue.h
  28. * Author: Rich Draves
  29. * Date: 1989
  30. *
  31. * Definitions for message queues.
  32. */
  33. #ifndef _IPC_IPC_MQUEUE_H_
  34. #define _IPC_IPC_MQUEUE_H_
  35. #include <mach/message.h>
  36. #include <kern/assert.h>
  37. #include <kern/lock.h>
  38. #include <kern/macros.h>
  39. #include <ipc/ipc_kmsg_queue.h>
  40. #include <ipc/ipc_kmsg.h>
  41. #include <ipc/ipc_thread.h>
  42. typedef struct ipc_mqueue {
  43. decl_simple_lock_data(, imq_lock_data)
  44. struct ipc_kmsg_queue imq_messages;
  45. struct ipc_thread_queue imq_threads;
  46. } *ipc_mqueue_t;
  47. #define IMQ_NULL ((ipc_mqueue_t) 0)
  48. #define imq_lock_init(mq) simple_lock_init(&(mq)->imq_lock_data)
  49. #define imq_lock(mq) simple_lock(&(mq)->imq_lock_data)
  50. #define imq_lock_try(mq) simple_lock_try(&(mq)->imq_lock_data)
  51. #define imq_unlock(mq) simple_unlock(&(mq)->imq_lock_data)
  52. extern void
  53. ipc_mqueue_init(ipc_mqueue_t);
  54. extern void
  55. ipc_mqueue_move(ipc_mqueue_t, ipc_mqueue_t, ipc_port_t);
  56. extern void
  57. ipc_mqueue_changed(ipc_mqueue_t, mach_msg_return_t);
  58. extern mach_msg_return_t
  59. ipc_mqueue_send(ipc_kmsg_t, mach_msg_option_t, mach_msg_timeout_t);
  60. extern mach_msg_return_t
  61. ipc_mqueue_copyin(ipc_space_t, mach_port_t, ipc_mqueue_t *, ipc_object_t *);
  62. #define IMQ_NULL_CONTINUE ((void (*)()) 0)
  63. extern mach_msg_return_t
  64. ipc_mqueue_receive(ipc_mqueue_t, mach_msg_option_t,
  65. mach_msg_size_t, mach_msg_timeout_t,
  66. boolean_t, void* ,
  67. ipc_kmsg_t *, mach_port_seqno_t *);
  68. /*
  69. * extern void
  70. * ipc_mqueue_send_always(ipc_kmsg_t);
  71. *
  72. * Unfortunately, to avoid warnings/lint about unused variables
  73. * when assertions are turned off, we need two versions of this.
  74. */
  75. #include <kern/assert.h>
  76. #if MACH_ASSERT
  77. #define ipc_mqueue_send_always(kmsg) \
  78. MACRO_BEGIN \
  79. mach_msg_return_t mr; \
  80. \
  81. mr = ipc_mqueue_send((kmsg), MACH_SEND_ALWAYS, \
  82. MACH_MSG_TIMEOUT_NONE); \
  83. assert(mr == MACH_MSG_SUCCESS); \
  84. MACRO_END
  85. #else /* MACH_ASSERT */
  86. #define ipc_mqueue_send_always(kmsg) \
  87. MACRO_BEGIN \
  88. (void) ipc_mqueue_send((kmsg), MACH_SEND_ALWAYS, \
  89. MACH_MSG_TIMEOUT_NONE); \
  90. MACRO_END
  91. #endif /* MACH_ASSERT */
  92. #endif /* _IPC_IPC_MQUEUE_H_ */