1144518Sdavidxu/*- 2144518Sdavidxu * Copyright (C) 2005 David Xu <davidxu@freebsd.org> 3144518Sdavidxu * All rights reserved. 4144518Sdavidxu * 5144518Sdavidxu * Redistribution and use in source and binary forms, with or without 6144518Sdavidxu * modification, are permitted provided that the following conditions 7144518Sdavidxu * are met: 8144518Sdavidxu * 1. Redistributions of source code must retain the above copyright 9144518Sdavidxu * notice, this list of conditions and the following disclaimer. 10144518Sdavidxu * 2. Neither the name of the author nor the names of its contributors 11144518Sdavidxu * may be used to endorse or promote products derived from this software 12144518Sdavidxu * without specific prior written permission. 13144518Sdavidxu * 14144518Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15144518Sdavidxu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16144518Sdavidxu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17144518Sdavidxu * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18144518Sdavidxu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19144518Sdavidxu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20144518Sdavidxu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21144518Sdavidxu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22144518Sdavidxu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23144518Sdavidxu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24144518Sdavidxu * SUCH DAMAGE. 25144518Sdavidxu * 26144518Sdavidxu * $FreeBSD$ 27144518Sdavidxu */ 28144518Sdavidxu 29144518Sdavidxu#include <stdlib.h> 30144518Sdavidxu#include <sys/types.h> 31144518Sdavidxu#include <rtld_tls.h> 32144518Sdavidxu 33144518Sdavidxu#include "pthread_md.h" 34144518Sdavidxu 35144518Sdavidxustruct tcb * 36144518Sdavidxu_tcb_ctor(struct pthread *thread, int initial) 37144518Sdavidxu{ 38144518Sdavidxu struct tcb *tcb; 39144518Sdavidxu 40231619Sgonzo tcb = _rtld_allocate_tls((initial) ? _tcb_get() : NULL, 41231619Sgonzo sizeof(struct tcb), 16); 42144518Sdavidxu if (tcb) 43144518Sdavidxu tcb->tcb_thread = thread; 44231619Sgonzo 45144518Sdavidxu return (tcb); 46144518Sdavidxu} 47144518Sdavidxu 48144518Sdavidxuvoid 49144518Sdavidxu_tcb_dtor(struct tcb *tcb) 50144518Sdavidxu{ 51231619Sgonzo 52231619Sgonzo _rtld_free_tls(tcb, sizeof(struct tcb), 16); 53144518Sdavidxu} 54