[lib][console] move the state of the console into an object

This will allow in the future multiple instances of it to be active at
at a time. Place the current console in a new TLS slot per thread so
threads created as a side effect of console commands can properly run
commands.
This commit is contained in:
Travis Geiselbrecht
2021-05-28 18:43:47 -07:00
parent c49e63e62c
commit 89f9805277
5 changed files with 157 additions and 85 deletions

View File

@@ -48,6 +48,9 @@ typedef int (*thread_start_routine)(void *arg);
/* thread local storage */
enum thread_tls_list {
#ifdef WITH_LIB_CONSOLE
TLS_ENTRY_CONSOLE, // current console
#endif
#ifdef WITH_LIB_UTHREAD
TLS_ENTRY_UTHREAD,
#endif

View File

@@ -202,7 +202,7 @@ thread_t *thread_create_etc(thread_t *t, const char *name, thread_start_routine
/* save whether or not we need to free the thread struct and/or stack */
t->flags = flags;
/* inheirit thread local storage from the parent */
/* inherit thread local storage from the parent */
thread_t *current_thread = get_current_thread();
int i;
for (i=0; i < MAX_TLS_ENTRY; i++)