Back to index

glibc  2.9
errno-loc.c
Go to the documentation of this file.
00001 /* MT support function to get address of `errno' variable, linuxthreads
00002    version.
00003    Copyright (C) 1996, 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <errno.h>
00022 #include <tls.h>
00023 #include <linuxthreads/internals.h>
00024 #include <sysdep-cancel.h>
00025 
00026 #if ! USE___THREAD && !RTLD_PRIVATE_ERRNO
00027 #undef errno
00028 extern int errno;
00029 #endif
00030 
00031 int *
00032 #if ! USE___THREAD
00033 weak_const_function
00034 #endif
00035 __errno_location (void)
00036 {
00037 #if ! USE___THREAD && !defined NOT_IN_libc
00038   if (! SINGLE_THREAD_P)
00039     {
00040       pthread_descr self = thread_self();
00041       return LIBC_THREAD_GETMEM (self, p_errnop);
00042     }
00043 #endif
00044   return &errno;
00045 }
00046 libc_hidden_def (__errno_location)