brian
brian

Reputation: 263

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

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

Upvotes: 0

Views: 101

Answers (1)

brian
brian

Reputation: 263

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.

Upvotes: 0

Related Questions