[lib][libc] clear errno in the thread TLS

When creating new thread, the TLS entries are copied from the parent
thread, but zero out errno so it defaults to 0.
This commit is contained in:
Travis Geiselbrecht
2025-07-28 23:54:07 -07:00
parent 00b6ca080e
commit bab69228bd

View File

@@ -206,8 +206,10 @@ thread_t *thread_create_etc(thread_t *t, const char *name, thread_start_routine
/* inherit thread local storage from the parent */
thread_t *current_thread = get_current_thread();
int i;
for (i=0; i < MAX_TLS_ENTRY; i++)
for (i=0; i < MAX_TLS_ENTRY; i++) {
t->tls[i] = current_thread->tls[i];
}
t->tls[TLS_ENTRY_ERRNO] = 0; /* clear errno */
/* set up the initial stack frame */
arch_thread_initialize(t);