mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-03 17:58:30 +00:00
Flatten InfoZIP directory and fix build issues
This commit is contained in:
parent
ae638c0850
commit
87396f43bc
66 changed files with 869 additions and 5763 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
@ -44,7 +45,9 @@
|
|||
ssize_t pread(int fd, void *buf, size_t size, int64_t offset) {
|
||||
ssize_t rc;
|
||||
if (fd == -1 || offset < 0) return einval();
|
||||
if (__isfdkind(fd, kFdZip)) {
|
||||
if (IsAsan() && !__asan_is_valid(buf, size)) {
|
||||
rc = efault();
|
||||
} else if (__isfdkind(fd, kFdZip)) {
|
||||
rc =
|
||||
weaken(__zipos_read)((struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle,
|
||||
(struct iovec[]){{buf, size}}, 1, offset);
|
||||
|
|
|
@ -25,19 +25,13 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/iov.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
/**
|
||||
* Reads with maximum generality.
|
||||
*
|
||||
* @return number of bytes actually read, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
|
||||
static ssize_t Preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
|
||||
static bool once, demodernize;
|
||||
int i, err;
|
||||
ssize_t rc;
|
||||
|
@ -106,3 +100,27 @@ ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
|
|||
|
||||
return toto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads with maximum generality.
|
||||
*
|
||||
* @return number of bytes actually read, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
ssize_t preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
|
||||
ssize_t rc;
|
||||
rc = Preadv(fd, iov, iovlen, off);
|
||||
#if defined(SYSDEBUG) && _DATATRACE
|
||||
if (__strace > 0) {
|
||||
if (rc == -1 && errno == EFAULT) {
|
||||
STRACE("preadv(%d, %p, %d, %'ld) → %'zd% m", fd, iov, iovlen, off, rc);
|
||||
} else {
|
||||
kprintf(STRACE_PROLOGUE "preadv(%d, [", fd);
|
||||
__strace_iov(iov, iovlen, rc != -1 ? rc : 0);
|
||||
kprintf("], %d, %'ld) → %'ld% m%n", iovlen, off, rc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
@ -43,7 +44,9 @@ ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) {
|
|||
size_t wrote;
|
||||
if (fd == -1 || offset < 0) return einval();
|
||||
size = MIN(size, 0x7ffff000);
|
||||
if (!IsWindows()) {
|
||||
if (IsAsan() && !__asan_is_valid(buf, size)) {
|
||||
rc = efault();
|
||||
} else if (!IsWindows()) {
|
||||
rc = sys_pwrite(fd, buf, size, offset, offset);
|
||||
} else if (__isfdkind(fd, kFdFile)) {
|
||||
rc = sys_write_nt(fd, (struct iovec[]){{buf, size}}, 1, offset);
|
||||
|
|
|
@ -24,24 +24,14 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/iov.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
|
||||
/**
|
||||
* Writes data from multiple buffers to offset.
|
||||
*
|
||||
* Please note that it's not an error for a short write to happen. This
|
||||
* can happen in the kernel if EINTR happens after some of the write has
|
||||
* been committed. It can also happen if we need to polyfill this system
|
||||
* call using pwrite().
|
||||
*
|
||||
* @return number of bytes actually sent, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
|
||||
static ssize_t Pwritev(int fd, const struct iovec *iov, int iovlen,
|
||||
int64_t off) {
|
||||
static bool once, demodernize;
|
||||
int i, err;
|
||||
ssize_t rc;
|
||||
|
@ -110,3 +100,32 @@ ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
|
|||
|
||||
return toto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data from multiple buffers to offset.
|
||||
*
|
||||
* Please note that it's not an error for a short write to happen. This
|
||||
* can happen in the kernel if EINTR happens after some of the write has
|
||||
* been committed. It can also happen if we need to polyfill this system
|
||||
* call using pwrite().
|
||||
*
|
||||
* @return number of bytes actually sent, or -1 w/ errno
|
||||
* @asyncsignalsafe
|
||||
* @vforksafe
|
||||
*/
|
||||
ssize_t pwritev(int fd, const struct iovec *iov, int iovlen, int64_t off) {
|
||||
ssize_t rc;
|
||||
rc = Pwritev(fd, iov, iovlen, off);
|
||||
#if defined(SYSDEBUG) && _DATATRACE
|
||||
if (__strace > 0) {
|
||||
if (rc == -1 && errno == EFAULT) {
|
||||
STRACE("pwritev(%d, %p, %d, %'ld) → %'zd% m", fd, iov, iovlen, off, rc);
|
||||
} else {
|
||||
kprintf(STRACE_PROLOGUE "readv(%d, ", fd);
|
||||
__strace_iov(iov, iovlen, rc != -1 ? rc : 0);
|
||||
kprintf(", %d, %'ld) → %'ld% m%n", iovlen, off, rc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) {
|
|||
if (todo > len) {
|
||||
todo = len;
|
||||
}
|
||||
memcpy(&b2b->block.bytes[b2b->block_used], data, todo);
|
||||
if (todo) memcpy(&b2b->block.bytes[b2b->block_used], data, todo);
|
||||
b2b->block_used += todo;
|
||||
data += todo;
|
||||
len -= todo;
|
||||
|
@ -137,7 +137,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) {
|
|||
data += BLAKE2B_CBLOCK;
|
||||
len -= BLAKE2B_CBLOCK;
|
||||
}
|
||||
memcpy(b2b->block.bytes, data, len);
|
||||
if (len) memcpy(b2b->block.bytes, data, len);
|
||||
b2b->block_used = len;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue