Implemented DosCloseMutexSem().
authorRyan C. Gordon <icculus@icculus.org>
Thu, 14 Sep 2017 23:51:04 -0400
changeset 75 d6286f62f959
parent 74 50eae5a78040
child 76 40c940ca1588
Implemented DosCloseMutexSem().

This gets PhysicsFS's test_physfs.exe to run (although it's still broken in
other ways).
native/doscalls.c
native/doscalls.h
--- a/native/doscalls.c	Tue Nov 01 21:38:48 2016 -0400
+++ b/native/doscalls.c	Thu Sep 14 23:51:04 2017 -0400
@@ -258,6 +258,7 @@
     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 @@
     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 ...
 
--- a/native/doscalls.h	Tue Nov 01 21:38:48 2016 -0400
+++ b/native/doscalls.h	Thu Sep 14 23:51:04 2017 -0400
@@ -446,6 +446,7 @@
 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
 }