summaryrefslogtreecommitdiff
path: root/libports/ports.h
diff options
context:
space:
mode:
Diffstat (limited to 'libports/ports.h')
-rw-r--r--libports/ports.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/libports/ports.h b/libports/ports.h
index 652edb88..a625b479 100644
--- a/libports/ports.h
+++ b/libports/ports.h
@@ -29,6 +29,12 @@
#include <pthread.h>
#include <refcount.h>
+#ifdef PORTS_DEFINE_EI
+#define PORTS_EI
+#else
+#define PORTS_EI __extern_inline
+#endif
+
/* These are global values for common flags used in the various structures.
Not all of these are meaningful in all flag fields. */
#define PORTS_INHIBITED 0x0100 /* block RPC's */
@@ -234,6 +240,53 @@ mach_port_t ports_get_send_right (void *port);
void *ports_lookup_port (struct port_bucket *bucket,
mach_port_t port, struct port_class *class);
+/* Like ports_lookup_port, but uses PAYLOAD to look up the object. If
+ this function is used, PAYLOAD must be a pointer to the port
+ structure. */
+extern void *ports_lookup_payload (struct port_bucket *bucket,
+ unsigned long payload,
+ struct port_class *class);
+
+/* This returns the ports name. This function can be used as
+ intranpayload function turning payloads back into port names. If
+ this function is used, PAYLOAD must be a pointer to the port
+ structure. */
+extern mach_port_t ports_payload_get_name (unsigned int payload);
+
+#if defined(__USE_EXTERN_INLINES) || defined(PORTS_DEFINE_EI)
+
+PORTS_EI void *
+ports_lookup_payload (struct port_bucket *bucket,
+ unsigned long payload,
+ struct port_class *class)
+{
+ struct port_info *pi = (struct port_info *) payload;
+
+ if (pi && bucket && pi->bucket != bucket)
+ pi = NULL;
+
+ if (pi && class && pi->class != class)
+ pi = NULL;
+
+ if (pi)
+ refcounts_unsafe_ref (&pi->refcounts, NULL);
+
+ return pi;
+}
+
+PORTS_EI mach_port_t
+ports_payload_get_name (unsigned int payload)
+{
+ struct port_info *pi = (struct port_info *) payload;
+
+ if (pi)
+ return pi->port_right;
+
+ return MACH_PORT_NULL;
+}
+
+#endif /* Use extern inlines. */
+
/* Allocate another reference to PORT. */
void ports_port_ref (void *port);