Move errno to a pthread_internal_t field.
This change is intended to allow native-bridge to use independent
TLS memory for host and guest environments, while still sharing a
thread-local errno between the two.
Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I838cd321e159add60760bc12a8aa7e9ddc960c33
Merged-In: I838cd321e159add60760bc12a8aa7e9ddc960c33
(cherry picked from commit a9c7c55462
)
This commit is contained in:
parent
8b475e598d
commit
37754cdef6
|
@ -29,8 +29,8 @@
|
|||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/bionic_tls.h"
|
||||
#include "pthread_internal.h"
|
||||
|
||||
int* __errno() {
|
||||
return reinterpret_cast<int*>(&(__get_tls()[TLS_SLOT_ERRNO]));
|
||||
return &__get_thread()->errno_value;
|
||||
}
|
||||
|
|
|
@ -145,6 +145,8 @@ class pthread_internal_t {
|
|||
|
||||
bionic_tls* bionic_tls;
|
||||
|
||||
int errno_value;
|
||||
|
||||
// The thread pointer (__get_tls()) points at this field. This field must come last so that
|
||||
// an executable's TLS segment can be allocated at a fixed offset after the thread pointer.
|
||||
void* tls[BIONIC_TLS_SLOTS];
|
||||
|
|
|
@ -56,7 +56,8 @@ __BEGIN_DECLS
|
|||
enum {
|
||||
TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86.
|
||||
TLS_SLOT_THREAD_ID,
|
||||
TLS_SLOT_ERRNO,
|
||||
|
||||
// TLS slot 2 was used for errno but is now free.
|
||||
|
||||
// These two aren't used by bionic itself, but allow the graphics code to
|
||||
// access TLS directly rather than using the pthread API.
|
||||
|
|
Loading…
Reference in New Issue