From ceb7900db777687d166bd0d7d937d5283d1480f6 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 14 Sep 2017 23:51:04 -0400 Subject: [PATCH] Implemented DosCloseMutexSem(). This gets PhysicsFS's test_physfs.exe to run (although it's still broken in other ways). --- native/doscalls.c | 18 ++++++++++++++++++ native/doscalls.h | 1 + 2 files changed, 19 insertions(+) diff --git a/native/doscalls.c b/native/doscalls.c index ce4b80e..65b303d 100644 --- a/native/doscalls.c +++ b/native/doscalls.c @@ -258,6 +258,7 @@ LX_NATIVE_MODULE_INIT({ if (!initDoscalls()) return NULL; }) LX_NATIVE_EXPORT(DosWaitEventSem, 329), LX_NATIVE_EXPORT(DosQueryEventSem, 330), LX_NATIVE_EXPORT(DosCreateMutexSem, 331), + LX_NATIVE_EXPORT(DosCloseMutexSem, 333), LX_NATIVE_EXPORT(DosRequestMutexSem, 334), LX_NATIVE_EXPORT(DosReleaseMutexSem, 335), LX_NATIVE_EXPORT(DosSubSetMem, 344), @@ -2995,5 +2996,22 @@ static APIRET16 bridge16to32_DosSemSet(uint8 *args) return DosSemSet(sem); } // bridge16to32_DosSemSet + +APIRET DosCloseMutexSem(HMTX hmtx) +{ + TRACE_NATIVE("DosCloseMutexSem(%u)", (uint) hmtx); + + if (hmtx) { + pthread_mutex_t *mutex = (pthread_mutex_t *) hmtx; + const int rc = pthread_mutex_destroy(mutex); + if (rc == 0) + return NO_ERROR; + else if (rc == EBUSY) + return ERROR_SEM_BUSY; + } + + return ERROR_INVALID_HANDLE; +} // DosCloseMutexSem + // end of doscalls.c ... diff --git a/native/doscalls.h b/native/doscalls.h index 6bbc1c4..6ebf8d9 100644 --- a/native/doscalls.h +++ b/native/doscalls.h @@ -446,6 +446,7 @@ APIRET OS2API DosQueryExtLIBPATH(PSZ pszExtLIBPATH, ULONG flags); APIRET OS2API DosSetMaxFH(ULONG cFH); APIRET OS2API DosQueryThreadContext(TID tid, ULONG level, PCONTEXTRECORD pcxt); ULONG OS2API DosSelToFlat(VOID); +APIRET OS2API DosCloseMutexSem(HMTX hmtx); #ifdef __cplusplus }