Skip to content

Commit

Permalink
Merge pull request #1470 from Fancy2209/SemaphoreStubs
Browse files Browse the repository at this point in the history
Implement Semaphore CarbonCore Stubs
  • Loading branch information
CuriousTommy authored Jan 14, 2024
2 parents c28d636 + 882fec3 commit 5ee6a68
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ enum {
};

typedef void* MPCriticalRegionID;
typedef struct OpaqueMPSemaphoreID *MPSemaphoreID;
typedef ItemCount MPSemaphoreCount;

Boolean _MPIsFullyInitialized();
OSStatus MPDelayUntil(AbsoluteTime* time);
Expand All @@ -23,7 +25,10 @@ OSStatus MPCreateCriticalRegion(MPCriticalRegionID* criticalRegion);
OSStatus MPDeleteCriticalRegion(MPCriticalRegionID criticalRegion);
OSStatus MPEnterCriticalRegion(MPCriticalRegionID criticalRegion, Duration timeout);
OSStatus MPExitCriticalRegion(MPCriticalRegionID criticalRegion);

OSStatus MPCreateSemaphore(MPSemaphoreCount maximumValue, MPSemaphoreCount initialValue, MPSemaphoreID *semaphore);
OSStatus MPDeleteSemaphore(MPSemaphoreID semaphore);
OSStatus MPSignalSemaphore(MPSemaphoreID semaphore);
OSStatus MPWaitOnSemaphore(MPSemaphoreID semaphore, Duration timeout);
// other functions are missing...

#ifdef __cplusplus
Expand Down
31 changes: 31 additions & 0 deletions src/frameworks/CoreServices/src/CarbonCore/Multiprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ along with Darling. If not, see <http://www.gnu.org/licenses/>.
#include <unistd.h>
#include <ctime>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <CarbonCore/MacErrors.h>

static int verbose = 0;
__attribute__((constructor)) static void initme(void) {
verbose = getenv("STUB_VERBOSE") != NULL;
}

Boolean _MPIsFullyInitialized()
{
return true;
Expand Down Expand Up @@ -109,3 +116,27 @@ OSStatus MPExitCriticalRegion(MPCriticalRegionID criticalRegion)
else
return paramErr;
}

OSStatus MPCreateSemaphore(MPSemaphoreCount maximumValue, MPSemaphoreCount initialValue, MPSemaphoreID *semaphore)
{
if (verbose) puts("STUB: MPCreateSemaphore called");
return noErr;
}

OSStatus MPDeleteSemaphore(MPSemaphoreID semaphore)
{
if (verbose) puts("STUB: MPDeleteSemaphore called");
return noErr;
}

OSStatus MPSignalSemaphore(MPSemaphoreID semaphore)
{
if (verbose) puts("STUB: MPSignalSemaphore called");
return noErr;
}

OSStatus MPWaitOnSemaphore(MPSemaphoreID semaphore, Duration timeout)
{
if (verbose) puts("STUB: MPWaitOnSemaphore called");
return noErr;
}

0 comments on commit 5ee6a68

Please sign in to comment.