]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - lib/libthr/arch/sparc64/include/pthread_md.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.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 register struct tcb *_tp __asm("%g7");
54
55 #define _tcb    (_tp)
56
57 /*
58  * The tcb constructors.
59  */
60 struct tcb      *_tcb_ctor(struct pthread *, int);
61 void            _tcb_dtor(struct tcb *);
62
63 /* Called from the thread to set its private data. */
64 static __inline void
65 _tcb_set(struct tcb *tcb)
66 {
67         _tp = tcb;
68 }
69
70 /*
71  * Get the current tcb.
72  */
73 static __inline struct tcb *
74 _tcb_get(void)
75 {
76         return (_tcb);
77 }
78
79 extern struct pthread *_thr_initial;
80
81 static __inline struct pthread *
82 _get_curthread(void)
83 {
84         if (_thr_initial)
85                 return (_tcb->tcb_thread);
86         return (NULL);
87 }
88
89 #endif /* _PTHREAD_MD_H_ */