mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 05:59:10 +00:00
Polish recent changes and make improvements
- Simulate SIGPIPE on Windows NT - Fix commandv() regression on Windows NT - Fix sigprocmask() strace bug on OpenBSD - Add many more system calls to --strace logging - Make errno state more pristine in redbean strace
This commit is contained in:
parent
10a766ebd0
commit
39688a73e4
69 changed files with 460 additions and 1976 deletions
|
@ -130,8 +130,8 @@ int sys_setsockopt_nt(struct Fd *, int, int, const void *, uint32_t) hidden;
|
|||
|
||||
size_t __iovec2nt(struct NtIovec[hasatleast 16], const struct iovec *,
|
||||
size_t) hidden;
|
||||
ssize_t sys_sendto_nt(struct Fd *, const struct iovec *, size_t, uint32_t,
|
||||
void *, uint32_t) hidden;
|
||||
ssize_t sys_sendto_nt(int, const struct iovec *, size_t, uint32_t, void *,
|
||||
uint32_t) hidden;
|
||||
ssize_t sys_recvfrom_nt(struct Fd *, const struct iovec *, size_t, uint32_t,
|
||||
void *, uint32_t *) hidden;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
|
@ -40,6 +41,7 @@ static textwindows void WinSockCleanup(void) {
|
|||
textwindows noasan void WinSockInit(void) {
|
||||
int rc;
|
||||
atexit(WinSockCleanup);
|
||||
STRACE("WSAStartup()");
|
||||
if ((rc = WSAStartup(VERSION, &kNtWsaData)) != 0 ||
|
||||
kNtWsaData.wVersion != VERSION) {
|
||||
ExitProcess(123);
|
||||
|
|
|
@ -58,10 +58,10 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) {
|
|||
if (__isfdopen(fd)) {
|
||||
if (msg->msg_control) return einval(); /* control msg not supported */
|
||||
if (__isfdkind(fd, kFdSocket)) {
|
||||
return sys_sendto_nt(&g_fds.p[fd], msg->msg_iov, msg->msg_iovlen, flags,
|
||||
return sys_sendto_nt(fd, msg->msg_iov, msg->msg_iovlen, flags,
|
||||
msg->msg_name, msg->msg_namelen);
|
||||
} else if (__isfdkind(fd, kFdFile)) {
|
||||
return sys_write_nt(&g_fds.p[fd], msg->msg_iov, msg->msg_iovlen, -1);
|
||||
return sys_write_nt(fd, msg->msg_iov, msg->msg_iovlen, -1);
|
||||
} else {
|
||||
return enotsock();
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
* @param fd must be a socket
|
||||
* @return number of bytes handed off, or -1 w/ errno
|
||||
*/
|
||||
textwindows ssize_t sys_sendto_nt(struct Fd *fd, const struct iovec *iov,
|
||||
textwindows ssize_t sys_sendto_nt(int fd, const struct iovec *iov,
|
||||
size_t iovlen, uint32_t flags,
|
||||
void *opt_in_addr, uint32_t in_addrsize) {
|
||||
uint32_t sent;
|
||||
struct NtIovec iovnt[16];
|
||||
if (WSASendTo(fd->handle, iovnt, __iovec2nt(iovnt, iov, iovlen), &sent, flags,
|
||||
opt_in_addr, in_addrsize, NULL, NULL) != -1) {
|
||||
if (WSASendTo(g_fds.p[fd].handle, iovnt, __iovec2nt(iovnt, iov, iovlen),
|
||||
&sent, flags, opt_in_addr, in_addrsize, NULL, NULL) != -1) {
|
||||
return sent;
|
||||
} else {
|
||||
return __winsockerr();
|
||||
|
|
|
@ -67,12 +67,12 @@ ssize_t sendto(int fd, const void *buf, size_t size, uint32_t flags,
|
|||
} else {
|
||||
if (__isfdopen(fd)) {
|
||||
if (__isfdkind(fd, kFdSocket)) {
|
||||
return sys_sendto_nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1,
|
||||
flags, opt_addr, addrsize);
|
||||
return sys_sendto_nt(fd, (struct iovec[]){{buf, size}}, 1, flags,
|
||||
opt_addr, addrsize);
|
||||
} else if (__isfdkind(fd, kFdFile)) { /* e.g. socketpair() */
|
||||
if (flags) return einval();
|
||||
if (opt_addr) return eisconn();
|
||||
return sys_write_nt(&g_fds.p[fd], (struct iovec[]){{buf, size}}, 1, -1);
|
||||
return sys_write_nt(fd, (struct iovec[]){{buf, size}}, 1, -1);
|
||||
} else {
|
||||
return enotsock();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue