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

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc

Issue 757293005: [NaCl SDK] nacl_io: wrap kernel intercept calls in a macro (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
index 4d1e1b65ce5205fd071da0d61f5ccd032c67ed5f..8a595a57a5b43a367e8e40b1d6bf71528e7ab7aa 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc
@@ -26,6 +26,20 @@ using namespace nacl_io;
return x; \
}
+#define TRACE_KP_CALLS 0
+
+#if TRACE_KP_CALLS
+#define TRACE_KP nacl_io_log
+#else
+#define TRACE_KP(...)
+#endif
+
+#define KP_CALL(METHOD, ARGS) \
binji 2014/12/02 18:31:56 I like this in general, but I don't like that you'
Sam Clegg 2015/01/13 18:46:29 Done.
+ ON_NOSYS_RETURN(-1); \
+ int rtn = s_state.kp-> METHOD ARGS; \
+ TRACE_KP("ki_" #METHOD " -> %d\n", rtn); \
+ return rtn;
+
struct KernelInterceptState {
KernelProxy* kp;
PepperInterface* ppapi;
@@ -136,11 +150,6 @@ nacl_io::KernelProxy* ki_get_proxy() {
return s_state.kp;
}
-int ki_chdir(const char* path) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->chdir(path);
-}
-
void ki_exit(int status) {
if (ki_is_initialized())
s_state.kp->exit(status);
@@ -173,44 +182,40 @@ char* ki_getwd(char* buf) {
return s_state.kp->getwd(buf);
}
+int ki_chdir(const char* path) {
+ KP_CALL(chdir, (path));
+}
+
int ki_dup(int oldfd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->dup(oldfd);
+ KP_CALL(dup, (oldfd));
}
int ki_dup2(int oldfd, int newfd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->dup2(oldfd, newfd);
+ KP_CALL(dup2, (oldfd, newfd));
}
int ki_chmod(const char* path, mode_t mode) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->chmod(path, mode);
+ KP_CALL(chmod, (path, mode));
}
int ki_fchdir(int fd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->fchdir(fd);
+ KP_CALL(fchdir, (fd));
}
int ki_fchmod(int fd, mode_t mode) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->fchmod(fd, mode);
+ KP_CALL(fchmod, (fd, mode));
}
int ki_stat(const char* path, struct stat* buf) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->stat(path, buf);
+ KP_CALL(stat, (path, buf));
}
int ki_mkdir(const char* path, mode_t mode) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->mkdir(path, mode);
+ KP_CALL(mkdir, (path, mode));
}
int ki_rmdir(const char* path) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->rmdir(path);
+ KP_CALL(rmdir, (path));
}
int ki_mount(const char* source,
@@ -218,23 +223,19 @@ int ki_mount(const char* source,
const char* filesystemtype,
unsigned long mountflags,
const void* data) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->mount(source, target, filesystemtype, mountflags, data);
+ KP_CALL(mount, (source, target, filesystemtype, mountflags, data));
}
int ki_umount(const char* path) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->umount(path);
+ KP_CALL(umount, (path));
}
int ki_open(const char* path, int oflag, mode_t mode) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->open(path, oflag, mode);
+ KP_CALL(open, (path, oflag, mode));
}
int ki_pipe(int pipefds[2]) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->pipe(pipefds);
+ KP_CALL(pipe, (pipefds));
}
ssize_t ki_read(int fd, void* buf, size_t nbyte) {
@@ -248,28 +249,23 @@ ssize_t ki_write(int fd, const void* buf, size_t nbyte) {
}
int ki_fstat(int fd, struct stat* buf) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->fstat(fd, buf);
+ KP_CALL(fstat, (fd, buf));
}
int ki_getdents(int fd, void* buf, unsigned int count) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->getdents(fd, buf, count);
+ KP_CALL(getdents, (fd, buf, count));
}
int ki_ftruncate(int fd, off_t length) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->ftruncate(fd, length);
+ KP_CALL(ftruncate, (fd, length));
}
int ki_fsync(int fd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->fsync(fd);
+ KP_CALL(fsync, (fd));
}
int ki_fdatasync(int fd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->fdatasync(fd);
+ KP_CALL(fdatasync, (fd));
}
int ki_isatty(int fd) {
@@ -278,8 +274,7 @@ int ki_isatty(int fd) {
}
int ki_close(int fd) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->close(fd);
+ KP_CALL(close, (fd));
}
off_t ki_lseek(int fd, off_t offset, int whence) {
@@ -288,48 +283,39 @@ off_t ki_lseek(int fd, off_t offset, int whence) {
}
int ki_remove(const char* path) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->remove(path);
+ KP_CALL(remove, (path));
}
int ki_unlink(const char* path) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->unlink(path);
+ KP_CALL(unlink, (path));
}
int ki_truncate(const char* path, off_t length) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->truncate(path, length);
+ KP_CALL(truncate, (path, length));
}
int ki_lstat(const char* path, struct stat* buf) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->lstat(path, buf);
+ KP_CALL(lstat, (path, buf));
}
int ki_link(const char* oldpath, const char* newpath) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->link(oldpath, newpath);
+ KP_CALL(link, (oldpath, newpath));
}
int ki_rename(const char* path, const char* newpath) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->rename(path, newpath);
+ KP_CALL(rename, (path, newpath));
}
int ki_symlink(const char* oldpath, const char* newpath) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->symlink(oldpath, newpath);
+ KP_CALL(symlink, (oldpath, newpath));
}
int ki_access(const char* path, int amode) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->access(path, amode);
+ KP_CALL(access, (path, amode));
}
int ki_readlink(const char* path, char* buf, size_t count) {
- ON_NOSYS_RETURN(-1);
- return s_state.kp->readlink(path, buf, count);
+ KP_CALL(readlink, (path, buf, count));
}
int ki_utimes(const char* path, const struct timeval times[2]) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698