pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

libpthread_dbg: Set proper license and add more headers to fix build



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Feb 8 01:34:23 2017 +0100
Changeset:	84d03c8f0d0fec830c18bd792d630f489be8515e

Modified Files:
	libpthread_dbg/Makefile
	libpthread_dbg/files/Makefile
	libpthread_dbg/files/pthread_dbg.c
	libpthread_dbg/files/pthread_int.h
Added Files:
	libpthread_dbg/files/arch/aarch64/pthread_md.h
	libpthread_dbg/files/arch/alpha/pthread_md.S
	libpthread_dbg/files/arch/alpha/pthread_md.h
	libpthread_dbg/files/arch/arm/pthread_md.h
	libpthread_dbg/files/arch/hppa/pthread_md.S
	libpthread_dbg/files/arch/hppa/pthread_md.h
	libpthread_dbg/files/arch/i386/pthread_md.h
	libpthread_dbg/files/arch/ia64/pthread_md.h
	libpthread_dbg/files/arch/m68k/pthread_md.h
	libpthread_dbg/files/arch/mips/pthread_md.h
	libpthread_dbg/files/arch/or1k/pthread_md.h
	libpthread_dbg/files/arch/powerpc/pthread_md.h
	libpthread_dbg/files/arch/riscv/pthread_md.h
	libpthread_dbg/files/arch/sh3/pthread_md.h
	libpthread_dbg/files/arch/sparc/pthread_md.h
	libpthread_dbg/files/arch/sparc64/pthread_md.h
	libpthread_dbg/files/arch/vax/pthread_md.h
	libpthread_dbg/files/arch/x86_64/pthread_md.h

Log Message:
libpthread_dbg: Set proper license and add more headers to fix build

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=84d03c8f0d0fec830c18bd792d630f489be8515e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 libpthread_dbg/Makefile                        |  2 +-
 libpthread_dbg/files/Makefile                  | 18 +++++
 libpthread_dbg/files/arch/aarch64/pthread_md.h | 57 +++++++++++++++
 libpthread_dbg/files/arch/alpha/pthread_md.S   | 57 +++++++++++++++
 libpthread_dbg/files/arch/alpha/pthread_md.h   | 57 +++++++++++++++
 libpthread_dbg/files/arch/arm/pthread_md.h     | 80 +++++++++++++++++++++
 libpthread_dbg/files/arch/hppa/pthread_md.S    | 67 ++++++++++++++++++
 libpthread_dbg/files/arch/hppa/pthread_md.h    | 64 +++++++++++++++++
 libpthread_dbg/files/arch/i386/pthread_md.h    | 94 +++++++++++++++++++++++++
 libpthread_dbg/files/arch/ia64/pthread_md.h    | 45 ++++++++++++
 libpthread_dbg/files/arch/m68k/pthread_md.h    | 49 +++++++++++++
 libpthread_dbg/files/arch/mips/pthread_md.h    | 47 +++++++++++++
 libpthread_dbg/files/arch/or1k/pthread_md.h    | 47 +++++++++++++
 libpthread_dbg/files/arch/powerpc/pthread_md.h | 61 ++++++++++++++++
 libpthread_dbg/files/arch/riscv/pthread_md.h   | 47 +++++++++++++
 libpthread_dbg/files/arch/sh3/pthread_md.h     | 62 ++++++++++++++++
 libpthread_dbg/files/arch/sparc/pthread_md.h   | 50 +++++++++++++
 libpthread_dbg/files/arch/sparc64/pthread_md.h | 47 +++++++++++++
 libpthread_dbg/files/arch/vax/pthread_md.h     | 58 +++++++++++++++
 libpthread_dbg/files/arch/x86_64/pthread_md.h  | 97 ++++++++++++++++++++++++++
 libpthread_dbg/files/pthread_dbg.c             |  8 +--
 libpthread_dbg/files/pthread_int.h             |  2 +-
 22 files changed, 1110 insertions(+), 6 deletions(-)

