Slightly optimize iovec on Windows

This commit is contained in:
Justine Tunney 2024-09-16 21:36:22 -07:00
parent 774c67fcd3
commit 65e425fbca
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 136 additions and 8 deletions

View file

@ -29,15 +29,21 @@
*/
textwindows size_t __iovec2nt(struct NtIovec iovnt[hasatleast 16],
const struct iovec *iov, size_t iovlen) {
size_t i, limit;
for (limit = 0x7ffff000, i = 0; i < MIN(16, iovlen); ++i) {
iovnt[i].buf = iov[i].iov_base;
size_t i, j, limit = 0x7ffff000;
for (j = i = 0; i < iovlen; ++i) {
if (!iov[i].iov_len)
continue;
if (j == 16)
break;
iovnt[j].buf = iov[i].iov_base;
if (iov[i].iov_len < limit) {
limit -= (iovnt[i].len = iov[i].iov_len);
limit -= (iovnt[j].len = iov[i].iov_len);
++j;
} else {
iovnt[i].len = limit;
iovnt[j].len = limit;
++j;
break;
}
}
return i;
return j;
}

View file

@ -2044,7 +2044,7 @@ syscon misc IF_NAMESIZE 0x10 0x10 0x10 0x10 0x10 0x10 0x10 0
syscon misc INTERMEDIATE_C_GOOD 10 10 0 0 0 0 0 0
syscon misc INTERMEDIATE_GOOD 8 8 0 0 0 0 0 0
syscon misc IOV_MAX 0x0400 0x0400 0x0400 0x0400 0x0400 0x0400 0x0400 16 # unix consensus & MSG_MAXIOVLEN
syscon misc IOV_MAX 1024 1024 1024 1024 1024 1024 1024 16 # unix consensus & MSG_MAXIOVLEN
syscon misc LINE_MAX 0x0800 0x0800 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus
syscon misc LINKED_CMD_COMPLETE 10 10 0 0 0 0 0 0
syscon misc LINKED_FLG_CMD_COMPLETE 11 11 0 0 0 0 0 0

View file

@ -1,2 +1,2 @@
#include "libc/sysv/consts/syscon.internal.h"
.syscon misc,IOV_MAX,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,0x0400,16
.syscon misc,IOV_MAX,1024,1024,1024,1024,1024,1024,1024,16