source: vendor/emx/current/include/sys/fmutex.h

Last change on this file was 18, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.9 KB
Line 
1/* sys/fmutex.h (emx+gcc) */
2
3/* Fast mutex semaphores. */
4
5/* This header requires <sys/builtin.h>. */
6
7#ifndef _SYS_FMUTEX_H
8#define _SYS_FMUTEX_H
9
10#if defined (__cplusplus)
11extern "C" {
12#endif
13
14/* Constants for _fmutex.fs. See _fmutex_available() for ordering. */
15
16#define _FMS_UNINIT 0
17#define _FMS_AVAILABLE 1
18#define _FMS_OWNED_SIMPLE 2
19#define _FMS_OWNED_HARD 3
20
21/* Constants for _fmutex_create() */
22
23#define _FMC_SHARED 0x01
24
25/* Constants for _fmutex_request() */
26
27#define _FMR_IGNINT 0x01
28#define _FMR_NOWAIT 0x02
29
30/* We cannot use __attribute__ ((__packed__)) because G++ does not
31 support this. */
32
33#pragma pack(1)
34typedef struct
35{
36 unsigned long hev; /* HEV */
37 __volatile__ signed char fs; /* Status */
38} _fmutex;
39#pragma pack()
40
41
42unsigned __fmutex_request_internal (_fmutex *, unsigned, signed char);
43unsigned __fmutex_create_internal (_fmutex *, unsigned);
44unsigned __fmutex_release_internal (_fmutex *);
45
46
47static __inline__ unsigned _fmutex_request (_fmutex *sem, unsigned flags)
48{
49 signed char fs;
50
51 fs = __cxchg (&sem->fs, _FMS_OWNED_SIMPLE);
52 if (fs == _FMS_AVAILABLE)
53 return 0;
54 else
55 return __fmutex_request_internal (sem, flags, fs);
56}
57
58
59static __inline__ unsigned _fmutex_release (_fmutex *sem)
60{
61 signed char fs;
62
63 fs = __cxchg (&sem->fs, _FMS_AVAILABLE);
64 if (fs == _FMS_OWNED_HARD)
65 return __fmutex_release_internal (sem);
66 else
67 return 0;
68}
69
70
71static __inline__ int _fmutex_available (_fmutex *sem)
72{
73 return sem->fs <= _FMS_AVAILABLE;
74}
75
76
77unsigned _fmutex_create (_fmutex *, unsigned);
78unsigned _fmutex_open (_fmutex *);
79unsigned _fmutex_close (_fmutex *);
80void _fmutex_dummy (_fmutex *);
81
82void _fmutex_checked_close (_fmutex *);
83void _fmutex_checked_create (_fmutex *, unsigned);
84void _fmutex_checked_open (_fmutex *);
85void _fmutex_checked_release (_fmutex *);
86void _fmutex_checked_request (_fmutex *, unsigned);
87
88#if defined (__cplusplus)
89}
90#endif
91
92#endif /* not _SYS_FMUTEX_H */
Note: See TracBrowser for help on using the repository browser.