diff options
author | François Tigeot <ftigeot@wolfpond.org> | 2012-02-05 19:04:46 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-02-06 10:45:06 +0100 |
commit | b61ddcbad769ee18f78ff4003d1cd6047e0a12fc (patch) | |
tree | ddb5568dad5ada315b26ffc2b0ae1aa5bda46951 /sal | |
parent | 664b22c56b7e37006e07ad194fe2ab98980cb8f0 (diff) |
OSL_USE_SYS_V_SEMAPHORE is never defined
* Remove the System V semaphore implementation variant
* POSIX thread-local code was always used for synchronization
primitives anyway
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/semaphor.c | 181 |
1 files changed, 0 insertions, 181 deletions
diff --git a/sal/osl/unx/semaphor.c b/sal/osl/unx/semaphor.c index 7cb375f49c43..b38113b34fd4 100644 --- a/sal/osl/unx/semaphor.c +++ b/sal/osl/unx/semaphor.c @@ -32,8 +32,6 @@ #include <osl/semaphor.h> #include <osl/diagnose.h> -#ifndef OSL_USE_SYS_V_SEMAPHORE - /* This is the (default) POSIX thread-local semaphore variant */ /* @@ -134,183 +132,4 @@ sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) { return sal_False; } -#else /* OSL_USE_SYS_V_SEMAPHORE */ - -/*******************************************************************************/ - -/* This is the SYS V private semaphore variant */ - -/* - Implemetation notes: - The void* represented by oslSemaphore is used - as a pointer to an osl_TSemImpl struct -*/ - - -#if defined(NETBSD) -union semun { - int val; /* value for SETVAL */ - struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ - u_short *array; /* array for GETALL & SETALL */ -}; -#endif - -typedef struct _osl_TSemImpl -{ - int m_Id; - -} osl_TSemImpl; - -/*****************************************************************************/ -/* osl_createSemaphore */ -/*****************************************************************************/ -oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount) -{ - union semun arg; - - oslSemaphore Semaphore; - osl_TSemImpl* pSem; - - Semaphore= malloc(sizeof(osl_TSemImpl)); - OSL_POSTCOND(Semaphore, "malloc failed\n"); /* ptr valid? */ - - pSem= (osl_TSemImpl*)Semaphore; - - - /* unnamed (private) semaphore */ - - pSem->m_Id= semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); - - - /* create failed? */ - if (pSem->m_Id < 0) - { - OSL_TRACE("osl_createSemaphore failed (semget). Errno: %d; %s\n", - errno, - strerror(errno)); - - free(Semaphore); - return 0; - } - - /* set initial count */ - - arg.val= initialCount; - - if(semctl(pSem->m_Id, 0, SETVAL, arg) < 0) - { - OSL_TRACE("osl_createSemaphore failed (semctl(SETVAL)). Errno: %d; %s\n", - errno, - strerror(errno)); - - if(semctl(pSem->m_Id, 0, IPC_RMID, arg) < 0) - { - OSL_TRACE("semctl(IPC_RMID) failed. Errno: %d; %s", errno, strerror(errno)); - } - - free(Semaphore); - return 0; - } - - - return Semaphore; -} - -/*****************************************************************************/ -/* osl_destroySemaphore */ -/*****************************************************************************/ -void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore) { - - if(Semaphore) /* ptr valid? */ - { - union semun arg; - - osl_TSemImpl* pSem= (osl_TSemImpl*)Semaphore; - - if(semctl(pSem->m_Id, 0, IPC_RMID, arg) < 0) - - { - OSL_TRACE("osl_destroySemaphore failed. (semctl(IPC_RMID)). Errno: %d; %s\n", - errno, - strerror(errno)); - } - - free(Semaphore); - } -} - -/*****************************************************************************/ -/* osl_acquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore) { - - /* abort in debug mode */ - OSL_PRECOND(Semaphore != 0, "Semaphore not created\n"); - - - if (Semaphore != 0) /* be tolerant in release mode */ - { - struct sembuf op; - osl_TSemImpl* pSem= (osl_TSemImpl*)Semaphore; - - op.sem_num= 0; - op.sem_op= -1; - op.sem_flg= SEM_UNDO; - - return semop(pSem->m_Id, &op, 1) >= 0; - - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_tryToAcquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore) { - - /* abort in debug mode */ - OSL_PRECOND(Semaphore != 0, "Semaphore not created\n"); - - if (Semaphore != 0) /* be tolerant in release mode */ - { - struct sembuf op; - osl_TSemImpl* pSem= (osl_TSemImpl*)Semaphore; - - op.sem_num= 0; - op.sem_op= -1; - op.sem_flg= SEM_UNDO | IPC_NOWAIT; - - return semop(pSem->m_Id, &op, 1) >= 0; - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_releaseSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) -{ - - /* abort in debug mode */ - OSL_PRECOND(Semaphore != 0, "Semaphore not created\n"); - - if (Semaphore != 0) /* be tolerant in release mode */ - { - struct sembuf op; - osl_TSemImpl* pSem= (osl_TSemImpl*)Semaphore; - - op.sem_num= 0; - op.sem_op= 1; - op.sem_flg= SEM_UNDO; - - return semop(pSem->m_Id, &op, 1) >= 0; - } - - return sal_False; -} - -#endif /* OSL_USE_SYS_V_SEMAPHORE */ - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |