1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : /*
8 : * NaCl Server Runtime global scoped objects for handling global resources.
9 : */
10 :
11 : #include "native_client/src/shared/platform/nacl_interruptible_mutex.h"
12 : #include "native_client/src/shared/platform/nacl_log.h"
13 : #include "native_client/src/shared/platform/nacl_sync.h"
14 : #include "native_client/src/shared/platform/nacl_sync_checked.h"
15 : #include "native_client/src/shared/platform/nacl_threads.h"
16 : #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
17 : #include "native_client/src/trusted/service_runtime/nacl_app.h"
18 : #include "native_client/src/trusted/service_runtime/nacl_app_thread.h"
19 : #include "native_client/src/trusted/service_runtime/nacl_globals.h"
20 :
21 : struct NaClMutex nacl_thread_mu;
22 :
23 : struct NaClThreadContext *nacl_user[NACL_THREAD_MAX] = {NULL};
24 : struct NaClThreadContext *nacl_sys[NACL_THREAD_MAX] = {NULL};
25 : struct NaClAppThread *nacl_thread[NACL_THREAD_MAX] = {NULL};
26 : uint32_t nacl_tls[NACL_THREAD_MAX] = {0};
27 : #if NACL_WINDOWS
28 : uint32_t nacl_thread_ids[NACL_THREAD_MAX] = {0};
29 : #endif
30 :
31 : /*
32 : * Hack for gdb. This records xlate_base in a place where (1) gdb can find it,
33 : * and (2) gdb doesn't need debug info (it just needs symbol info).
34 : */
35 : uintptr_t nacl_global_xlate_base;
36 :
37 14 : void NaClGlobalModuleInit(void) {
38 14 : NaClXMutexCtor(&nacl_thread_mu);
39 14 : NaClInitGlobals();
40 14 : }
41 :
42 :
43 9 : void NaClGlobalModuleFini(void) {
44 9 : NaClMutexDtor(&nacl_thread_mu);
45 9 : }
|