Skip to content

Commit b5f7dbd

Browse files
authored
use bit shift to set bitflags
nitpicking, this makes it practically impossible to accidentally use a number with 2 bits set in the future, it's also my personal preference, its trivial to see "LOCK_NB use bit 2" and that "the next unused bit is bit 4" here it also highlights that there is something strange about the userland LOCK_UN constant which has been (or is being?) discussed here php#8428
1 parent fa6d97d commit b5f7dbd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

ext/standard/flock_compat.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
PHPAPI int php_flock(int fd, int operation);
3636

3737
#ifndef HAVE_FLOCK
38-
# define LOCK_SH 1
39-
# define LOCK_EX 2
40-
# define LOCK_NB 4
41-
# define LOCK_UN 8
38+
# define LOCK_SH (1 << 0)
39+
# define LOCK_EX (1 << 1)
40+
# define LOCK_NB (1 << 2)
41+
# define LOCK_UN (1 << 3)
4242
PHPAPI int flock(int fd, int operation);
4343
#endif
4444

4545
/* Userland LOCK_* constants */
46-
#define PHP_LOCK_SH 1
47-
#define PHP_LOCK_EX 2
48-
#define PHP_LOCK_UN 3
49-
#define PHP_LOCK_NB 4
46+
#define PHP_LOCK_SH (1 << 0)
47+
#define PHP_LOCK_EX (1 << 1)
48+
#define PHP_LOCK_UN ((1 << 0) | (1 << 1))
49+
#define PHP_LOCK_NB (1 << 2)
5050

5151
#ifdef PHP_WIN32
5252
# ifdef EWOULDBLOCK

0 commit comments

Comments
 (0)