1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Author: Sascha Schumann <sascha@schumann.cx> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 #ifndef FLOCK_COMPAT_H 18 #define FLOCK_COMPAT_H 19 20 #ifdef HAVE_STRUCT_FLOCK 21 #include <unistd.h> 22 #include <fcntl.h> 23 #include <sys/file.h> 24 #endif 25 26 #ifdef PHP_WIN32 27 #include <io.h> 28 #include "config.w32.h" 29 #endif 30 31 /* php_flock internally uses fcntl whether or not flock is available 32 * This way our php_flock even works on NFS files. 33 * More info: /usr/src/linux/Documentation 34 */ 35 PHPAPI int php_flock(int fd, int operation); 36 37 #ifndef HAVE_FLOCK 38 # define LOCK_SH 1 39 # define LOCK_EX 2 40 # define LOCK_NB 4 41 # define LOCK_UN 8 42 PHPAPI int flock(int fd, int operation); 43 #endif 44 45 /* 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 50 51 #ifdef PHP_WIN32 52 # ifdef EWOULDBLOCK 53 # undef EWOULDBLOCK 54 # endif 55 # define EWOULDBLOCK WSAEWOULDBLOCK 56 # define fsync _commit 57 # define ftruncate(a, b) chsize(a, b) 58 #endif /* defined(PHP_WIN32) */ 59 60 #endif /* FLOCK_COMPAT_H */ 61