Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: ppapi/native_client/src/untrusted/irt_stub/thread_creator.c

Issue 10914053: Relocating files in the nacl repo that belong in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 */
6
7 #include "native_client/src/untrusted/irt_stub/thread_creator.h"
8
9 #include <pthread.h>
10
11 #include "native_client/src/include/nacl_macros.h"
12 #include "native_client/src/untrusted/irt/irt.h"
13
14
15 static int thread_create(uintptr_t *tid,
16 void (*func)(void *thread_argument),
17 void *thread_argument) {
18 /*
19 * We know that newlib and glibc use a small pthread_t type, so we
20 * do not need to wrap pthread_t values.
21 */
22 NACL_ASSERT_SAME_SIZE(pthread_t, uintptr_t);
23
24 return pthread_create((pthread_t *) tid, NULL,
25 (void *(*)(void *thread_argument)) func,
26 thread_argument);
27 }
28
29 static int thread_join(uintptr_t tid) {
30 return pthread_join((pthread_t) tid, NULL);
31 }
32
33 const static struct PP_ThreadFunctions thread_funcs = {
34 thread_create,
35 thread_join
36 };
37
38 /*
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.
45 *
46 * If an application developer wants to avoid that cost, they can
47 * override this function with an empty definition.
48 */
49 void __nacl_register_thread_creator(const struct nacl_irt_ppapihook *hooks) {
50 hooks->ppapi_register_thread_creator(&thread_funcs);
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698