OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 entire file is wrapped in this #if. We do this so this .cc file can be | 5 // The entire file is wrapped in this #if. We do this so this .cc file can be |
6 // compiled, even on a non-Windows build. | 6 // compiled, even on a non-Windows build. |
7 #if defined(WIN32) | 7 #if defined(WIN32) |
8 | 8 |
9 #include "nacl_io/kernel_wrap.h" | 9 #include "nacl_io/kernel_wrap.h" |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return ki_utime(filename, times); | 208 return ki_utime(filename, times); |
209 } | 209 } |
210 | 210 |
211 int _write(int fd, const void* buf, size_t nbyte) { | 211 int _write(int fd, const void* buf, size_t nbyte) { |
212 if (!ki_is_initialized()) | 212 if (!ki_is_initialized()) |
213 return 0; | 213 return 0; |
214 | 214 |
215 return ki_write(fd, buf, nbyte); | 215 return ki_write(fd, buf, nbyte); |
216 } | 216 } |
217 | 217 |
218 | |
219 // "real" functions, i.e. the unwrapped original functions. On Windows we don't | |
220 // wrap, so the real functions aren't accessible. In most cases, we just fail. | |
221 | |
222 int _real_close(int fd) { | |
223 return ENOSYS; | |
224 } | |
225 | |
226 int _real_fstat(int fd, struct stat *buf) { | |
227 return 0; | |
228 } | |
229 | |
230 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t *nread) { | |
231 return ENOSYS; | |
232 } | |
233 | |
234 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) { | |
235 return ENOSYS; | |
236 } | |
237 | |
238 int _real_mkdir(const char* pathname, mode_t mode) { | |
239 return ENOSYS; | |
240 } | |
241 | |
242 int _real_mmap(void** addr, size_t length, int prot, int flags, int fd, | |
243 off_t offset) { | |
244 return ENOSYS; | |
245 } | |
246 | |
247 int _real_munmap(void* addr, size_t length) { | |
248 return ENOSYS; | |
249 } | |
250 | |
251 int _real_open(const char* pathname, int oflag, mode_t cmode, int* newfd) { | |
252 return ENOSYS; | |
253 } | |
254 | |
255 int _real_open_resource(const char* file, int* fd) { | |
256 return ENOSYS; | |
257 } | |
258 | |
259 int _real_read(int fd, void *buf, size_t count, size_t *nread) { | |
260 *nread = count; | |
261 return 0; | |
262 } | |
263 | |
264 int _real_rmdir(const char* pathname) { | |
265 return ENOSYS; | |
266 } | |
267 | |
268 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) { | |
269 *nwrote = count; | |
270 return 0; | |
271 } | |
272 | |
273 #define USECS_FROM_WIN_TO_TO_UNIX_EPOCH 11644473600000LL | |
274 uint64_t usec_since_epoch() { | |
275 FILETIME ft; | |
276 ULARGE_INTEGER ularge; | |
277 GetSystemTimeAsFileTime(&ft); | |
278 | |
279 ularge.LowPart = ft.dwLowDateTime; | |
280 ularge.HighPart = ft.dwHighDateTime; | |
281 | |
282 // Truncate to usec resolution. | |
283 return ularge.QuadPart / 10; | |
284 } | |
285 | |
286 // Do nothing for Windows, we replace the library at link time. | 218 // Do nothing for Windows, we replace the library at link time. |
287 void kernel_wrap_init() { | 219 void kernel_wrap_init() { |
288 } | 220 } |
289 | 221 |
290 void kernel_wrap_uninit() { | 222 void kernel_wrap_uninit() { |
291 } | 223 } |
292 | 224 |
293 EXTERN_C_END | 225 EXTERN_C_END |
294 | 226 |
295 #endif // defined(WIN32) | 227 #endif // defined(WIN32) |
296 | 228 |
OLD | NEW |