diff options
Diffstat (limited to 'sysdeps/hurd/include/hurd/port.h')
-rw-r--r-- | sysdeps/hurd/include/hurd/port.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sysdeps/hurd/include/hurd/port.h b/sysdeps/hurd/include/hurd/port.h index ca1d2d111a..7828dd6fc1 100644 --- a/sysdeps/hurd/include/hurd/port.h +++ b/sysdeps/hurd/include/hurd/port.h @@ -1,6 +1,30 @@ #ifndef _HURD_PORT_H #include_next <hurd/port.h> + #ifndef _ISOMAC +struct _hurd_port_use_data + { + struct hurd_port *p; + struct hurd_userlink link; + mach_port_t port; + }; + +extern void _hurd_port_use_cleanup (void *arg); + +/* Like HURD_PORT_USE, but cleans fd on cancel. */ +#define HURD_PORT_USE_CANCEL(portcell, expr) \ + ({ struct _hurd_port_use_data __d; \ + __typeof(expr) __result; \ + void *__crit; \ + __d.p = (portcell); \ + __crit = _hurd_critical_section_lock (); \ + __d.port = port = _hurd_port_get (__d.p, &__d.link); \ + __libc_cleanup_push (_hurd_port_use_cleanup, &__d); \ + _hurd_critical_section_unlock (__crit); \ + __result = (expr); \ + __libc_cleanup_pop (1); \ + __result; }) + libc_hidden_proto (_hurd_port_locked_get) libc_hidden_proto (_hurd_port_locked_set) #ifdef _HURD_PORT_H_HIDDEN_DEF |