source: vendor/emx/current/include/sys/smutex.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.0 KB
Line 
1/* sys/smutex.h (emx+gcc) */
2
3/* Simple mutex semaphores. These semaphores need not be created and
4 destroyed, _smutex objects just have to be initialized to zero.
5 _smutex semaphores are implemented with looping and DosSleep.
6 Therefore, they should be used only if a collision is very
7 unlikely, for instance, during initializing. In all other cases,
8 _fmutex or HMTX semaphores should be used. */
9
10/* This header requires <sys/builtin.h>. */
11
12#ifndef _SYS_SMUTEX_H
13#define _SYS_SMUTEX_H
14
15#if defined (__cplusplus)
16extern "C" {
17#endif
18
19typedef signed char _smutex;
20
21
22void __smutex_request_internal (__volatile__ _smutex *);
23
24
25static __inline__ void _smutex_request (__volatile__ _smutex *sem)
26{
27 if (__cxchg (sem, 1) != 0)
28 __smutex_request_internal (sem);
29}
30
31
32static __inline__ void _smutex_release (__volatile__ _smutex *sem)
33{
34 *sem = 0;
35}
36
37
38static __inline__ int _smutex_available (__volatile__ _smutex *sem)
39{
40 return *sem == 0;
41}
42
43
44#if defined (__cplusplus)
45}
46#endif
47
48#endif /* not _SYS_SMUTEX_H */
Note: See TracBrowser for help on using the repository browser.