OLD | NEW |
| (Empty) |
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 #include <unistd.h> | |
8 | |
9 #include "native_client/src/shared/platform/nacl_log.h" | |
10 #include "native_client/src/shared/srpc/nacl_srpc.h" | |
11 | |
12 /* | |
13 * This is declared as weak because plugin_main_nacl.cc on the | |
14 * Chromium side has a copy of IrtInit(). | |
15 * TODO(mseaborn): Remove IrtInit() from there and use this copy. | |
16 */ | |
17 __attribute__((weak)) | |
18 int IrtInit(void) { | |
19 static int initialized = 0; | |
20 if (initialized) { | |
21 return 0; | |
22 } | |
23 if (!NaClSrpcModuleInit()) { | |
24 return 1; | |
25 } | |
26 NaClLogModuleInit(); /* Enable NaClLog'ing used by CHECK(). */ | |
27 initialized = 1; | |
28 return 0; | |
29 } | |
30 | |
31 static __attribute__((constructor)) void CallIrtInit(void) { | |
32 if (IrtInit()) { | |
33 static const char fatal_msg[] = | |
34 "irt initialization (IRTInit) failed.\n"; | |
35 write(2, fatal_msg, sizeof(fatal_msg) - 1); | |
36 _exit(-1); | |
37 } | |
38 } | |
OLD | NEW |