xref: /freebsd/lib/libthr/arch/riscv/include/pthread_tls.h (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
15d00c5a6SKonstantin Belousov /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
35d00c5a6SKonstantin Belousov  *
45d00c5a6SKonstantin Belousov  * Copyright (c) 2019 The FreeBSD Foundation
55d00c5a6SKonstantin Belousov  *
65d00c5a6SKonstantin Belousov  * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
75d00c5a6SKonstantin Belousov  * under sponsorship from the FreeBSD Foundation.
85d00c5a6SKonstantin Belousov  *
95d00c5a6SKonstantin Belousov  * Redistribution and use in source and binary forms, with or without
105d00c5a6SKonstantin Belousov  * modification, are permitted provided that the following conditions
115d00c5a6SKonstantin Belousov  * are met:
125d00c5a6SKonstantin Belousov  * 1. Redistributions of source code must retain the above copyright
135d00c5a6SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer.
145d00c5a6SKonstantin Belousov  * 2. Redistributions in binary form must reproduce the above copyright
155d00c5a6SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer in the
165d00c5a6SKonstantin Belousov  *    documentation and/or other materials provided with the distribution.
175d00c5a6SKonstantin Belousov  *
185d00c5a6SKonstantin Belousov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
195d00c5a6SKonstantin Belousov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
205d00c5a6SKonstantin Belousov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
215d00c5a6SKonstantin Belousov  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
225d00c5a6SKonstantin Belousov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
235d00c5a6SKonstantin Belousov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
245d00c5a6SKonstantin Belousov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
255d00c5a6SKonstantin Belousov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
265d00c5a6SKonstantin Belousov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
275d00c5a6SKonstantin Belousov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
285d00c5a6SKonstantin Belousov  * SUCH DAMAGE.
295d00c5a6SKonstantin Belousov  */
305d00c5a6SKonstantin Belousov 
315d00c5a6SKonstantin Belousov #ifndef _ARCH_RISCV_PTHREAD_TLS_H
325d00c5a6SKonstantin Belousov #define	_ARCH_RISCV_PTHREAD_TLS_H
335d00c5a6SKonstantin Belousov 
345d00c5a6SKonstantin Belousov static __inline uintptr_t
_get_static_tls_base(struct pthread * thr,size_t offset)355d00c5a6SKonstantin Belousov _get_static_tls_base(struct pthread *thr, size_t offset)
365d00c5a6SKonstantin Belousov {
375d00c5a6SKonstantin Belousov 	uintptr_t tlsbase;
385d00c5a6SKonstantin Belousov 
395d00c5a6SKonstantin Belousov 	tlsbase = (uintptr_t)thr->tcb;
405d00c5a6SKonstantin Belousov 	tlsbase += offset;
415d00c5a6SKonstantin Belousov 	return (tlsbase);
425d00c5a6SKonstantin Belousov }
435d00c5a6SKonstantin Belousov 
445d00c5a6SKonstantin Belousov #endif
45