Elevate Windows production worthiness

- SQLite file locking now works on Windows
- SQLite will now use fdatasync() on non-Apple platforms
- Fix Ctrl-C handler on Windows to not crash with TLS
- Signals now work in multithreaded apps on Windows
- fcntl() will now accurately report EINVAL errors
- fcntl() now has excellent --strace logging
- Token bucket replenish now go 100x faster
- *NSYNC cancellations now work on Windows
- Support closefrom() on NetBSD
This commit is contained in:
Justine Tunney 2022-10-13 13:44:41 -07:00
parent d38700687a
commit 997ce29ddc
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
95 changed files with 959 additions and 418 deletions

View file

@ -30,6 +30,8 @@
#include "libc/calls/weirdtypes.h"
#include "libc/errno.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/errfuns.h"
#include "third_party/musl/lockf.h"
asm(".ident\t\"\\n\\n\
Musl libc (MIT License)\\n\
@ -44,25 +46,20 @@ int lockf(int fd, int op, off_t size)
.l_whence = SEEK_CUR,
.l_len = size,
};
if (op == F_TEST){
switch (op) {
case F_TEST:
l.l_type = F_RDLCK;
if (fcntl(fd, F_GETLK, &l) < 0)
return -1;
if (l.l_type == F_UNLCK || l.l_pid == getpid())
return 0;
errno = EACCES;
return -1;
}
if (op == F_ULOCK) {
return eacces();
case F_ULOCK:
l.l_type = F_UNLCK;
case F_TLOCK:
return fcntl(fd, F_SETLK, &l);
}
if (op == F_TLOCK) {
return fcntl(fd, F_SETLK, &l);
}
if (op == F_LOCK) {
case F_LOCK:
return fcntl(fd, F_SETLKW, &l);
}
errno = EINVAL;
return -1;
return einval();
}