| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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 | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 /* | |
| 8 * Subclass of the gio object for use in trusted code, providing I/O | |
| 9 * services to a shared memory object. | |
| 10 */ | |
| 11 | |
| 12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_H_ | |
| 13 #define NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_H_ | |
| 14 | |
| 15 #include "native_client/src/include/nacl_base.h" | |
| 16 | |
| 17 #include "native_client/src/shared/gio/gio.h" | |
| 18 | |
| 19 EXTERN_C_BEGIN | |
| 20 | |
| 21 struct NaClDesc; | |
| 22 | |
| 23 struct NaClGioShm { | |
| 24 /* public */ | |
| 25 struct Gio base; | |
| 26 struct NaClDesc *shmp; | |
| 27 /* | |
| 28 * the shmp is public for e.g. xferring via nrd_xfer | |
| 29 */ | |
| 30 | |
| 31 size_t io_offset; | |
| 32 size_t shm_sz; | |
| 33 char *cur_window; | |
| 34 size_t window_offset; | |
| 35 size_t window_size; | |
| 36 }; | |
| 37 | |
| 38 /* | |
| 39 * Create a Gio object backed by a NaClDesc -- any NaClDesc objects | |
| 40 * for which the Map virtual function is usable. The shm_size is the | |
| 41 * size of the file data in the shm object -- so the requirement is | |
| 42 * that *shmp object's size is at least shm_size (and it would | |
| 43 * normally be, since the object size is rounded to | |
| 44 * NACL_MAP_PAGESIZE). The shm_size value is used to limit Seek and | |
| 45 * to know when to report EOF on Read. | |
| 46 * | |
| 47 * The NaClGioShm object is read-only. It takes a reference to the | |
| 48 * shmp when constructed, and releases a reference on destruction. | |
| 49 */ | |
| 50 int NaClGioShmCtor(struct NaClGioShm *self, | |
| 51 struct NaClDesc *shmp, | |
| 52 size_t shm_size); | |
| 53 | |
| 54 int NaClGioShmAllocCtor(struct NaClGioShm *self, | |
| 55 size_t shm_size); | |
| 56 | |
| 57 /* Dtor is a virtual function */ | |
| 58 | |
| 59 EXTERN_C_END | |
| 60 | |
| 61 #endif /* NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_H_ */ | |
| OLD | NEW |