lock.h | lock.h | |||
---|---|---|---|---|
/* Locking in multithreaded situations. | /* Locking in multithreaded situations. | |||
Copyright (C) 2005-2010 Free Software Foundation, Inc. | Copyright (C) 2005-2014 Free Software Foundation, Inc. | |||
This program is free software; you can redistribute it and/or modify | This program is free software; you can redistribute it and/or modify | |||
it under the terms of the GNU Lesser General Public License as published by | it under the terms of the GNU Lesser General Public License as published by | |||
the Free Software Foundation; either version 2, or (at your option) | the Free Software Foundation; either version 2, or (at your option) | |||
any later version. | any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU Lesser General Public License for more details. | GNU Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public License | You should have received a copy of the GNU Lesser General Public License | |||
along with this program; if not, write to the Free Software Foundation, | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | |||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | ||||
/* Written by Bruno Haible <bruno@clisp.org>, 2005. | /* Written by Bruno Haible <bruno@clisp.org>, 2005. | |||
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, | Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, | |||
gthr-win32.h. */ | gthr-win32.h. */ | |||
/* This file contains locking primitives for use with a given thread librar y. | /* This file contains locking primitives for use with a given thread librar y. | |||
It does not contain primitives for creating threads or for other | It does not contain primitives for creating threads or for other | |||
synchronization primitives. | synchronization primitives. | |||
Normal (non-recursive) locks: | Normal (non-recursive) locks: | |||
skipping to change at line 616 | skipping to change at line 615 | |||
extern int glthread_once_singlethreaded (gl_once_t *once_control); | extern int glthread_once_singlethreaded (gl_once_t *once_control); | |||
# ifdef __cplusplus | # ifdef __cplusplus | |||
} | } | |||
# endif | # endif | |||
#endif | #endif | |||
/* ======================================================================== = */ | /* ======================================================================== = */ | |||
#if USE_WIN32_THREADS | #if USE_WINDOWS_THREADS | |||
# define WIN32_LEAN_AND_MEAN /* avoid including junk */ | ||||
# include <windows.h> | # include <windows.h> | |||
# ifdef __cplusplus | # ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
# endif | # endif | |||
/* We can use CRITICAL_SECTION directly, rather than the Win32 Event, Mutex | /* We can use CRITICAL_SECTION directly, rather than the native Windows Eve | |||
, | nt, | |||
Semaphore types, because | Mutex, Semaphore types, because | |||
- we need only to synchronize inside a single process (address space), | - we need only to synchronize inside a single process (address space), | |||
not inter-process locking, | not inter-process locking, | |||
- we don't need to support trylock operations. (TryEnterCriticalSecti on | - we don't need to support trylock operations. (TryEnterCriticalSecti on | |||
does not work on Windows 95/98/ME. Packages that need trylock usual ly | does not work on Windows 95/98/ME. Packages that need trylock usual ly | |||
define their own mutex type.) */ | define their own mutex type.) */ | |||
/* There is no way to statically initialize a CRITICAL_SECTION. It needs | /* There is no way to statically initialize a CRITICAL_SECTION. It needs | |||
to be done lazily, once only. For this we need spinlocks. */ | to be done lazily, once only. For this we need spinlocks. */ | |||
typedef struct { volatile int done; volatile long started; } gl_spinlock_t; | typedef struct { volatile int done; volatile long started; } gl_spinlock_t; | |||
skipping to change at line 711 | skipping to change at line 711 | |||
# define glthread_rwlock_destroy(LOCK) \ | # define glthread_rwlock_destroy(LOCK) \ | |||
glthread_rwlock_destroy_func (LOCK) | glthread_rwlock_destroy_func (LOCK) | |||
extern void glthread_rwlock_init_func (gl_rwlock_t *lock); | extern void glthread_rwlock_init_func (gl_rwlock_t *lock); | |||
extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); | extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock); | |||
extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); | extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock); | |||
extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); | extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock); | |||
extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); | extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock); | |||
/* --------------------- gl_recursive_lock_t datatype --------------------- */ | /* --------------------- gl_recursive_lock_t datatype --------------------- */ | |||
/* The Win32 documentation says that CRITICAL_SECTION already implements a | /* The native Windows documentation says that CRITICAL_SECTION already | |||
recursive lock. But we need not rely on it: It's easy to implement a | implements a recursive lock. But we need not rely on it: It's easy to | |||
recursive lock without this assumption. */ | implement a recursive lock without this assumption. */ | |||
typedef struct | typedef struct | |||
{ | { | |||
gl_spinlock_t guard; /* protects the initialization */ | gl_spinlock_t guard; /* protects the initialization */ | |||
DWORD owner; | DWORD owner; | |||
unsigned long depth; | unsigned long depth; | |||
CRITICAL_SECTION lock; | CRITICAL_SECTION lock; | |||
} | } | |||
gl_recursive_lock_t; | gl_recursive_lock_t; | |||
# define gl_recursive_lock_define(STORAGECLASS, NAME) \ | # define gl_recursive_lock_define(STORAGECLASS, NAME) \ | |||
skipping to change at line 765 | skipping to change at line 765 | |||
extern void glthread_once_func (gl_once_t *once_control, void (*initfunctio n) (void)); | extern void glthread_once_func (gl_once_t *once_control, void (*initfunctio n) (void)); | |||
# ifdef __cplusplus | # ifdef __cplusplus | |||
} | } | |||
# endif | # endif | |||
#endif | #endif | |||
/* ======================================================================== = */ | /* ======================================================================== = */ | |||
#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WI N32_THREADS) | #if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WI NDOWS_THREADS) | |||
/* Provide dummy implementation if threads are not supported. */ | /* Provide dummy implementation if threads are not supported. */ | |||
/* -------------------------- gl_lock_t datatype -------------------------- */ | /* -------------------------- gl_lock_t datatype -------------------------- */ | |||
typedef int gl_lock_t; | typedef int gl_lock_t; | |||
# define gl_lock_define(STORAGECLASS, NAME) | # define gl_lock_define(STORAGECLASS, NAME) | |||
# define gl_lock_define_initialized(STORAGECLASS, NAME) | # define gl_lock_define_initialized(STORAGECLASS, NAME) | |||
# define glthread_lock_init(NAME) 0 | # define glthread_lock_init(NAME) 0 | |||
# define glthread_lock_lock(NAME) 0 | # define glthread_lock_lock(NAME) 0 | |||
End of changes. 7 change blocks. | ||||
11 lines changed or deleted | 11 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |