0

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"?

brian
  • 265
  • 1
  • 9

1 Answers1

0

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.

brian
  • 265
  • 1
  • 9