mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 00:38:31 +00:00
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:
parent
d38700687a
commit
997ce29ddc
95 changed files with 959 additions and 418 deletions
21
third_party/musl/lockf.c
vendored
21
third_party/musl/lockf.c
vendored
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue