Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_wrap_newlib.cc

Issue 19271009: [NaCl SDK} Add EventListener and EventEmitter to support epoll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <sys/types.h> // Include something that will define __GLIBC__. 5 #include <sys/types.h> // Include something that will define __GLIBC__.
6 6
7 // The entire file is wrapped in this #if. We do this so this .cc file can be 7 // The entire file is wrapped in this #if. We do this so this .cc file can be
8 // compiled, even on a non-newlib build. 8 // compiled, even on a non-newlib build.
9 #if defined(__native_client__) && !defined(__GLIBC__) 9 #if defined(__native_client__) && !defined(__GLIBC__)
10 10
11 #include "nacl_io/kernel_wrap.h" 11 #include "nacl_io/kernel_wrap.h"
12 #include <dirent.h> 12 #include <dirent.h>
13 #include <errno.h> 13 #include <errno.h>
14 #include <irt.h> 14 #include <irt.h>
15 #include <sys/mman.h> 15 #include <sys/mman.h>
16 #include <sys/stat.h> 16 #include <sys/stat.h>
17 #include <sys/time.h>
17 #include "nacl_io/kernel_intercept.h" 18 #include "nacl_io/kernel_intercept.h"
18 19
19 EXTERN_C_BEGIN 20 EXTERN_C_BEGIN
20 21
21 #define REAL(name) __nacl_irt_##name##_real 22 #define REAL(name) __nacl_irt_##name##_real
22 #define WRAP(name) __nacl_irt_##name##_wrap 23 #define WRAP(name) __nacl_irt_##name##_wrap
23 #define STRUCT_NAME(group) __libnacl_irt_##group 24 #define STRUCT_NAME(group) __libnacl_irt_##group
24 #define DECLARE_STRUCT(group) \ 25 #define DECLARE_STRUCT(group) \
25 extern struct nacl_irt_##group STRUCT_NAME(group); 26 extern struct nacl_irt_##group STRUCT_NAME(group);
26 #define DECLARE_STRUCT_VERSION(group, version) \ 27 #define DECLARE_STRUCT_VERSION(group, version) \
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 255 }
255 256
256 int _real_rmdir(const char* pathname) { 257 int _real_rmdir(const char* pathname) {
257 return ENOSYS; 258 return ENOSYS;
258 } 259 }
259 260
260 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) { 261 int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
261 return REAL(write)(fd, buf, count, nwrote); 262 return REAL(write)(fd, buf, count, nwrote);
262 } 263 }
263 264
265 uint64_t usec_since_epoch() {
266 struct timeval tv;
267 gettimeofday(&tv, NULL);
268 return tv.tv_usec + (tv.tv_sec * 1000000);
269 }
264 270
265 void kernel_wrap_init() { 271 void kernel_wrap_init() {
266 static bool wrapped = false; 272 static bool wrapped = false;
267 273
268 if (!wrapped) { 274 if (!wrapped) {
269 wrapped = true; 275 wrapped = true;
270 DO_WRAP(fdio, close); 276 DO_WRAP(fdio, close);
271 DO_WRAP(fdio, dup); 277 DO_WRAP(fdio, dup);
272 DO_WRAP(fdio, dup2); 278 DO_WRAP(fdio, dup2);
273 DO_WRAP(fdio, fstat); 279 DO_WRAP(fdio, fstat);
274 DO_WRAP(fdio, getdents); 280 DO_WRAP(fdio, getdents);
275 DO_WRAP(fdio, read); 281 DO_WRAP(fdio, read);
276 DO_WRAP(fdio, seek); 282 DO_WRAP(fdio, seek);
277 DO_WRAP(fdio, write); 283 DO_WRAP(fdio, write);
278 DO_WRAP(filename, open); 284 DO_WRAP(filename, open);
279 DO_WRAP(filename, stat); 285 DO_WRAP(filename, stat);
280 DO_WRAP(memory, mmap); 286 DO_WRAP(memory, mmap);
281 DO_WRAP(memory, munmap); 287 DO_WRAP(memory, munmap);
282 } 288 }
283 } 289 }
284 290
285 291
286 EXTERN_C_END 292 EXTERN_C_END
287 293
288 294
289 #endif // defined(__native_client__) && !defined(__GLIBC__) 295 #endif // defined(__native_client__) && !defined(__GLIBC__)
290 296
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698