1144518Sdavidxu/*-
2144518Sdavidxu * Copyright (c) 2003 Jake Burkholder <jake@freebsd.org>.
3144518Sdavidxu * Copyright (c) 2003 Marcel Moolenaar
4144518Sdavidxu * All rights reserved.
5144518Sdavidxu *
6144518Sdavidxu * Redistribution and use in source and binary forms, with or without
7144518Sdavidxu * modification, are permitted provided that the following conditions
8144518Sdavidxu * are met:
9144518Sdavidxu *
10144518Sdavidxu * 1. Redistributions of source code must retain the above copyright
11144518Sdavidxu *    notice, this list of conditions and the following disclaimer.
12144518Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright
13144518Sdavidxu *    notice, this list of conditions and the following disclaimer in the
14144518Sdavidxu *    documentation and/or other materials provided with the distribution.
15144518Sdavidxu *
16144518Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17144518Sdavidxu * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18144518Sdavidxu * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19144518Sdavidxu * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20144518Sdavidxu * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21144518Sdavidxu * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22144518Sdavidxu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23144518Sdavidxu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24144518Sdavidxu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25144518Sdavidxu * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26144518Sdavidxu *
27144518Sdavidxu * $FreeBSD: releng/11.0/lib/libthr/arch/sparc64/include/pthread_md.h 277490 2015-01-21 16:41:05Z andrew $
28144518Sdavidxu */
29144518Sdavidxu
30144518Sdavidxu/*
31144518Sdavidxu * Machine-dependent thread prototypes/definitions.
32144518Sdavidxu */
33144518Sdavidxu#ifndef _PTHREAD_MD_H_
34144518Sdavidxu#define	_PTHREAD_MD_H_
35144518Sdavidxu
36144518Sdavidxu#include <stddef.h>
37144518Sdavidxu
38165241Sdavidxu#define	CPU_SPINWAIT
39165241Sdavidxu
40144518Sdavidxu#define	DTV_OFFSET		offsetof(struct tcb, tcb_dtv)
41144518Sdavidxu
42144518Sdavidxu/*
43144518Sdavidxu * Variant II tcb, first two members are required by rtld.
44144518Sdavidxu * %g7 points to the structure.
45144518Sdavidxu */
46144518Sdavidxustruct tcb {
47176225Sobrien	struct tcb		*tcb_self;	/* required by rtld */
48176225Sobrien	void			*tcb_dtv;	/* required by rtld */
49176225Sobrien	struct pthread		*tcb_thread;	/* our hook */
50144518Sdavidxu	void			*tcb_spare[1];
51144518Sdavidxu};
52144518Sdavidxu
53144518Sdavidxu/* Called from the thread to set its private data. */
54144518Sdavidxustatic __inline void
55144518Sdavidxu_tcb_set(struct tcb *tcb)
56144518Sdavidxu{
57223228Smarius
58223228Smarius	__asm __volatile("mov %0, %%g7" : : "r" (tcb));
59144518Sdavidxu}
60144518Sdavidxu
61144518Sdavidxustatic __inline struct tcb *
62144518Sdavidxu_tcb_get(void)
63144518Sdavidxu{
64223228Smarius	register struct tcb *tp __asm("%g7");
65223228Smarius
66223228Smarius	return (tp);
67144518Sdavidxu}
68144518Sdavidxu
69144518Sdavidxustatic __inline struct pthread *
70144518Sdavidxu_get_curthread(void)
71144518Sdavidxu{
72223228Smarius
73223228Smarius	return (_tcb_get()->tcb_thread);
74144518Sdavidxu}
75144518Sdavidxu
76223228Smarius#define HAS__UMTX_OP_ERR	1
77223228Smarius
78144518Sdavidxu#endif /* _PTHREAD_MD_H_ */
79