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

Side by Side Diff: src/untrusted/pthread/pthread_types.h

Issue 11299315: Cleanup: Fix various coding style issues in src/untrusted/pthread (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Review Created 8 years 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
« no previous file with comments | « src/untrusted/pthread/pthread.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 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 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 /* 7 /*
8 * Native Client pthreads implementation layer 8 * Native Client pthreads implementation layer
9 */ 9 */
10 10
11 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_ 11 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_
12 #define NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_ 1 12 #define NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_ 1
13 13
14 #include "native_client/src/untrusted/pthread/pthread.h" 14 #include "native_client/src/untrusted/pthread/pthread.h"
15 15
16 16
17 #ifdef __cplusplus 17 #ifdef __cplusplus
18 extern "C" { 18 extern "C" {
19 #endif 19 #endif
20 20
21 void nc_token_init(volatile int *token, int acquire); 21 void nc_token_init(volatile int *token, int acquire);
22 int nc_token_acquire(volatile int *token); 22 int nc_token_acquire(volatile int *token);
23 void nc_token_release(volatile int *token); 23 void nc_token_release(volatile int *token);
24 24
25 int nc_pthread_condvar_ctor(pthread_cond_t * cond); 25 int nc_pthread_condvar_ctor(pthread_cond_t *cond);
26 26
27 typedef enum { 27 typedef enum {
28 THREAD_RUNNING, 28 THREAD_RUNNING,
29 THREAD_TERMINATED 29 THREAD_TERMINATED
30 } nc_thread_status_t; 30 } nc_thread_status_t;
31 31
32 typedef struct entry { 32 typedef struct entry {
33 STAILQ_ENTRY(entry) entries; /* a pointer - 4 bytes */ 33 STAILQ_ENTRY(entry) entries; /* a pointer - 4 bytes */
34 int32_t is_used; /* 4 bytes */ 34 int32_t is_used; /* 4 bytes */
35 int32_t size; /* 4 bytes */ 35 int32_t size; /* 4 bytes */
(...skipping 17 matching lines...) Expand all
53 * ("tcbhead_t") as long as we keep the field "dtv" untouched and 53 * ("tcbhead_t") as long as we keep the field "dtv" untouched and
54 * use tls_base in a compatible way (which we already do). 54 * use tls_base in a compatible way (which we already do).
55 */ 55 */
56 typedef struct { 56 typedef struct {
57 void *tls_base; /* tls accesses are made relative to this base */ 57 void *tls_base; /* tls accesses are made relative to this base */
58 void *unused_dtv; /* increase compatibility with glibc's tcbhead_t */ 58 void *unused_dtv; /* increase compatibility with glibc's tcbhead_t */
59 int joinable; 59 int joinable;
60 int join_waiting; 60 int join_waiting;
61 nc_thread_memory_block_t *stack_node; 61 nc_thread_memory_block_t *stack_node;
62 nc_thread_memory_block_t *tls_node; 62 nc_thread_memory_block_t *tls_node;
63 nc_thread_function start_func; 63 nc_thread_function start_func;
64 void* state; 64 void *state;
65 /* 65 /*
66 * irt_thread_data is used when libpthread is linked into the IRT. 66 * irt_thread_data is used when libpthread is linked into the IRT.
67 * It is used for free()ing the thread block. 67 * It is used for free()ing the thread block.
68 * TODO(mseaborn): This plays a similar role to tls_node; the two 68 * TODO(mseaborn): This plays a similar role to tls_node; the two
69 * could be unified in future. 69 * could be unified in future.
70 */ 70 */
71 void *irt_thread_data; 71 void *irt_thread_data;
72 struct __nc_basic_thread_data *basic_data; 72 struct __nc_basic_thread_data *basic_data;
73 } nc_thread_descriptor_t; 73 } nc_thread_descriptor_t;
74 74
75 typedef struct __nc_basic_thread_data { 75 typedef struct __nc_basic_thread_data {
76 void *retval; 76 void *retval;
77 nc_thread_status_t status; 77 nc_thread_status_t status;
78 pthread_cond_t join_condvar; 78 pthread_cond_t join_condvar;
79 /* pointer to the tdb, will be null after the thread terminates */ 79 /* Pointer to the tdb, will be null after the thread terminates. */
80 nc_thread_descriptor_t *tdb; 80 nc_thread_descriptor_t *tdb;
81 } nc_basic_thread_data_t; 81 } nc_basic_thread_data_t;
82 82
83 /* 83 /*
84 * This structure is allocated for all threads. However, for threads 84 * This structure is allocated for all threads. However, for threads
85 * created with pthread_create(), the basic_data field is not used, 85 * created with pthread_create(), the basic_data field is not used,
86 * and a separate nc_basic_thread_data_t struct is allocated. The 86 * and a separate nc_basic_thread_data_t struct is allocated. The
87 * initial thread, and threads created by the IRT's thread_create() 87 * initial thread, and threads created by the IRT's thread_create()
88 * interface, do use the basic_data field though. 88 * interface, do use the basic_data field though.
89 * TODO(mseaborn): Clean this up to be more consistent. 89 * TODO(mseaborn): Clean this up to be more consistent.
90 */ 90 */
91 struct nc_combined_tdb { 91 struct nc_combined_tdb {
92 nc_thread_descriptor_t tdb; 92 nc_thread_descriptor_t tdb;
93 nc_basic_thread_data_t basic_data; 93 nc_basic_thread_data_t basic_data;
94 }; 94 };
95 95
96 96
97 #define MEMORY_BLOCK_ALLOCATION_SIZE(real_size) \ 97 #define MEMORY_BLOCK_ALLOCATION_SIZE(real_size) \
98 (sizeof(nc_thread_memory_block_t) + (real_size)) 98 (sizeof(nc_thread_memory_block_t) + (real_size))
99 99
100 #ifdef __cplusplus 100 #ifdef __cplusplus
101 } 101 }
102 #endif 102 #endif
103 103
104 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_ */ 104 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_PTHREAD_NC_PTHREAD_TYPES_H_ */
OLDNEW
« no previous file with comments | « src/untrusted/pthread/pthread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698