bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 18/23] libports: add ports_payload_get_name


From: Justus Winter
Subject: [PATCH 18/23] libports: add ports_payload_get_name
Date: Fri, 29 Nov 2013 01:03:46 +0100

This function maps payloads back to port names. This can be used as
intranspayload functions in situations where the server function
expects a port name.

* libports/ports.h: Add function ports_payload_get_name.
---
 libports/ports.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libports/ports.h b/libports/ports.h
index 2f63142..0a7f500 100644
--- a/libports/ports.h
+++ b/libports/ports.h
@@ -238,6 +238,18 @@ void *ports_lookup_port (struct port_bucket *bucket,
 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.  */
+static inline 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;
+}
+
 /* Allocate another reference to PORT. */
 void ports_port_ref (void *port);
 
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]