summaryrefslogtreecommitdiff
path: root/lib/libpthread/arch
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2008-02-10 18:50:54 +0000
committerad <ad@NetBSD.org>2008-02-10 18:50:54 +0000
commita67e1e347544393a4828fa21d5cf6f670590fd76 (patch)
treec200cca9ccceecd65fe50f0b925bb5ad7831fa14 /lib/libpthread/arch
parent749400b7044c2a3ca87455ac26cc1184b678a353 (diff)
- Remove libpthread's atomic ops.
- Remove the old spinlock-based mutex and rwlock implementations. - Use the atomic ops from libc.
Diffstat (limited to 'lib/libpthread/arch')
-rw-r--r--lib/libpthread/arch/hppa/pthread_md.h5
-rw-r--r--lib/libpthread/arch/i386/_context_u.S30
-rw-r--r--lib/libpthread/arch/i386/pthread_md.h34
-rw-r--r--lib/libpthread/arch/m68k/pthread_md.h5
-rw-r--r--lib/libpthread/arch/sh3/pthread_md.h5
-rw-r--r--lib/libpthread/arch/sparc/pthread_md.h5
-rw-r--r--lib/libpthread/arch/vax/pthread_md.h5
-rw-r--r--lib/libpthread/arch/x86_64/_context_u.S28
-rw-r--r--lib/libpthread/arch/x86_64/pthread_md.h32
9 files changed, 31 insertions, 118 deletions
diff --git a/lib/libpthread/arch/hppa/pthread_md.h b/lib/libpthread/arch/hppa/pthread_md.h
index 5e106df0621..bd7371cf486 100644
--- a/lib/libpthread/arch/hppa/pthread_md.h
+++ b/lib/libpthread/arch/hppa/pthread_md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.4 2007/09/24 12:19:39 skrll Exp $ */
+/* $NetBSD: pthread_md.h,v 1.5 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -98,4 +98,7 @@ do { \
(uc)->uc_flags = ((uc)->uc_flags | _UC_FPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)
+/* Don't need additional memory barriers. */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
#endif /* !_LIB_PTHREAD_HPPA_MD_H */
diff --git a/lib/libpthread/arch/i386/_context_u.S b/lib/libpthread/arch/i386/_context_u.S
index 6720bd67402..8d9cba7737a 100644
--- a/lib/libpthread/arch/i386/_context_u.S
+++ b/lib/libpthread/arch/i386/_context_u.S
@@ -1,4 +1,4 @@
-/* $NetBSD: _context_u.S,v 1.7 2007/11/13 17:20:09 ad Exp $ */
+/* $NetBSD: _context_u.S,v 1.8 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -100,31 +100,3 @@ STUB(_swapcontext_u_xmm)
movl %eax, (UC_REGS + _REG_UESP * 4)(%ecx)
movl 8(%esp), %ecx
SETC
-
-STUB(pthread__atomic_swap_ptr)
- movl 4(%esp), %ecx
- movl 8(%esp), %eax
- xchgl %eax, (%ecx)
- ret
-
-STUB(pthread__atomic_or_ulong)
- movl 4(%esp), %ecx
- movl 8(%esp), %eax
- lock
- orl %eax, (%ecx)
- ret
-
-STUB(pthread__membar_full)
- lock
- addl $0, -4(%esp)
- ret
-
-STUB(pthread__membar_producer)
- /* A store is enough */
- addl $0, -4(%esp)
- ret
-
-STUB(pthread__membar_consumer)
- lock
- addl $0, -4(%esp)
- ret
diff --git a/lib/libpthread/arch/i386/pthread_md.h b/lib/libpthread/arch/i386/pthread_md.h
index c99ae7f412e..6128b557c18 100644
--- a/lib/libpthread/arch/i386/pthread_md.h
+++ b/lib/libpthread/arch/i386/pthread_md.h
@@ -1,7 +1,7 @@
-/* $NetBSD: pthread_md.h,v 1.11 2007/11/13 17:20:10 ad Exp $ */
+/* $NetBSD: pthread_md.h,v 1.12 2008/02/10 18:50:55 ad Exp $ */
/*-
- * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2001, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -182,9 +182,11 @@ pthread__sp(void)
} while (/*CONSTCOND*/0)
#define pthread__smt_pause() __asm __volatile("rep; nop" ::: "memory")
-#define PTHREAD__HAVE_ATOMIC
/* #define PTHREAD__HAVE_THREADREG */
+/* Don't need additional memory barriers. */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
void pthread__threadreg_set(pthread_t);
static inline pthread_t
@@ -199,30 +201,4 @@ pthread__threadreg_get(void)
return self;
}
-static inline void *
-pthread__atomic_cas_ptr(volatile void *ptr, const void *old, const void *new)
-{
- volatile uintptr_t *cast = ptr;
- void *ret;
-
- __asm __volatile ("lock; cmpxchgl %2, %1"
- : "=a" (ret), "=m" (*cast)
- : "r" (new), "m" (*cast), "0" (old));
-
- return ret;
-}
-
-static inline void *
-pthread__atomic_cas_ptr_ni(volatile void *ptr, const void *old, const void *new)
-{
- volatile uintptr_t *cast = ptr;
- void *ret;
-
- __asm __volatile ("cmpxchgl %2, %1"
- : "=a" (ret), "=m" (*cast)
- : "r" (new), "m" (*cast), "0" (old));
-
- return ret;
-}
-
#endif /* _LIB_PTHREAD_I386_MD_H */
diff --git a/lib/libpthread/arch/m68k/pthread_md.h b/lib/libpthread/arch/m68k/pthread_md.h
index 3bcfe9b9954..4f873a1ff85 100644
--- a/lib/libpthread/arch/m68k/pthread_md.h
+++ b/lib/libpthread/arch/m68k/pthread_md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.4 2005/12/24 21:11:16 perry Exp $ */
+/* $NetBSD: pthread_md.h,v 1.5 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -99,4 +99,7 @@ pthread__sp(void)
(uc)->uc_flags = ((uc)->uc_flags | _UC_FPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)
+/* m68k will not go SMP */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
#endif /* _LIB_PTHREAD_M68K_MD_H */
diff --git a/lib/libpthread/arch/sh3/pthread_md.h b/lib/libpthread/arch/sh3/pthread_md.h
index 8f5db27e859..59933c3f66d 100644
--- a/lib/libpthread/arch/sh3/pthread_md.h
+++ b/lib/libpthread/arch/sh3/pthread_md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.3 2005/12/24 21:11:17 perry Exp $ */
+/* $NetBSD: pthread_md.h,v 1.4 2008/02/10 18:50:55 ad Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
@@ -90,4 +90,7 @@ pthread__sp(void)
#define PTHREAD_FPREG_TO_UCONTEXT(uc, freg)
#endif
+/* sh3 will not go SMP */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
#endif /* _LIB_PTHREAD_SH3_MD_H */
diff --git a/lib/libpthread/arch/sparc/pthread_md.h b/lib/libpthread/arch/sparc/pthread_md.h
index af2210747a9..4d105d7e698 100644
--- a/lib/libpthread/arch/sparc/pthread_md.h
+++ b/lib/libpthread/arch/sparc/pthread_md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.4 2005/12/24 21:11:17 perry Exp $ */
+/* $NetBSD: pthread_md.h,v 1.5 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -92,4 +92,7 @@ pthread__sp(void)
(uc)->uc_flags = ((uc)->uc_flags | _UC_FPU) & ~_UC_USER; \
} while (/*CONSTCOND*/0)
+/* Don't need additional memory barriers. */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
#endif /* _LIB_PTHREAD_SPARC_MD_H */
diff --git a/lib/libpthread/arch/vax/pthread_md.h b/lib/libpthread/arch/vax/pthread_md.h
index 7ffe5220a4a..e2ed4cca1d3 100644
--- a/lib/libpthread/arch/vax/pthread_md.h
+++ b/lib/libpthread/arch/vax/pthread_md.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_md.h,v 1.4 2005/12/24 21:11:17 perry Exp $ */
+/* $NetBSD: pthread_md.h,v 1.5 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -85,4 +85,7 @@ pthread__sp(void)
#define PTHREAD_FPREG_TO_UCONTEXT(uc, reg) do { \
} while (/*CONSTCOND*/0)
+/* Don't need additional memory barriers. */
+#define PTHREAD__ATOMIC_IS_MEMBAR
+
#endif /* _LIB_PTHREAD_VAX_MD_H */
diff --git a/lib/libpthread/arch/x86_64/_context_u.S b/lib/libpthread/arch/x86_64/_context_u.S
index 8719b4fff5e..b9ec75ccf4e 100644
--- a/lib/libpthread/arch/x86_64/_context_u.S
+++ b/lib/libpthread/arch/x86_64/_context_u.S
@@ -1,4 +1,4 @@
-/* $NetBSD: _context_u.S,v 1.9 2007/11/13 17:20:10 ad Exp $ */
+/* $NetBSD: _context_u.S,v 1.10 2008/02/10 18:50:55 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -137,29 +137,3 @@ STUB(_swapcontext_u)
movq %rax, (UC_REGS + _REG_URSP * 8)(%rdi)
movq %rsi, %rdi
SETC
-
-STUB(pthread__atomic_swap_ptr)
- movq %rsi, %rax
- lock
- xchgq %rax, (%rdi)
- ret
-
-STUB(pthread__atomic_or_ulong)
- lock
- orq %rsi, (%rdi)
- ret
-
-STUB(pthread__membar_full)
- lock
- addq $0, -8(%rsp)
- ret
-
-STUB(pthread__membar_producer)
- /* A store is enough */
- movq $0, -8(%rsp)
- ret
-
-STUB(pthread__membar_consumer)
- lock
- addq $0, -8(%rsp)
- ret
diff --git a/lib/libpthread/arch/x86_64/pthread_md.h b/lib/libpthread/arch/x86_64/pthread_md.h
index 7f04edfd85a..6db24f0faf0 100644
--- a/lib/libpthread/arch/x86_64/pthread_md.h
+++ b/lib/libpthread/arch/x86_64/pthread_md.h
@@ -1,7 +1,7 @@
-/* $NetBSD: pthread_md.h,v 1.7 2007/11/13 17:20:10 ad Exp $ */
+/* $NetBSD: pthread_md.h,v 1.8 2008/02/10 18:50:55 ad Exp $ */
/*-
- * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * Copyright (c) 2001, 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -104,32 +104,8 @@ pthread__sp(void)
} while (/*CONSTCOND*/0)
#define pthread__smt_pause() __asm __volatile("rep; nop" ::: "memory")
-#define PTHREAD__HAVE_ATOMIC
-static inline void *
-pthread__atomic_cas_ptr(volatile void *ptr, const void *old, const void *new)
-{
- volatile uintptr_t *cast = ptr;
- void *ret;
-
- __asm __volatile ("lock; cmpxchgq %2, %1"
- : "=a" (ret), "=m" (*cast)
- : "r" (new), "m" (*cast), "0" (old));
-
- return ret;
-}
-
-static inline void *
-pthread__atomic_cas_ptr_ni(volatile void *ptr, const void *old, const void *new)
-{
- volatile uintptr_t *cast = ptr;
- void *ret;
-
- __asm __volatile ("cmpxchgq %2, %1"
- : "=a" (ret), "=m" (*cast)
- : "r" (new), "m" (*cast), "0" (old));
-
- return ret;
-}
+/* Don't need additional memory barriers. */
+#define PTHREAD__ATOMIC_IS_MEMBAR
#endif /* _LIB_PTHREAD_X86_64_MD_H */