]> git.ozlabs.org Git - ppp.git/blob - pppd/spinlock.h
Makefile.am: Add explicit openssl directory to pppd include path
[ppp.git] / pppd / spinlock.h
1 #ifndef PPP_SPINLOCK_H
2 #define PPP_SPINLOCK_H
3
4 #include "pppdconf.h"
5
6 #include "tdb.h"
7
8 #ifdef USE_SPINLOCKS
9
10 #define RWLOCK_BIAS 0x1000UL
11
12 /* OS SPECIFIC */
13 #define MAX_BUSY_LOOPS 1000
14 #undef USE_SCHED_YIELD
15
16 /* ARCH SPECIFIC */
17 /* We should make sure these are padded to a cache line */
18 #if defined(SPARC_SPINLOCKS)
19 typedef volatile char spinlock_t;
20 #elif defined(POWERPC_SPINLOCKS)
21 typedef volatile unsigned long spinlock_t;
22 #elif defined(INTEL_SPINLOCKS)
23 typedef volatile int spinlock_t;
24 #elif defined(MIPS_SPINLOCKS)
25 typedef volatile unsigned long spinlock_t;
26 #else
27 #error Need to implement spinlock code in spinlock.h
28 #endif
29
30 typedef struct {
31         spinlock_t lock;
32         volatile int count;
33 } tdb_rwlock_t;
34
35 int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type);
36 int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
37 int tdb_create_rwlocks(int fd, unsigned int hash_size);
38 int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
39
40 #define TDB_SPINLOCK_SIZE(hash_size) (((hash_size) + 1) * sizeof(tdb_rwlock_t))
41
42 #else /* !USE_SPINLOCKS */
43 #if 0
44 #define tdb_create_rwlocks(fd, hash_size) 0
45 #define tdb_spinlock(tdb, list, rw_type) (-1)
46 #define tdb_spinunlock(tdb, list, rw_type) (-1)
47 #else
48 int tdb_spinlock(TDB_CONTEXT *tdb, int list, int rw_type);
49 int tdb_spinunlock(TDB_CONTEXT *tdb, int list, int rw_type);
50 int tdb_create_rwlocks(int fd, unsigned int hash_size);
51 #endif
52 int tdb_clear_spinlocks(TDB_CONTEXT *tdb);
53 #define TDB_SPINLOCK_SIZE(hash_size) 0
54
55 #endif
56
57 #endif // PPP_SPINLOCK_H