1133063Sdfr/*- 2133063Sdfr * Copyright (c) 2004 Doug Rabson 3133063Sdfr * All rights reserved. 4133063Sdfr * 5133063Sdfr * Redistribution and use in source and binary forms, with or without 6133063Sdfr * modification, are permitted provided that the following conditions 7133063Sdfr * are met: 8133063Sdfr * 1. Redistributions of source code must retain the above copyright 9133063Sdfr * notice, this list of conditions and the following disclaimer. 10133063Sdfr * 2. Redistributions in binary form must reproduce the above copyright 11133063Sdfr * notice, this list of conditions and the following disclaimer in the 12133063Sdfr * documentation and/or other materials provided with the distribution. 13133063Sdfr * 14133063Sdfr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15133063Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16133063Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17133063Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18133063Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19133063Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20133063Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21133063Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22133063Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23133063Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24133063Sdfr * SUCH DAMAGE. 25133063Sdfr * 26133063Sdfr * $FreeBSD: releng/11.0/libexec/rtld-elf/rtld_tls.h 280816 2015-03-29 18:53:21Z kib $ 27133063Sdfr */ 28133063Sdfr 29133063Sdfr/* 30133063Sdfr * Semi-public interface from thread libraries to rtld for managing 31133063Sdfr * TLS. 32133063Sdfr */ 33133063Sdfr 34133063Sdfr#ifndef _RTLD_TLS_H_ 35133063Sdfr#define _RTLD_TLS_H_ 36133063Sdfr 37133063Sdfr/* 38133063Sdfr * Allocate a TLS block for a new thread. The memory allocated will 39133063Sdfr * include 'tcbsize' bytes aligned to a 'tcbalign' boundary (in bytes) 40133063Sdfr * for the thread library's private purposes. The location of the TCB 41133063Sdfr * block is returned by this function. For architectures using 42133063Sdfr * 'Variant I' TLS, the thread local storage follows the TCB, and for 43133063Sdfr * 'Variant II', the thread local storage precedes it. For 44133063Sdfr * architectures using the 'Variant II' model (e.g. i386, amd64, 45133063Sdfr * sparc64), the TCB must begin with two pointer fields which are used 46133063Sdfr * by rtld for its TLS implementation. For the 'Variant I' model, the 47133063Sdfr * TCB must begin with a single pointer field for rtld's 48133063Sdfr * implementation. 49133063Sdfr * 50133063Sdfr * If the value of 'oldtls' is non-NULL, the new TLS block will be 51133063Sdfr * initialised using the values contained in 'oldtls' and 'oldtls' 52133063Sdfr * will be freed. This is typically used when initialising a thread 53133063Sdfr * library to migrate from using the initial bootstrap TLS block 54133063Sdfr * created by rtld to one which contains suitable thread library 55133063Sdfr * private data. 56133063Sdfr * 57133063Sdfr * The value returned from this function is suitable for installing 58133063Sdfr * directly into the thread pointer register. 59133063Sdfr */ 60280816Skibvoid *_rtld_allocate_tls(void* oldtls, size_t tcbsize, size_t tcbalign) 61280816Skib __exported; 62133063Sdfr 63133063Sdfr/* 64133063Sdfr * Free a TLS block allocated using _rtld_allocate_tls(). The tcbsize 65133063Sdfr * and tcbalign parameters must be the same as those used to allocate 66133063Sdfr * the block. 67133063Sdfr */ 68280816Skibvoid _rtld_free_tls(void *tcb, size_t tcbsize, size_t tcbalign) __exported; 69133063Sdfr 70133063Sdfr#endif 71