Difference between __errno_location defined in "csu/errno-loc.c" "nptl/errno-loc.c"

51 Views Asked by At

I noticed that in Glibc the macro "errno" got expanded to an invocation of "__errno_location". However, there are two different definitions of "__errno_location":

  1. The one defined in "csu/errno-loc.c" and hence in "libc.a" returns the address of the thread-local variable "__libc_errno";

  2. Another one defined in "nptl/errno-loc.c" and hence in "libpthread.a" returns the address of the thread-local variable "errno".

What are the differences between these two definitions and which one is used when my C code expands the macro "errno"?

1

There are 1 best solutions below

0
brian On

Just noticed the following declaration in csu/errno.c

extern __thread int __libc_errno __attribute__ ((alias ("errno")))

attribute_hidden;

The two __errno_location definitions return the same address.