about summary refs log tree commit diff
path: root/sysdeps/hurd/include/hurd/port.h
blob: e8c4b713381fdd5c4452266364ad709fff9977e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef	_HURD_PORT_H
#include_next <hurd/port.h>

#ifndef _ISOMAC
#include <libc-lock.h>

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;					      \
     mach_port_t port;							      \
     __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
libc_hidden_def (_hurd_port_locked_get)
libc_hidden_def (_hurd_port_locked_set)
#endif
#endif
#endif