diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-02-23 12:44:21 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:52:05 -0500 |
commit | d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a (patch) | |
tree | 2c567a9bf3c8f28bc19c546dd0cfad2aa0dc816e /source4/lib | |
parent | 559ba6f12aacf3639ad6268490bc8ed33b1fb803 (diff) | |
download | samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.tar.gz samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.tar.bz2 samba-d3bcaf66a8568fc19a3013f9dc974fb08ee3a39a.zip |
r13654: Move some more stuff out of include/
(This used to be commit 2ec7bba03a2edf713004941e9ed74798f5cf8d32)
Diffstat (limited to 'source4/lib')
-rw-r--r-- | source4/lib/mutex.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/source4/lib/mutex.h b/source4/lib/mutex.h new file mode 100644 index 0000000000..bb26c84f5d --- /dev/null +++ b/source4/lib/mutex.h @@ -0,0 +1,69 @@ +#ifndef _MUTEX_H_ +#define _MUTEX_H_ +/* + Unix SMB/CIFS implementation. + Samba mutex functions + Copyright (C) Andrew Tridgell 2003 + Copyright (C) James J Myers 2003 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* To add a new read/write lock, add it to enum rwlock_id + */ +enum rwlock_id { RWLOCK_SMBD, /* global smbd lock */ + + RWLOCK_MAX /* this MUST be kept last */ +}; + +#define MUTEX_LOCK_BY_ID(mutex_index) smb_mutex_lock_by_id(mutex_index, #mutex_index) +#define MUTEX_UNLOCK_BY_ID(mutex_index) smb_mutex_unlock_by_id(mutex_index, #mutex_index) +#define MUTEX_INIT(mutex, name) smb_mutex_init(mutex, #name) +#define MUTEX_DESTROY(mutex, name) smb_mutex_destroy(mutex, #name) +#define MUTEX_LOCK(mutex, name) smb_mutex_lock(mutex, #name) +#define MUTEX_UNLOCK(mutex, name) smb_mutex_unlock(mutex, #name) + +#define RWLOCK_INIT(rwlock, name) smb_rwlock_init(rwlock, #name) +#define RWLOCK_DESTROY(rwlock, name) smb_rwlock_destroy(rwlock, #name) +#define RWLOCK_LOCK_WRITE(rwlock, name) smb_rwlock_lock_write(rwlock, #name) +#define RWLOCK_LOCK_READ(rwlock, name) smb_rwlock_lock_read(rwlock, #name) +#define RWLOCK_UNLOCK(rwlock, name) smb_rwlock_unlock(rwlock, #name) + + + +/* this null typedef ensures we get the types right and avoids the + pitfalls of void* */ +typedef struct smb_mutex { + void *mutex; +} smb_mutex_t; +typedef struct { + void *rwlock; +} smb_rwlock_t; + +/* the mutex model operations structure - contains function pointers to + the model-specific implementations of each operation */ +struct mutex_ops { + int (*mutex_init)(smb_mutex_t *mutex, const char *name); + int (*mutex_lock)(smb_mutex_t *mutex, const char *name); + int (*mutex_unlock)(smb_mutex_t *mutex, const char *name); + int (*mutex_destroy)(smb_mutex_t *mutex, const char *name); + int (*rwlock_init)(smb_rwlock_t *rwlock, const char *name); + int (*rwlock_lock_write)(smb_rwlock_t *rwlock, const char *name); + int (*rwlock_lock_read)(smb_rwlock_t *rwlock, const char *name); + int (*rwlock_unlock)(smb_rwlock_t *rwlock, const char *name); + int (*rwlock_destroy)(smb_rwlock_t *rwlock, const char *name); +}; + +#endif /* endif _MUTEX_H_ */ |