flock_compat.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef FLOCK_COMPAT_H
  17. #define FLOCK_COMPAT_H
  18. #if HAVE_STRUCT_FLOCK
  19. #include <unistd.h>
  20. #include <fcntl.h>
  21. #include <sys/file.h>
  22. #endif
  23. #ifdef PHP_WIN32
  24. #include <io.h>
  25. #include "config.w32.h"
  26. #endif
  27. /* php_flock internally uses fcntl whether or not flock is available
  28. * This way our php_flock even works on NFS files.
  29. * More info: /usr/src/linux/Documentation
  30. */
  31. PHPAPI int php_flock(int fd, int operation);
  32. #ifndef HAVE_FLOCK
  33. # define LOCK_SH 1
  34. # define LOCK_EX 2
  35. # define LOCK_NB 4
  36. # define LOCK_UN 8
  37. PHPAPI int flock(int fd, int operation);
  38. #endif
  39. /* Userland LOCK_* constants */
  40. #define PHP_LOCK_SH 1
  41. #define PHP_LOCK_EX 2
  42. #define PHP_LOCK_UN 3
  43. #define PHP_LOCK_NB 4
  44. #ifdef PHP_WIN32
  45. # ifdef EWOULDBLOCK
  46. # undef EWOULDBLOCK
  47. # endif
  48. # define EWOULDBLOCK WSAEWOULDBLOCK
  49. # define fsync _commit
  50. # define ftruncate(a, b) chsize(a, b)
  51. #endif /* defined(PHP_WIN32) */
  52. #if !HAVE_INET_ATON
  53. #if HAVE_NETINET_IN_H
  54. #include <netinet/in.h>
  55. #endif
  56. #if HAVE_ARPA_INET_H
  57. #include <arpa/inet.h>
  58. #endif
  59. #ifndef PHP_WIN32
  60. extern int inet_aton(const char *, struct in_addr *);
  61. #endif
  62. #endif
  63. #endif /* FLOCK_COMPAT_H */