| 1 | /* sys/rmutex.h (emx+gcc) */
|
|---|
| 2 |
|
|---|
| 3 | /* _rmutex semaphores are registered _fmutex semaphores. They are a
|
|---|
| 4 | bit bigger than _fmutex metaphores but they are inherited by child
|
|---|
| 5 | processes created with fork(). Shared _rmutex semaphores behave
|
|---|
| 6 | like _fmutex semaphores, ie, they are not registered and therefore
|
|---|
| 7 | not inherited by child processes created with fork(). (As malloc()
|
|---|
| 8 | uses _rmutex semaphores, we have to support shared semaphores
|
|---|
| 9 | anyway.) */
|
|---|
| 10 |
|
|---|
| 11 | /* This header requires <sys/builtin.h> and <sys/fmutex.h>. */
|
|---|
| 12 |
|
|---|
| 13 | #ifndef _SYS_RMUTEX_H
|
|---|
| 14 | #define _SYS_RMUTEX_H
|
|---|
| 15 |
|
|---|
| 16 | #if defined (__cplusplus)
|
|---|
| 17 | extern "C" {
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | /* See also <emx/io.h> and /emx/test/internal.c. */
|
|---|
| 21 | typedef struct __rmutex
|
|---|
| 22 | {
|
|---|
| 23 | struct __rmutex *next;
|
|---|
| 24 | struct __rmutex *prev;
|
|---|
| 25 | _fmutex fm;
|
|---|
| 26 | unsigned char flags;
|
|---|
| 27 | unsigned short count;
|
|---|
| 28 | } _rmutex;
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 | static __inline__ unsigned _rmutex_request (_rmutex *sem, unsigned flags)
|
|---|
| 32 | {
|
|---|
| 33 | return _fmutex_request (&sem->fm, flags);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | static __inline__ unsigned _rmutex_release (_rmutex *sem)
|
|---|
| 38 | {
|
|---|
| 39 | return _fmutex_release (&sem->fm);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | static __inline__ int _rmutex_available (_rmutex *sem)
|
|---|
| 44 | {
|
|---|
| 45 | return _fmutex_available (&sem->fm);
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | unsigned _rmutex_close (_rmutex *);
|
|---|
| 50 | unsigned _rmutex_create (_rmutex *, unsigned);
|
|---|
| 51 | unsigned _rmutex_open (_rmutex *);
|
|---|
| 52 | void _rmutex_dummy (_rmutex *);
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | static __inline__ void _rmutex_checked_release (_rmutex *sem)
|
|---|
| 56 | {
|
|---|
| 57 | _fmutex_checked_release (&sem->fm);
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | static __inline__ void _rmutex_checked_request (_rmutex *sem, unsigned flags)
|
|---|
| 62 | {
|
|---|
| 63 | _fmutex_checked_request (&sem->fm, flags);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | void _rmutex_checked_close (_rmutex *);
|
|---|
| 68 | void _rmutex_checked_create (_rmutex *, unsigned);
|
|---|
| 69 | void _rmutex_checked_open (_rmutex *);
|
|---|
| 70 |
|
|---|
| 71 | #if defined (__cplusplus)
|
|---|
| 72 | }
|
|---|
| 73 | #endif
|
|---|
| 74 |
|
|---|
| 75 | #endif /* not _SYS_RMUTEX_H */
|
|---|