diff options
Diffstat (limited to 'hurd/hurd/port.h')
-rw-r--r-- | hurd/hurd/port.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/hurd/hurd/port.h b/hurd/hurd/port.h index 4fea1aa4d2..8afee90e29 100644 --- a/hurd/hurd/port.h +++ b/hurd/hurd/port.h @@ -60,6 +60,10 @@ struct hurd_port /* Initialize *PORT to INIT. */ +void _hurd_port_init (struct hurd_port *port, mach_port_t init); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE void _hurd_port_init (struct hurd_port *port, mach_port_t init) { @@ -67,6 +71,8 @@ _hurd_port_init (struct hurd_port *port, mach_port_t init) port->users = NULL; port->port = init; } +# endif +#endif /* Cleanup function for non-local exits. */ @@ -75,6 +81,12 @@ extern void _hurd_port_cleanup (void *, jmp_buf, int); /* Get a reference to *PORT, which is locked. Pass return value and LINK to _hurd_port_free when done. */ +mach_port_t +_hurd_port_locked_get (struct hurd_port *port, + struct hurd_userlink *link); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE mach_port_t _hurd_port_locked_get (struct hurd_port *port, struct hurd_userlink *link) @@ -90,9 +102,17 @@ _hurd_port_locked_get (struct hurd_port *port, __spin_unlock (&port->lock); return result; } +# endif +#endif /* Same, but locks PORT first. */ +mach_port_t +_hurd_port_get (struct hurd_port *port, + struct hurd_userlink *link); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE mach_port_t _hurd_port_get (struct hurd_port *port, struct hurd_userlink *link) @@ -104,10 +124,19 @@ _hurd_port_get (struct hurd_port *port, HURD_CRITICAL_END; return result; } +# endif +#endif /* Free a reference gotten with `USED_PORT = _hurd_port_get (PORT, LINK);' */ +void +_hurd_port_free (struct hurd_port *port, + struct hurd_userlink *link, + mach_port_t used_port); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE void _hurd_port_free (struct hurd_port *port, struct hurd_userlink *link, @@ -127,11 +156,17 @@ _hurd_port_free (struct hurd_port *port, if (dealloc) __mach_port_deallocate (__mach_task_self (), used_port); } +# endif +#endif /* Set *PORT's port to NEWPORT. NEWPORT's reference is consumed by PORT->port. PORT->lock is locked. */ +void _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE void _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport) { @@ -142,9 +177,15 @@ _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport) if (old != MACH_PORT_NULL) __mach_port_deallocate (__mach_task_self (), old); } +# endif +#endif /* Same, but locks PORT first. */ +void _hurd_port_set (struct hurd_port *port, mach_port_t newport); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) _HURD_PORT_H_EXTERN_INLINE void _hurd_port_set (struct hurd_port *port, mach_port_t newport) { @@ -153,6 +194,8 @@ _hurd_port_set (struct hurd_port *port, mach_port_t newport) _hurd_port_locked_set (port, newport); HURD_CRITICAL_END; } +# endif +#endif #endif /* hurd/port.h */ |