]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - lib/libthr/arch/sparc64/include/pthread_md.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / lib / libthr / arch / sparc64 / include / pthread_md.h
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$
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  */
46 struct 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 /*
54  * The tcb constructors.
55  */
56 struct tcb      *_tcb_ctor(struct pthread *, int);
57 void            _tcb_dtor(struct tcb *);
58
59 /* Called from the thread to set its private data. */
60 static __inline void
61 _tcb_set(struct tcb *tcb)
62 {
63
64         __asm __volatile("mov %0, %%g7" : : "r" (tcb));
65 }
66
67 static __inline struct tcb *
68 _tcb_get(void)
69 {
70         register struct tcb *tp __asm("%g7");
71
72         return (tp);
73 }
74
75 static __inline struct pthread *
76 _get_curthread(void)
77 {
78
79         return (_tcb_get()->tcb_thread);
80 }
81
82 #define HAS__UMTX_OP_ERR        1
83
84 #endif /* _PTHREAD_MD_H_ */