pthread_md.h revision 331722
1/*-
2 * Copyright (c) 2003 Jake Burkholder <jake@freebsd.org>.
3 * Copyright (c) 2003 Marcel Moolenaar
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * $FreeBSD: stable/11/lib/libthr/arch/sparc64/include/pthread_md.h 331722 2018-03-29 02:50:57Z eadler $
28 */
29
30/*
31 * Machine-dependent thread prototypes/definitions.
32 */
33#ifndef _PTHREAD_MD_H_
34#define	_PTHREAD_MD_H_
35
36#include <stddef.h>
37
38#define	CPU_SPINWAIT
39
40#define	DTV_OFFSET		offsetof(struct tcb, tcb_dtv)
41
42/*
43 * Variant II tcb, first two members are required by rtld.
44 * %g7 points to the structure.
45 */
46struct tcb {
47	struct tcb		*tcb_self;	/* required by rtld */
48	void			*tcb_dtv;	/* required by rtld */
49	struct pthread		*tcb_thread;	/* our hook */
50	void			*tcb_spare[1];
51};
52
53/* Called from the thread to set its private data. */
54static __inline void
55_tcb_set(struct tcb *tcb)
56{
57
58	__asm __volatile("mov %0, %%g7" : : "r" (tcb));
59}
60
61static __inline struct tcb *
62_tcb_get(void)
63{
64	register struct tcb *tp __asm("%g7");
65
66	return (tp);
67}
68
69static __inline struct pthread *
70_get_curthread(void)
71{
72
73	return (_tcb_get()->tcb_thread);
74}
75
76#define HAS__UMTX_OP_ERR	1
77
78#endif /* _PTHREAD_MD_H_ */
79