|
43 | 43 | *will "fail" if interrupted. Therefore TAS() should always be invoked |
44 | 44 | *in a retry loop, even if you are certain the lock is free. |
45 | 45 | * |
| 46 | + *ANOTHER CAUTION: be sure that TAS() and S_UNLOCK() represent sequence |
| 47 | + *points, ie, loads and stores of other values must not be moved across |
| 48 | + *a lock or unlock. In most cases it suffices to make the operation be |
| 49 | + *done through a "volatile" pointer. |
| 50 | + * |
46 | 51 | *On most supported platforms, TAS() uses a tas() function written |
47 | 52 | *in assembly language to execute a hardware atomic-test-and-set |
48 | 53 | *instruction. Equivalent OS-supplied mutex routines could be used too. |
|
58 | 63 | * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group |
59 | 64 | * Portions Copyright (c) 1994, Regents of the University of California |
60 | 65 | * |
61 | | - * $Id: s_lock.h,v 1.95 2001/09/29 04:02:26 tgl Exp $ |
| 66 | + * $Id: s_lock.h,v 1.96 2001/12/1102:58:49 tgl Exp $ |
62 | 67 | * |
63 | 68 | *------------------------------------------------------------------------- |
64 | 69 | */ |
@@ -306,7 +311,7 @@ tas(volatile slock_t *s_lock) |
306 | 311 | do \ |
307 | 312 | {\ |
308 | 313 | __asm__ __volatile__ ("mb \n"); \ |
309 | | -*(lock) = 0; \ |
| 314 | +*((volatile slock_t *) (lock)) = 0; \ |
310 | 315 | } while (0) |
311 | 316 |
|
312 | 317 | static __inline__int |
@@ -500,7 +505,7 @@ extern inttas_sema(volatile slock_t *lock); |
500 | 505 | #endif/* S_LOCK_FREE */ |
501 | 506 |
|
502 | 507 | #if !defined(S_UNLOCK) |
503 | | -#defineS_UNLOCK(lock)(*(lock) = 0) |
| 508 | +#defineS_UNLOCK(lock)(*((volatile slock_t *) (lock)) = 0) |
504 | 509 | #endif/* S_UNLOCK */ |
505 | 510 |
|
506 | 511 | #if !defined(S_INIT_LOCK) |
|