Skip to content

Commit 6016148

Browse files
committed
new alpha linux locking from Travis Melhiser <melhiser@viper.co.union.nc.us>
1 parent 06a7001 commit 6016148

File tree

1 file changed

+21
-51
lines changed

1 file changed

+21
-51
lines changed

src/include/storage/s_lock.h

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.11 1997/10/30 05:24:19 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.12 1997/11/07 21:35:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -24,10 +24,6 @@
2424
* ;
2525
* }
2626
*
27-
* In addition to modifying this file you will need to modify
28-
* the appropriate ...src/include/port/...h file to define
29-
* HAS_TEST_AND_SET for the appropriate circumstances.
30-
*
3127
* If this is not done, POSTGRES will default to using System V
3228
* semaphores (and take a large performance hit -- around 40% of
3329
* its time on a DS5000/240 is spent in semop(3)...).
@@ -232,31 +228,6 @@ tas_dummy()
232228

233229
#endif /* sun3 */
234230

235-
/*
236-
* M68000 ports under NetBSD.
237-
*
238-
* This version should also work on a sun3, but I can't test it.
239-
* Conversely the sun3 version should work under NetBSD/m68k, but
240-
* it doesn't.
241-
*/
242-
#if defined(__NetBSD__) && defined(__m68k__)
243-
244-
static void S_LOCK(char *lock)
245-
{
246-
asm("
247-
movel a6@(8),a0
248-
LOOP:
249-
tas a0@
250-
bmi LOOP
251-
");
252-
}
253-
254-
#define S_UNLOCK(lock) (*(lock) = 0)
255-
256-
#define S_INIT_LOCK(lock) S_UNLOCK(lock)
257-
258-
#endif /* M68000 && NetBSD */
259-
260231
/*
261232
* sparc machines
262233
*/
@@ -342,29 +313,28 @@ tas_dummy()
342313

343314
#if defined(__alpha__) && defined(linux)
344315

345-
#define S_LOCK(lock) do \
346-
{ \
347-
slock_t _res; \
348-
do \
349-
{ \
350-
__asm__(" ldq $0, %0 \n\
351-
bne $0, already_set \n\
352-
ldq_l $0, %0 \n\
353-
bne $0, already_set \n\
354-
or $31, 1, $0 \n\
355-
stq_c $0, %0 \n\
356-
beq $0, stqc_fail \n\
357-
success: bis $31, $31, %1 \n\
358-
mb \n\
359-
jmp $31, end \n\
360-
stqc_fail: or $31, 1, $0 \n\
361-
already_set: bis $0, $0, %1 \n\
362-
end: nop ": "=m"(*lock), "=r"(_res): :"0"); \
363-
} while (_res != 0); \
364-
} while (0)
316+
#define S_LOCK(lock) do { \
317+
slock_t _res; \
318+
do { \
319+
__asm__(" ldq $0, %0 \n\
320+
bne $0, already_set%= \n\
321+
ldq_l $0, %0 \n\
322+
bne $0, already_set%= \n\
323+
or $31, 1, $0 \n\
324+
stq_c $0, %0 \n\
325+
beq $0, stqc_fail%= \n\
326+
success%=: \n\
327+
bis $31, $31, %1 \n\
328+
mb \n\
329+
jmp $31, end%= \n\
330+
stqc_fail%=: or $31, 1, $0 \n\
331+
already_set%=: bis $0, $0, %1 \n\
332+
end%=: nop ": "=m"(*lock), "=r"(_res): :"0"); \
333+
} while (_res != 0); \
334+
} while (0)
365335

366336

367-
#define S_UNLOCK(lock) (__asm__("mb"), *(lock) = 0)
337+
#define S_UNLOCK(lock) ({ __asm__("mb \n"); *(lock) = 0; })
368338

369339
#define S_INIT_LOCK(lock) S_UNLOCK(lock)
370340

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy