]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/port.h
xnu-1456.1.26.tar.gz
[apple/xnu.git] / osfmk / mach / port.h
index 5e11865401a19cfff4298ecad0c04d42eb2d7a4a..9db876f17ad2827ae6324b76fc2aea45a0cca43e 100644 (file)
@@ -140,13 +140,21 @@ struct ipc_port ;
 
 typedef struct ipc_port                *ipc_port_t;
 
-#define IPC_PORT_NULL          ((ipc_port_t) 0)
-#define IPC_PORT_DEAD          ((ipc_port_t)~0)
+#define IPC_PORT_NULL          ((ipc_port_t) 0UL)
+#define IPC_PORT_DEAD          ((ipc_port_t)~0UL)
 #define IPC_PORT_VALID(port) \
        ((port) != IPC_PORT_NULL && (port) != IPC_PORT_DEAD)
 
 typedef ipc_port_t             mach_port_t;
 
+/*
+ * Since the 32-bit and 64-bit representations of ~0 are different,
+ * explicitly handle MACH_PORT_DEAD
+ */
+
+#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x))
+#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x))
+
 #else  /* KERNEL */
 
 /*