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 #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 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 | 213 |
214 int WRAP(write)(int fd, const void *buf, size_t count, size_t *nwrote) { | 214 int WRAP(write)(int fd, const void *buf, size_t count, size_t *nwrote) { |
215 if (!ki_is_initialized()) | 215 if (!ki_is_initialized()) |
216 return REAL(write)(fd, buf, count, nwrote); | 216 return REAL(write)(fd, buf, count, nwrote); |
217 | 217 |
218 ssize_t signed_nwrote = ki_write(fd, buf, count); | 218 ssize_t signed_nwrote = ki_write(fd, buf, count); |
219 *nwrote = static_cast<size_t>(signed_nwrote); | 219 *nwrote = static_cast<size_t>(signed_nwrote); |
220 return (signed_nwrote < 0) ? errno : 0; | 220 return (signed_nwrote < 0) ? errno : 0; |
221 } | 221 } |
222 | 222 |
223 // Socket functions | |
Sam Clegg
2013/08/01 20:50:53
duplicate line
torinmr
2013/08/01 22:04:00
Done.
| |
224 // Socket functions | |
225 int accept(int fd, struct sockaddr* addr, socklen_t* len) { | |
226 return ki_accept(fd, addr, len); | |
227 } | |
228 | |
229 int bind(int fd, const struct sockaddr* addr, socklen_t len) { | |
230 return ki_bind(fd, addr, len); | |
231 } | |
232 | |
233 int connect(int fd, const struct sockaddr* addr, socklen_t len) { | |
234 return ki_connect(fd, addr, len); | |
235 } | |
236 | |
237 int getpeername(int fd, struct sockaddr* addr, socklen_t* len) { | |
238 return ki_getpeername(fd, addr, len); | |
239 } | |
240 | |
241 int getsockname(int fd, struct sockaddr* addr, socklen_t* len) { | |
242 return ki_getsockname(fd, addr, len); | |
243 } | |
244 int getsockopt(int fd, int lvl, int optname, void* optval, socklen_t* len) { | |
245 return ki_getsockopt(fd, lvl, optname, optval, len); | |
246 } | |
247 | |
248 int listen(int fd, int backlog) { | |
249 return ki_listen(fd, backlog); | |
250 } | |
251 | |
252 ssize_t recv(int fd, void* buf, size_t len, int flags) { | |
253 return ki_recv(fd, buf, len, flags); | |
254 } | |
255 | |
256 ssize_t recvfrom(int fd, void* buf, size_t len, int flags, | |
257 struct sockaddr* addr, socklen_t* addrlen) { | |
258 return ki_recvfrom(fd, buf, len, flags, addr, addrlen); | |
259 } | |
260 | |
261 ssize_t recvmsg(int fd, struct msghdr* msg, int flags) { | |
262 return ki_recvmsg(fd, msg, flags); | |
263 } | |
264 | |
265 ssize_t send(int fd, const void* buf, size_t len, int flags) { | |
266 return ki_send(fd, buf, len, flags); | |
267 } | |
268 | |
269 ssize_t sendto(int fd, const void* buf, size_t len, int flags, | |
270 const struct sockaddr* addr, socklen_t addrlen) { | |
271 return ki_sendto(fd, buf, len, flags, addr, addrlen); | |
272 } | |
273 | |
274 ssize_t sendmsg(int fd, const struct msghdr* msg, int flags) { | |
275 return ki_sendmsg(fd, msg, flags); | |
276 } | |
277 | |
278 int setsockopt(int fd, int lvl, int optname, const void* optval, | |
279 socklen_t len) { | |
Sam Clegg
2013/08/01 20:50:53
alignment.
torinmr
2013/08/01 22:04:00
Done.
| |
280 return ki_setsockopt(fd, lvl, optname, optval, len); | |
281 } | |
282 | |
283 int shutdown(int fd, int how) { | |
284 return ki_shutdown(fd, how); | |
285 } | |
286 | |
287 int socket(int domain, int type, int protocol) { | |
288 return ki_socket(domain, type, protocol); | |
289 } | |
290 | |
291 int socketpair(int domain, int type, int protocol, int* sv) { | |
292 return ki_socketpair(domain, type, protocol, sv); | |
293 } | |
223 | 294 |
224 // "real" functions, i.e. the unwrapped original functions. | 295 // "real" functions, i.e. the unwrapped original functions. |
225 | 296 |
226 int _real_close(int fd) { | 297 int _real_close(int fd) { |
227 return REAL(close)(fd); | 298 return REAL(close)(fd); |
228 } | 299 } |
229 | 300 |
230 int _real_fstat(int fd, struct stat *buf) { | 301 int _real_fstat(int fd, struct stat *buf) { |
231 return REAL(fstat)(fd, buf); | 302 return REAL(fstat)(fd, buf); |
232 } | 303 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL); | 362 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL); |
292 s_wrapped = false; | 363 s_wrapped = false; |
293 } | 364 } |
294 } | 365 } |
295 | 366 |
296 EXTERN_C_END | 367 EXTERN_C_END |
297 | 368 |
298 | 369 |
299 #endif // defined(__native_client__) && !defined(__GLIBC__) | 370 #endif // defined(__native_client__) && !defined(__GLIBC__) |
300 | 371 |
OLD | NEW |