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 #ifndef LIBRARIES_NACL_IO_KERNEL_WRAP_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_WRAP_H_ |
6 #define LIBRARIES_NACL_IO_KERNEL_WRAP_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_WRAP_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 #include <signal.h> | 9 #include <signal.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #define NOTHROW __THROW | 23 #define NOTHROW __THROW |
24 #else | 24 #else |
25 #define NOTHROW | 25 #define NOTHROW |
26 #endif | 26 #endif |
27 | 27 |
28 // Most kernel intercept functions (ki_*) return -1 and set the global errno. | 28 // Most kernel intercept functions (ki_*) return -1 and set the global errno. |
29 // However, the IRT wrappers are expected to return errno on failure. These | 29 // However, the IRT wrappers are expected to return errno on failure. These |
30 // macros are used in the wrappers to check that the ki_ function actually | 30 // macros are used in the wrappers to check that the ki_ function actually |
31 // set errno and to its value. | 31 // set errno and to its value. |
32 #define RTN_ERRNO_IF(cond) \ | 32 #define RTN_ERRNO_IF(cond) \ |
33 if (cond) { \ | 33 if (cond) { \ |
34 assert(errno != 0); \ | 34 assert(errno != 0); \ |
35 return errno; \ | 35 return errno; \ |
36 } | 36 } |
37 | 37 |
38 #define ERRNO_RTN(cond) \ | 38 #define ERRNO_RTN(cond) \ |
39 RTN_ERRNO_IF(cond < 0); \ | 39 RTN_ERRNO_IF(cond < 0); \ |
40 return 0; | 40 return 0; |
41 | 41 |
42 #if defined(WIN32) | 42 #if defined(WIN32) |
43 typedef int chmod_mode_t; | 43 typedef int chmod_mode_t; |
44 typedef int getcwd_size_t; | 44 typedef int getcwd_size_t; |
45 typedef int read_ssize_t; | 45 typedef int read_ssize_t; |
46 typedef int write_ssize_t; | 46 typedef int write_ssize_t; |
47 #define NAME(x) _##x | 47 #define NAME(x) _##x |
48 #else | 48 #else |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // Socket Functions | 123 // Socket Functions |
124 int accept(int fd, struct sockaddr* addr, socklen_t* len); | 124 int accept(int fd, struct sockaddr* addr, socklen_t* len); |
125 int bind(int fd, const struct sockaddr* addr, socklen_t len); | 125 int bind(int fd, const struct sockaddr* addr, socklen_t len); |
126 int connect(int fd, const struct sockaddr* addr, socklen_t len); | 126 int connect(int fd, const struct sockaddr* addr, socklen_t len); |
127 struct hostent* gethostbyname(const char* name); | 127 struct hostent* gethostbyname(const char* name); |
128 int getpeername(int fd, struct sockaddr* addr, socklen_t* len); | 128 int getpeername(int fd, struct sockaddr* addr, socklen_t* len); |
129 int getsockname(int fd, struct sockaddr* addr, socklen_t* len); | 129 int getsockname(int fd, struct sockaddr* addr, socklen_t* len); |
130 int getsockopt(int fd, int lvl, int optname, void* optval, socklen_t* len); | 130 int getsockopt(int fd, int lvl, int optname, void* optval, socklen_t* len); |
131 int listen(int fd, int backlog); | 131 int listen(int fd, int backlog); |
132 ssize_t recv(int fd, void* buf, size_t len, int flags); | 132 ssize_t recv(int fd, void* buf, size_t len, int flags); |
133 ssize_t recvfrom(int fd, void* buf, size_t len, int flags, | 133 ssize_t recvfrom(int fd, |
134 struct sockaddr* addr, socklen_t* addrlen); | 134 void* buf, |
| 135 size_t len, |
| 136 int flags, |
| 137 struct sockaddr* addr, |
| 138 socklen_t* addrlen); |
135 ssize_t recvmsg(int fd, struct msghdr* msg, int flags); | 139 ssize_t recvmsg(int fd, struct msghdr* msg, int flags); |
136 ssize_t send(int fd, const void* buf, size_t len, int flags); | 140 ssize_t send(int fd, const void* buf, size_t len, int flags); |
137 ssize_t sendto(int fd, const void* buf, size_t len, int flags, | 141 ssize_t sendto(int fd, |
138 const struct sockaddr* addr, socklen_t addrlen); | 142 const void* buf, |
| 143 size_t len, |
| 144 int flags, |
| 145 const struct sockaddr* addr, |
| 146 socklen_t addrlen); |
139 ssize_t sendmsg(int fd, const struct msghdr* msg, int flags); | 147 ssize_t sendmsg(int fd, const struct msghdr* msg, int flags); |
140 int setsockopt(int fd, int lvl, int optname, const void* optval, | 148 int setsockopt(int fd, int lvl, int optname, const void* optval, socklen_t len); |
141 socklen_t len); | |
142 int shutdown(int fd, int how); | 149 int shutdown(int fd, int how); |
143 int socket(int domain, int type, int protocol); | 150 int socket(int domain, int type, int protocol); |
144 int socketpair(int domain, int type, int protocl, int* sv); | 151 int socketpair(int domain, int type, int protocl, int* sv); |
145 #endif // PROVIDES_SOCKET_API | 152 #endif // PROVIDES_SOCKET_API |
146 | 153 |
147 EXTERN_C_END | 154 EXTERN_C_END |
148 | 155 |
149 #endif // LIBRARIES_NACL_IO_KERNEL_WRAP_H_ | 156 #endif // LIBRARIES_NACL_IO_KERNEL_WRAP_H_ |
OLD | NEW |