summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-04-24 09:53:58 +0200
committerBenoit Foucher <benoit@zeroc.com>2018-04-24 09:53:58 +0200
commitbffe8dad96937c1c45c80eaf288fbb0cb5a8de33 (patch)
tree2f7738b1c850ac328f5119e605a67f3620d7134d
parentAdded diagnostic information in case the JS controller can't connect to the p... (diff)
downloadice-bffe8dad96937c1c45c80eaf288fbb0cb5a8de33.tar.bz2
ice-bffe8dad96937c1c45c80eaf288fbb0cb5a8de33.tar.xz
ice-bffe8dad96937c1c45c80eaf288fbb0cb5a8de33.zip
Enable asserts for the extension when built with debug (ICE-8703)
-rw-r--r--php/src/php5/Config.h22
-rw-r--r--php/src/php7/Config.h22
2 files changed, 44 insertions, 0 deletions
diff --git a/php/src/php5/Config.h b/php/src/php5/Config.h
index ebc27f30289..62a1e144a6e 100644
--- a/php/src/php5/Config.h
+++ b/php/src/php5/Config.h
@@ -50,6 +50,18 @@ extern "C"
# pragma GCC diagnostic warning "-Wnarrowing"
#endif
+//
+// The php.h header defines/undefines NDEBUG based on how the PHP binary was built.
+// As a result, asserts are always disabled unless building against a php binary
+// built with --enable-debug. We want to enable asserts for the PHP Ice extension
+// when it's built without OPTIMIZE=yes. We save NDEBUG in a tmp macro here and
+// explicitly re-include the assert.h header with the saved NDEBUG macro after
+// including php.h
+//
+#ifndef NDEBUG
+#define TMPDEBUG
+#endif
+
#include "php.h"
#ifdef _WIN32
@@ -65,6 +77,16 @@ extern "C"
}
#endif
+//
+// Enable asserts if the extension is built with debug. It's fine to include several times
+// assert.h with a different NDEBUG setting.
+//
+#ifdef TMPDEBUG
+#undef TMPDEBUG
+#undef NDEBUG
+#include <assert.h>
+#endif
+
extern zend_module_entry ice_module_entry;
#define phpext_ice_ptr &ice_module_entry
diff --git a/php/src/php7/Config.h b/php/src/php7/Config.h
index 8a3b5be29f1..c683d2edcaa 100644
--- a/php/src/php7/Config.h
+++ b/php/src/php7/Config.h
@@ -50,6 +50,18 @@ extern "C"
# pragma GCC diagnostic warning "-Wnarrowing"
#endif
+//
+// The php.h header defines/undefines NDEBUG based on how the PHP binary was built.
+// As a result, asserts are always disabled unless building against a php binary
+// built with --enable-debug. We want to enable asserts for the PHP Ice extension
+// when it's built without OPTIMIZE=yes. We save NDEBUG in a tmp macro here and
+// explicitly re-include the assert.h header with the saved NDEBUG macro after
+// including php.h
+//
+#ifndef NDEBUG
+#define TMPDEBUG
+#endif
+
#include "php.h"
#ifdef _WIN32
@@ -65,6 +77,16 @@ extern "C"
}
#endif
+//
+// Enable asserts if the extension is built with debug. It's fine to include several times
+// assert.h with a different NDEBUG setting.
+//
+#ifdef TMPDEBUG
+#undef TMPDEBUG
+#undef NDEBUG
+#include <assert.h>
+#endif
+
extern zend_module_entry ice_module_entry;
#define phpext_ice_ptr &ice_module_entry