1 | --- ../include/mutex.h.orig Sun May 6 21:19:20 2001 |
---|
2 | +++ ../include/mutex.h Sat Mar 6 10:31:57 2004 |
---|
3 | @@ -482,6 +482,43 @@ |
---|
4 | * 'set' mutexes have the value 1, like on Intel; the returned value from |
---|
5 | * MUTEX_SET() is 1 if the mutex previously had its low bit clear, 0 otherwise. |
---|
6 | */ |
---|
7 | + |
---|
8 | +/* |
---|
9 | + * Note from http://cvs.osafoundation.org/index.cgi/osaf/chandler/persistence/db/dbinc/mutex.h?rev=HEAD |
---|
10 | + * by Andi Vajda <andi at osafoundation dot org> |
---|
11 | + * |
---|
12 | + * Mutexes on Mac OS X work the same way as the standard PowerPC version, but |
---|
13 | + * the assembler syntax is subtly different -- the standard PowerPC version |
---|
14 | + * assembles but doesn't work correctly. This version makes (unnecessary?) |
---|
15 | + * use of a stupid linker trick: __db_mutex_tas_dummy is never called, but the |
---|
16 | + * ___db_mutex_set label is used as a function name. |
---|
17 | + */ |
---|
18 | + |
---|
19 | +#if defined(__APPLE__) && defined(__MACH__) && defined(__ppc__) |
---|
20 | +#warning "Using apple specific mutexes" |
---|
21 | +extern int __db_mutex_set __P((volatile tsl_t *)); |
---|
22 | +void |
---|
23 | +__db_mutex_tas_dummy() |
---|
24 | +{ |
---|
25 | + __asm__ __volatile__(" \n\ |
---|
26 | + .globl ___db_mutex_set \n\ |
---|
27 | +___db_mutex_set: \n\ |
---|
28 | + lwarx r5,0,r3 \n\ |
---|
29 | + cmpwi r5,0 \n\ |
---|
30 | + bne fail \n\ |
---|
31 | + addi r5,r5,1 \n\ |
---|
32 | + stwcx. r5,0,r3 \n\ |
---|
33 | + beq success \n\ |
---|
34 | +fail: \n\ |
---|
35 | + li r3,0 \n\ |
---|
36 | + blr \n\ |
---|
37 | +success: \n\ |
---|
38 | + li r3,1 \n\ |
---|
39 | + blr"); |
---|
40 | +} |
---|
41 | +#define MUTEX_SET(tsl) __db_mutex_set(tsl) |
---|
42 | +#else |
---|
43 | + |
---|
44 | #define MUTEX_SET(tsl) ({ \ |
---|
45 | int __one = 1; \ |
---|
46 | int __r; \ |
---|
47 | @@ -499,6 +536,7 @@ |
---|
48 | !(__r & 1); \ |
---|
49 | }) |
---|
50 | |
---|
51 | +#endif |
---|
52 | #define MUTEX_UNSET(tsl) (*(tsl) = 0) |
---|
53 | #define MUTEX_INIT(tsl) MUTEX_UNSET(tsl) |
---|
54 | #endif |
---|