2021-02-26 02:30:17 +00:00
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
2023-12-08 03:11:56 +00:00
|
|
|
│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │
|
2020-06-15 14:18:57 +00:00
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
2021-02-26 02:30:17 +00:00
|
|
|
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
2020-06-15 14:18:57 +00:00
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
2020-06-15 14:18:57 +00:00
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
2020-06-15 14:18:57 +00:00
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2023-09-07 23:03:19 +00:00
|
|
|
#include "libc/calls/internal.h"
|
2022-08-13 20:11:56 +00:00
|
|
|
#include "libc/calls/struct/iovec.internal.h"
|
2022-08-11 19:13:18 +00:00
|
|
|
#include "libc/intrin/weaken.h"
|
2021-02-26 02:30:17 +00:00
|
|
|
#include "libc/sock/internal.h"
|
2022-05-23 22:06:11 +00:00
|
|
|
#include "libc/sock/syscall_fd.internal.h"
|
2021-02-26 02:30:17 +00:00
|
|
|
#include "libc/sysv/errfuns.h"
|
2023-08-18 11:55:57 +00:00
|
|
|
#ifdef __x86_64__
|
|
|
|
|
2023-09-07 23:03:19 +00:00
|
|
|
textwindows ssize_t sys_readv_nt(int fd, const struct iovec *iov, int iovlen) {
|
|
|
|
switch (g_fds.p[fd].kind) {
|
2021-02-26 02:30:17 +00:00
|
|
|
case kFdFile:
|
|
|
|
case kFdConsole:
|
2023-10-14 08:06:00 +00:00
|
|
|
case kFdDevNull:
|
2024-05-03 14:59:51 +00:00
|
|
|
case kFdDevRandom:
|
2021-02-26 02:30:17 +00:00
|
|
|
return sys_read_nt(fd, iov, iovlen, -1);
|
|
|
|
case kFdSocket:
|
2022-09-13 06:10:38 +00:00
|
|
|
return _weaken(sys_recv_nt)(fd, iov, iovlen, 0);
|
2021-02-26 02:30:17 +00:00
|
|
|
default:
|
|
|
|
return ebadf();
|
|
|
|
}
|
|
|
|
}
|
2023-08-18 11:55:57 +00:00
|
|
|
|
|
|
|
#endif /* __x86_64__ */
|