OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2013 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 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_ | 6 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_ |
7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_ | 7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H_ |
8 | 8 |
9 #include <stdarg.h> | 9 #include <stdarg.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 * success or a non-zero value on error. | 131 * success or a non-zero value on error. |
132 */ | 132 */ |
133 #define NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1 \ | 133 #define NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1 \ |
134 "nacl-irt-private-pnacl-translator-link-0.1" | 134 "nacl-irt-private-pnacl-translator-link-0.1" |
135 struct nacl_irt_private_pnacl_translator_link { | 135 struct nacl_irt_private_pnacl_translator_link { |
136 void (*serve_link_request)(int (*func)(int nexe_fd, | 136 void (*serve_link_request)(int (*func)(int nexe_fd, |
137 const int *obj_file_fds, | 137 const int *obj_file_fds, |
138 int obj_file_fd_count)); | 138 int obj_file_fd_count)); |
139 }; | 139 }; |
140 | 140 |
| 141 /* |
| 142 * This is an internal interface, for use by PNaCl's sandboxed compilers for |
| 143 * communicating with the browser. This applies to pnacl-llc and pnacl-sz |
| 144 * though how pnacl-llc and pnacl-sz use the interface can be slightly |
| 145 * different (e.g., pnacl-sz will only use the first the obj_file_fds entry). |
| 146 * |
| 147 * serve_translate_request(funcs) loops waiting for sequences of requests |
| 148 * via IPC, and then calls the appropriate callback to handle the IPC, |
| 149 * on the same thread. |
| 150 */ |
| 151 struct nacl_irt_pnacl_compile_funcs { |
| 152 /* |
| 153 * |init_callback| is used to initialize the translation process with |
| 154 * configuration info: |
| 155 * (*) |num_threads| is the number of recommended *translate* threads |
| 156 * to use (there may be other worker threads). For pnacl-sz, |
| 157 * num_threads == 0 is for completely sequential translation |
| 158 * (no worker threads). |
| 159 * (*) |obj_file_fds| is an array of FDs for writing an output object file |
| 160 * (*) |obj_file_fd_count| length of the |obj_file_fds| array. |
| 161 * (*) |cmd_flags| is array of null-terminated commandline flag strings. |
| 162 * I.e., an argv vector with a final NULL entry. |
| 163 * The caller retains ownership and immediately frees this array. |
| 164 * (*) |cmd_flags_len| is the number of strings in the |cmd_flags| array. |
| 165 * I.e., the argc for the argv. |
| 166 * Returns a null-terminated error message or NULL on success. |
| 167 */ |
| 168 char *(*init_callback)(uint32_t num_threads, |
| 169 int *obj_file_fds, size_t obj_file_fd_count, |
| 170 char **cmd_flags, size_t cmd_flags_len); |
| 171 /* |
| 172 * |data_callback| is invoked to stream additional bitcode data to |
| 173 * the translator. |
| 174 * Return zero on success or a non-zero value on error. If there is an |
| 175 * error, then the caller can/should still call |end_callback| to get |
| 176 * a message describing the error. |
| 177 */ |
| 178 int (*data_callback)(const void *data, size_t num_bytes); |
| 179 /* |
| 180 * |end_callback| is invoked to signal the end of the data stream. |
| 181 * This must block until translation is actually complete or an error |
| 182 * has occurred and the translator process can be terminated. |
| 183 * Returns a null-terminated error message or NULL on success. |
| 184 */ |
| 185 char *(*end_callback)(void); |
| 186 /* TODO(jvoung): have a separate method for getting internal UMA stats. */ |
| 187 }; |
| 188 |
| 189 #define NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1 \ |
| 190 "nacl-irt-private-pnacl-translator-compile-0.1" |
| 191 struct nacl_irt_private_pnacl_translator_compile { |
| 192 void (*serve_translate_request)( |
| 193 const struct nacl_irt_pnacl_compile_funcs *funcs); |
| 194 }; |
| 195 |
141 #if defined(__cplusplus) | 196 #if defined(__cplusplus) |
142 } | 197 } |
143 #endif | 198 #endif |
144 | 199 |
145 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H */ | 200 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_DEV_H */ |
OLD | NEW |