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

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

Issue 303223007: [NaCl SDK] nacl_io: Run clang-format over nacl_io sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
index 990b8236b94792887ec7489bf92108ed8f6844d3..5e43c6c41737d0fb00f0a5ab4677a5679a5ac819 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_glibc.cc
@@ -26,7 +26,6 @@
#include "nacl_io/log.h"
#include "nacl_io/osmman.h"
-
namespace {
void stat_to_nacl_stat(const struct stat* buf, nacl_abi_stat* nacl_buf) {
@@ -55,7 +54,7 @@ void nacl_stat_to_stat(const nacl_abi_stat* nacl_buf, struct stat* buf) {
buf->st_uid = nacl_buf->nacl_abi_st_uid;
buf->st_gid = nacl_buf->nacl_abi_st_gid;
buf->st_rdev = nacl_buf->nacl_abi_st_rdev;
- buf->st_size = nacl_buf->nacl_abi_st_size ;
+ buf->st_size = nacl_buf->nacl_abi_st_size;
buf->st_blksize = nacl_buf->nacl_abi_st_blksize;
buf->st_blocks = nacl_buf->nacl_abi_st_blocks;
buf->st_atime = nacl_buf->nacl_abi_st_atime;
@@ -107,60 +106,57 @@ EXTERN_C_BEGIN
#define WRAP(name) __nacl_irt_##name##_wrap
// Declare REAL function pointer.
-#define DECLARE_REAL_PTR(name) \
- typeof(__nacl_irt_##name) REAL(name);
+#define DECLARE_REAL_PTR(name) typeof(__nacl_irt_##name) REAL(name);
// Assign the REAL function pointer.
-#define ASSIGN_REAL_PTR(name) \
+#define ASSIGN_REAL_PTR(name) \
assert(__nacl_irt_##name != NULL); \
REAL(name) = __nacl_irt_##name;
// Switch IRT's pointer to the REAL pointer
-#define USE_REAL(name) \
- __nacl_irt_##name = (typeof(__nacl_irt_##name)) REAL(name)
+#define USE_REAL(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))REAL(name)
// Switch IRT's pointer to the WRAP function
-#define USE_WRAP(name) \
- __nacl_irt_##name = (typeof(__nacl_irt_##name)) WRAP(name)
+#define USE_WRAP(name) __nacl_irt_##name = (typeof(__nacl_irt_##name))WRAP(name)
#define EXPAND_SYMBOL_LIST_OPERATION(OP) \
- OP(chdir); \
- OP(close); \
- OP(dup); \
- OP(dup2); \
- OP(exit); \
- OP(fstat); \
- OP(getcwd); \
- OP(getdents); \
- OP(mkdir); \
- OP(open); \
- OP(poll);\
- OP(read); \
- OP(rmdir); \
- OP(seek); \
- OP(stat); \
- OP(select); \
- OP(write); \
- OP(mmap); \
- OP(munmap); \
- OP(open_resource); \
- \
- OP(socket); \
- OP(accept); \
- OP(bind); \
- OP(listen); \
- OP(connect); \
- OP(send); \
- OP(sendmsg); \
- OP(sendto); \
- OP(recv); \
- OP(recvmsg); \
- OP(recvfrom); \
- OP(getpeername); \
- OP(getsockname); \
- OP(getsockopt); \
- OP(setsockopt); \
- OP(socketpair); \
+ OP(chdir); \
+ OP(close); \
+ OP(dup); \
+ OP(dup2); \
+ OP(exit); \
+ OP(fstat); \
+ OP(getcwd); \
+ OP(getdents); \
+ OP(mkdir); \
+ OP(open); \
+ OP(poll); \
+ OP(read); \
+ OP(rmdir); \
+ OP(seek); \
+ OP(stat); \
+ OP(select); \
+ OP(write); \
+ OP(mmap); \
+ OP(munmap); \
+ OP(open_resource); \
+ \
+ OP(socket); \
+ OP(accept); \
+ OP(bind); \
+ OP(listen); \
+ OP(connect); \
+ OP(send); \
+ OP(sendmsg); \
+ OP(sendto); \
+ OP(recv); \
+ OP(recvmsg); \
+ OP(recvfrom); \
+ OP(getpeername); \
+ OP(getsockname); \
+ OP(getsockopt); \
+ OP(setsockopt); \
+ OP(socketpair); \
OP(shutdown);
// TODO(bradnelson): Add these as well.
@@ -199,7 +195,7 @@ void WRAP(exit)(int status) {
ki_exit(status);
}
-int WRAP(fstat)(int fd, struct nacl_abi_stat *nacl_buf) {
+int WRAP(fstat)(int fd, struct nacl_abi_stat* nacl_buf) {
struct stat buf;
memset(&buf, 0, sizeof(struct stat));
int res = ki_fstat(fd, &buf);
@@ -213,7 +209,7 @@ int WRAP(getcwd)(char* buf, size_t size) {
return 0;
}
-int WRAP(getdents)(int fd, dirent* nacl_buf, size_t nacl_count, size_t *nread) {
+int WRAP(getdents)(int fd, dirent* nacl_buf, size_t nacl_count, size_t* nread) {
int nacl_offset = 0;
// "buf" contains dirent(s); "nacl_buf" contains nacl_abi_dirent(s).
// nacl_abi_dirent(s) are smaller than dirent(s), so nacl_count bytes buffer
@@ -247,7 +243,11 @@ int WRAP(mkdir)(const char* pathname, mode_t mode) {
return 0;
}
-int WRAP(mmap)(void** addr, size_t length, int prot, int flags, int fd,
+int WRAP(mmap)(void** addr,
+ size_t length,
+ int prot,
+ int flags,
+ int fd,
off_t offset) {
if (flags & MAP_ANONYMOUS)
return REAL(mmap)(addr, length, prot, flags, fd, offset);
@@ -276,13 +276,13 @@ int WRAP(open_resource)(const char* file, int* fd) {
return 0;
}
-int WRAP(poll)(struct pollfd *fds, nfds_t nfds, int timeout, int* count) {
+int WRAP(poll)(struct pollfd* fds, nfds_t nfds, int timeout, int* count) {
*count = ki_poll(fds, nfds, timeout);
RTN_ERRNO_IF(*count < 0);
return 0;
}
-int WRAP(read)(int fd, void *buf, size_t count, size_t *nread) {
+int WRAP(read)(int fd, void* buf, size_t count, size_t* nread) {
ssize_t signed_nread = ki_read(fd, buf, count);
*nread = static_cast<size_t>(signed_nread);
RTN_ERRNO_IF(signed_nread < 0);
@@ -300,14 +300,18 @@ int WRAP(seek)(int fd, off_t offset, int whence, off_t* new_offset) {
return 0;
}
-int WRAP(select)(int nfds, fd_set* readfds, fd_set* writefds,
- fd_set* exceptfds, struct timeval* timeout, int* count) {
+int WRAP(select)(int nfds,
+ fd_set* readfds,
+ fd_set* writefds,
+ fd_set* exceptfds,
+ struct timeval* timeout,
+ int* count) {
*count = ki_select(nfds, readfds, writefds, exceptfds, timeout);
RTN_ERRNO_IF(*count < 0);
return 0;
}
-int WRAP(stat)(const char *pathname, struct nacl_abi_stat *nacl_buf) {
+int WRAP(stat)(const char* pathname, struct nacl_abi_stat* nacl_buf) {
struct stat buf;
memset(&buf, 0, sizeof(struct stat));
int res = ki_stat(pathname, &buf);
@@ -323,8 +327,10 @@ int WRAP(write)(int fd, const void* buf, size_t count, size_t* nwrote) {
return 0;
}
-int WRAP(accept)(int sockfd, struct sockaddr* addr,
- socklen_t* addrlen, int *sd) {
+int WRAP(accept)(int sockfd,
+ struct sockaddr* addr,
+ socklen_t* addrlen,
+ int* sd) {
*sd = ki_accept(sockfd, addr, addrlen);
RTN_ERRNO_IF(*sd < 0);
return 0;
@@ -350,13 +356,19 @@ int WRAP(getsockname)(int sockfd, struct sockaddr* addr, socklen_t* addrlen) {
return 0;
}
-int WRAP(getsockopt)(int sockfd, int level, int optname, void* optval,
+int WRAP(getsockopt)(int sockfd,
+ int level,
+ int optname,
+ void* optval,
socklen_t* optlen) {
RTN_ERRNO_IF(ki_getsockopt(sockfd, level, optname, optval, optlen) < 0);
return 0;
}
-int WRAP(setsockopt)(int sockfd, int level, int optname, const void* optval,
+int WRAP(setsockopt)(int sockfd,
+ int level,
+ int optname,
+ const void* optval,
socklen_t optlen) {
RTN_ERRNO_IF(ki_setsockopt(sockfd, level, optname, optval, optlen) < 0);
return 0;
@@ -374,15 +386,20 @@ int WRAP(recv)(int sockfd, void* buf, size_t len, int flags, int* count) {
return 0;
}
-int WRAP(recvfrom)(int sockfd, void* buf, size_t len, int flags,
- struct sockaddr* addr, socklen_t* addrlen, int* count) {
+int WRAP(recvfrom)(int sockfd,
+ void* buf,
+ size_t len,
+ int flags,
+ struct sockaddr* addr,
+ socklen_t* addrlen,
+ int* count) {
ssize_t signed_nread = ki_recvfrom(sockfd, buf, len, flags, addr, addrlen);
*count = static_cast<int>(signed_nread);
RTN_ERRNO_IF(signed_nread < 0);
return 0;
}
-int WRAP(recvmsg)(int sockfd, struct msghdr* msg, int flags, int *count) {
+int WRAP(recvmsg)(int sockfd, struct msghdr* msg, int flags, int* count) {
ssize_t signed_nread = ki_recvmsg(sockfd, msg, flags);
*count = static_cast<int>(signed_nread);
RTN_ERRNO_IF(signed_nread < 0);
@@ -397,8 +414,12 @@ ssize_t WRAP(send)(int sockfd, const void* buf, size_t len, int flags,
return 0;
}
-ssize_t WRAP(sendto)(int sockfd, const void* buf, size_t len, int flags,
- const struct sockaddr* addr, socklen_t addrlen,
+ssize_t WRAP(sendto)(int sockfd,
+ const void* buf,
+ size_t len,
+ int flags,
+ const struct sockaddr* addr,
+ socklen_t addrlen,
int* count) {
ssize_t signed_nread = ki_sendto(sockfd, buf, len, flags, addr, addrlen);
*count = static_cast<int>(signed_nread);
@@ -406,7 +427,9 @@ ssize_t WRAP(sendto)(int sockfd, const void* buf, size_t len, int flags,
return 0;
}
-ssize_t WRAP(sendmsg)(int sockfd, const struct msghdr* msg, int flags,
+ssize_t WRAP(sendmsg)(int sockfd,
+ const struct msghdr* msg,
+ int flags,
int* count) {
ssize_t signed_nread = ki_sendmsg(sockfd, msg, flags);
*count = static_cast<int>(signed_nread);
@@ -439,7 +462,7 @@ static void assign_real_pointers() {
}
#define CHECK_REAL(func) \
- if (!REAL(func)) \
+ if (!REAL(func)) \
assign_real_pointers();
// "real" functions, i.e. the unwrapped original functions.
@@ -485,8 +508,8 @@ int _real_getdents(int fd, void* buf, size_t count, size_t* nread) {
d->d_ino = nacl_d->nacl_abi_d_ino;
d->d_off = nacl_d->nacl_abi_d_off;
d->d_reclen = nacl_d->nacl_abi_d_reclen + d_name_shift;
- size_t d_name_len = nacl_d->nacl_abi_d_reclen -
- offsetof(nacl_abi_dirent, nacl_abi_d_name);
+ size_t d_name_len =
+ nacl_d->nacl_abi_d_reclen - offsetof(nacl_abi_dirent, nacl_abi_d_name);
memcpy(d->d_name, nacl_d->nacl_abi_d_name, d_name_len);
offset += d->d_reclen;
@@ -507,7 +530,11 @@ int _real_mkdir(const char* pathname, mode_t mode) {
return REAL(mkdir)(pathname, mode);
}
-int _real_mmap(void** addr, size_t length, int prot, int flags, int fd,
+int _real_mmap(void** addr,
+ size_t length,
+ int prot,
+ int flags,
+ int fd,
off_t offset) {
CHECK_REAL(mmap);
return REAL(mmap)(addr, length, prot, flags, fd, offset);
@@ -528,7 +555,7 @@ int _real_open_resource(const char* file, int* fd) {
return REAL(open_resource)(file, fd);
}
-int _real_read(int fd, void *buf, size_t count, size_t *nread) {
+int _real_read(int fd, void* buf, size_t count, size_t* nread) {
CHECK_REAL(read);
return REAL(read)(fd, buf, count, nread);
}
@@ -538,7 +565,7 @@ int _real_rmdir(const char* pathname) {
return REAL(rmdir)(pathname);
}
-int _real_write(int fd, const void *buf, size_t count, size_t *nwrote) {
+int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
CHECK_REAL(write);
return REAL(write)(fd, buf, count, nwrote);
}

Powered by Google App Engine
This is Rietveld 408576698