Changeset 2298
- Timestamp:
- Aug 22, 2005, 2:14:50 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 5 edited
-
ChangeLog.LIBC (modified) (1 diff, 1 prop)
-
include/InnoTekLIBC/backend.h (modified) (9 diffs, 1 prop)
-
src/lib/sys/safesems.c (modified) (24 diffs, 1 prop)
-
src/lib/sys/sysv_sem.c (modified) (32 diffs, 1 prop)
-
src/lib/sys/sysv_shm.c (modified) (22 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.122to1.123
r2297 r2298 6 6 - libc: 7 7 o Tried to workaround the race conditions in __libc_Back_safesemEvSleep/Wakeup. 8 These might affect SysV sems and shm.8 These might affect SysV sems. 9 9 o Corrected the declarations of _DLL_InitTerm. 10 10 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/backend.h
-
Property cvs2svn:cvs-rev
changed from
1.30to1.31
r2297 r2298 967 967 * @{ */ 968 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 969 985 /** 970 986 * Creates a safe mutex sem. … … 972 988 * @returns 0 on success. 973 989 * @returns Negative error code (errno.h) on failure. 974 * @param p hmtx Where to store the semaphore handle.990 * @param pe. 975 991 * @param fShared Set if the semaphore should be sharable between processes. 976 992 */ 977 int __libc_Back_safesemMtxCreate( uintptr_t *phmtx, int fShared);993 int __libc_Back_safesemMtxCreate(mtx, int fShared); 978 994 979 995 /** … … 982 998 * @returns 0 on success. 983 999 * @returns Negative error code (errno.h) on failure. 984 * @param hmtx The semaphore handle.985 */ 986 int __libc_Back_safesemMtxOpen( uintptr_t hmtx);1000 * @param e. 1001 */ 1002 int __libc_Back_safesemMtxOpen(mtx); 987 1003 988 1004 /** … … 991 1007 * @returns 0 on success. 992 1008 * @returns Negative error code (errno.h) on failure. 993 * @param hmtx The semaphore handle.994 */ 995 int __libc_Back_safesemMtxClose( uintptr_t hmtx);1009 * @param e. 1010 */ 1011 int __libc_Back_safesemMtxClose(mtx); 996 1012 997 1013 /** … … 1000 1016 * @returns 0 on success. 1001 1017 * @returns Negative errno on failure. 1002 * @param hmtx Handle to the mutex.1003 */ 1004 int __libc_Back_safesemMtxLock( uintptr_t hmtx);1018 * @param . 1019 */ 1020 int __libc_Back_safesemMtxLock(mtx); 1005 1021 1006 1022 /** … … 1009 1025 * @returns 0 on success. 1010 1026 * @returns Negative errno on failure. 1011 * @param hmtx Handle to the mutex. 1012 */ 1013 int __libc_Back_safesemMtxUnlock(uintptr_t hmtx); 1027 * @param pmtx Pointer to the semaphore structure. 1028 */ 1029 int __libc_Back_safesemMtxUnlock(__LIBC_PSAFESEMMTX pmtx); 1030 1031 1032 /** 1033 * Safe Event Semaphore structure. 1034 * 1035 * For shared semaphores this structure must be in shared memory so all users 1036 * actually use the very same structure. 1037 * 1038 * @remark The event semaphore business is difficult because the lack of 1039 * atomic mutex release + event wait apis in OS/2. We have to 1040 * jump around the place to get this working nearly safly... 1041 */ 1042 typedef struct __LIBC_SAFESEMEV 1043 { 1044 #ifdef __OS2__ 1045 /** The event semaphore. */ 1046 unsigned long hev; 1047 #endif 1048 /** Number of threads which are supposed to be blocking on the above event semaphore. */ 1049 uint32_t volatile cWaiters; 1050 /** The mutex semaphore used to protect the event semaphore. */ 1051 __LIBC_PSAFESEMMTX pmtx; 1052 /** Set if the semaphore is shared. 1053 * If shared this structure is allocated from SPM, else it's from the heap. */ 1054 unsigned fShared; 1055 } __LIBC_SAFESEMEV; 1056 /** Pointer to a SAFESEM Event structure. */ 1057 typedef __LIBC_SAFESEMEV *__LIBC_PSAFESEMEV; 1014 1058 1015 1059 /** … … 1018 1062 * @returns 0 on success. 1019 1063 * @returns Negative error code (errno.h) on failure. 1020 * @param phev Where to store the semaphore handle. 1064 * @param pev Pointer to the semaphore structure to initialize. 1065 * @param pmtx Pointer to the mutex semaphore which protects the event semaphore. 1021 1066 * @param fShared Set if the semaphore should be sharable between processes. 1022 1067 */ 1023 int __libc_Back_safesemEvCreate( uintptr_t *phev, int fShared);1068 int __libc_Back_safesemEvCreate(, int fShared); 1024 1069 1025 1070 /** 1026 1071 * Opens a shared safe event sem. 1027 1072 * 1028 * @returns 0 on success. 1029 * @returns Negative error code (errno.h) on failure. 1030 * @param hev The semaphore handle. 1031 */ 1032 int __libc_Back_safesemEvOpen(uintptr_t hev); 1073 * The caller is responsible for opening the associated mutex 1074 * semaphore before calling this function. 1075 * 1076 * @returns 0 on success. 1077 * @returns Negative error code (errno.h) on failure. 1078 * @param pev Pointer to the semaphore structure to open. 1079 */ 1080 int __libc_Back_safesemEvOpen(__LIBC_PSAFESEMEV pev); 1033 1081 1034 1082 /** … … 1037 1085 * @returns 0 on success. 1038 1086 * @returns Negative error code (errno.h) on failure. 1039 * @param hev The semaphore handle.1040 */ 1041 int __libc_Back_safesemEvClose( uintptr_t hev);1087 * @param e. 1088 */ 1089 int __libc_Back_safesemEvClose(ev); 1042 1090 1043 1091 /** 1044 1092 * Sleep on a semaphore. 1045 1093 * 1046 * This is the most difficult thing we're doing in this file. 1047 * 1048 * @returns 0 on success. 1049 * @returns Negative error code (errno.h) on failure. 1050 * 1051 * @param hev The semaphore to sleep on. 1052 * @param hmtx The semaphore protecting hev and which is to be unlocked while 1053 * sleeping and reaquired upon waking up. 1054 * @param pfnComplete Function to execute on signal and on wait completion. 1094 * The caller must own the associated mutex semaphore. The mutex semaphore will 1095 * be released as we go to sleep and reclaimed when we wake up. 1096 * 1097 * The pfnComplete callback is used to correct state before signals are handled. 1098 * It will always be called be for this function returns, and it'll either be under 1099 * the protection of the signal mutex or the associated mutex (both safe sems). 1100 * 1101 * This is the most difficult thing we're doing in this API. On OS/2 we have 1102 * potential (at least theoretically) race conditions... 1103 * 1104 * @returns 0 on success. 1105 * @returns Negative error code (errno.h) on failure. 1106 * 1107 * @param pev Pointer to the semaphore structure to sleep on. 1108 * @param pfnComplete Function to execute on signal or on wait completion. 1055 1109 * @param pvUser User argument to pfnComplete. 1056 1110 */ 1057 int __libc_Back_safesemEvSleep( uintptr_t hev, uintptr_t hmtx, void (*pfnComplete)(void *pvUser), void *pvUser);1111 int __libc_Back_safesemEvSleep(, void (*pfnComplete)(void *pvUser), void *pvUser); 1058 1112 1059 1113 /** … … 1062 1116 * @returns 0 on success. 1063 1117 * @returns Negative error code (errno.h) on failure. 1064 * @param hev Event semaphore to post. 1065 * @param hmtx The semaphore protecting hev (see __libc_Back_safesemEvSleep). 1066 * The caller should own this semaphore, it's purpose is debug strictness only! 1067 */ 1068 int __libc_Back_safesemEvWakeup(uintptr_t hev, uintptr_t hmtx); 1118 * @param pev Pointer to the semaphore structure to post. 1119 */ 1120 int __libc_Back_safesemEvWakeup(__LIBC_PSAFESEMEV pev); 1069 1121 1070 1122 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/safesems.c
-
Property cvs2svn:cvs-rev
changed from
1.2to1.3
r2297 r2298 38 38 #include <sys/errno.h> 39 39 #include "syscalls.h" 40 #include <emx/umalloc.h> 40 #include <sys/builtin.h> 41 #include <InnoTekLIBC/FastInfoBlocks.h> 41 42 #include <InnoTekLIBC/thread.h> 42 43 #include <InnoTekLIBC/backend.h> 43 #include <InnoTekLIBC/sharedpm.h>44 44 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IPC 45 45 #include <InnoTekLIBC/logstrict.h> … … 49 49 * Structures and Typedefs * 50 50 *******************************************************************************/ 51 /**52 * Event semaphore tracking structure.53 *54 * The event semaphore business is difficult because the lack of55 * atomic mutex release + event wait apis in OS/2. We have to56 * jump around the place to get this working nearly safly...57 */58 typedef struct __LIBC_SAFESEMEV59 {60 /** The event semaphore. */61 HEV hev;62 /** Number of threads which are supposed to be blocking on the above event semaphore. */63 uint32_t volatile cWaiters;64 /** Number of processes using the semaphore. */65 uint32_t volatile cUsers;66 /** Set if the semaphore is shared.67 * If shared this structure is allocated from SPM, else it's from the heap. */68 unsigned fShared;69 #ifdef __LIBC_STRICT70 /** The mutex semaphore used to protect the event semaphore.71 * Strict builds only. */72 uintptr_t hmtx;73 #endif74 } __LIBC_SAFESEMEV, *__LIBC_PSAFESEMEV;75 76 77 51 /** 78 52 * Arguments to semEvSleepSignalCallback(). … … 100 74 * @returns 0 on success. 101 75 * @returns Negative error code (errno.h) on failure. 102 * @param p hmtx Where to store the semaphore handle.76 * @param pe. 103 77 * @param fShared Set if the semaphore should be sharable between processes. 104 78 */ 105 int __libc_Back_safesemMtxCreate(uintptr_t *phmtx, int fShared) 106 { 107 FS_VAR_SAVE_LOAD(); 108 HMTX hmtx = NULLHANDLE; 109 int rc = DosCreateMutexSemEx(NULL, &hmtx, fShared ? DC_SEM_SHARED : 0, FALSE); 110 FS_RESTORE(); 79 int __libc_Back_safesemMtxCreate(__LIBC_PSAFESEMMTX pmtx, int fShared) 80 { 81 LIBCLOG_ENTER("pmtx=%p fShared=%d\n", (void *)pmtx, fShared); 82 pmtx->hmtx = NULLHANDLE; 83 int rc = DosCreateMutexSemEx(NULL, &pmtx->hmtx, fShared ? DC_SEM_SHARED : 0, FALSE); 111 84 if (rc) 112 return -__libc_native2errno(rc); 113 *phmtx = hmtx; 114 return 0; 85 rc = -__libc_native2errno(rc); 86 LIBCLOG_RETURN_MSG(rc, "ret %d hmtx=%#lx\n", rc, pmtx->hmtx); 115 87 } 116 88 … … 121 93 * @returns 0 on success. 122 94 * @returns Negative error code (errno.h) on failure. 123 * @param hmtx The semaphore handle. 124 */ 125 int __libc_Back_safesemMtxOpen(uintptr_t hmtx) 126 { 127 FS_VAR_SAVE_LOAD(); 128 HMTX hmtxOS2 = hmtx; 129 int rc = DosOpenMutexSemEx(NULL, &hmtxOS2); 130 FS_RESTORE(); 95 * @param pmtx Pointer to the semaphore structure. 96 */ 97 int __libc_Back_safesemMtxOpen(__LIBC_PSAFESEMMTX pmtx) 98 { 99 LIBCLOG_ENTER("pmtx=%p:{.hmtx=%#lx}\n", (void *)pmtx, pmtx->hmtx); 100 int rc = DosOpenMutexSemEx(NULL, &pmtx->hmtx); 131 101 if (rc) 132 r eturn-__libc_native2errno(rc);133 return 0;102 r -__libc_native2errno(rc); 103 ; 134 104 } 135 105 … … 140 110 * @returns 0 on success. 141 111 * @returns Negative error code (errno.h) on failure. 142 * @param hmtx The semaphore handle. 143 */ 144 int __libc_Back_safesemMtxClose(uintptr_t hmtx) 145 { 146 FS_VAR_SAVE_LOAD(); 147 int rc = DosCloseMutexSemEx(hmtx); 148 FS_RESTORE(); 149 if (rc) 150 return -__libc_native2errno(rc); 151 return 0; 112 * @param pmtx Pointer to the semaphore structure. 113 */ 114 int __libc_Back_safesemMtxClose(__LIBC_PSAFESEMMTX pmtx) 115 { 116 LIBCLOG_ENTER("pmtx=%p:{.hmtx=%#lx}\n", (void *)pmtx, pmtx->hmtx); 117 int rc = DosCloseMutexSemEx(pmtx->hmtx); 118 if (!rc) 119 rc = -__libc_native2errno(rc); 120 LIBCLOG_RETURN_INT(rc); 152 121 } 153 122 … … 157 126 * stack available. If there isn't, a crash is usually the 158 127 * result. 128 159 129 * @internal 160 130 */ … … 175 145 * @returns 0 on success. 176 146 * @returns Negative errno on failure. 177 * @param hmtx Handle to the mutex. 178 */ 179 int __libc_Back_safesemMtxLock(uintptr_t hmtx) 180 { 181 LIBCLOG_ENTER("hmtx=%#x\n", hmtx); 182 ULONG ul; 147 * @param pmtx Pointer to the semaphore structure. 148 */ 149 int __libc_Back_safesemMtxLock(__LIBC_PSAFESEMMTX pmtx) 150 { 151 LIBCLOG_ENTER("pmtx=%p:{.hmtx=%#lx}\n", (void *)pmtx, pmtx->hmtx); 152 ULONG ul = 0; 153 HMTX hmtx = pmtx->hmtx; 183 154 int rc; 184 155 FS_VAR(); … … 194 165 195 166 /* 196 * Request semaphore and enter "must complete section" to avoid signal trouble.167 * Request semaphore and enter "mustcomplete section" to avoid signal trouble. 197 168 */ 198 169 FS_SAVE_LOAD(); 170 171 172 173 174 175 176 177 178 179 180 199 181 rc = DosRequestMutexSem(hmtx, 30*1000); 200 182 DosEnterMustComplete(&ul); … … 207 189 /* failure out */ 208 190 DosExitMustComplete(&ul); 209 LIBC_ASSERTM_FAILED("DosRequestMutexSem(% x) failed with rc=%d!\n",hmtx, rc);191 LIBC_ASSERTM_FAILED("DosRequestMutexSem(%hmtx, rc); 210 192 rc = -__libc_native2errno(rc); 211 193 FS_RESTORE(); … … 219 201 * @returns 0 on success. 220 202 * @returns Negative errno on failure. 221 * @param hmtx Handle to the mutex.222 */ 223 int __libc_Back_safesemMtxUnlock( uintptr_t hmtx)224 { 225 LIBCLOG_ENTER(" hmtx=%#x\n",hmtx);226 ULONG ul = 0;227 int rc;203 * @param . 204 */ 205 int __libc_Back_safesemMtxUnlock(mtx) 206 { 207 LIBCLOG_ENTER("hmtx); 208 ULONG ul = 0; 209 int rc; 228 210 FS_VAR(); 229 211 … … 232 214 */ 233 215 FS_SAVE_LOAD(); 234 rc = DosReleaseMutexSem( hmtx);216 rc = DosReleaseMutexSem(hmtx); 235 217 if (rc) 236 218 { 237 219 FS_RESTORE(); 238 LIBC_ASSERTM_FAILED("DosReleaseMutexSem(% x) -> %d\n",hmtx, rc);220 LIBC_ASSERTM_FAILED("DosReleaseMutexSem(%hmtx, rc); 239 221 rc = -__libc_native2errno(rc); 240 222 LIBCLOG_RETURN_INT(rc); … … 248 230 249 231 232 250 233 /** 251 234 * Creates a safe event sem. … … 253 236 * @returns 0 on success. 254 237 * @returns Negative error code (errno.h) on failure. 255 * @param phev Where to store the semaphore handle. 238 * @param pev Pointer to the semaphore structure to initialize. 239 * @param pmtx Pointer to the mutex semaphore which protects the event semaphore. 256 240 * @param fShared Set if the semaphore should be sharable between processes. 257 241 */ 258 int __libc_Back_safesemEvCreate(uintptr_t *phev, int fShared) 259 { 260 LIBCLOG_ENTER("phev=%p fShared=%d\n", (void *)phev, fShared); 261 int rc; 262 __LIBC_PSAFESEMEV pEv = NULL; 263 FS_VAR_SAVE_LOAD(); 264 if (fShared) 265 { 266 /* 267 * Allocate from SPM, be very careful. 268 */ 269 __LIBC_SPMXCPTREGREC RegRec; 270 rc = __libc_spmLock(&RegRec, NULL); 271 if (!rc) 272 { 273 pEv = __libc_spmAllocLocked(sizeof(*pEv)); 274 if (pEv) 275 { 276 pEv->hev = NULLHANDLE; 277 pEv->cWaiters = 0; 278 pEv->cUsers = 1; 279 pEv->fShared = fShared; 280 #ifdef __LIBC_STRICT 281 pEv->hmtx = 0; 282 #endif 283 284 rc = DosCreateEventSemEx(NULL, &pEv->hev, fShared ? DC_SEM_SHARED : 0, FALSE); 285 if (rc) 286 { 287 __libc_spmFree(pEv); 288 rc = -__libc_native2errno(rc); 289 } 290 } 291 else 292 rc = -ENOMEM; 293 __libc_spmUnlock(&RegRec); 294 } 295 } 296 else 297 { 298 /* 299 * Allocate from high mem heap. 300 */ 301 pEv = _hmalloc(sizeof(*pEv)); 302 if (pEv) 303 { 304 pEv->hev = NULLHANDLE; 305 pEv->cWaiters = 0; 306 pEv->cUsers = 1; 307 pEv->fShared = fShared; 308 #ifdef __LIBC_STRICT 309 pEv->hmtx = 0; 310 #endif 311 312 rc = DosCreateEventSemEx(NULL, &pEv->hev, fShared ? DC_SEM_SHARED : 0, FALSE); 313 if (rc) 314 { 315 free(pEv); 316 rc = -__libc_native2errno(rc); 317 } 318 } 319 else 320 rc = -ENOMEM; 321 } 322 FS_RESTORE(); 323 324 if (!rc) 325 *phev = (uintptr_t)pEv; 326 LIBCLOG_RETURN_MSG(rc, "ret %d *phev=%#x\n", rc, *phev); 242 int __libc_Back_safesemEvCreate(__LIBC_PSAFESEMEV pev, __LIBC_PSAFESEMMTX pmtx, int fShared) 243 { 244 LIBCLOG_ENTER("phev=%p pmtx=%p:{.hmtx=%#lx} fShared=%d\n", (void *)pev, (void *)pmtx, pmtx->hmtx, fShared); 245 246 pev->hev = NULLHANDLE; 247 pev->cWaiters = 0; 248 pev->pmtx = pmtx; 249 pev->fShared = fShared; 250 251 int rc = DosCreateEventSemEx(NULL, &pev->hev, fShared ? DC_SEM_SHARED : 0, FALSE); 252 if (rc) 253 rc = -__libc_native2errno(rc); 254 255 LIBCLOG_RETURN_MSG(rc, "ret %d pev->hev=%#lx\n", rc, pev->hev); 327 256 } 328 257 … … 331 260 * Opens a shared safe event sem. 332 261 * 333 * @returns 0 on success. 334 * @returns Negative error code (errno.h) on failure. 335 * @param hev The semaphore handle. 336 */ 337 int __libc_Back_safesemEvOpen(uintptr_t hev) 338 { 339 LIBCLOG_ENTER("hev=%#x\n", hev); 340 __LIBC_PSAFESEMEV pEv = (__LIBC_PSAFESEMEV)hev; 341 FS_VAR_SAVE_LOAD(); 342 int rc = DosOpenEventSemEx(NULL, &pEv->hev); 343 FS_RESTORE(); 344 if (!rc) 345 __atomic_increment_u32(&pEv->cUsers); 346 else 347 rc = -__libc_native2errno(rc); 262 * The caller is responsible for opening the associated mutex 263 * semaphore before calling this function. 264 * 265 * @returns 0 on success. 266 * @returns Negative error code (errno.h) on failure. 267 * @param pev Pointer to the semaphore structure to open. 268 */ 269 int __libc_Back_safesemEvOpen(__LIBC_PSAFESEMEV pev) 270 { 271 LIBCLOG_ENTER("pev=%p:{.hev=%#lx .cWaiters=%d .pmtx=%p .fShared=%d}\n", 272 (void *)pev, pev->hev, pev->cWaiters, (void *)pev->pmtx, pev->fShared); 273 274 int rc = DosOpenEventSemEx(NULL, &pev->hev); 275 if (rc) 276 rc = -__libc_native2errno(rc); 277 348 278 LIBCLOG_RETURN_INT(rc); 349 279 } … … 355 285 * @returns 0 on success. 356 286 * @returns Negative error code (errno.h) on failure. 357 * @param hev The semaphore handle. 358 */ 359 int __libc_Back_safesemEvClose(uintptr_t hev) 360 { 361 LIBCLOG_ENTER("hev=%#x\n", hev); 362 __LIBC_PSAFESEMEV pEv = (__LIBC_PSAFESEMEV)hev; 363 FS_VAR_SAVE_LOAD(); 364 int rc = DosCloseEventSemEx(pEv->hev); 365 FS_RESTORE(); 366 if (!rc) 367 { 368 if ( pEv->cUsers 369 && !__atomic_decrement_u32(&pEv->cUsers)) 370 { 371 pEv->hev = NULLHANDLE; 372 if (pEv->fShared) 373 __libc_spmFree(pEv); 374 else 375 free(pEv); 376 } 377 } 378 else 379 rc = -__libc_native2errno(rc); 287 * @param pev Pointer to the semaphore structure to close. 288 */ 289 int __libc_Back_safesemEvClose(__LIBC_PSAFESEMEV pev) 290 { 291 LIBCLOG_ENTER("pev=%p:{.hev=%#lx .cWaiters=%d .pmtx=%p .fShared=%d}\n", 292 (void *)pev, pev->hev, pev->cWaiters, (void *)pev->pmtx, pev->fShared); 293 294 int rc = DosCloseEventSemEx(pev->hev); 295 if (rc) 296 rc = -__libc_native2errno(rc); 297 380 298 LIBCLOG_RETURN_INT(rc); 381 299 } … … 398 316 int rc = DosSetPriority(PRTYS_THREAD, pArgs->ulOldPri >> 8, pArgs->ulOldPri & 0xff, 0); 399 317 if (rc) 400 __libc_Back_panic(0, NULL, "DosSetPriority(PRTYS_THREAD, %x, %x, 0) -> %d \n",318 __libc_Back_panic(0, NULL, "DosSetPriority(PRTYS_THREAD, %x, %x, 0) -> %d 401 319 (unsigned)pArgs->ulOldPri >> 8, (unsigned)pArgs->ulOldPri & 0xff, rc); 402 320 pArgs->fDone = 1; … … 409 327 * Sleep on a semaphore. 410 328 * 411 * This is the most difficult thing we're doing in this file. 412 * 413 * @returns 0 on success. 414 * @returns Negative error code (errno.h) on failure. 415 * 416 * @param hev The semaphore to sleep on. 417 * @param hmtx The semaphore protecting hev and which is to be unlocked while 418 * sleeping and reaquired upon waking up. 419 * @param pfnComplete Function to execute on signal and on wait completion. 329 * The caller must own the associated mutex semaphore. The mutex semaphore will 330 * be released as we go to sleep and reclaimed when we wake up. 331 * 332 * The pfnComplete callback is used to correct state before signals are handled. 333 * It will always be called be for this function returns, and it'll either be under 334 * the protection of the signal mutex or the associated mutex (both safe sems). 335 * 336 * This is the most difficult thing we're doing in this API. On OS/2 we have 337 * potential (at least theoretically) race conditions... 338 * 339 * @returns 0 on success. 340 * @returns Negative error code (errno.h) on failure. 341 * 342 * @param pev Pointer to the semaphore structure to sleep on. 343 * @param pfnComplete Function to execute on signal or on wait completion. 420 344 * @param pvUser User argument to pfnComplete. 421 345 */ 422 int __libc_Back_safesemEvSleep(uintptr_t hev, uintptr_t hmtx, void (*pfnComplete)(void *pvUser), void *pvUser) 423 { 424 LIBCLOG_ENTER("hev=%#x hmtx=%#x pfnComplete=%p pvUser=%p\n", hev, hmtx, (void *)pfnComplete, pvUser); 425 __LIBC_PSAFESEMEV pEv = (__LIBC_PSAFESEMEV)hev; 426 427 #ifdef __LIBC_STRICT 428 /* 429 * Keep track of hmtx. 430 */ 431 if (pEv->hmtx) 432 LIBC_ASSERTM(pEv->hmtx == hmtx, "pEv->hmtx=%#x hmtx=%#x\n", pEv->hmtx, hmtx); 433 else 434 pEv->hmtx = hmtx; 435 #endif 346 int __libc_Back_safesemEvSleep(__LIBC_PSAFESEMEV pev, void (*pfnComplete)(void *pvUser), void *pvUser) 347 { 348 LIBCLOG_ENTER("pev=%p:{.hev=%#lx .cWaiters=%d .pmtx=%p .fShared=%d} pfnComplete=%p pvUser=%p\n", 349 (void *)pev, pev->hev, pev->cWaiters, (void *)pev->pmtx, pev->fShared, (void *)pfnComplete, pvUser); 436 350 437 351 /* … … 446 360 PPIB pPib; 447 361 DosGetInfoBlocks(&pTib, &pPib); 448 362 449 363 struct SignalArgs Args; 450 364 Args.ulOldPri = pTib->tib_ptib2->tib2_ulpri; … … 453 367 Args.pfnComplete = pfnComplete; 454 368 Args.pvUser = pvUser; 455 369 370 /* install signal callback. */ 456 371 pThrd->pvSigCallbackUser = &Args; 457 372 pThrd->pfnSigCallback = semEvSleepSignalCallback; 458 373 459 374 /* 460 * Raise priority to time critical to increase our chances of actually getting 375 * Raise priority to time critical to increase our chances of actually getting 461 376 * blocked before something bad like rescheduling or signaling strikes us. 462 377 */ … … 468 383 LIBC_ASSERTM(!rc, "DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 0, 0) -> %d\n", rc); 469 384 } 470 385 471 386 /* 472 387 * Release the sempahore and exit the must complete section. 473 388 */ 474 __atomic_increment_u32(&p Ev->cWaiters);475 rc = __libc_Back_safesemMtxUnlock( hmtx);389 __atomic_increment_u32(&pv->cWaiters); 390 rc = __libc_Back_safesemMtxUnlock(mtx); 476 391 if (!rc) 477 392 { … … 481 396 int rc2 = 0; 482 397 if (!Args.fDone) 483 rc2 = DosWaitEventSem(p Ev->hev, SEM_INDEFINITE_WAIT);484 398 rc2 = DosWaitEventSem(pv->hev, SEM_INDEFINITE_WAIT); 399 485 400 /* 486 * Reclaim the ownership of the sempahore (w/must-complete) and deregister 487 * the signal notification callback before we check if we was interrupted or not during the wait. 401 * Reclaim the ownership of the mutex and handle event semaphore errors. 488 402 */ 489 __atomic_decrement_u32(&p Ev->cWaiters);403 __atomic_decrement_u32(&pv->cWaiters); 490 404 LIBCLOG_MSG("woke up - rc2=%d\n", rc2); 491 rc = __libc_Back_safesemMtxLock(hmtx); 492 pThrd->pfnSigCallback = NULL; 493 pThrd->pvSigCallbackUser = NULL; 494 if (!Args.fDone) 495 { 496 /* 497 * Not interrupted. 498 * Check for errors, do completion and restore priority. 499 */ 500 if (rc2) 501 rc = -__libc_native2errno(rc2); 502 pfnComplete(pvUser); 503 rc2 = DosSetPriority(PRTYS_THREAD, Args.ulOldPri >> 8, Args.ulOldPri & 0xff, 0); 504 if (rc2) 505 __libc_Back_panic(0, NULL, "DosSetPriority(PRTYS_THREAD, %x, %x, 0) -> %d\n", 506 (unsigned)Args.ulOldPri >> 8, (unsigned)Args.ulOldPri & 0xff, rc2); 507 } 508 else if (!rc) 509 rc = -EINTR; 510 405 rc = __libc_Back_safesemMtxLock(pev->pmtx); 406 if (!rc && rc2) 407 rc = -__libc_native2errno(rc2); 408 409 /* 410 * Restore priority before resetting the semaphore. 411 */ 412 rc2 = DosSetPriority(PRTYS_THREAD, Args.ulOldPri >> 8, Args.ulOldPri & 0xff, 0); 413 if (rc2) 414 __libc_Back_panic(0, NULL, "DosSetPriority(PRTYS_THREAD, %x, %x, 0) -> %d (1)\n", 415 (unsigned)Args.ulOldPri >> 8, (unsigned)Args.ulOldPri & 0xff, rc2); 416 if (pev->cWaiters > 0) 417 DosSleep(0); /* hurry up guys */ 418 511 419 /* 512 420 * Reset the event semaphore. 513 421 */ 514 422 ULONG ulIgnore; 515 rc2 = DosResetEventSem(p Ev->hev, &ulIgnore);516 LIBC_ASSERTM(!rc2 && ERROR_ALREADY_RESET, "DosResetEventSem(%#lx,)->%d\n", p Ev->hev, rc2);423 rc2 = DosResetEventSem(pv->hev, &ulIgnore); 424 LIBC_ASSERTM(!rc2 && ERROR_ALREADY_RESET, "DosResetEventSem(%#lx,)->%d\n", pv->hev, rc2); 517 425 } 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 518 454 FS_RESTORE(); 519 455 } 520 456 else 457 458 521 459 rc = -ENOSYS; 460 522 461 523 462 LIBCLOG_RETURN_INT(rc); … … 528 467 * Wakes up all threads sleeping on a given event semaphore. 529 468 * 530 * @returns 0 on success. 531 * @returns Negative error code (errno.h) on failure. 532 * @param hev Event semaphore to post. 533 * @param hmtx The semaphore protecting hev (see __libc_Back_safesemEvSleep). 534 * The caller should own this semaphore, it's purpose is debug strictness only! 535 */ 536 int __libc_Back_safesemEvWakeup(uintptr_t hev, uintptr_t hmtx) 537 { 538 LIBCLOG_ENTER("hev=%#x hmtx=%#x\n", hev, hmtx); 539 __LIBC_PSAFESEMEV pEv = (__LIBC_PSAFESEMEV)hev; 469 * The caller must own the associated mutex semaphore when calling this 470 * function. 471 * 472 * @returns 0 on success. 473 * @returns Negative error code (errno.h) on failure. 474 * @param pev Pointer to the semaphore structure to post. 475 */ 476 int __libc_Back_safesemEvWakeup(__LIBC_PSAFESEMEV pev) 477 { 478 LIBCLOG_ENTER("pev=%p:{.hev=%#lx .cWaiters=%d .pmtx=%p .fShared=%d}\n", 479 (void *)pev, pev->hev, pev->cWaiters, (void *)pev->pmtx, pev->fShared); 540 480 FS_VAR_SAVE_LOAD(); 541 481 int rc; … … 543 483 #ifdef __LIBC_STRICT 544 484 /* 545 * Check hmtx.485 * Check . 546 486 */ 547 LIBC_ASSERTM(!pEv->hmtx || pEv->hmtx == hmtx, "pEv->hmtx=%#x hmtx=%#x\n", pEv->hmtx, hmtx);548 487 ULONG cNesting; 549 488 PID pid; 550 489 TID tid; 551 rc = DosQueryMutexSem( hmtx, &pid, &tid, &cNesting);552 LIBC_ASSERTM(!rc, "DosQueryMutexSem(%# x,,,) -> %d\n",hmtx, rc);490 rc = DosQueryMutexSem(hmtx, &pid, &tid, &cNesting); 491 LIBC_ASSERTM(!rc, "DosQueryMutexSem(%#hmtx, rc); 553 492 if (!rc) 554 493 LIBC_ASSERTM(pid == fibGetPid() && tid == fibGetTid(), 555 494 "pid=%d fibGetPid()->%d tid=%d fibGetTid()->%d\n", (int)pid, fibGetPid(), (int)tid, fibGetTid()); 556 #endif 495 #endif 557 496 558 497 /* 559 498 * Post it. 560 499 */ 561 rc = DosPostEventSem( hev);500 rc = DosPostEventSem(hev); 562 501 if (!rc) 563 502 { 564 if ( !rc && pEv->cWaiters)503 if (v->cWaiters) 565 504 { 566 /* give the waiting threads a fair chance to get past the DosWaitEventSem() call.*/505 /* */ 567 506 unsigned cYields = 3; 568 507 do 569 508 { 570 509 DosSleep(0); 571 LIBCLOG_MSG("cWaiters=%d cYields=%d\n", p Ev->cWaiters, cYields);572 } while (p Ev->cWaiters && --cYields > 0);510 LIBCLOG_MSG("cWaiters=%d cYields=%d\n", pv->cWaiters, cYields); 511 } while (pv->cWaiters && --cYields > 0); 573 512 } 574 513 } … … 580 519 rc = -__libc_native2errno(rc); 581 520 } 521 582 522 FS_RESTORE(); 583 523 LIBCLOG_RETURN_INT(rc); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sysv_sem.c
-
Property cvs2svn:cvs-rev
changed from
1.5to1.6
r2297 r2298 51 51 struct semid_ds u; 52 52 /** Event semaphore to wait on. */ 53 uintptr_t hev;54 /** Mutex protecting the semid_ds and hev members. */55 uintptr_t hmtx;53 ev; 54 /** Mutex protecting the semid_ds and ev members. */ 55 mtx; 56 56 }; 57 57 … … 74 74 struct sem *sem; 75 75 /** Mutex protecting the undo list and other global sem stuff. */ 76 uintptr_t hmtx;76 mtx; 77 77 /** list of active undo structures. */ 78 78 SLIST_HEAD(, sem_undo) semu_list; … … 95 95 //static int *semu; /* undo structure pool */ 96 96 97 //#define SEMUNDO_MTX gpGlobals-> hmtx98 #define SEMUNDO_LOCK() __libc_Back_safesemMtxLock( gpGlobals->hmtx);99 #define SEMUNDO_UNLOCK() __libc_Back_safesemMtxUnlock( gpGlobals->hmtx);100 #define SEMUNDO_LOCKASSERT(how) do {} while (0) //mtx_assert( gpGlobals->hmtx, (how));97 //#define SEMUNDO_MTX gpGlobals->mtx 98 #define SEMUNDO_LOCK() __libc_Back_safesemMtxLock(mtx); 99 #define SEMUNDO_UNLOCK() __libc_Back_safesemMtxUnlock(mtx); 100 #define SEMUNDO_LOCKASSERT(how) do {} while (0) //mtx_assert(mtx, (how)); 101 101 102 102 struct sem { … … 306 306 bzero(pGlobals, cb); 307 307 //pGlobals->cUsers = 0; 308 pGlobals->uVersion = 1;308 pGlobals->uVersion = ; 309 309 //pGlobals->semtot = 0; 310 310 uint8_t *pu8 = (uint8_t *)(pGlobals + 1); … … 322 322 } 323 323 } 324 325 326 327 328 329 330 331 332 324 333 325 334 /* … … 330 339 { 331 340 /* create */ 332 rc = __libc_Back_safesemMtxCreate(&pGlobals-> hmtx, 1);341 rc = __libc_Back_safesemMtxCreate(&pGlobals->mtx, 1); 333 342 for (i = 0; i < pGlobals->seminfo.semmni && !rc; i++) 334 rc = __libc_Back_safesemMtxCreate(&pGlobals->sema[i]. hmtx, 1);343 rc = __libc_Back_safesemMtxCreate(&pGlobals->sema[i].mtx, 1); 335 344 for (i = 0; i < pGlobals->seminfo.semmni && !rc; i++) 336 rc = __libc_Back_safesemEvCreate(&pGlobals->sema[i]. hev, 1);345 rc = __libc_Back_safesemEvCreate(&pGlobals->sema[i]., 1); 337 346 } 338 347 else 339 348 { 340 349 /* open */ 341 rc = __libc_Back_safesemMtxOpen( pGlobals->hmtx);350 rc = __libc_Back_safesemMtxOpen(mtx); 342 351 for (i = 0; i < pGlobals->seminfo.semmni && !rc; i++) 343 rc = __libc_Back_safesemMtxOpen( pGlobals->sema[i].hmtx);352 rc = __libc_Back_safesemMtxOpen(mtx); 344 353 for (i = 0; i < pGlobals->seminfo.semmni && !rc; i++) 345 rc = __libc_Back_safesemEvOpen( pGlobals->sema[i].hev);354 rc = __libc_Back_safesemEvOpen(ev); 346 355 } 347 356 __atomic_increment_u32(&pGlobals->cUsers); … … 562 571 u_short usval, count; 563 572 uid_t uid; 564 uintptr_t hmtx;573 mtx; 565 574 int semid_in = semid; 566 575 … … 580 589 error = 0; 581 590 rval = 0; 582 hmtx = NULLHANDLE;591 ; 583 592 584 593 switch(cmd) { … … 587 596 LIBCLOG_ERROR_RETURN_INT(-EINVAL); 588 597 semaptr = &sema[semid]; 589 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);598 __libc_Back_safesemMtxLock(mtx); 590 599 if ((semaptr->u.sem_perm.mode & SEM_ALLOC) == 0) { 591 600 error = EINVAL; … … 594 603 if ((error = -__libc_spmCanIPC(&semaptr->u.sem_perm, IPC_R))) 595 604 goto done2; 596 __libc_Back_safesemMtxUnlock( hmtx); hmtx = NULLHANDLE;605 __libc_Back_safesemMtxUnlock(; 597 606 memcpy(real_arg.buf, &semaptr->u, sizeof(struct semid_ds)); 598 607 rval = IXSEQ_TO_IPCID(semid, semaptr->u.sem_perm); … … 608 617 switch (cmd) { 609 618 case IPC_RMID: 610 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);619 __libc_Back_safesemMtxLock(mtx); 611 620 if ((error = semvalid(semid_in, semaptr)) != 0) 612 621 goto done2; … … 628 637 semundo_clear(semid, -1); 629 638 SEMUNDO_UNLOCK(); 630 __libc_Back_safesemEvWakeup( semaptr->hev, semaptr->hmtx);639 __libc_Back_safesemEvWakeup(); 631 640 break; 632 641 … … 634 643 if ((error = copyin(real_arg.buf, &sbuf, sizeof(sbuf))) != 0) 635 644 goto done2; 636 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);645 __libc_Back_safesemMtxLock(mtx); 637 646 if ((error = semvalid(semid_in, semaptr)) != 0) 638 647 goto done2; … … 647 656 648 657 case IPC_STAT: 649 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);658 __libc_Back_safesemMtxLock(mtx); 650 659 if ((error = semvalid(semid_in, semaptr)) != 0) 651 660 goto done2; … … 653 662 goto done2; 654 663 sbuf = semaptr->u; 655 __libc_Back_safesemMtxUnlock( hmtx); hmtx = NULLHANDLE;664 __libc_Back_safesemMtxUnlock(; 656 665 error = copyout(semaptr, real_arg.buf, 657 666 sizeof(struct semid_ds)); … … 659 668 660 669 case GETNCNT: 661 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);670 __libc_Back_safesemMtxLock(mtx); 662 671 if ((error = semvalid(semid_in, semaptr)) != 0) 663 672 goto done2; … … 672 681 673 682 case GETPID: 674 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);683 __libc_Back_safesemMtxLock(mtx); 675 684 if ((error = semvalid(semid_in, semaptr)) != 0) 676 685 goto done2; … … 685 694 686 695 case GETVAL: 687 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);696 __libc_Back_safesemMtxLock(mtx); 688 697 if ((error = semvalid(semid_in, semaptr)) != 0) 689 698 goto done2; … … 699 708 case GETALL: 700 709 array = _hmalloc(sizeof(*array) * semaptr->u.sem_nsems); 701 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);710 __libc_Back_safesemMtxLock(mtx); 702 711 if ((error = semvalid(semid_in, semaptr)) != 0) 703 712 goto done2; … … 706 715 for (i = 0; i < semaptr->u.sem_nsems; i++) 707 716 array[i] = semaptr->u.sem_base[i].semval; 708 __libc_Back_safesemMtxUnlock( hmtx); hmtx = NULLHANDLE;717 __libc_Back_safesemMtxUnlock(; 709 718 error = copyout(array, real_arg.array, 710 719 i * sizeof(real_arg.array[0])); … … 712 721 713 722 case GETZCNT: 714 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);723 __libc_Back_safesemMtxLock(mtx); 715 724 if ((error = semvalid(semid_in, semaptr)) != 0) 716 725 goto done2; … … 725 734 726 735 case SETVAL: 727 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);736 __libc_Back_safesemMtxLock(mtx); 728 737 if ((error = semvalid(semid_in, semaptr)) != 0) 729 738 goto done2; … … 742 751 semundo_clear(semid, semnum); 743 752 SEMUNDO_UNLOCK(); 744 __libc_Back_safesemEvWakeup( semaptr->hev, semaptr->hmtx);753 __libc_Back_safesemEvWakeup(); 745 754 break; 746 755 747 756 case SETALL: 748 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);757 __libc_Back_safesemMtxLock(mtx); 749 758 raced: 750 759 if ((error = semvalid(semid_in, semaptr)) != 0) 751 760 goto done2; 752 761 count = semaptr->u.sem_nsems; 753 __libc_Back_safesemMtxUnlock( hmtx); hmtx = NULLHANDLE;762 __libc_Back_safesemMtxUnlock(; 754 763 array = _hmalloc(sizeof(*array) * count); 755 764 error = copyin(real_arg.array, array, count * sizeof(*array)); 756 765 if (error) 757 766 break; 758 __libc_Back_safesemMtxLock( hmtx = semaptr->hmtx);767 __libc_Back_safesemMtxLock(mtx); 759 768 if ((error = semvalid(semid_in, semaptr)) != 0) 760 769 goto done2; … … 778 787 semundo_clear(semid, -1); 779 788 SEMUNDO_UNLOCK(); 780 __libc_Back_safesemEvWakeup( semaptr->hev, semaptr->hmtx);789 __libc_Back_safesemEvWakeup(); 781 790 break; 782 791 … … 787 796 788 797 done2: 789 if ( hmtx)790 __libc_Back_safesemMtxUnlock( hmtx);798 if (mtx) 799 __libc_Back_safesemMtxUnlock(mtx); 791 800 792 801 if (array != NULL) … … 821 830 struct semid_kernel * sema = gpGlobals->sema; 822 831 823 error = __libc_Back_safesemMtxLock( gpGlobals->hmtx);832 error = __libc_Back_safesemMtxLock(mtx); 824 833 if (error) 825 834 LIBCLOG_ERROR_RETURN_INT(error); … … 899 908 error = -IXSEQ_TO_IPCID(semid, sema[semid].u.sem_perm); 900 909 done2: 901 __libc_Back_safesemMtxUnlock( gpGlobals->hmtx);910 __libc_Back_safesemMtxUnlock(mtx); 902 911 if (!error) 903 912 LIBCLOG_RETURN_INT(-error); … … 991 1000 992 1001 semaptr = &sema[semid]; 993 error = __libc_Back_safesemMtxLock( semaptr->hmtx);1002 error = __libc_Back_safesemMtxLock(mtx); 994 1003 if (error) { 995 1004 if (sops != small_sops) … … 1113 1122 __atomic_increment_u16(Args.pu16); 1114 1123 DPRINTF(("semop: good night (%d)!\n", sopptr->sem_op)); 1115 error = -__libc_Back_safesemEvSleep( semaptr->hev, semaptr->hmtx, SleepDone, &Args);1124 error = -__libc_Back_safesemEvSleep(, SleepDone, &Args); 1116 1125 DPRINTF(("semop: good morning (error=%d)!\n", error)); 1117 1126 /* return code is checked below, after sem[nz]cnt-- */ … … 1208 1217 if (do_wakeup) { 1209 1218 DPRINTF(("semop: doing wakeup\n")); 1210 __libc_Back_safesemEvWakeup( semaptr->hev, semaptr->hmtx);1219 __libc_Back_safesemEvWakeup(); 1211 1220 DPRINTF(("semop: back from wakeup\n")); 1212 1221 } 1213 1222 DPRINTF(("semop: done\n")); 1214 1223 done2: 1215 __libc_Back_safesemMtxUnlock( semaptr->hmtx);1224 __libc_Back_safesemMtxUnlock(mtx); 1216 1225 if (sops != small_sops) 1217 1226 free(sops); … … 1272 1281 semaptr = &gpGlobals->sema[semid]; 1273 1282 SEMUNDO_LOCK(); 1274 __libc_Back_safesemMtxUnlock( semaptr->hmtx);1283 __libc_Back_safesemMtxUnlock(mtx); 1275 1284 if ((semaptr->u.sem_perm.mode & SEM_ALLOC) == 0) { 1276 1285 panic("semexit - semid not allocated"); … … 1298 1307 semaptr->u.sem_base[semnum].semval += adjval; 1299 1308 1300 __libc_Back_safesemEvWakeup( semaptr->hev, semaptr->hmtx);1309 __libc_Back_safesemEvWakeup(); 1301 1310 DPRINTF(("semexit: back from wakeup\n")); 1302 1311 skip: 1303 __libc_Back_safesemMtxUnlock( semaptr->hmtx);1312 __libc_Back_safesemMtxUnlock(mtx); 1304 1313 SEMUNDO_UNLOCK(); 1305 1314 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/sysv_shm.c
-
Property cvs2svn:cvs-rev
changed from
1.5to1.6
r2297 r2298 30 30 */ 31 31 32 32 33 #include "libc-alias.h" 33 34 #include <sys/cdefs.h> … … 65 66 /* debug printf */ 66 67 #define DPRINTF(a) LIBCLOG_MSG a 68 69 70 71 72 67 73 68 74 … … 82 88 volatile uint32_t cUsers; 83 89 /** Mutex protecting everything. */ 84 uintptr_t hmtx;90 mtx; 85 91 /** Event semaphore which the daemon should sleep on. 86 92 * This is posted whenever a memory object is created or deleted. */ 87 uintptr_t hevDaemon;93 evDaemon; 88 94 89 95 int shm_last_free; … … 286 292 pGlobals->shm_nused--; 287 293 shmseg->shm_perm.mode = SHMSEG_FREE; 288 __libc_Back_safesemEvWakeup( pGlobals->hevDaemon, pGlobals->hmtx);294 __libc_Back_safesemEvWakeup(); 289 295 } 290 296 … … 314 320 pGlobals->shm_last_free = segnum; 315 321 } 316 __libc_Back_safesemEvWakeup( pGlobals->hevDaemon, pGlobals->hmtx);322 __libc_Back_safesemEvWakeup(); 317 323 return (0); 318 324 } … … 344 350 } 345 351 346 error = __libc_Back_safesemMtxLock( gpGlobals->hmtx);352 error = __libc_Back_safesemMtxLock(mtx); 347 353 if (error) 348 354 LIBCLOG_ERROR_RETURN_INT(error); … … 365 371 error = shm_delete_mapping(shmmap_s, 0); 366 372 done2: 367 __libc_Back_safesemMtxUnlock( gpGlobals->hmtx);373 __libc_Back_safesemMtxUnlock(mtx); 368 374 return (-error); 369 375 } … … 394 400 struct __libc_SysV_Shm *pGlobals = gpGlobals; 395 401 396 error = __libc_Back_safesemMtxLock( pGlobals->hmtx);402 error = __libc_Back_safesemMtxLock(mtx); 397 403 if (error) 398 404 LIBCLOG_ERROR_RETURN_INT(error); … … 403 409 shmmap_s = g_vm_shm; 404 410 if (shmmap_s == NULL) { 405 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);411 __libc_Back_safesemMtxUnlock(mtx); 406 412 size = shminfo.shmseg * sizeof(struct shmmap_state); 407 413 shmmap_s = _hmalloc(size); … … 410 416 for (i = 0; i < shminfo.shmseg; i++) 411 417 shmmap_s[i].shmid = -1; 412 __libc_Back_safesemMtxLock( pGlobals->hmtx);418 __libc_Back_safesemMtxLock(mtx); 413 419 if (!g_vm_shm) 414 420 g_vm_shm = shmmap_s; … … 479 485 480 486 done2: 481 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);487 __libc_Back_safesemMtxUnlock(mtx); 482 488 *ppvActual = (void *)attach_va; 483 489 if (!error) … … 516 522 struct __libc_SysV_Shm *pGlobals = gpGlobals; 517 523 518 error = __libc_Back_safesemMtxLock( pGlobals->hmtx);524 error = __libc_Back_safesemMtxLock(mtx); 519 525 if (error) 520 526 return error; … … 602 608 } 603 609 done2: 604 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);610 __libc_Back_safesemMtxUnlock(mtx); 605 611 if (error) 606 612 rval = -error; … … 755 761 struct __libc_SysV_Shm *pGlobals = gpGlobals; 756 762 757 rval = __libc_Back_safesemMtxLock( pGlobals->hmtx);763 rval = __libc_Back_safesemMtxLock(mtx); 758 764 if (rval) 759 765 LIBCLOG_ERROR_RETURN_INT(rval); … … 778 784 rval = shmget_allocate_segment(key, size, mode); 779 785 done2: 780 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);786 __libc_Back_safesemMtxUnlock(mtx); 781 787 if (rval >= 0) 782 788 LIBCLOG_RETURN_INT(rval); … … 812 818 struct shmmap_state *shm = g_vm_shm; 813 819 if (shm) { 814 __libc_Back_safesemMtxLock( pGlobals->hmtx);820 __libc_Back_safesemMtxLock(mtx); 815 821 int c = shminfo.shmseg; 816 822 while (c-- > 0) … … 819 825 pGlobals->shmsegs[IPCID_TO_IX(shm->shmid)].shm_nattch++; 820 826 } 821 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);827 __libc_Back_safesemMtxUnlock(mtx); 822 828 } 823 829 } … … 839 845 if (pGlobals && !fDone) { 840 846 fDone = 1; 841 __libc_Back_safesemMtxLock( pGlobals->hmtx);847 __libc_Back_safesemMtxLock(mtx); 842 848 struct shmmap_state *shm = g_vm_shm; 843 849 if (shm) { … … 874 880 } 875 881 } 876 __libc_Back_safesemMtxUnlock( pGlobals->hmtx);882 __libc_Back_safesemMtxUnlock(mtx); 877 883 __atomic_decrement_u32(&pGlobals->cUsers); 878 884 gpGlobals = NULL; … … 937 943 /* init globals */ 938 944 bzero(pGlobals, cb); 939 pGlobals->uVersion = 1;945 pGlobals->uVersion = ; 940 946 pGlobals->cUsers = 0; 941 947 //pGlobals->shm_last_free = 0; … … 956 962 } 957 963 } 964 965 966 967 968 969 970 971 972 958 973 959 974 /* … … 963 978 { 964 979 /* create */ 965 rc = __libc_Back_safesemMtxCreate(&pGlobals-> hmtx, 1);980 rc = __libc_Back_safesemMtxCreate(&pGlobals->mtx, 1); 966 981 if (!rc) 967 rc = __libc_Back_safesemEvCreate(&pGlobals-> hevDaemon, 1);982 rc = __libc_Back_safesemEvCreate(&pGlobals->, 1); 968 983 } 969 984 else 970 985 { 971 986 /* open */ 972 rc = __libc_Back_safesemMtxOpen( pGlobals->hmtx);987 rc = __libc_Back_safesemMtxOpen(mtx); 973 988 if (!rc) 974 rc = __libc_Back_safesemEvOpen( pGlobals->hevDaemon);989 rc = __libc_Back_safesemEvOpen(evDaemon); 975 990 } 976 991 __atomic_increment_u32(&pGlobals->cUsers); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
