OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <irt.h> | 7 #include <irt.h> |
8 #ifdef __GLIBC__ | 8 #ifdef __GLIBC__ |
9 #include <irt_syscalls.h> | 9 #include <irt_syscalls.h> |
10 #endif | 10 #endif |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 int symlink(const char *path1, const char *path2) { | 164 int symlink(const char *path1, const char *path2) { |
165 return kp->symlink(path1, path2); | 165 return kp->symlink(path1, path2); |
166 } | 166 } |
167 | 167 |
168 int kill(pid_t pid, int sig) { | 168 int kill(pid_t pid, int sig) { |
169 return kp->kill(pid, sig); | 169 return kp->kill(pid, sig); |
170 } | 170 } |
171 | 171 |
| 172 struct hostent* gethostbyname(const char* name) { |
| 173 return kp->gethostbyname(name); |
| 174 } |
| 175 |
172 int unlink(const char *path) { | 176 int unlink(const char *path) { |
173 return kp->unlink(path); | 177 return kp->unlink(path); |
174 } | 178 } |
175 | 179 |
176 ssize_t __real_read(int fd, void *buf, size_t count) { | 180 ssize_t __real_read(int fd, void *buf, size_t count) { |
177 if (REAL(read)) { | 181 if (REAL(read)) { |
178 size_t nread; | 182 size_t nread; |
179 int error = REAL(read)(fd, buf, count, &nread); | 183 int error = REAL(read)(fd, buf, count, &nread); |
180 if (error) { | 184 if (error) { |
181 errno = error; | 185 errno = error; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 struct sockaddr *src_addr, socklen_t *addrlen, int* ret) { | 401 struct sockaddr *src_addr, socklen_t *addrlen, int* ret) { |
398 *ret = kp->recvfrom(sockfd, buf, len, flags, src_addr, addrlen); | 402 *ret = kp->recvfrom(sockfd, buf, len, flags, src_addr, addrlen); |
399 return (*ret < 0) ? errno : 0; | 403 return (*ret < 0) ? errno : 0; |
400 } | 404 } |
401 | 405 |
402 int WRAP(recvmsg) (int sockfd, struct msghdr *msg, int flags, int* ret) { | 406 int WRAP(recvmsg) (int sockfd, struct msghdr *msg, int flags, int* ret) { |
403 *ret = kp->recvmsg(sockfd, msg, flags); | 407 *ret = kp->recvmsg(sockfd, msg, flags); |
404 return (*ret < 0) ? errno : 0; | 408 return (*ret < 0) ? errno : 0; |
405 } | 409 } |
406 | 410 |
| 411 struct hostent* WRAP(gethostbyname) (const char* name) { |
| 412 return kp->gethostbyname(name); |
| 413 } |
| 414 |
| 415 |
407 int WRAP(getsockname) (int sockfd, struct sockaddr* addr, | 416 int WRAP(getsockname) (int sockfd, struct sockaddr* addr, |
408 socklen_t* addrlen) { | 417 socklen_t* addrlen) { |
409 return (kp->getsockname(sockfd, addr, addrlen)) < 0 ? errno : 0; | 418 return (kp->getsockname(sockfd, addr, addrlen)) < 0 ? errno : 0; |
410 } | 419 } |
411 | 420 |
412 int WRAP(getpeername) (int sockfd, struct sockaddr* addr, | 421 int WRAP(getpeername) (int sockfd, struct sockaddr* addr, |
413 socklen_t* addrlen) { | 422 socklen_t* addrlen) { |
414 return (kp->getpeername(sockfd, addr, addrlen) < 0) ? errno : 0; | 423 return (kp->getpeername(sockfd, addr, addrlen) < 0) ? errno : 0; |
415 } | 424 } |
416 | 425 |
(...skipping 10 matching lines...) Expand all Loading... |
427 } | 436 } |
428 | 437 |
429 int WRAP(socketpair) (int domain, int type, int protocol, int sv[2]) { | 438 int WRAP(socketpair) (int domain, int type, int protocol, int sv[2]) { |
430 return (kp->socketpair(domain, type, protocol, sv) < 0) ? errno : 0; | 439 return (kp->socketpair(domain, type, protocol, sv) < 0) ? errno : 0; |
431 } | 440 } |
432 | 441 |
433 int WRAP(shutdown) (int sockfd, int how) { | 442 int WRAP(shutdown) (int sockfd, int how) { |
434 return (kp->shutdown(sockfd, how) < 0) ? errno : 0; | 443 return (kp->shutdown(sockfd, how) < 0) ? errno : 0; |
435 } | 444 } |
436 | 445 |
437 int WRAP(epoll_create) (int size, int* ret) { | |
438 *ret = kp->epoll_create(size); | |
439 return (*ret < 0) ? errno : 0; | |
440 } | |
441 | |
442 int WRAP(epoll_ctl) (int epfd, int op, int fd, struct epoll_event *event) { | |
443 return (kp->epoll_ctl(epfd, op, fd, event) < 0) ? errno : 0; | |
444 } | |
445 | |
446 int WRAP(epoll_wait) (int epfd, struct epoll_event *events, | |
447 int maxevents, int timeout, int *count) { | |
448 *count = kp->epoll_wait(epfd, events, maxevents, timeout); | |
449 return (*count < 0) ? errno : 0; | |
450 } | |
451 | |
452 int WRAP(epoll_pwait) (int epfd, struct epoll_event *events, | |
453 int maxevents, int timeout, const sigset_t *sigmask, | |
454 size_t sigset_size, int *count) { | |
455 *count = kp->epoll_pwait(epfd, events, maxevents, timeout, sigmask, | |
456 sigset_size); | |
457 return (*count < 0) ? errno : 0; | |
458 } | |
459 | |
460 int WRAP(poll) (struct pollfd *fds, nfds_t nfds, int timeout, int *count) { | |
461 *count = kp->poll(fds, nfds, timeout); | |
462 return (*count < 0) ? errno : 0; | |
463 } | |
464 | |
465 int WRAP(ppoll) (struct pollfd *fds, nfds_t nfds, | |
466 const struct timespec *timeout, const sigset_t *sigmask, | |
467 size_t sigset_size, int *count) { | |
468 *count = kp->ppoll(fds, nfds, timeout, sigmask, sigset_size); | |
469 return (*count < 0) ? errno : 0; | |
470 } | |
471 #endif | 446 #endif |
472 } | 447 } |
473 | 448 |
474 static struct NaClMountsStaticInitializer { | 449 static struct NaClMountsStaticInitializer { |
475 NaClMountsStaticInitializer() { | 450 NaClMountsStaticInitializer() { |
476 DO_WRAP(fdio, close); | 451 DO_WRAP(fdio, close); |
477 DO_WRAP(fdio, fstat); | 452 DO_WRAP(fdio, fstat); |
478 DO_WRAP(fdio, getdents); | 453 DO_WRAP(fdio, getdents); |
479 DO_WRAP(fdio, read); | 454 DO_WRAP(fdio, read); |
480 DO_WRAP(fdio, seek); | 455 DO_WRAP(fdio, seek); |
(...skipping 18 matching lines...) Expand all Loading... |
499 DO_WRAP(net, sendmsg); | 474 DO_WRAP(net, sendmsg); |
500 DO_WRAP(net, recv); | 475 DO_WRAP(net, recv); |
501 DO_WRAP(net, recvfrom); | 476 DO_WRAP(net, recvfrom); |
502 DO_WRAP(net, recvmsg); | 477 DO_WRAP(net, recvmsg); |
503 DO_WRAP(net, getpeername); | 478 DO_WRAP(net, getpeername); |
504 DO_WRAP(net, getsockname); | 479 DO_WRAP(net, getsockname); |
505 DO_WRAP(net, getsockopt); | 480 DO_WRAP(net, getsockopt); |
506 DO_WRAP(net, setsockopt); | 481 DO_WRAP(net, setsockopt); |
507 DO_WRAP(net, socketpair); | 482 DO_WRAP(net, socketpair); |
508 DO_WRAP(net, shutdown); | 483 DO_WRAP(net, shutdown); |
509 | |
510 DO_WRAP(net, epoll_create); | |
511 DO_WRAP(net, epoll_ctl); | |
512 DO_WRAP(net, epoll_wait); | |
513 DO_WRAP(net, epoll_pwait); | |
514 DO_WRAP(net, poll); | |
515 DO_WRAP(net, ppoll); | |
516 #endif | 484 #endif |
517 } | 485 } |
518 } nacl_mounts_static_initializer; | 486 } nacl_mounts_static_initializer; |
519 | 487 |
520 #ifndef __GLIBC__ | 488 #ifndef __GLIBC__ |
521 | 489 |
522 | 490 |
523 // Several more that newlib lacks, that don't route to kernel proxy for now. | 491 // Several more that newlib lacks, that don't route to kernel proxy for now. |
524 | 492 |
525 extern "C" { | 493 extern "C" { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 return 0; | 536 return 0; |
569 } | 537 } |
570 | 538 |
571 void (*signal(int sig, void (*func)(int)))(int) { | 539 void (*signal(int sig, void (*func)(int)))(int) { |
572 return reinterpret_cast<void(*)(int)>(-1); | 540 return reinterpret_cast<void(*)(int)>(-1); |
573 } | 541 } |
574 | 542 |
575 }; | 543 }; |
576 | 544 |
577 #endif // !__GLIBC__ | 545 #endif // !__GLIBC__ |
OLD | NEW |