[Libreoffice-commits] .: sal/osl

Stephan Bergmann sbergmann at kemper.freedesktop.org
Mon Feb 6 01:46:46 PST 2012


 sal/osl/unx/semaphor.c |  181 -------------------------------------------------
 1 file changed, 181 deletions(-)

New commits:
commit b61ddcbad769ee18f78ff4003d1cd6047e0a12fc
Author: François Tigeot <ftigeot at wolfpond.org>
Date:   Sun Feb 5 19:04:46 2012 +0100

    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

diff --git a/sal/osl/unx/semaphor.c b/sal/osl/unx/semaphor.c
index 7cb375f..b38113b 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: */


More information about the Libreoffice-commits mailing list