diffs:
diff --git a/libpthread_dbg/Makefile b/libpthread_dbg/Makefile
index acb43435ca..756eae356c 100644
--- a/libpthread_dbg/Makefile
+++ b/libpthread_dbg/Makefile
@@ -7,7 +7,7 @@ CATEGORIES=	pkgtools
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
 #HOMEPAGE=
 COMMENT=	POSIX Debug Threads Library
-LICENSE=	2-clause-bsd
+LICENSE=	original-bsd
 
 USE_BSD_MAKEFILE=	yes
 USE_TOOLS=		nroff
diff --git a/libpthread_dbg/files/Makefile b/libpthread_dbg/files/Makefile
index fd1cfab0df..7dad4b2687 100644
--- a/libpthread_dbg/files/Makefile
+++ b/libpthread_dbg/files/Makefile
@@ -3,10 +3,28 @@
 
 #.include <bsd.own.mk>
 
+LIB=	pthread_dbg
+
 SRCS=	pthread_dbg.c 
 
 CPPFLAGS+=	-D__LIBPTHREAD_SOURCE__
 
+.if defined(PTHREAD_MACHINE_ARCH) && !empty(PTHREAD_MACHINE_ARCH) && \
+    exists(${.CURDIR}/arch/${PTHREAD_MACHINE_ARCH})
+ARCHSUBDIR=     ${PTHREAD_MACHINE_ARCH}
+.elif exists(${.CURDIR}/arch/${MACHINE_ARCH})
+ARCHSUBDIR=     ${MACHINE_ARCH}
+.elif exists(${.CURDIR}/arch/${MACHINE_CPU})
+ARCHSUBDIR=     ${MACHINE_CPU}
+.else
+.BEGIN:
+	@echo "no ARCHSUBDIR for ${MACHINE_ARCH}/${MACHINE_CPU}; skipping..."
+.endif
+
+ARCHDIR=        ${.CURDIR}/arch/${ARCHSUBDIR}
+
+CPPFLAGS+=      -I${ARCHDIR}
+
 INCS=	pthread_dbg.h
 
 MAN+=	pthread_dbg.3
