Back to index

glibc  2.9
errno.c
Go to the documentation of this file.
00001 /* Definition of `errno' variable.  Canonical version.
00002    Copyright (C) 2002, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
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 #include <errno.h>
00021 #include <tls.h>
00022 #include <dl-sysdep.h>
00023 #undef errno
00024 
00025 #if RTLD_PRIVATE_ERRNO
00026 
00027 /* Code compiled for rtld refers only to this name.  */
00028 int rtld_errno attribute_hidden;
00029 
00030 #elif USE___THREAD
00031 
00032 __thread int errno;
00033 extern __thread int __libc_errno __attribute__ ((alias ("errno")))
00034   attribute_hidden;
00035 
00036 #else
00037 
00038 /* This differs from plain `int errno;' in that it doesn't create
00039    a common definition, but a plain symbol that resides in .bss,
00040    which can have an alias.  */
00041 int errno __attribute__ ((nocommon));
00042 strong_alias (errno, _errno)
00043 
00044 /* We declare these with compat_symbol so that they are not visible at
00045    link time.  Programs must use the accessor functions.  RTLD is special,
00046    since it's not exported from there at any time.  */
00047 # if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
00048 #  include <shlib-compat.h>
00049 compat_symbol (libc, errno, errno, GLIBC_2_0);
00050 compat_symbol (libc, _errno, _errno, GLIBC_2_0);
00051 # endif
00052 
00053 #endif