flock_compat.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Sascha Schumann <sascha@schumann.cx> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef FLOCK_COMPAT_H
  19. #define FLOCK_COMPAT_H
  20. /* php_flock internally uses fcntl whether or not flock is available
  21. * This way our php_flock even works on NFS files.
  22. * More info: /usr/src/linux/Documentation
  23. */
  24. PHPAPI int php_flock(int fd, int operation);
  25. #ifndef HAVE_FLOCK
  26. # define LOCK_SH 1
  27. # define LOCK_EX 2
  28. # define LOCK_NB 4
  29. # define LOCK_UN 8
  30. PHPAPI int flock(int fd, int operation);
  31. #endif
  32. /* Userland LOCK_* constants */
  33. #define PHP_LOCK_SH 1
  34. #define PHP_LOCK_EX 2
  35. #define PHP_LOCK_UN 3
  36. #define PHP_LOCK_NB 4
  37. #ifdef PHP_WIN32
  38. # ifdef EWOULDBLOCK
  39. # undef EWOULDBLOCK
  40. # endif
  41. # define EWOULDBLOCK WSAEWOULDBLOCK
  42. # define fsync _commit
  43. # define ftruncate(a, b) chsize(a, b)
  44. #endif /* defined(PHP_WIN32) */
  45. #if !HAVE_INET_ATON
  46. #if HAVE_NETINET_IN_H
  47. #include <netinet/in.h>
  48. #endif
  49. #if HAVE_ARPA_INET_H
  50. #include <arpa/inet.h>
  51. #endif
  52. #ifndef PHP_WIN32
  53. extern int inet_aton(const char *, struct in_addr *);
  54. #endif
  55. #endif
  56. #endif /* FLOCK_COMPAT_H */