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