source: branches/libc-0.6/src/emx/include/sys/smutex.h

Last change on this file was 2260, checked in by bird, 20 years ago

o Started fixing exec() backend.
o Fixed some more mktime / localtime bugs.
o Fixed crash on simple LIBC_ASSERT() caused by NULL format string.
o Generate device numbers for devices and pipes too.
o Fixed mixup of Dev and Inode during filehandle inheritance.
o Fixed dup and dup2 bug in relation to the FD_CLOEXEC clearing.
o Fixed bug in codepage normalization during setlocale().
o Fixed bug in regex where the lock was overwritten after initialization.
o Switch the glibc locks to smutex to avoid leaking event semaphores.
o Added _smutex_try_request().

  • Property cvs2svn:cvs-rev set to 1.3
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.1 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#ifndef _SYS_SMUTEX_H
11#define _SYS_SMUTEX_H
12
13#include <sys/builtin.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
31static __inline__ int _smutex_try_request (__volatile__ _smutex *sem)
32{
33 return __cxchg (sem, 1) == 0;
34}
35
36
37static __inline__ void _smutex_release (__volatile__ _smutex *sem)
38{
39 *sem = 0;
40}
41
42
43static __inline__ int _smutex_available (__volatile__ _smutex *sem)
44{
45 return *sem == 0;
46}
47
48
49#if defined (__cplusplus)
50}
51#endif
52
53#endif /* not _SYS_SMUTEX_H */
Note: See TracBrowser for help on using the repository browser.