OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2011 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 <pthread.h> |
| 8 |
| 9 #include "native_client/src/include/nacl_macros.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/ppruntime.h" |
| 11 |
| 12 |
| 13 /* |
| 14 * This provides a default definition that is overridden in the IRT. |
| 15 * TODO(mseaborn): Remove this when PPAPI is only supported via the IRT. |
| 16 * See http://code.google.com/p/nativeclient/issues/detail?id=1691 |
| 17 */ |
| 18 |
| 19 static int thread_create(uintptr_t *tid, |
| 20 void (*func)(void *thread_argument), |
| 21 void *thread_argument) { |
| 22 /* |
| 23 * We know that newlib and glibc use a small pthread_t type, so we |
| 24 * do not need to wrap pthread_t values. |
| 25 */ |
| 26 NACL_COMPILE_TIME_ASSERT(sizeof(pthread_t) == sizeof(uintptr_t)); |
| 27 |
| 28 return pthread_create((pthread_t *) tid, NULL, |
| 29 (void *(*)(void *thread_argument)) func, |
| 30 thread_argument); |
| 31 } |
| 32 |
| 33 static int thread_join(uintptr_t tid) { |
| 34 return pthread_join((pthread_t) tid, NULL); |
| 35 } |
| 36 |
| 37 const static struct PP_ThreadFunctions thread_funcs = { |
| 38 thread_create, |
| 39 thread_join |
| 40 }; |
| 41 |
| 42 void PpapiPluginRegisterDefaultThreadCreator() { |
| 43 PpapiPluginRegisterThreadCreator(&thread_funcs); |
| 44 } |
OLD | NEW |