php_gearman.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Gearman PHP Extension
  3. *
  4. * Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
  5. * Eric Day <eday@oddments.org>
  6. * All rights reserved.
  7. *
  8. * Use and distribution licensed under the PHP license. See
  9. * the LICENSE file in this directory for full text.
  10. */
  11. #ifndef __PHP_GEARMAN_H
  12. #define __PHP_GEARMAN_H
  13. #include "php.h"
  14. #include "php_ini.h"
  15. #include "ext/standard/info.h"
  16. #include "zend_exceptions.h"
  17. #include "zend_interfaces.h"
  18. #include <libgearman-1.0/gearman.h>
  19. #include <libgearman-1.0/interface/status.h>
  20. #include <libgearman-1.0/status.h>
  21. /* module version */
  22. #define PHP_GEARMAN_VERSION "2.1.2"
  23. extern zend_module_entry gearman_module_entry;
  24. #define phpext_gearman_ptr &gearman_module_entry
  25. typedef enum {
  26. GEARMAN_OBJ_CREATED = (1 << 0)
  27. } gearman_obj_flags_t;
  28. extern zend_class_entry *gearman_exception_ce;
  29. #define GEARMAN_EXCEPTION(__error, __error_code) { \
  30. zend_throw_exception(gearman_exception_ce, __error, __error_code); \
  31. return; \
  32. }
  33. void *_php_malloc(size_t size, void *arg);
  34. void _php_free(void *ptr, void *arg);
  35. /* backward compat macros */
  36. #ifndef ZVAL_EMPTY_ARRAY
  37. #define ZVAL_EMPTY_ARRAY(value) array_init(value)
  38. #endif
  39. #ifndef RETVAL_EMPTY_ARRAY
  40. #define RETVAL_EMPTY_ARRAY() ZVAL_EMPTY_ARRAY(return_value)
  41. #endif
  42. #ifndef RETURN_EMPTY_ARRAY
  43. #define RETURN_EMPTY_ARRAY() do { RETVAL_EMPTY_ARRAY(); return; } while (0)
  44. #endif
  45. #ifndef IS_MIXED
  46. # define IS_MIXED 0
  47. #endif
  48. #ifndef ZEND_ARG_INFO_WITH_DEFAULT_VALUE
  49. #define ZEND_ARG_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, default_value) \
  50. ZEND_ARG_INFO(pass_by_ref, name)
  51. #endif
  52. #if PHP_VERSION_ID < 70200
  53. #undef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX
  54. #define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
  55. static const zend_internal_arg_info name[] = { \
  56. { (const char*)(zend_uintptr_t)(required_num_args), ( #class_name ), 0, return_reference, allow_null, 0 },
  57. #endif
  58. #ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX
  59. # define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
  60. ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null)
  61. #endif
  62. #ifndef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX
  63. # define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, num_args, type) \
  64. ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, num_args)
  65. #endif
  66. #ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX
  67. # define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, return_reference, required_num_args, class_name, type) \
  68. ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
  69. #endif
  70. #ifndef ZEND_ARG_TYPE_MASK
  71. # define ZEND_ARG_TYPE_MASK(pass_by_ref, name, type_mask, default_value) \
  72. ZEND_ARG_TYPE_INFO(pass_by_ref, name, 0, 0)
  73. #endif
  74. #ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE
  75. # define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \
  76. ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
  77. #endif
  78. #endif /* __PHP_GEARMAN_H */