mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibC: Align LOCK_* with various other impls
Same motivation as the previous commit.
This commit is contained in:
1 parent
cc0614db24
commit
e20af91244
2 files changed
+9
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user