]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/ipc/ipc_mqueue.h
xnu-3789.70.16.tar.gz
[apple/xnu.git] / osfmk / ipc / ipc_mqueue.h
index 2a83023e83289d83b659c64877007b960d7afae7..af0a534a4027ded7a31a38a21154c694f5e54d4f 100644 (file)
@@ -93,10 +93,10 @@ typedef struct ipc_mqueue {
 #if MACH_FLIPC
                        struct flipc_port       *fport; // Null for local port, or ptr to flipc port
 #endif
-               } __attribute__((__packed__)) port;
+               } port;
                struct {
                        struct waitq_set        setq;
-               } __attribute__((__packed__)) pset;
+               } pset;
        } data;
        struct klist imq_klist;
 } *ipc_mqueue_t;
@@ -132,6 +132,23 @@ typedef struct ipc_mqueue {
 #define imq_held(mq)           waitq_held(&(mq)->imq_wait_queue)
 #define imq_valid(mq)          waitq_valid(&(mq)->imq_wait_queue)
 
+/*
+ * Get an ipc_mqueue pointer from a waitq pointer. These are traditionally the
+ * same pointer, but this conversion makes no assumptions on union structure
+ * member positions - it should allow the waitq to move around in either the
+ * port-set mqueue or the port mqueue independently.
+ */
+#define        imq_from_waitq(waitq)   (waitq_is_set(waitq) ? \
+                                       ((struct ipc_mqueue *)((void *)( \
+                                               (uintptr_t)(waitq) - \
+                                               __offsetof(struct ipc_mqueue, imq_wait_queue)) \
+                                       )) : \
+                                       ((struct ipc_mqueue *)((void *)( \
+                                               (uintptr_t)(waitq) - \
+                                               __offsetof(struct ipc_mqueue, imq_set_queue)) \
+                                       )) \
+                                )
+
 extern void imq_reserve_and_lock(ipc_mqueue_t mq,
                                 uint64_t *reserved_prepost);