Back to index

glibc  2.9
createthread.c
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* The "thread register" gets initialized from a segment descriptor.
00021    Initialize such a descriptor first.  */
00022 #define PREPARE_CREATE \
00023   union user_desc_init desc;                                                \
00024                                                                      \
00025   /* Describe the thread-local storage segment.  */                         \
00026                                                                      \
00027   /* The 'entry_number' field.  The first three bits of the segment         \
00028      register value select the GDT, ignore them.  We get the index          \
00029      from the value of the %gs register in the current thread.  */          \
00030   desc.vals[0] = TLS_GET_GS () >> 3;                                        \
00031   /* The 'base_addr' field.  Pointer to the TCB.  */                        \
00032   desc.vals[1] = (unsigned long int) pd;                             \
00033   /* The 'limit' field.  We use 4GB which is 0xfffff pages.  */                    \
00034   desc.vals[2] = 0xfffff;                                            \
00035   /* Collapsed value of the bitfield:                                       \
00036        .seg_32bit = 1                                                       \
00037        .contents = 0                                                 \
00038        .read_exec_only = 0                                           \
00039        .limit_in_pages = 1                                           \
00040        .seg_not_present = 0                                          \
00041        .useable = 1 */                                                      \
00042   desc.vals[3] = 0x51
00043 
00044 /* Value passed to 'clone' for initialization of the thread register.  */
00045 #define TLS_VALUE &desc.desc
00046 
00047 
00048 /* Get the real implementation.  */
00049 #include <nptl/sysdeps/pthread/createthread.c>