1930d2950Szrj /*
2930d2950Szrj * Copyright (c) 2003 Daniel Eischen <deischen@freebsd.org>
3930d2950Szrj * All rights reserved.
4930d2950Szrj *
5930d2950Szrj * Redistribution and use in source and binary forms, with or without
6930d2950Szrj * modification, are permitted provided that the following conditions
7930d2950Szrj * are met:
8930d2950Szrj *
9930d2950Szrj * 1. Redistributions of source code must retain the above copyright
10930d2950Szrj * notice, this list of conditions and the following disclaimer.
11930d2950Szrj * 2. Neither the name of the author nor the names of its contributors
12930d2950Szrj * may be used to endorse or promote products derived from this software
13930d2950Szrj * without specific prior written permission.
14930d2950Szrj *
15930d2950Szrj * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16930d2950Szrj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17930d2950Szrj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18930d2950Szrj * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19930d2950Szrj * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20930d2950Szrj * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21930d2950Szrj * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22930d2950Szrj * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23930d2950Szrj * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24930d2950Szrj * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25930d2950Szrj *
26930d2950Szrj * $FreeBSD: src/lib/libpthread/arch/amd64/amd64/pthread_md.c,v 1.4 2004/11/06 03:33:19 peter Exp $
27930d2950Szrj */
28930d2950Szrj
29930d2950Szrj #include <sys/types.h>
30930d2950Szrj #include <sys/tls.h>
31930d2950Szrj
32930d2950Szrj #include <machine/tls.h>
33930d2950Szrj
34930d2950Szrj #include "pthread_md.h"
35930d2950Szrj
36930d2950Szrj /*
37930d2950Szrj * The constructors.
38930d2950Szrj */
39930d2950Szrj struct tls_tcb *
_tcb_ctor(struct __pthread_s * thread,int initial)40*cf8046a9Szrj _tcb_ctor(struct __pthread_s *thread, int initial)
41930d2950Szrj {
42930d2950Szrj struct tls_tcb *tcb;
43930d2950Szrj
44930d2950Szrj if (initial)
45930d2950Szrj tcb = tls_get_tcb();
46930d2950Szrj else
47930d2950Szrj tcb = _libc_allocate_tls();
48930d2950Szrj
49930d2950Szrj if (tcb == NULL)
50930d2950Szrj return (NULL);
51930d2950Szrj
52930d2950Szrj tcb->tcb_pthread = thread;
53930d2950Szrj
54930d2950Szrj return (tcb);
55930d2950Szrj }
56930d2950Szrj
57930d2950Szrj void
_tcb_dtor(struct tls_tcb * tcb)58930d2950Szrj _tcb_dtor(struct tls_tcb *tcb)
59930d2950Szrj {
60930d2950Szrj _rtld_free_tls(tcb);
61930d2950Szrj }
62