LibC: Align LOCK_* with various other impls

Same motivation as the previous commit.
This commit is contained in:
Linus Groh authored and Andrew Kaster committed 2026-10-23 09:18:11 -04:00
1 parent cc0614db24
commit e20af91244
2 files changed
+9 -4

No files matched your search

+6 -1
View File
@@ -14,8 +14,13 @@ extern "C" {
int flock(int fd, int operation)
{
short type = F_RDLCK;
if (operation & LOCK_UN)
type = F_UNLCK;
else if (operation & LOCK_EX)
type = F_WRLCK;
struct flock lock {
short(operation & 0b11), SEEK_SET, 0, 0, 0
type, SEEK_SET, 0, 0, 0
};
return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
}
+3 -3
View File
@@ -10,10 +10,10 @@
__BEGIN_DECLS
#define LOCK_SH 0
#define LOCK_EX 1
#define LOCK_UN 2
#define LOCK_SH (1 << 0)
#define LOCK_EX (1 << 1)
#define LOCK_NB (1 << 2)
#define LOCK_UN (1 << 3)
int flock(int fd, int operation);