[lib][libc] Make errno thread safe using TLS APIs
Before this change, errno was "completely un-threadsafe" as the comment states. This changes errno to be threadsafe by making errno a thread local variable.
This commit is contained in:
committed by
Travis Geiselbrecht
parent
2d567e437d
commit
e51cf68c3c
@@ -57,6 +57,7 @@ enum thread_tls_list {
|
||||
#ifdef WITH_LIB_LKUSER
|
||||
TLS_ENTRY_LKUSER,
|
||||
#endif
|
||||
TLS_ENTRY_ERRNO,
|
||||
MAX_TLS_ENTRY
|
||||
};
|
||||
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* completely un-threadsafe implementation of errno */
|
||||
/* TODO: pull from kernel TLS or some other thread local storage */
|
||||
static int _errno;
|
||||
#include <kernel/thread.h>
|
||||
|
||||
int *__geterrno(void) {
|
||||
return &_errno;
|
||||
return (int*)tls_get(TLS_ENTRY_ERRNO);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user