simplify errno implementation

the motivation for the errno_ptr field in the thread structure, which
this commit removes, was to allow the main thread's errno to keep its
address when lazy thread pointer initialization was used. &errno was
evaluated prior to setting up the thread pointer and stored in
errno_ptr for the main thread; subsequently created threads would have
errno_ptr pointing to their own errno_val in the thread structure.

since lazy initialization was removed, there is no need for this extra
level of indirection; __errno_location can simply return the address
of the thread's errno_val directly. this does cause &errno to change,
but the change happens before entry to application code, and thus is
not observable.
This commit is contained in:
Rich Felker
2014-06-10 04:49:49 -04:00
parent df15168cf8
commit ac31bf278d
4 changed files with 2 additions and 4 deletions
+1 -1
View File
@@ -3,6 +3,6 @@
int *__errno_location(void)
{
static int e;
if (libc.has_thread_pointer) return __pthread_self()->errno_ptr;
if (libc.has_thread_pointer) return &__pthread_self()->errno_val;
return &e;
}