Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / ppapi / native_client / src / untrusted / irt_stub / thread_creator.c
blobd70186d4940e8c0ead8d47d66a6891422a4e4fd6
1 /*
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
4 * found in the LICENSE file.
5 */
7 #include "ppapi/native_client/src/untrusted/irt_stub/thread_creator.h"
9 #include <pthread.h>
11 #include "native_client/src/include/nacl_macros.h"
12 #include "native_client/src/untrusted/irt/irt.h"
15 static int thread_create(uintptr_t *tid,
16 void (*func)(void *thread_argument),
17 void *thread_argument) {
19 * We know that newlib and glibc use a small pthread_t type, so we
20 * do not need to wrap pthread_t values.
22 NACL_ASSERT_SAME_SIZE(pthread_t, uintptr_t);
24 return pthread_create((pthread_t *) tid, NULL,
25 (void *(*)(void *thread_argument)) func,
26 thread_argument);
29 static int thread_join(uintptr_t tid) {
30 return pthread_join((pthread_t) tid, NULL);
33 const static struct PP_ThreadFunctions thread_funcs = {
34 thread_create,
35 thread_join
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
41 * query rather than a set of static functions. This means that we
42 * register the audio thread functions unconditionally. This adds the
43 * small overhead of pulling in pthread_create() even if the
44 * application does not use PPB_Audio or libpthread.
46 * If an application developer wants to avoid that cost, they can
47 * override this function with an empty definition.
49 void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *hooks) {
50 hooks->ppapi_register_thread_creator(&thread_funcs);