Changeset 1661 for trunk/src/emx/include
- Timestamp:
- Nov 22, 2004, 2:46:26 AM (21 years ago)
- Location:
- trunk/src/emx/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r1660 r1661 207 207 208 208 #define STREAM_LOCK(f) \ 209 (_fmutex_request(&(f)->__u.__fsem, _FMR_IGNINT) != 0 \ 210 ? abort () : (void)0) 209 ((f)->__uVersion != _FILE_STDIO_VERSION ? __stream_abort (f, "version error") \ 210 : _fmutex_request(&(f)->__u.__fsem, _FMR_IGNINT) != 0 \ 211 ? __stream_abort (f, "fmutex request") : 0) 211 212 212 213 #define STREAM_UNLOCK(f) \ 213 (_fmutex_release(&(f)->__u.__fsem) != 0 ? abort() : (void)0)214 (_fmutex_release(&(f)->__u.__fsem) != 0 ? __stream_abort (f, "fmutex release") : (void)0) 214 215 215 216 #define STREAM_LOCK_NOWAIT(f) \ 216 (_fmutex_request(&(f)->__u.__fsem, _FMR_NOWAIT) == 0) 217 218 #define STREAM_UNLOCKED(f) _fmutex_available(&(f)->__u.__fsem) 217 (((f)->__uVersion == _FILE_STDIO_VERSION || __stream_abort (f, "version error")) && _fmutex_request(&(f)->__u.__fsem, _FMR_NOWAIT) == 0) 218 219 #define STREAM_UNLOCKED(f) ((f)->__uVersion == _FILE_STDIO_VERSION && _fmutex_available(&(f)->__u.__fsem)) 220 221 int __stream_abort(struct _FILE *f, const char *pszMsg); 219 222 220 223 #endif /* defined (_SYS_FMUTEX_H) */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/os2emx.h
-
Property cvs2svn:cvs-rev
changed from
1.24
to1.25
r1660 r1661 13308 13308 #define FS_SAVE() __asm__ __volatile__ ("movl %%fs, %%eax; movl %%eax,%0;" : : "m" (__fs__) : "%eax" ) 13309 13309 #define FS_SAVE_LOAD() __asm__ __volatile__ ("movl %%fs, %%eax; movl %%eax,%0; movl $DosTIB, %%eax; movl %%eax, %%fs" : : "m" (__fs__) : "%eax" ) 13310 #define FS_VAR_SAVE_LOAD() FS_VAR(); FS_SAVE_LOAD() 13310 13311 #define FS_RESTORE() __asm__ __volatile__ ("movl %0, %%eax; movl %%eax,%%fs;" : : "m" (__fs__) : "%eax" ) 13311 13312 #else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdio.h
-
Property cvs2svn:cvs-rev
changed from
1.13
to1.14
r1660 r1661 178 178 #define _FILE_T 179 179 #define _FILE_MEMBERS_HAVE_UNDERSCORE 180 struct _file2; 180 #define _FILE_STDIO_VERSION (0x06000000 | sizeof(struct _FILE)) 181 181 typedef struct _FILE 182 182 { 183 unsigned __uVersion; 183 184 char * _ptr; 184 185 char * _buffer; … … 201 202 _fmutex __fsem; 202 203 #endif 203 char __rsem_ersatz[ 8];204 char __rsem_ersatz[12]; 204 205 } __u; 205 /** Pointer to the stream vector which thi eFILE belongs to.206 /** Pointer to the stream vector which this FILE belongs to. 206 207 * This member is the first which should not be zeroed by _newstream()! */ 207 208 void *__pSV; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/fmutex.h
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1660 r1661 6 6 7 7 #ifndef _SYS_FMUTEX_H 8 #define _SYS_FMUTEX_H8 #define _SYS_FMUTEX_H 9 9 10 #include <stdlib.h> /* need abort */ 10 #include <sys/cdefs.h> 11 #include <stdlib.h> /* need abort */ 12 #include <InnoTekLIBC/FastInfoBlocks.h> 11 13 12 #if defined (__cplusplus) 13 extern "C" { 14 #endif 14 __BEGIN_DECLS 15 15 16 16 /* Constants for _fmutex.fs. See _fmutex_available() for ordering. */ 17 17 18 #define _FMS_UNINIT 019 #define _FMS_AVAILABLE 120 #define _FMS_OWNED_SIMPLE 221 #define _FMS_OWNED_HARD 318 #define _FMS_UNINIT 0 19 #define _FMS_AVAILABLE 1 20 #define _FMS_OWNED_SIMPLE 2 21 #define _FMS_OWNED_HARD 3 22 22 23 23 /* Constants for _fmutex_create() */ 24 24 25 #define _FMC_SHARED 0x01 25 #define _FMC_SHARED 0x01 26 #define _FMC_MUST_COMPLETE 0x02 27 #define _FMC_DUMMY 0x04 /* internal */ 26 28 27 29 /* Constants for _fmutex_request() */ 28 30 29 #define _FMR_IGNINT 0x0130 #define _FMR_NOWAIT 0x0231 #define _FMR_IGNINT 0x01 32 #define _FMR_NOWAIT 0x02 31 33 32 34 /* We cannot use __attribute__ ((__packed__)) because G++ does not 33 35 support this. */ 34 36 35 #pragma pack(1)37 #pragma pack(1) 36 38 typedef struct 37 39 { 38 40 /** Handle to event semaphore. */ 39 unsigned long hev;41 unsigned long hev; 40 42 /** Semaphore status. */ 41 __volatile__ signed charfs;43 volatile signed char fs; 42 44 /** Semaphore create flags. (_FMC_SHARED) */ 43 unsigned char flags; 44 /** padding the struct to 8 bytes. */ 45 unsigned char padding[2]; 45 unsigned char flags; 46 /** padding the struct to 16 bytes. */ 47 unsigned char padding[2]; 48 /** The (pid << 16) | tid of the owner. */ 49 volatile unsigned Owner; 50 /** Descriptive name of the mutex. */ 51 const char *pszDesc; 46 52 } _fmutex; 47 #pragma pack() 53 #pragma pack() 54 48 55 49 56 50 57 unsigned __fmutex_request_internal (_fmutex *, unsigned, signed char); 51 unsigned __fmutex_ create_internal(_fmutex *, unsigned);58 unsigned __fmutex_request_internal_must_complete (_fmutex *, unsigned); 52 59 unsigned __fmutex_release_internal (_fmutex *); 60 unsigned __fmutex_release_internal_must_complete (_fmutex *); 53 61 54 62 55 63 static __inline__ unsigned _fmutex_request (_fmutex *sem, unsigned flags) 56 64 { 57 signed char fs; 58 59 fs = __cxchg (&sem->fs, _FMS_OWNED_SIMPLE); 60 if (fs == _FMS_AVAILABLE) 61 return 0; 62 else 63 return __fmutex_request_internal (sem, flags, fs); 65 if (!(sem->flags & _FMC_MUST_COMPLETE)) 66 { 67 signed char fs = __cxchg (&sem->fs, _FMS_OWNED_SIMPLE); 68 if (fs == _FMS_AVAILABLE) 69 { 70 __atomic_xchg(&sem->Owner, fibGetTidPid()); 71 return 0; 72 } 73 else 74 return __fmutex_request_internal (sem, flags, fs); 75 } 76 else 77 return __fmutex_request_internal_must_complete (sem, flags); 64 78 } 65 79 … … 67 81 static __inline__ unsigned _fmutex_release (_fmutex *sem) 68 82 { 69 signed char fs; 70 71 fs = __cxchg (&sem->fs, _FMS_AVAILABLE); 72 if (fs == _FMS_OWNED_HARD) 73 return __fmutex_release_internal (sem); 74 else 75 return 0; 83 if (!(sem->flags & _FMC_MUST_COMPLETE)) 84 { 85 signed char fs; 86 __atomic_xchg(&sem->Owner, 0); 87 fs = __cxchg(&sem->fs, _FMS_AVAILABLE); 88 if (fs != _FMS_OWNED_HARD) 89 return 0; 90 else 91 return __fmutex_release_internal (sem); 92 } 93 else 94 return __fmutex_release_internal_must_complete (sem); 76 95 } 77 78 96 79 97 static __inline__ int _fmutex_available (_fmutex *sem) 80 98 { 81 return sem->fs <= _FMS_AVAILABLE;99 return sem->fs <= _FMS_AVAILABLE; 82 100 } 83 101 84 102 85 103 unsigned _fmutex_create (_fmutex *, unsigned); 104 unsigned _fmutex_create2 (_fmutex *sem, unsigned, const char *); 86 105 unsigned _fmutex_open (_fmutex *); 87 106 unsigned _fmutex_close (_fmutex *); 88 107 void _fmutex_dummy (_fmutex *); 89 108 90 void _fmutex_checked_close (_fmutex *); 91 void _fmutex_checked_create (_fmutex *, unsigned); 92 void _fmutex_checked_open (_fmutex *); 109 void _fmutex_checked_close(_fmutex *); 110 void _fmutex_checked_create(_fmutex *, unsigned); 111 void _fmutex_checked_create2(_fmutex *, unsigned, const char *); 112 void _fmutex_checked_open(_fmutex *); 113 void _fmutex_abort(_fmutex *, const char *); 93 114 94 115 static __inline__ void _fmutex_checked_release (_fmutex * sem) 95 116 { 96 if (_fmutex_release (sem) != 0) 97 abort (); 117 if (sem->Owner != fibGetTidPid()) 118 _fmutex_abort(sem, "release not owner"); 119 if (_fmutex_release (sem) != 0) 120 _fmutex_abort(sem, "release"); 98 121 } 99 122 100 123 static __inline__ void _fmutex_checked_request (_fmutex * sem, unsigned flags) 101 124 { 102 if (_fmutex_request (sem, flags) != 0)103 abort ();125 if (_fmutex_request (sem, flags) != 0) 126 _fmutex_abort(sem, "request"); 104 127 } 105 128 106 #if defined (__cplusplus) 107 } 108 #endif 129 __END_DECLS 109 130 110 131 #endif /* not _SYS_FMUTEX_H */ 132 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.