Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #if defined WIN32 || defined __linux__ | |
|
binji
2013/11/15 17:26:23
copyright
binji
2013/11/15 17:26:23
in the other files we use defined(...)
Sam Clegg
2013/11/15 18:13:34
Done.
Sam Clegg
2013/11/15 18:13:34
Done.
| |
| 2 | |
| 3 #include <errno.h> | |
| 4 | |
| 5 #include "nacl_io/kernel_wrap.h" | |
| 6 #include "nacl_io/kernel_wrap_real.h" | |
| 7 | |
| 8 // "real" functions, i.e. the unwrapped original functions. On Windows we don't | |
|
binji
2013/11/15 17:26:23
change comment?
Sam Clegg
2013/11/15 18:13:34
Done.
| |
| 9 // wrap, so the real functions aren't accessible. In most cases, we just fail. | |
| 10 | |
|
binji
2013/11/15 17:26:23
The linux host implementation is a bit different t
| |
| 11 int _real_close(int fd) { | |
| 12 return ENOSYS; | |
| 13 } | |
| 14 | |
| 15 int _real_fstat(int fd, struct stat *buf) { | |
| 16 return 0; | |
| 17 } | |
| 18 | |
| 19 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) { | |
| 20 return ENOSYS; | |
| 21 } | |
| 22 | |
| 23 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) { | |
| 24 return ENOSYS; | |
| 25 } | |
| 26 | |
| 27 int _real_mkdir(const char* pathname, mode_t mode) { | |
| 28 return ENOSYS; | |
| 29 } | |
| 30 | |
| 31 int _real_mmap(void** addr, size_t length, int prot, int flags, int fd, | |
| 32 off_t offset) { | |
| 33 return ENOSYS; | |
| 34 } | |
| 35 | |
| 36 int _real_munmap(void* addr, size_t length) { | |
| 37 return ENOSYS; | |
| 38 } | |
| 39 | |
| 40 int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) { | |
| 41 return ENOSYS; | |
| 42 } | |
| 43 | |
| 44 int _real_open_resource(const char* file, int* fd) { | |
| 45 return ENOSYS; | |
| 46 } | |
| 47 | |
| 48 int _real_read(int fd, void *buf, size_t count, size_t *nread) { | |
| 49 *nread = count; | |
| 50 return 0; | |
| 51 } | |
| 52 | |
| 53 int _real_rmdir(const char* pathname) { | |
| 54 return ENOSYS; | |
| 55 } | |
| 56 | |
| 57 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) { | |
| 58 int rtn = write(fd, buf, count); | |
| 59 if (rtn < 0) | |
| 60 return -1; | |
| 61 | |
| 62 *nwrote = rtn; | |
| 63 return 0; | |
| 64 } | |
| 65 | |
| 66 #endif | |
| 67 | |
| 68 #ifdef __linux__ | |
| 69 | |
| 70 void kernel_wrap_init() { | |
| 71 } | |
| 72 | |
| 73 void kernel_wrap_uninit() { | |
| 74 } | |
| 75 | |
| 76 #endif | |
| OLD | NEW |