summaryrefslogtreecommitdiffstats
path: root/hdr_histogram-lib0114.patch
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2022-03-01 11:32:45 +0100
committerRemi Collet <remi@php.net>2022-03-01 11:32:45 +0100
commit063b35668aee19754a95def85ab02fc7bf78abd6 (patch)
treedf146785e92a190748b82554bcfc29500d9aa41f /hdr_histogram-lib0114.patch
parent6353959bced6e46fb3fa91da63f270d6b8e707ab (diff)
add patch for libhdr_histogram 0.11.4
Diffstat (limited to 'hdr_histogram-lib0114.patch')
-rw-r--r--hdr_histogram-lib0114.patch218
1 files changed, 218 insertions, 0 deletions
diff --git a/hdr_histogram-lib0114.patch b/hdr_histogram-lib0114.patch
new file mode 100644
index 0000000..727a011
--- /dev/null
+++ b/hdr_histogram-lib0114.patch
@@ -0,0 +1,218 @@
+From 857918bdb4bf1a4faf769e01aaa3c3f5bd14021a Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 1 Mar 2022 10:31:21 +0100
+Subject: [PATCH] Fix for libhdr_histogram version 0.11.4
+
+---
+ config.m4 | 76 ++++++++++++++++++++++++++++++--------------------
+ hdrhistogram.c | 34 ++++++++++++++--------
+ 2 files changed, 68 insertions(+), 42 deletions(-)
+
+diff --git a/config.m4 b/config.m4
+index aa4fec8..729a038 100644
+--- a/config.m4
++++ b/config.m4
+@@ -3,41 +3,57 @@ PHP_ARG_WITH(hdrhistogram,
+ [ --with-hdrhistogram[=DIR] Enable "hdrhistogram" extension support])
+
+ if test "$PHP_HDRHISTOGRAM" != "no"; then
+- SEARCH_PATH="/usr/local /usr"
+- SEARCH_FOR="/include/hdr/hdr_histogram.h" # you most likely want to change this
++ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+
+- if test -r $PHP_HDRHISTOGRAM/$SEARCH_FOR; then
+- HDRHISTOGRAM_PATH=$PHP_HDRHISTOGRAM
++ if test "$PHP_HDRHISTOGRAM" = "yes" -a -x "$PKG_CONFIG" && $PKG_CONFIG --exists hdr_histogram; then
++
++ AC_MSG_CHECKING([for hdrhistogram from pkg-config])
++ LIBHDR_CFLAGS=`$PKG_CONFIG hdr_histogram --cflags`
++ LIBHDR_LIBDIR=`$PKG_CONFIG hdr_histogram --libs`
++ LIBHDR_VERSON=`$PKG_CONFIG hdr_histogram --modversion`
++ AC_MSG_RESULT(found $LIBHDR_VERSON)
++ if $PKG_CONFIG hdr_histogram --atleast-version 0.11.4; then
++ AC_DEFINE(HAVE_HDRHISTOGRAM_0_11_4,1,[ ])
++ fi
++ PHP_EVAL_LIBLINE($LIBHDR_LIBDIR, HDRHISTOGRAM_SHARED_LIBADD)
++ PHP_EVAL_INCLINE($LIBHDR_CFLAGS)
+ else
+- AC_MSG_CHECKING([for hdrhistogram files in default path])
+- for i in $SEARCH_PATH ; do
+- if test -r $i/$SEARCH_FOR; then
+- HDRHISTOGRAM_PATH=$i
+- AC_MSG_RESULT(found in $i)
++ SEARCH_PATH="/usr/local /usr"
++ SEARCH_FOR="/include/hdr/hdr_histogram.h" # you most likely want to change this
++
++ if test -r $PHP_HDRHISTOGRAM/$SEARCH_FOR; then
++ HDRHISTOGRAM_PATH=$PHP_HDRHISTOGRAM
++ else
++ AC_MSG_CHECKING([for hdrhistogram files in default path])
++ for i in $SEARCH_PATH ; do
++ if test -r $i/$SEARCH_FOR; then
++ HDRHISTOGRAM_PATH=$i
++ AC_MSG_RESULT(found in $i)
++ fi
++ done
+ fi
+- done
+- fi
+
+- if test -z "$HDRHISTOGRAM_PATH"; then
+- AC_MSG_RESULT([not found])
+- AC_MSG_ERROR([Please reinstall the hdrhistogram library])
+- fi
++ if test -z "$HDRHISTOGRAM_PATH"; then
++ AC_MSG_RESULT([not found])
++ AC_MSG_ERROR([Please reinstall the hdrhistogram library])
++ fi
+
+- PHP_ADD_INCLUDE($HDRHISTOGRAM_PATH/include)
+-
+- LIBNAME=hdr_histogram
+- LIBSYMBOL=hdr_init
+-
+- PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
+- [
+- PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $HDRHISTOGRAM_PATH/$PHP_LIBDIR, HDRHISTOGRAM_SHARED_LIBADD)
+- AC_DEFINE(HAVE_HDRHISTOGRAM,1,[ ])
+- ],[
+- AC_MSG_ERROR([wrong hdrhistogram lib version or lib not found])
+- ],[
+- -L$HDRHISTOGRAM_PATH/$PHP_LIBDIR
+- ]
+- )
++ PHP_ADD_INCLUDE($HDRHISTOGRAM_PATH/include)
++
++ LIBNAME=hdr_histogram
++ LIBSYMBOL=hdr_init
++
++ PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL,
++ [
++ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $HDRHISTOGRAM_PATH/$PHP_LIBDIR, HDRHISTOGRAM_SHARED_LIBADD)
++ AC_DEFINE(HAVE_HDRHISTOGRAM,1,[ ])
++ ],[
++ AC_MSG_ERROR([wrong hdrhistogram lib version or lib not found])
++ ],[
++ -L$HDRHISTOGRAM_PATH/$PHP_LIBDIR
++ ]
++ )
++ fi
+
+ PHP_SUBST(HDRHISTOGRAM_SHARED_LIBADD)
+
+diff --git a/hdrhistogram.c b/hdrhistogram.c
+index d3595a3..cff2c18 100644
+--- a/hdrhistogram.c
++++ b/hdrhistogram.c
+@@ -117,17 +117,17 @@ PHP_MINFO_FUNCTION(hdrhistogram)
+ PHP_FUNCTION(hdr_init)
+ {
+ struct hdr_histogram *hdr;
+- long lowest_trackable_value, highest_trackable_value, significant_figures;
++ long lowest_discernible_value, highest_trackable_value, significant_figures;
+ int res;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll",
+- &lowest_trackable_value, &highest_trackable_value, &significant_figures) == FAILURE) {
++ &lowest_discernible_value, &highest_trackable_value, &significant_figures) == FAILURE) {
+ php_error_docref(NULL, E_WARNING, "Invalid arguments passed.");
+
+ RETURN_FALSE;
+ }
+
+- res = hdr_init(lowest_trackable_value, highest_trackable_value, significant_figures, &hdr);
++ res = hdr_init(lowest_discernible_value, highest_trackable_value, significant_figures, &hdr);
+
+ if (res == 0) {
+ hdr_register_hdr_resource(return_value, hdr);
+@@ -342,8 +342,11 @@ PHP_FUNCTION(hdr_add)
+ hdra = hdr_fetch_resource(a, return_value);
+ hdrb = hdr_fetch_resource(b, return_value);
+
++#ifdef HAVE_HDRHISTOGRAM_0_11_4
++ res = hdr_init(hdra->lowest_discernible_value, hdra->highest_trackable_value, hdra->significant_figures, &hdr_new);
++#else
+ res = hdr_init(hdra->lowest_trackable_value, hdra->highest_trackable_value, hdra->significant_figures, &hdr_new);
+-
++#endif
+ hdr_add(hdr_new, hdra);
+ hdr_add(hdr_new, hdrb);
+
+@@ -477,9 +480,16 @@ PHP_FUNCTION(hdr_export)
+
+ array_init(return_value);
+
++
++#ifdef HAVE_HDRHISTOGRAM_0_11_4
++ if (hdr->lowest_discernible_value > 1) {
++ add_assoc_long(return_value, "ltv", hdr->lowest_discernible_value);
++ }
++#else
+ if (hdr->lowest_trackable_value > 1) {
+ add_assoc_long(return_value, "ltv", hdr->lowest_trackable_value);
+ }
++#endif
+ if (hdr->highest_trackable_value != 60000) {
+ add_assoc_long(return_value, "htv", hdr->highest_trackable_value);
+ }
+@@ -513,7 +523,7 @@ PHP_FUNCTION(hdr_import)
+ {
+ struct hdr_histogram *hdr;
+ zval *import, *value, *item;
+- long lowest_trackable_value, highest_trackable_value, significant_figures;
++ long lowest_discernible_value, highest_trackable_value, significant_figures;
+ int res, count;
+ zend_ulong i, bucket, skipped;
+
+@@ -522,12 +532,12 @@ PHP_FUNCTION(hdr_import)
+ }
+
+ if (value = hdr_hash_find(Z_ARRVAL_P(import), "ltv", 4)) {
+- lowest_trackable_value = Z_LVAL_P(value);
++ lowest_discernible_value = Z_LVAL_P(value);
+ } else {
+- lowest_trackable_value = 1;
++ lowest_discernible_value = 1;
+ }
+
+- if (lowest_trackable_value <= 0) {
++ if (lowest_discernible_value <= 0) {
+ php_error_docref(NULL, E_WARNING, "lowest_trackable_value (ltv) must be >= 1.");
+ RETURN_FALSE;
+ }
+@@ -560,7 +570,7 @@ PHP_FUNCTION(hdr_import)
+ skipped = 0;
+ }
+
+- if (skipped < 0 || lowest_trackable_value < 1 || highest_trackable_value < lowest_trackable_value || significant_figures < 1) {
++ if (skipped < 0 || lowest_discernible_value < 1 || highest_trackable_value < lowest_discernible_value || significant_figures < 1) {
+ php_error_docref(NULL, E_WARNING, "Invalid values for ltv, htv, sf or sk keys given.");
+ RETURN_FALSE;
+ }
+@@ -570,7 +580,7 @@ PHP_FUNCTION(hdr_import)
+ // version 3 format
+ if (value != NULL && Z_TYPE_P(value) == IS_ARRAY) {
+ count = zend_hash_num_elements(Z_ARRVAL_P(value));
+- res = hdr_init(lowest_trackable_value, highest_trackable_value, significant_figures, &hdr);
++ res = hdr_init(lowest_discernible_value, highest_trackable_value, significant_figures, &hdr);
+
+ if (res == 0) {
+ hdr_register_hdr_resource(return_value, hdr);
+@@ -612,7 +622,7 @@ PHP_FUNCTION(hdr_import)
+ if (value != NULL && Z_TYPE_P(value) == IS_ARRAY) {
+ count = zend_hash_num_elements(Z_ARRVAL_P(value));
+
+- res = hdr_init(lowest_trackable_value, highest_trackable_value, significant_figures, &hdr);
++ res = hdr_init(lowest_discernible_value, highest_trackable_value, significant_figures, &hdr);
+
+ if (res == 0) {
+ hdr_register_hdr_resource(return_value, hdr);
+@@ -655,7 +665,7 @@ PHP_FUNCTION(hdr_import)
+
+ // version 2 format
+ if (value != NULL && Z_TYPE_P(value) == IS_ARRAY) {
+- res = hdr_init(lowest_trackable_value, highest_trackable_value, significant_figures, &hdr);
++ res = hdr_init(lowest_discernible_value, highest_trackable_value, significant_figures, &hdr);
+
+ if (res == 0) {
+ hdr_register_hdr_resource(return_value, hdr);