2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2005 David Xu <davidxu@freebsd.org>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * from: src/lib/libthr/arch/arm/include/pthread_md.h,v 1.3 2005/10/29 13:40:31 davidxu
33 * Machine-dependent thread prototypes/definitions.
35 #ifndef _PTHREAD_MD_H_
36 #define _PTHREAD_MD_H_
38 #include <sys/types.h>
39 #include <machine/sysarch.h>
40 #include <machine/tls.h>
44 #define DTV_OFFSET offsetof(struct tcb, tcb_dtv)
47 * Variant I tcb. The structure layout is fixed, don't blindly
52 struct pthread *tcb_thread;
55 /* Called from the thread to set its private data. */
57 _tcb_set(struct tcb *tcb)
60 sysarch(MIPS_SET_TLS, tcb);
64 * Get the current tcb.
66 #ifdef TLS_USE_SYSARCH
67 static __inline struct tcb *
72 sysarch(MIPS_GET_TLS, &tcb);
76 #else /* ! TLS_USE_SYSARCH */
78 # if defined(__mips_n64)
79 static __inline struct tcb *
84 __asm__ __volatile__ (
92 * XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317'
94 * Remove the offset since this really a request to get the TLS
95 * pointer via sysarch() (in theory). Of course, this may go away
96 * once the TLS code is rewritten.
98 return (struct tcb *)(_rv - TLS_TP_OFFSET - TLS_TCB_SIZE);
101 static __inline struct tcb *
106 __asm__ __volatile__ (
114 * XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317'
116 * Remove the offset since this really a request to get the TLS
117 * pointer via sysarch() (in theory). Of course, this may go away
118 * once the TLS code is rewritten.
120 return (struct tcb *)(_rv - TLS_TP_OFFSET - TLS_TCB_SIZE);
122 # endif /* ! __mips_n64 */
123 #endif /* ! TLS_USE_SYSARCH */
125 static __inline struct pthread *
129 return (_tcb_get()->tcb_thread);
133 #endif /* _PTHREAD_MD_H_ */