Index: src/trusted/service_runtime/arch/mips/nacl_tls.c |
diff --git a/src/trusted/service_runtime/arch/mips/nacl_tls.c b/src/trusted/service_runtime/arch/mips/nacl_tls.c |
index b89b7772c34859764dba82aeeeafabe3fa9e9859..1e2e1a89d956e7c6045ec51816df00d22436e956 100644 |
--- a/src/trusted/service_runtime/arch/mips/nacl_tls.c |
+++ b/src/trusted/service_runtime/arch/mips/nacl_tls.c |
@@ -19,18 +19,15 @@ |
static struct NaClMutex gNaClTlsMu; |
static int gNaClThreadIdxInUse[NACL_THREAD_MAX]; /* bool */ |
-/* |
- * This holds the index of the current thread. |
- * This is also used directly in nacl_syscall.S (NaClSyscallSeg). |
- */ |
-__thread uint32_t gNaClThreadIdx = NACL_TLS_INDEX_INVALID; |
+/* May be NULL if the current thread does not host a NaClAppThread. */ |
+THREAD struct NaClThreadContext *nacl_current_thread; |
bsy
2013/02/19 19:03:08
maybe nacl_current_thread_context?
Mark Seaborn
2013/03/27 00:29:07
I opted to leave this as "nacl_current_thread" bec
|
-uint32_t NaClTlsGetIdx(void) { |
- return gNaClThreadIdx; |
+void NaClTlsSetCurrentThread(struct NaClAppThread *natp) { |
+ nacl_current_thread = &natp->user; |
} |
-void NaClTlsSetIdx(uint32_t tls_idx) { |
- gNaClThreadIdx = tls_idx; |
+struct NaClAppThread *NaClTlsGetCurrentThread(void) { |
+ return NaClAppThreadFromThreadContext(nacl_current_thread); |
} |
uint32_t NaClGetThreadIdx(struct NaClAppThread *natp) { |
@@ -84,8 +81,9 @@ static int NaClThreadIdxAllocate(void) { |
/* |
- * Allocation does not mean we can set gNaClThreadIdx, since we are not |
- * that thread. Setting it must wait until the thread actually launches. |
+ * Allocation does not mean we can set nacl_current_thread, since we |
+ * are not that thread. Setting it must wait until the thread |
+ * actually launches. |
*/ |
uint32_t NaClTlsAllocate(struct NaClAppThread *natp) { |
int idx = NaClThreadIdxAllocate(); |