1*5d00c5a6SKonstantin Belousov /*- 2*5d00c5a6SKonstantin Belousov * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3*5d00c5a6SKonstantin Belousov * 4*5d00c5a6SKonstantin Belousov * Copyright (c) 2019 The FreeBSD Foundation 5*5d00c5a6SKonstantin Belousov * 6*5d00c5a6SKonstantin Belousov * This software was developed by Konstantin Belousov <kib@FreeBSD.org> 7*5d00c5a6SKonstantin Belousov * under sponsorship from the FreeBSD Foundation. 8*5d00c5a6SKonstantin Belousov * 9*5d00c5a6SKonstantin Belousov * Redistribution and use in source and binary forms, with or without 10*5d00c5a6SKonstantin Belousov * modification, are permitted provided that the following conditions 11*5d00c5a6SKonstantin Belousov * are met: 12*5d00c5a6SKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 13*5d00c5a6SKonstantin Belousov * notice, this list of conditions and the following disclaimer. 14*5d00c5a6SKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 15*5d00c5a6SKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 16*5d00c5a6SKonstantin Belousov * documentation and/or other materials provided with the distribution. 17*5d00c5a6SKonstantin Belousov * 18*5d00c5a6SKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19*5d00c5a6SKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*5d00c5a6SKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*5d00c5a6SKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22*5d00c5a6SKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23*5d00c5a6SKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24*5d00c5a6SKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25*5d00c5a6SKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26*5d00c5a6SKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27*5d00c5a6SKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28*5d00c5a6SKonstantin Belousov * SUCH DAMAGE. 29*5d00c5a6SKonstantin Belousov * 30*5d00c5a6SKonstantin Belousov * $FreeBSD$ 31*5d00c5a6SKonstantin Belousov */ 32*5d00c5a6SKonstantin Belousov 33*5d00c5a6SKonstantin Belousov #ifndef _ARCH_RISCV_PTHREAD_TLS_H 34*5d00c5a6SKonstantin Belousov #define _ARCH_RISCV_PTHREAD_TLS_H 35*5d00c5a6SKonstantin Belousov 36*5d00c5a6SKonstantin Belousov static __inline uintptr_t 37*5d00c5a6SKonstantin Belousov _get_static_tls_base(struct pthread *thr, size_t offset) 38*5d00c5a6SKonstantin Belousov { 39*5d00c5a6SKonstantin Belousov uintptr_t tlsbase; 40*5d00c5a6SKonstantin Belousov 41*5d00c5a6SKonstantin Belousov tlsbase = (uintptr_t)thr->tcb; 42*5d00c5a6SKonstantin Belousov tlsbase += offset; 43*5d00c5a6SKonstantin Belousov return (tlsbase); 44*5d00c5a6SKonstantin Belousov } 45*5d00c5a6SKonstantin Belousov 46*5d00c5a6SKonstantin Belousov #endif 47