]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / nptl / sysdeps / unix / sysv / linux / libc_pthread_init.c
1 /* Copyright (C) 2002,2003,2005,2006,2007,2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <unistd.h>
21 #include <list.h>
22 #include <fork.h>
23 #include <dl-sysdep.h>
24 #include <tls.h>
25 #include <string.h>
26 #include <pthreadP.h>
27 #include <bits/libc-lock.h>
28 #include <sysdep.h>
29 #include <ldsodefs.h>
30
31
32 #ifdef TLS_MULTIPLE_THREADS_IN_TCB
33 void
34 #else
35 extern int __libc_multiple_threads attribute_hidden;
36
37 int *
38 #endif
39 __libc_pthread_init (
40      unsigned long int *ptr,
41      void (*reclaim) (void),
42      const struct pthread_functions *functions)
43 {
44   /* Remember the pointer to the generation counter in libpthread.  */
45   __fork_generation_pointer = ptr;
46
47   /* Called by a child after fork.  */
48   __register_atfork (NULL, NULL, reclaim, NULL);
49
50 #ifdef SHARED
51   /* We copy the content of the variable pointed to by the FUNCTIONS
52      parameter to one in libc.so since this means access to the array
53      can be done with one memory access instead of two.
54    */
55    memcpy (&__libc_pthread_functions, functions,
56            sizeof (__libc_pthread_functions));
57   __libc_pthread_functions_init = 1;
58 #endif
59
60 #ifndef TLS_MULTIPLE_THREADS_IN_TCB
61   return &__libc_multiple_threads;
62 #endif
63 }
64
65 #ifdef SHARED
66 #if 0
67 void
68 libc_freeres_fn (freeres_libptread)
69 {
70   if (__libc_pthread_functions_init)
71     PTHFCT_CALL (ptr_freeres, ());
72 }
73 #endif
74 #endif