diff options
author | Thorsten Behrens <tbehrens@suse.com> | 2012-12-04 12:36:09 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2012-12-04 12:38:09 +0100 |
commit | d911673a64250ece50f6ca5578385adabcae5e5d (patch) | |
tree | 268d926b6fe13ea891b0a0f61f1bbc178e2f52ae /sal/osl | |
parent | 2d655683dda815021011d9dd135a263f0003bed5 (diff) |
API CHANGE: remove long-deprecated Semaphore & related stuff.
osl::semaphore was not portable & thusly long-deprecated. Also
killing further unused clients of that code in salhelper.
Change-Id: Ie1c1924e06e8ce3be33fd1dc2c6933f2de8b5217
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/unx/semaphor.c | 126 | ||||
-rw-r--r-- | sal/osl/unx/system.c | 69 | ||||
-rw-r--r-- | sal/osl/unx/system.h | 25 | ||||
-rw-r--r-- | sal/osl/w32/pipe.c | 1 | ||||
-rw-r--r-- | sal/osl/w32/semaphor.c | 104 |
5 files changed, 0 insertions, 325 deletions
diff --git a/sal/osl/unx/semaphor.c b/sal/osl/unx/semaphor.c deleted file mode 100644 index bff843f29725..000000000000 --- a/sal/osl/unx/semaphor.c +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "system.h" - -#include <osl/semaphor.h> -#include <osl/diagnose.h> - -/* This is the (default) POSIX thread-local semaphore variant */ - -/* - Implemetation notes: - The void* represented by oslSemaphore is used - as a pointer to an sem_t struct -*/ - -/*****************************************************************************/ -/* osl_createSemaphore */ -/*****************************************************************************/ - -oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount) -{ - int ret = 0; - oslSemaphore Semaphore; - - Semaphore= malloc(sizeof(sem_t)); - - OSL_ASSERT(Semaphore); /* ptr valid? */ - - if ( Semaphore == 0 ) - { - return 0; - } - - /* unnamed semaphore, not shared between processes */ - - ret= sem_init((sem_t*)Semaphore, 0, initialCount); - - /* create failed? */ - if (ret != 0) - { - OSL_TRACE("osl_createSemaphore failed. Errno: %d; %s\n", - errno, - strerror(errno)); - - free(Semaphore); - Semaphore = NULL; - } - - return Semaphore; -} - -/*****************************************************************************/ -/* osl_destroySemaphore */ -/*****************************************************************************/ -void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore) -{ - if(Semaphore) /* ptr valid? */ - { - sem_destroy((sem_t*)Semaphore); - free(Semaphore); - } -} - -/*****************************************************************************/ -/* osl_acquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_wait((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_tryToAcquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_trywait((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/*****************************************************************************/ -/* osl_releaseSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) { - - OSL_ASSERT(Semaphore != 0); /* abort in debug mode */ - - if (Semaphore != 0) /* be tolerant in release mode */ - { - return (sem_post((sem_t*)Semaphore) == 0); - } - - return sal_False; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c index fca765566785..8c8280dff70c 100644 --- a/sal/osl/unx/system.c +++ b/sal/osl/unx/system.c @@ -207,75 +207,6 @@ int macxp_resolveAlias(char *path, int buflen) #endif /* NO_PTHREAD_RTL */ -#ifdef NO_PTHREAD_SEMAPHORES -int sem_init(sem_t* sem, int pshared, unsigned int value) -{ - (void)pshared; - pthread_mutex_init(&sem->mutex, PTHREAD_MUTEXATTR_DEFAULT); - pthread_cond_init(&sem->increased, PTHREAD_CONDATTR_DEFAULT); - - sem->value = (int)value; - return 0; -} - -int sem_destroy(sem_t* sem) -{ - pthread_mutex_destroy(&sem->mutex); - pthread_cond_destroy(&sem->increased); - sem->value = 0; - return 0; -} - -int sem_wait(sem_t* sem) -{ - pthread_mutex_lock(&sem->mutex); - - while (sem->value <= 0) - { - pthread_cond_wait(&sem->increased, &sem->mutex); - } - - sem->value--; - pthread_mutex_unlock(&sem->mutex); - - return 0; -} - -int sem_trywait(sem_t* sem) -{ - int result = 0; - - pthread_mutex_lock(&sem->mutex); - - if (sem->value > 0) - { - sem->value--; - } - else - { - errno = EAGAIN; - result = -1; - } - - pthread_mutex_unlock(&sem->mutex); - - return result; -} - -int sem_post(sem_t* sem) -{ - pthread_mutex_lock(&sem->mutex); - - sem->value++; - - pthread_mutex_unlock(&sem->mutex); - - pthread_cond_signal(&sem->increased); - - return 0; -} -#endif - #if defined(FREEBSD) char *fcvt(double value, int ndigit, int *decpt, int *sign) { diff --git a/sal/osl/unx/system.h b/sal/osl/unx/system.h index 8d7e734b6c6b..057257e691f6 100644 --- a/sal/osl/unx/system.h +++ b/sal/osl/unx/system.h @@ -73,7 +73,6 @@ # include <dlfcn.h> # include <endian.h> # include <sys/time.h> -# include <semaphore.h> # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LITTLE_ENDIAN # elif __BYTE_ORDER == __BIG_ENDIAN @@ -103,7 +102,6 @@ # include <dlfcn.h> # include <endian.h> # include <sys/time.h> -# include <semaphore.h> # define IORESOURCE_TRANSFER_BSD # define IOCHANNEL_TRANSFER_BSD_RENO # define pthread_testcancel() @@ -118,7 +116,6 @@ # define ETIME ETIMEDOUT # include <pthread.h> # include <sys/sem.h> -# include <semaphore.h> # include <dlfcn.h> # include <sys/filio.h> # include <sys/ioctl.h> @@ -148,7 +145,6 @@ # define ETIME ETIMEDOUT # include <pthread.h> # include <sys/sem.h> -# include <semaphore.h> # include <dlfcn.h> # include <sys/filio.h> # include <sys/ioctl.h> @@ -173,7 +169,6 @@ # define ETIME ETIMEDOUT # include <pthread.h> # include <sys/sem.h> -# include <semaphore.h> # include <dlfcn.h> # include <sys/filio.h> # include <sys/ioctl.h> @@ -208,7 +203,6 @@ # endif # define SLEEP_TIMESPEC(timespec) nsleep(×pec, 0) # define LIBPATH "LIBPATH" -# define NO_PTHREAD_SEMAPHORES #endif #ifdef SOLARIS @@ -216,7 +210,6 @@ # include <sys/un.h> # include <stropts.h> # include <pthread.h> -# include <semaphore.h> # include <netinet/tcp.h> # include <sys/filio.h> # include <dlfcn.h> @@ -243,7 +236,6 @@ # include <netinet/tcp.h> # include <machine/endian.h> # include <sys/time.h> -# include <sys/semaphore.h> /* fixme are premac and postmac still needed here? */ # include <premac.h> # include <mach-o/dyld.h> @@ -283,7 +275,6 @@ int macxp_resolveAlias(char *path, int buflen); # include <netinet/tcp.h> # include <machine/endian.h> # include <sys/time.h> -# include <sys/semaphore.h> # if BYTE_ORDER == LITTLE_ENDIAN # ifndef _LITTLE_ENDIAN # define _LITTLE_ENDIAN @@ -403,22 +394,6 @@ typedef struct sockaddr_ipx { /* END HACK */ -#ifdef NO_PTHREAD_SEMAPHORES - -typedef struct -{ - pthread_mutex_t mutex; - pthread_cond_t increased; - int value; -} sem_t; -extern int sem_init(sem_t* sem, int pshared, unsigned int value); -extern int sem_destroy(sem_t* sem); -extern int sem_wait(sem_t* sem); -extern int sem_trywait(sem_t* sem); -extern int sem_post(sem_t* sem); - -#endif - #ifdef NO_PTHREAD_RTL #if !defined FREEBSD || (__FreeBSD_version < 500112) #if !defined NETBSD diff --git a/sal/osl/w32/pipe.c b/sal/osl/w32/pipe.c index 62125b9ddb81..149de07f73ce 100644 --- a/sal/osl/w32/pipe.c +++ b/sal/osl/w32/pipe.c @@ -25,7 +25,6 @@ #include <osl/diagnose.h> #include <osl/thread.h> #include <osl/mutex.h> -#include <osl/semaphor.h> #include <osl/conditn.h> #include <osl/interlck.h> #include <osl/process.h> diff --git a/sal/osl/w32/semaphor.c b/sal/osl/w32/semaphor.c deleted file mode 100644 index de3828b31e8f..000000000000 --- a/sal/osl/w32/semaphor.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "system.h" - -#include <osl/diagnose.h> -#include <osl/semaphor.h> - -/* - Implemetation notes: - The void* represented by oslSemaphore is used - to store a WIN32 HANDLE. -*/ - - -/*****************************************************************************/ -/* osl_createSemaphore */ -/*****************************************************************************/ -oslSemaphore SAL_CALL osl_createSemaphore(sal_uInt32 initialCount) -{ - oslSemaphore Semaphore; - - Semaphore= CreateSemaphore(0, initialCount, INT_MAX, 0); - - /* create failed? */ - if((HANDLE)Semaphore == INVALID_HANDLE_VALUE) - { - Semaphore= 0; - } - - return Semaphore; -} - -/*****************************************************************************/ -/* osl_destroySemaphore */ -/*****************************************************************************/ -void SAL_CALL osl_destroySemaphore(oslSemaphore Semaphore) -{ - - - if(Semaphore != 0) - { - CloseHandle((HANDLE)Semaphore); - } - -} - -/*****************************************************************************/ -/* osl_acquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_acquireSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - - switch ( WaitForSingleObject( (HANDLE)Semaphore, INFINITE ) ) - { - case WAIT_OBJECT_0: - return sal_True; - - default: - return (sal_False); - } -} - -/*****************************************************************************/ -/* osl_tryToAcquireSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_tryToAcquireSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - return (sal_Bool)(WaitForSingleObject((HANDLE)Semaphore, 0) == WAIT_OBJECT_0); -} - - -/*****************************************************************************/ -/* osl_releaseSemaphore */ -/*****************************************************************************/ -sal_Bool SAL_CALL osl_releaseSemaphore(oslSemaphore Semaphore) -{ - OSL_ASSERT(Semaphore != 0); - - /* increase count by one, not interested in previous count */ - return (sal_Bool)(ReleaseSemaphore((HANDLE)Semaphore, 1, NULL) != FALSE); -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |