2021-02-25 18:30:17 -08:00
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
2023-12-07 22:11:56 -05:00
|
|
|
│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │
|
2020-06-15 07:18:57 -07:00
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
2021-02-25 18:30:17 -08:00
|
|
|
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
2020-06-15 07:18:57 -07:00
|
|
|
│ │
|
2020-12-27 17:18:44 -08: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 07:18:57 -07:00
|
|
|
│ │
|
2020-12-27 17:18:44 -08: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 07:18:57 -07:00
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2023-09-07 16:03:19 -07:00
|
|
|
#include "libc/calls/internal.h"
|
2022-08-13 13:11:56 -07:00
|
|
|
#include "libc/calls/struct/iovec.internal.h"
|
2022-08-11 12:13:18 -07:00
|
|
|
#include "libc/intrin/weaken.h"
|
2021-02-25 18:30:17 -08:00
|
|
|
#include "libc/sock/internal.h"
|
2022-05-23 15:06:11 -07:00
|
|
|
#include "libc/sock/syscall_fd.internal.h"
|
2021-02-25 18:30:17 -08:00
|
|
|
#include "libc/sysv/errfuns.h"
|
2023-08-18 04:55:57 -07:00
|
|
|
#ifdef __x86_64__
|
|
|
|
|
2023-09-07 16:03:19 -07:00
|
|
|
textwindows ssize_t sys_readv_nt(int fd, const struct iovec *iov, int iovlen) {
|
|
|
|
switch (g_fds.p[fd].kind) {
|
2021-02-25 18:30:17 -08:00
|
|
|
case kFdFile:
|
|
|
|
case kFdConsole:
|
2023-10-14 01:06:00 -07:00
|
|
|
case kFdDevNull:
|
2024-05-03 10:59:51 -04:00
|
|
|
case kFdDevRandom:
|
2021-02-25 18:30:17 -08:00
|
|
|
return sys_read_nt(fd, iov, iovlen, -1);
|
|
|
|
case kFdSocket:
|
2022-09-12 23:10:38 -07:00
|
|
|
return _weaken(sys_recv_nt)(fd, iov, iovlen, 0);
|
2021-02-25 18:30:17 -08:00
|
|
|
default:
|
|
|
|
return ebadf();
|
|
|
|
}
|
|
|
|
}
|
2023-08-18 04:55:57 -07:00
|
|
|
|
|
|
|
#endif /* __x86_64__ */
|