OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium 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 // The Chromium build system defines __linux__ even for native client builds, | 5 // The Chromium build system defines __linux__ even for native client builds, |
6 // so guard against __native_client__ being defined as well. | 6 // so guard against __native_client__ being defined as well. |
7 #if defined(WIN32) || (defined(__linux__) && !defined(__native_client__)) | 7 #if defined(WIN32) || (defined(__linux__) && !defined(__native_client__)) |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 | 10 |
11 #include "nacl_io/kernel_wrap.h" | 11 #include "nacl_io/kernel_wrap.h" |
12 #include "nacl_io/kernel_wrap_real.h" | 12 #include "nacl_io/kernel_wrap_real.h" |
13 | 13 |
14 // "real" functions, i.e. the unwrapped original functions. For Windows/Linux | 14 // "real" functions, i.e. the unwrapped original functions. For Windows/Linux |
15 // host builds we don't wrap, so the real functions aren't accessible. In most | 15 // host builds we don't wrap, so the real functions aren't accessible. In most |
16 // cases, we just fail. | 16 // cases, we just fail. |
17 | 17 |
18 int _real_close(int fd) { | 18 int _real_close(int fd) { |
19 return ENOSYS; | 19 return ENOSYS; |
20 } | 20 } |
21 | 21 |
22 int _real_fstat(int fd, struct stat *buf) { | 22 int _real_fstat(int fd, struct stat* buf) { |
23 return 0; | 23 return 0; |
24 } | 24 } |
25 | 25 |
26 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) { | 26 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t* nread) { |
27 return ENOSYS; | 27 return ENOSYS; |
28 } | 28 } |
29 | 29 |
30 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) { | 30 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) { |
31 return ENOSYS; | 31 return ENOSYS; |
32 } | 32 } |
33 | 33 |
34 int _real_mkdir(const char* pathname, mode_t mode) { | 34 int _real_mkdir(const char* pathname, mode_t mode) { |
35 return ENOSYS; | 35 return ENOSYS; |
36 } | 36 } |
37 | 37 |
38 int _real_mmap(void** addr, size_t length, int prot, int flags, int fd, | 38 int _real_mmap(void** addr, |
| 39 size_t length, |
| 40 int prot, |
| 41 int flags, |
| 42 int fd, |
39 off_t offset) { | 43 off_t offset) { |
40 return ENOSYS; | 44 return ENOSYS; |
41 } | 45 } |
42 | 46 |
43 int _real_munmap(void* addr, size_t length) { | 47 int _real_munmap(void* addr, size_t length) { |
44 return ENOSYS; | 48 return ENOSYS; |
45 } | 49 } |
46 | 50 |
47 int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) { | 51 int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) { |
48 return ENOSYS; | 52 return ENOSYS; |
49 } | 53 } |
50 | 54 |
51 int _real_open_resource(const char* file, int* fd) { | 55 int _real_open_resource(const char* file, int* fd) { |
52 return ENOSYS; | 56 return ENOSYS; |
53 } | 57 } |
54 | 58 |
55 int _real_read(int fd, void *buf, size_t count, size_t *nread) { | 59 int _real_read(int fd, void* buf, size_t count, size_t* nread) { |
56 *nread = count; | 60 *nread = count; |
57 return 0; | 61 return 0; |
58 } | 62 } |
59 | 63 |
60 int _real_rmdir(const char* pathname) { | 64 int _real_rmdir(const char* pathname) { |
61 return ENOSYS; | 65 return ENOSYS; |
62 } | 66 } |
63 | 67 |
64 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) { | 68 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) { |
65 int rtn = write(fd, buf, count); | 69 int rtn = write(fd, buf, count); |
66 if (rtn < 0) | 70 if (rtn < 0) |
67 return -1; | 71 return -1; |
68 | 72 |
69 *nwrote = rtn; | 73 *nwrote = rtn; |
70 return 0; | 74 return 0; |
71 } | 75 } |
72 | 76 |
73 void _real_exit(int status) { | 77 void _real_exit(int status) { |
74 exit(status); | 78 exit(status); |
75 } | 79 } |
76 | 80 |
77 #endif | 81 #endif |
78 | 82 |
79 // The Chromium build system defines __linux__ even for native client builds, | 83 // The Chromium build system defines __linux__ even for native client builds, |
80 // so guard against __native_client__ being defined as well. | 84 // so guard against __native_client__ being defined as well. |
81 #if defined(__linux__) && !defined(__native_client__) | 85 #if defined(__linux__) && !defined(__native_client__) |
82 | 86 |
83 void kernel_wrap_init() { | 87 void kernel_wrap_init() { |
84 } | 88 } |
85 | 89 |
86 void kernel_wrap_uninit() { | 90 void kernel_wrap_uninit() { |
87 } | 91 } |
88 | 92 |
89 #endif | 93 #endif |
OLD | NEW |