diff --git a/libpthread_dbg/files/arch/aarch64/pthread_md.h b/libpthread_dbg/files/arch/aarch64/pthread_md.h
new file mode 100644
index 0000000000..d15f74e9e4
--- /dev/null
+++ b/libpthread_dbg/files/arch/aarch64/pthread_md.h
@@ -0,0 +1,57 @@
+/* $NetBSD: pthread_md.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_AARCH64_MD_H
+#define	_LIB_PTHREAD_AARCH64_MD_H
+
+static inline uintptr_t
+pthread__sp(void)
+{
+	uintptr_t ret;
+
+	__asm __volatile("mov %0, sp" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__smt_pause()	__asm __volatile("wfe") /* wfe */
+#define pthread__smt_wake()	__asm __volatile("sev") /* sev */
+
+#define	pthread__uc_sp(ucp)	((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ */
+#define _INITCONTEXT_U_MD(ucp)	\
+	(ucp)->uc_mcontext.__gregs[_REG_SPSR] = 0;
+
+#endif /* _LIB_PTHREAD_AARCH64_MD_H */
diff --git a/libpthread_dbg/files/arch/alpha/pthread_md.S b/libpthread_dbg/files/arch/alpha/pthread_md.S
new file mode 100644
index 0000000000..6ea5c5e54b
--- /dev/null
+++ b/libpthread_dbg/files/arch/alpha/pthread_md.S
@@ -0,0 +1,57 @@
+/*	$NetBSD: pthread_md.S,v 1.1 2009/05/18 13:03:35 njoly Exp $	*/
+
+/*-
+ * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+	.align 2
+LEAF(pthread__ras_simple_lock_init, 1)
+	stl	zero, 0(a0)
+	nop
+	RET
+END(pthread__ras_simple_lock_init)
+
+	.align 2
+LEAF(pthread__ras_simple_lock_try, 1)
+	ldiq	t0, 1
+pthread__lock_ras_start:	.globl	pthread__lock_ras_start
+	ldl	v0, 0(a0)
+	stl	t0, 0(a0)
+pthread__lock_ras_end:		.globl	pthread__lock_ras_end
+	cmpeq	v0, 0, v0
+	RET	
+END(pthread__ras_simple_lock_try)
+
+	.align 2
+LEAF(pthread__ras_simple_unlock, 1)
+	stl	zero, 0(a0)
+	nop
+	RET
+END(pthread__ras_simple_unlock)
diff --git a/libpthread_dbg/files/arch/alpha/pthread_md.h b/libpthread_dbg/files/arch/alpha/pthread_md.h
new file mode 100644
index 0000000000..4ea370e1af
--- /dev/null
+++ b/libpthread_dbg/files/arch/alpha/pthread_md.h
@@ -0,0 +1,57 @@
+/*	$NetBSD: pthread_md.h,v 1.7 2011/01/25 19:12:04 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_ALPHA_MD_H
+#define _LIB_PTHREAD_ALPHA_MD_H
+
+#define	PTHREAD__ASM_RASOPS
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("mov $30, %0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ * 0x0008 is ALPHA_PSL_USERSET from arch/alpha/include/alpha_cpu.h
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_PS] = 0x0008;
+
+#endif /* _LIB_PTHREAD_ALPHA_MD_H */
diff --git a/libpthread_dbg/files/arch/arm/pthread_md.h b/libpthread_dbg/files/arch/arm/pthread_md.h
new file mode 100644
index 0000000000..153c39fad8
--- /dev/null
+++ b/libpthread_dbg/files/arch/arm/pthread_md.h
@@ -0,0 +1,80 @@
+/*	$NetBSD: pthread_md.h,v 1.9 2013/08/15 22:37:29 matt Exp $	*/
+
+/*
+ * Copyright (c) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Jason R. Thorpe for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed for the NetBSD Project by
+ *	Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_ARM_MD_H
+#define	_LIB_PTHREAD_ARM_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm volatile("mov %0, sp"
+		: "=r" (ret));
+
+	return (ret);
+}
+
+#if defined(__thumb__) && defined(_ARM_ARCH_6)
+#define pthread__smt_pause()	__asm __volatile(".inst.n 0xbf20") /* wfe */
+#define pthread__smt_wake()	__asm __volatile(".inst.n 0xbf40") /* sev */
+#elif !defined(__thumb__)
+#define pthread__smt_pause()	__asm __volatile(".inst 0xe320f002") /* wfe */
+#define pthread__smt_wake()	__asm __volatile(".inst 0xe320f004") /* sev */
+#else
+#define pthread__smt_pause()
+#define pthread__smt_wake()
+#endif
+
+#define	pthread__uc_sp(ucp)	((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ */
+#ifdef __APCS_26__
+#define _INITCONTEXT_U_MD(ucp)						\
+/* Set R15_MODE_USR in the PC */					\
+	(ucp)->uc_mcontext.__gregs[_REG_PC] =				\
+	 ((ucp)->uc_mcontext.__gregs[_REG_PC] & 0x3fffffc) | 0x0;
+#else
+/* Set CPSR to PSR_USE32_MODE (0x10) from arm/armreg.h */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_CPSR] = 0x10;
+#endif
+
+#endif /* _LIB_PTHREAD_ARM_MD_H */
diff --git a/libpthread_dbg/files/arch/hppa/pthread_md.S b/libpthread_dbg/files/arch/hppa/pthread_md.S
new file mode 100644
index 0000000000..b388c0b224
--- /dev/null
+++ b/libpthread_dbg/files/arch/hppa/pthread_md.S
@@ -0,0 +1,67 @@
+/*	$NetBSD: pthread_md.S,v 1.1 2009/05/16 22:20:40 ad Exp $	*/
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wayne Knowles
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <machine/asm.h>
+
+LEAF_ENTRY(pthread__ras_simple_lock_init)
+	ldi	1,%ret0			/* 1 == unlocked */
+	stw	%ret0,0(%arg0)
+	stw	%ret0,4(%arg0)
+	stw	%ret0,8(%arg0)
+	stw	%ret0,12(%arg0)
+	bv,n	%r0(%rp)
+EXIT(pthread__ras_simple_lock_init)
+
+	.global pthread__lock_ras_start
+	.global pthread__lock_ras_end
+
+LEAF_ENTRY(pthread__ras_simple_lock_try)
+	ldo	15(%arg0),%arg0
+	depi	0,31,4,%arg0
+
+pthread__lock_ras_start:
+	ldw	0(%arg0),%ret0
+	stw	%r0,0(%arg0)		/* 0 == locked */
+pthread__lock_ras_end:
+
+	comiclr,= 0,%ret0,%ret0		/* if locked return 0 */
+	ldi	1,%ret0			/* else return 1 */
+	bv,n	%r0(%rp)
+EXIT(pthread__ras_simple_lock_try)
+
+
+LEAF_ENTRY(pthread__ras_simple_unlock)
+	ldo	15(%arg0),%arg0
+	depi	0,31,4,%arg0
+	ldi	1,%ret0			/* 1 == unlocked */
+	bv	%r0(%rp)
+	stw	%ret0,0(%arg0)
+EXIT(pthread__ras_simple_unlock)
diff --git a/libpthread_dbg/files/arch/hppa/pthread_md.h b/libpthread_dbg/files/arch/hppa/pthread_md.h
new file mode 100644
index 0000000000..566a2599c2
--- /dev/null
+++ b/libpthread_dbg/files/arch/hppa/pthread_md.h
@@ -0,0 +1,64 @@
+/*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:05 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_HPPA_MD_H
+#define _LIB_PTHREAD_HPPA_MD_H
+
+#include <machine/frame.h>
+
+#define	PTHREAD__ASM_RASOPS
+
+static inline unsigned long
+pthread__sp(void)
+{
+	register unsigned long sp __asm("r30");
+
+	return sp;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_PSW] = 0x4000f;
+
+/*
+ * Usable stack space below the ucontext_t.
+ */
+#define STACKSPACE	(HPPA_FRAME_SIZE)
+
+/* Don't need additional memory barriers. */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+#endif /* !_LIB_PTHREAD_HPPA_MD_H */
diff --git a/libpthread_dbg/files/arch/i386/pthread_md.h b/libpthread_dbg/files/arch/i386/pthread_md.h
new file mode 100644
index 0000000000..1fd734586c
--- /dev/null
+++ b/libpthread_dbg/files/arch/i386/pthread_md.h
@@ -0,0 +1,94 @@
+/*	$NetBSD: pthread_md.h,v 1.20 2012/03/02 23:19:47 joerg Exp $	*/
+
+/*-
+ * Copyright (c) 2001, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams, and by Andrew Doran.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_I386_MD_H
+#define _LIB_PTHREAD_I386_MD_H
+
+#include <sys/ucontext.h>
+#include <ucontext.h>
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+	__asm("movl %%esp, %0" : "=g" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_UESP])
+
+static inline void
+_initcontext_u_md(ucontext_t *ucp)
+{
+	__asm ("pushfl; popl %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_EFL]));
+	__asm ("pushl %%cs; popl %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_CS]));
+	__asm ("movl %%ds, %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_DS]));
+	__asm ("movl %%es, %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_ES]));
+	__asm ("movl %%fs, %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_FS]));
+	__asm ("movl %%gs, %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_GS]));
+	__asm ("movl %%ss, %0" : "=a" (ucp->uc_mcontext.__gregs[_REG_SS]));
+}
+
+#define	_INITCONTEXT_U_MD(ucp)	_initcontext_u_md(ucp);
+
+#define	pthread__smt_pause()	__asm __volatile("rep; nop" ::: "memory")
+
+/* Don't need additional memory barriers. */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+static inline void *
+_atomic_cas_ptr(volatile void *ptr, void *old, 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 *
+_atomic_cas_ptr_ni(volatile void *ptr, void *old, 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/libpthread_dbg/files/arch/ia64/pthread_md.h b/libpthread_dbg/files/arch/ia64/pthread_md.h
new file mode 100644
index 0000000000..056e68bef9
--- /dev/null
+++ b/libpthread_dbg/files/arch/ia64/pthread_md.h
@@ -0,0 +1,45 @@
+/*	$NetBSD: pthread_md.h,v 1.1 2015/04/17 13:14:19 martin Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_IA64_MD_H
+#define _LIB_PTHREAD_IA64_MD_H
+
+// #define	PTHREAD__ASM_RASOPS
+
+static inline unsigned long
+pthread__sp(void)
+{
+	return 0;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+#endif /* _LIB_PTHREAD_IA64_MD_H */
diff --git a/libpthread_dbg/files/arch/m68k/pthread_md.h b/libpthread_dbg/files/arch/m68k/pthread_md.h
new file mode 100644
index 0000000000..2ba7566a1b
--- /dev/null
+++ b/libpthread_dbg/files/arch/m68k/pthread_md.h
@@ -0,0 +1,49 @@
+/*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:05 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_M68K_MD_H
+#define _LIB_PTHREAD_M68K_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+	__asm("movl %%sp, %0" : "=g" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_A7])
+
+/* m68k will not go SMP */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+#endif /* _LIB_PTHREAD_M68K_MD_H */
diff --git a/libpthread_dbg/files/arch/mips/pthread_md.h b/libpthread_dbg/files/arch/mips/pthread_md.h
new file mode 100644
index 0000000000..143567ea0e
--- /dev/null
+++ b/libpthread_dbg/files/arch/mips/pthread_md.h
@@ -0,0 +1,47 @@
+/*	$NetBSD: pthread_md.h,v 1.9 2011/01/25 19:12:05 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_MIPS_MD_H
+#define _LIB_PTHREAD_MIPS_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("move %0, $sp" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+#endif /* !_LIB_PTHREAD_MIPS_MD_H */
diff --git a/libpthread_dbg/files/arch/or1k/pthread_md.h b/libpthread_dbg/files/arch/or1k/pthread_md.h
new file mode 100644
index 0000000000..f99616d9b9
--- /dev/null
+++ b/libpthread_dbg/files/arch/or1k/pthread_md.h
@@ -0,0 +1,47 @@
+/*	$NetBSD: pthread_md.h,v 1.1 2014/09/03 19:34:26 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_OR1K_MD_H
+#define _LIB_PTHREAD_OR1K_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long	ret;
+
+	__asm("l.ori	%0, r0, 0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[1])
+
+#endif /* _LIB_PTHREAD_OR1K_MD_H */
diff --git a/libpthread_dbg/files/arch/powerpc/pthread_md.h b/libpthread_dbg/files/arch/powerpc/pthread_md.h
new file mode 100644
index 0000000000..7bccf588ef
--- /dev/null
+++ b/libpthread_dbg/files/arch/powerpc/pthread_md.h
@@ -0,0 +1,61 @@
+/*	$NetBSD: pthread_md.h,v 1.7 2011/01/25 19:12:05 christos Exp $	*/
+
+/*
+ * Copyright (c) 2001 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Allen Briggs for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_POWERPC_MD_H
+#define _LIB_PTHREAD_POWERPC_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long	ret;
+
+	__asm("mr %0,1" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[1])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ * 0xd032 is PSL_USERSET from arch/powerpc/include/psl.h
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_MSR] = 0xd032;
+
+#endif /* _LIB_PTHREAD_POWERPC_MD_H */
diff --git a/libpthread_dbg/files/arch/riscv/pthread_md.h b/libpthread_dbg/files/arch/riscv/pthread_md.h
new file mode 100644
index 0000000000..de99c52eaf
--- /dev/null
+++ b/libpthread_dbg/files/arch/riscv/pthread_md.h
@@ -0,0 +1,47 @@
+/*	$NetBSD: pthread_md.h,v 1.2 2015/03/31 01:36:27 matt Exp $	*/
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_RISCV_MD_H
+#define _LIB_PTHREAD_RISCV_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("move\t%0, sp" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+#endif /* _LIB_PTHREAD_RISCV_MD_H */
diff --git a/libpthread_dbg/files/arch/sh3/pthread_md.h b/libpthread_dbg/files/arch/sh3/pthread_md.h
new file mode 100644
index 0000000000..525b66d9ef
--- /dev/null
+++ b/libpthread_dbg/files/arch/sh3/pthread_md.h
@@ -0,0 +1,62 @@
+/*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:06 christos Exp $ */
+
+/*
+ * Copyright 2003 Wasabi Systems, Inc.
+ * All rights reserved.
+ *
+ * Written by Steve C. Woodford for Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed for the NetBSD Project by
+ *      Wasabi Systems, Inc.
+ * 4. The name of Wasabi Systems, Inc. may not be used to endorse
+ *    or promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_SH3_MD_H
+#define _LIB_PTHREAD_SH3_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+	__asm("mov r15, %0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_R15])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_SR] = 0;
+
+/* sh3 will not go SMP */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+#endif /* _LIB_PTHREAD_SH3_MD_H */
diff --git a/libpthread_dbg/files/arch/sparc/pthread_md.h b/libpthread_dbg/files/arch/sparc/pthread_md.h
new file mode 100644
index 0000000000..85d61bc072
--- /dev/null
+++ b/libpthread_dbg/files/arch/sparc/pthread_md.h
@@ -0,0 +1,50 @@
+/*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:06 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_SPARC_MD_H
+#define _LIB_PTHREAD_SPARC_MD_H
+
+/*
+ * pthread__sp used for identifying thread
+ */
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("mov %%sp, %0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_O6])
+
+/* Don't need additional memory barriers. */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+#endif /* _LIB_PTHREAD_SPARC_MD_H */
diff --git a/libpthread_dbg/files/arch/sparc64/pthread_md.h b/libpthread_dbg/files/arch/sparc64/pthread_md.h
new file mode 100644
index 0000000000..4cf88edb7b
--- /dev/null
+++ b/libpthread_dbg/files/arch/sparc64/pthread_md.h
@@ -0,0 +1,47 @@
+/*	$NetBSD: pthread_md.h,v 1.7 2011/01/25 19:12:06 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_SPARC64_MD_H
+#define _LIB_PTHREAD_SPARC64_MD_H
+
+/*
+ * pthread__sp used for identifying thread
+ */
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("mov %%sp, %0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_O6])
+
+#endif /* _LIB_PTHREAD_SPARC64_MD_H */
diff --git a/libpthread_dbg/files/arch/vax/pthread_md.h b/libpthread_dbg/files/arch/vax/pthread_md.h
new file mode 100644
index 0000000000..cd1f814be3
--- /dev/null
+++ b/libpthread_dbg/files/arch/vax/pthread_md.h
@@ -0,0 +1,58 @@
+/*	$NetBSD: pthread_md.h,v 1.8 2011/01/25 19:12:06 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIB_PTHREAD_VAX_MD_H
+#define _LIB_PTHREAD_VAX_MD_H
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+
+	__asm("movl %%sp,%0" : "=r" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_SP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ * 0x03c00000 is PSL_U|PSL_PREVU from arch/vax/include/psl.h
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_PSL] = 0x03c00000;
+
+/* Don't need additional memory barriers. */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+#endif /* _LIB_PTHREAD_VAX_MD_H */
diff --git a/libpthread_dbg/files/arch/x86_64/pthread_md.h b/libpthread_dbg/files/arch/x86_64/pthread_md.h
new file mode 100644
index 0000000000..4b53218830
--- /dev/null
+++ b/libpthread_dbg/files/arch/x86_64/pthread_md.h
@@ -0,0 +1,97 @@
+/*	$NetBSD: pthread_md.h,v 1.12 2011/01/25 19:12:06 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001, 2007, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nathan J. Williams.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Adapted for x86_64 by fvdl%NetBSD.org@localhost
+ */
+
+#ifndef _LIB_PTHREAD_X86_64_MD_H
+#define _LIB_PTHREAD_X86_64_MD_H
+
+#include <sys/ucontext.h>
+
+static inline unsigned long
+pthread__sp(void)
+{
+	unsigned long ret;
+	__asm("movq %%rsp, %0" : "=g" (ret));
+
+	return ret;
+}
+
+#define pthread__uc_sp(ucp) ((ucp)->uc_mcontext.__gregs[_REG_URSP])
+
+/*
+ * Set initial, sane values for registers whose values aren't just
+ * "don't care".
+ * 0x23 is GSEL(GUDATA_SEL, SEL_UPL), and
+ * 0x1b is GSEL(GUCODE_SEL, SEL_UPL).
+ * 0x202 is PSL_USERSET.
+ */
+#define _INITCONTEXT_U_MD(ucp)						\
+	(ucp)->uc_mcontext.__gregs[_REG_GS] = 0x23,			\
+	(ucp)->uc_mcontext.__gregs[_REG_FS] = 0x23,			\
+	(ucp)->uc_mcontext.__gregs[_REG_ES] = 0x23,			\
+	(ucp)->uc_mcontext.__gregs[_REG_DS] = 0x23,			\
+	(ucp)->uc_mcontext.__gregs[_REG_CS] = 0x1b,			\
+	(ucp)->uc_mcontext.__gregs[_REG_SS] = 0x23,			\
+	(ucp)->uc_mcontext.__gregs[_REG_RFL] = 0x202;
+
+#define	pthread__smt_pause()	__asm __volatile("rep; nop" ::: "memory")
+
+/* Don't need additional memory barriers. */
+#define	PTHREAD__ATOMIC_IS_MEMBAR
+
+static inline void *
+_atomic_cas_ptr(volatile void *ptr, void *old, 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 *
+_atomic_cas_ptr_ni(volatile void *ptr, void *old, 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;
+}
+
+#endif /* _LIB_PTHREAD_X86_64_MD_H */
diff --git a/libpthread_dbg/files/pthread_dbg.c b/libpthread_dbg/files/pthread_dbg.c
index 70a821ab4b..b658ca1df6 100644
--- a/libpthread_dbg/files/pthread_dbg.c
+++ b/libpthread_dbg/files/pthread_dbg.c
@@ -53,10 +53,10 @@ __RCSID("$NetBSD: pthread_dbg.c,v 1.51 2016/11/22 04:51:06 kamil Exp $");
 
 #include <machine/reg.h>
 
-#include <pthread.h>
-#include <pthread_int.h>
-#include <pthread_dbg.h>
-#include <pthread_dbg_int.h>
+#include "pthread.h"
+#include "pthread_int.h"
+#include "pthread_dbg.h"
+#include "pthread_dbg_int.h"
 
 #define PT_STACKMASK (proc->stackmask)
 #define OFFSET(thread, field) \
diff --git a/libpthread_dbg/files/pthread_int.h b/libpthread_dbg/files/pthread_int.h
index b3463ee598..4cc46e511e 100644
--- a/libpthread_dbg/files/pthread_int.h
+++ b/libpthread_dbg/files/pthread_int.h
@@ -47,7 +47,7 @@
 #include "pthread_md.h"
 
 /* Need to use libc-private names for atomic operations. */
-#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
+//#include "../../common/lib/libc/atomic/atomic_op_namespace.h"
 
 #include <sys/atomic.h>
 #include <sys/rbtree.h>


Home | Main Index | Thread Index | Old Index