Fix File_Extractor semaphore for newer Mac OS X.
parent
17272ce43c
commit
b47fe40fcd
|
@ -61,7 +61,29 @@ WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled) { return Event_Crea
|
|||
WRes ManualResetEvent_CreateNotSignaled(CManualResetEvent *p) { return ManualResetEvent_Create(p, 0); }
|
||||
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p) { return AutoResetEvent_Create(p, 0); }
|
||||
|
||||
#ifdef __APPLE__
|
||||
WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount)
|
||||
{
|
||||
p->sem = dispatch_semaphore_create( initCount );
|
||||
p->count = initCount;
|
||||
p->maxCount = maxCount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCount)
|
||||
{
|
||||
if (previousCount)
|
||||
{
|
||||
*previousCount = p->count;
|
||||
}
|
||||
while (releaseCount--)
|
||||
{
|
||||
dispatch_semaphore_signal(p->sem);
|
||||
IncrementAtomic(&p->count);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount)
|
||||
{
|
||||
sem_init( &p->sem, 0, initCount );
|
||||
|
@ -81,6 +103,8 @@ static WRes Semaphore_Release(CSemaphore *p, LONG releaseCount, LONG *previousCo
|
|||
sem_post( &p->sem );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num)
|
||||
{ return Semaphore_Release(p, (LONG)num, NULL); }
|
||||
WRes Semaphore_Release1(CSemaphore *p) { return Semaphore_ReleaseN(p, 1); }
|
||||
|
|
|
@ -7,7 +7,13 @@
|
|||
#include "../Types.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <dispatch/dispatch.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -55,14 +61,23 @@ WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p);
|
|||
|
||||
typedef struct
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
dispatch_semaphore_t sem;
|
||||
SInt32 count;
|
||||
#else
|
||||
sem_t sem;
|
||||
#endif
|
||||
UInt32 maxCount;
|
||||
}
|
||||
CSemaphore;
|
||||
|
||||
#define Semaphore_Construct(p)
|
||||
#define Semaphore_Close(p)
|
||||
#ifdef __APPLE__
|
||||
#define Semaphore_Wait(p) { DecrementAtomic(&((p)->count)); dispatch_semaphore_wait((p)->sem, DISPATCH_TIME_FOREVER); }
|
||||
#else
|
||||
#define Semaphore_Wait(p) { sem_wait(&((p)->sem)); }
|
||||
#endif
|
||||
WRes Semaphore_Create(CSemaphore *p, UInt32 initCount, UInt32 maxCount);
|
||||
WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
|
||||
WRes Semaphore_Release1(CSemaphore *p);
|
||||
|
|
|
@ -147,8 +147,10 @@ static unrar_err_t next_( unrar_t* p, bool skipping_solid )
|
|||
if ( type != HEAD_FILE )
|
||||
{
|
||||
// Skip non-files
|
||||
#if 0
|
||||
if ( type != HEAD_SERVICE && type != HEAD_CRYPT && type != HEAD_MARK )
|
||||
debug_printf( "unrar: Skipping unknown block type: %X\n", (unsigned) type );
|
||||
#endif
|
||||
|
||||
update_solid_pos( p );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue