OLD | NEW |
1 // Copyright (c) 2012 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2012 The Native Client Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | 5 #include <limits> |
6 #include <new> | 6 #include <new> |
7 #include "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
8 #include "native_client/src/include/portability_string.h" | 8 #include "native_client/src/include/portability_string.h" |
9 #include "native_client/src/public/imc_types.h" | 9 #include "native_client/src/public/imc_types.h" |
10 #include "native_client/src/shared/imc/nacl_imc_c.h" | 10 #include "native_client/src/shared/imc/nacl_imc_c.h" |
11 #include "native_client/src/shared/platform/nacl_check.h" | 11 #include "native_client/src/shared/platform/nacl_check.h" |
12 #include "native_client/src/shared/platform/nacl_log.h" | 12 #include "native_client/src/shared/platform/nacl_log.h" |
13 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 13 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
14 #include "native_client/src/trusted/desc/nacl_desc_base.h" | 14 #include "native_client/src/trusted/desc/nacl_desc_base.h" |
15 #include "native_client/src/trusted/desc/nacl_desc_conn_cap.h" | 15 #include "native_client/src/trusted/desc/nacl_desc_conn_cap.h" |
16 #include "native_client/src/trusted/desc/nacl_desc_imc.h" | 16 #include "native_client/src/trusted/desc/nacl_desc_imc.h" |
17 #include "native_client/src/trusted/desc/nacl_desc_imc_shm.h" | 17 #include "native_client/src/trusted/desc/nacl_desc_imc_shm.h" |
18 #include "native_client/src/trusted/desc/nacl_desc_invalid.h" | 18 #include "native_client/src/trusted/desc/nacl_desc_invalid.h" |
19 #include "native_client/src/trusted/desc/nacl_desc_io.h" | 19 #include "native_client/src/trusted/desc/nacl_desc_io.h" |
20 #include "native_client/src/trusted/desc/nacl_desc_quota.h" | 20 #include "native_client/src/trusted/desc/nacl_desc_quota.h" |
21 #include "native_client/src/trusted/desc/nacl_desc_rng.h" | |
22 #include "native_client/src/trusted/desc/nacl_desc_sync_socket.h" | 21 #include "native_client/src/trusted/desc/nacl_desc_sync_socket.h" |
23 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 22 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
24 #include "native_client/src/trusted/desc/nrd_xfer.h" | 23 #include "native_client/src/trusted/desc/nrd_xfer.h" |
25 #include "native_client/src/trusted/nacl_base/nacl_refcount.h" | 24 #include "native_client/src/trusted/nacl_base/nacl_refcount.h" |
26 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" | 25 #include "native_client/src/trusted/service_runtime/include/sys/errno.h" |
27 #include "native_client/src/trusted/service_runtime/nacl_config.h" | 26 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
28 | 27 |
29 // TODO(polina): follow the style guide and replace "nhdp" and "ndiodp" with | 28 // TODO(polina): follow the style guide and replace "nhdp" and "ndiodp" with |
30 // "host_desc" and "io_desc" | 29 // "host_desc" and "io_desc" |
31 | 30 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 return NULL; | 298 return NULL; |
300 } | 299 } |
301 struct NaClDesc* desc_quota = MakeQuotaCommon(file_id, desc); | 300 struct NaClDesc* desc_quota = MakeQuotaCommon(file_id, desc); |
302 if (NULL == desc_quota) { | 301 if (NULL == desc_quota) { |
303 NaClDescSafeUnref(desc); | 302 NaClDescSafeUnref(desc); |
304 return NULL; | 303 return NULL; |
305 } | 304 } |
306 return MakeGenericCleanup(desc_quota); | 305 return MakeGenericCleanup(desc_quota); |
307 } | 306 } |
308 | 307 |
309 DescWrapper* DescWrapperFactory::OpenRng() { | |
310 struct NaClDescRng* nhrp = | |
311 reinterpret_cast<struct NaClDescRng*>(calloc(1, sizeof(*nhrp))); | |
312 if (NULL == nhrp) { | |
313 return NULL; | |
314 } | |
315 if (!NaClDescRngCtor(nhrp)) { | |
316 free(nhrp); | |
317 return NULL; | |
318 } | |
319 | |
320 return MakeGenericCleanup(reinterpret_cast<struct NaClDesc*>(nhrp)); | |
321 } | |
322 | |
323 DescWrapper* DescWrapperFactory::MakeInvalid() { | 308 DescWrapper* DescWrapperFactory::MakeInvalid() { |
324 struct NaClDescInvalid *desc = | 309 struct NaClDescInvalid *desc = |
325 const_cast<NaClDescInvalid*>(NaClDescInvalidMake()); | 310 const_cast<NaClDescInvalid*>(NaClDescInvalidMake()); |
326 if (NULL == desc) { | 311 if (NULL == desc) { |
327 return NULL; | 312 return NULL; |
328 } | 313 } |
329 | 314 |
330 return MakeGenericCleanup(reinterpret_cast<struct NaClDesc*>(desc)); | 315 return MakeGenericCleanup(reinterpret_cast<struct NaClDesc*>(desc)); |
331 } | 316 } |
332 | 317 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return reinterpret_cast<struct NaClDescVtbl const *>(desc_->base.vtbl)-> | 565 return reinterpret_cast<struct NaClDescVtbl const *>(desc_->base.vtbl)-> |
581 SemWait(desc_); | 566 SemWait(desc_); |
582 } | 567 } |
583 | 568 |
584 int DescWrapper::GetValue() { | 569 int DescWrapper::GetValue() { |
585 return reinterpret_cast<struct NaClDescVtbl const *>(desc_->base.vtbl)-> | 570 return reinterpret_cast<struct NaClDescVtbl const *>(desc_->base.vtbl)-> |
586 GetValue(desc_); | 571 GetValue(desc_); |
587 } | 572 } |
588 | 573 |
589 } // namespace nacl | 574 } // namespace nacl |
OLD | NEW |