2 Unix SMB/CIFS implementation.
4 trivial database library
6 Copyright (C) Anton Blanchard 2001
8 ** NOTE! The following LGPL license applies to the tdb
9 ** library. This does NOT imply that all of Samba is released
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #ifndef PPP_SPINLOCK_H
28 #define PPP_SPINLOCK_H
36 #define RWLOCK_BIAS 0x1000UL
39 #define MAX_BUSY_LOOPS 1000
40 #undef USE_SCHED_YIELD
43 /* We should make sure these are padded to a cache line */
44 #if defined(SPARC_SPINLOCKS)
45 typedef volatile char spinlock_t;
46 #elif defined(POWERPC_SPINLOCKS)
47 typedef volatile unsigned long spinlock_t;
48 #elif defined(INTEL_SPINLOCKS)
49 typedef volatile int spinlock_t;
50 #elif defined(MIPS_SPINLOCKS)
51 typedef volatile unsigned long spinlock_t;
53 #error Need to implement spinlock code in spinlock.h
61 int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type);
62 int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
63 int tdb_create_rwlocks(int fd, unsigned int hash_size);
64 int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
66 #define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t))
68 #else /* !USE_SPINLOCKS */
70 #define tdb_create_rwlocks(fd, hash_size) 0
71 #define tdb_spinlock(tdb, list, rw_type) (-1)
72 #define tdb_spinunlock(tdb, list, rw_type) (-1)
74 int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type);
75 int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
76 int tdb_create_rwlocks(int fd, unsigned int hash_size);
78 int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
79 #define TDB_SPINLOCK_SIZE(hash_size) 0
83 #endif // PPP_SPINLOCK_H