1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- The thread-safety code is now subject to conditional compilation.

Both the library and the user code need to be rebuilt with the
  preprocessor symbol __THREAD_SAFE defined to get thread-safe
  code.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14843 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2005-02-28 10:07:35 +00:00
parent f51faeb168
commit 1df294c07e
61 changed files with 488 additions and 319 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: locale_init_exit.c,v 1.6 2005-02-27 21:58:21 obarthel Exp $
* $Id: locale_init_exit.c,v 1.7 2005-02-28 10:07:30 obarthel Exp $
*
* :ts=4
*
@@ -41,10 +41,6 @@
/****************************************************************************/
static struct SignalSemaphore * locale_lock;
/****************************************************************************/
struct Library * NOCOMMON __LocaleBase;
/****************************************************************************/
@@ -188,6 +184,14 @@ __locale_init(void)
/****************************************************************************/
#if defined(__THREAD_SAFE)
/****************************************************************************/
static struct SignalSemaphore * locale_lock;
/****************************************************************************/
void
__locale_lock(void)
{
@@ -206,14 +210,22 @@ __locale_unlock(void)
/****************************************************************************/
#endif /* __THREAD_SAFE */
/****************************************************************************/
CLIB_DESTRUCTOR(__locale_exit_destructor)
{
ENTER();
__locale_exit();
FreeVec(locale_lock);
locale_lock = NULL;
#if defined(__THREAD_SAFE)
{
FreeVec(locale_lock);
locale_lock = NULL;
}
#endif /* __THREAD_SAFE */
LEAVE();
}
@@ -227,11 +239,15 @@ CLIB_CONSTRUCTOR(__locale_init_constructor)
ENTER();
locale_lock = AllocVec(sizeof(*locale_lock),MEMF_ANY|MEMF_PUBLIC);
if(locale_lock == NULL)
goto out;
#if defined(__THREAD_SAFE)
{
locale_lock = AllocVec(sizeof(*locale_lock),MEMF_ANY|MEMF_PUBLIC);
if(locale_lock == NULL)
goto out;
InitSemaphore(locale_lock);
InitSemaphore(locale_lock);
}
#endif /* __THREAD_SAFE */
for(i = 0 ; i < NUM_LOCALES ; i++)
strcpy(__locale_name_table[i],"C");