OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "ppapi/native_client/src/untrusted/irt_stub/thread_creator.h" | 7 #include "ppapi/native_client/src/untrusted/irt_stub/thread_creator.h" |
8 | 8 |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 return pthread_create((pthread_t *) tid, NULL, | 24 return pthread_create((pthread_t *) tid, NULL, |
25 (void *(*)(void *thread_argument)) func, | 25 (void *(*)(void *thread_argument)) func, |
26 thread_argument); | 26 thread_argument); |
27 } | 27 } |
28 | 28 |
29 static int thread_join(uintptr_t tid) { | 29 static int thread_join(uintptr_t tid) { |
30 return pthread_join((pthread_t) tid, NULL); | 30 return pthread_join((pthread_t) tid, NULL); |
31 } | 31 } |
32 | 32 |
33 const static struct PP_ThreadFunctions thread_funcs = { | 33 static const struct PP_ThreadFunctions thread_funcs = { |
34 thread_create, | 34 thread_create, |
35 thread_join | 35 thread_join |
36 }; | 36 }; |
37 | 37 |
38 /* | 38 /* |
39 * We cannot tell at link time whether the application uses PPB_Audio, | 39 * We cannot tell at link time whether the application uses PPB_Audio, |
40 * because of the way that PPAPI is defined via runtime interface | 40 * because of the way that PPAPI is defined via runtime interface |
41 * query rather than a set of static functions. This means that we | 41 * query rather than a set of static functions. This means that we |
42 * register the audio thread functions unconditionally. This adds the | 42 * register the audio thread functions unconditionally. This adds the |
43 * small overhead of pulling in pthread_create() even if the | 43 * small overhead of pulling in pthread_create() even if the |
44 * application does not use PPB_Audio or libpthread. | 44 * application does not use PPB_Audio or libpthread. |
45 * | 45 * |
46 * If an application developer wants to avoid that cost, they can | 46 * If an application developer wants to avoid that cost, they can |
47 * override this function with an empty definition. | 47 * override this function with an empty definition. |
48 */ | 48 */ |
49 void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *hooks) { | 49 void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *hooks) { |
50 hooks->ppapi_register_thread_creator(&thread_funcs); | 50 hooks->ppapi_register_thread_creator(&thread_funcs); |
51 } | 51 } |
OLD | NEW |