[SCM] PostGIS branch master updated. 3.4.0rc1-888-g0455f7270
git at osgeo.org
git at osgeo.org
Fri Jan 19 11:49:54 PST 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via 0455f7270e007aeeb743ecb5dfa314dc73b7a6f7 (commit)
from c5730e6c921d55bc178d1dfc7ecf40962d5e0a47 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0455f7270e007aeeb743ecb5dfa314dc73b7a6f7
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Jan 19 11:49:19 2024 -0800
Remove the PARANOIA define
and change over to using assert when possible
and ifndef NDEBUG blocks otherwise.
Add --enable-assert configure option
for those who want all runtime checks
turned on, and "full debug" CI jobs.
diff --git a/ci/github/run_debug.sh b/ci/github/run_debug.sh
index f3b742afd..bc709dfd4 100644
--- a/ci/github/run_debug.sh
+++ b/ci/github/run_debug.sh
@@ -2,7 +2,8 @@
set -e
./autogen.sh
-# Check that compilation works at nonzero POSTGIS_DEBUG_LEVEL
-./configure --enable-debug # sets PARANOIA_LEVEL
+# Check that compilation works with all checks
+# enabled
+./configure --enable-debug --enable-assert
sed -i 's/POSTGIS_DEBUG_LEVEL [0-9]$/POSTGIS_DEBUG_LEVEL 4/' postgis_config.h
make -j
diff --git a/configure.ac b/configure.ac
index 23ebf55c8..74808d679 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1300,9 +1300,12 @@ dnl Allow the developer to turn on expensive checks and debugging flags
dnl with --enable-debug
dnl
-AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debugging code and flags]),
+AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Enable debugging flags]),
[ENABLE_DEBUG=1], [ENABLE_DEBUG=0])
+AC_ARG_ENABLE([assert], AS_HELP_STRING([--enable-assert], [Enable assertions and expensive correctness checks]),
+ [ENABLE_ASSERT=1], [ENABLE_ASSERT=0])
+
dnl Allow the developer to turn on link time optimization is supported by compiler
dnl with --enable-lto (for non-debug build)
AC_ARG_ENABLE(
@@ -1318,17 +1321,22 @@ AC_ARG_ENABLE(
dnl Add -Wall to CFLAGS
_LT_COMPILER_OPTION([if $compiler supports -Wall], [_cv_wall], [-Wall], [], [CFLAGS="$CFLAGS -Wall"], [])
+dnl We only turn on link-time optimizations for full production builds
+dnl because they make debugger use problematic
if test $ENABLE_DEBUG -eq 1; then
- AC_DEFINE([PARANOIA_LEVEL], [10], [Enable use of memory checks])
- CFLAGS="$CFLAGS -g"
+ CFLAGS="$CFLAGS -g"
else
- AC_DEFINE([PARANOIA_LEVEL], [0], [Disable use of memory checks])
- CPPFLAGS="-DNDEBUG $CPPFLAGS"
+ CFLAGS="$CFLAGS -O2"
+ if test $ENABLE_LTO -eq 1; then
+ _LT_COMPILER_OPTION([if $compiler supports -flto],[_cv_flto],[-flto],[],[CFLAGS="$CFLAGS -flto"],[])
+ _LT_LINKER_OPTION([if $compiler supports -flto],[_cv_flto],[[-flto]],[LDFLAGS="$LDFLAGS -flto"])
+ fi
+fi
- if test $ENABLE_LTO -eq 1; then
- _LT_COMPILER_OPTION([if $compiler supports -flto],[_cv_flto],[-flto],[],[CFLAGS="$CFLAGS -flto"],[])
- _LT_LINKER_OPTION([if $compiler supports -flto],[_cv_flto],[[-flto]],[LDFLAGS="$LDFLAGS -flto"])
- fi
+dnl If asserts are not requested, we need to disable them
+dnl and other safety checks with NDEBUG
+if test $ENABLE_ASSERT -eq 0; then
+ CPPFLAGS="-DNDEBUG $CPPFLAGS"
fi
AC_DEFINE([POSTGIS_DEBUG_LEVEL], [0], [Define debug level. Default 0])
diff --git a/liblwgeom/lwcollection.c b/liblwgeom/lwcollection.c
index 2cba81c1b..53b3877d2 100644
--- a/liblwgeom/lwcollection.c
+++ b/liblwgeom/lwcollection.c
@@ -212,12 +212,11 @@ LWCOLLECTION* lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
/* Allocate more space if we need it */
lwcollection_reserve(col, col->ngeoms + 1);
-#if PARANOIA_LEVEL > 1
+#ifndef NDEBUG
/* See http://trac.osgeo.org/postgis/ticket/2933 */
/* Make sure we don't already have a reference to this geom */
{
- uint32_t i = 0;
- for (i = 0; i < col->ngeoms; i++)
+ for (uint32_t i = 0; i < col->ngeoms; i++)
{
if (col->geoms[i] == geom)
{
diff --git a/liblwgeom/lwgeom_api.c b/liblwgeom/lwgeom_api.c
index e966251d5..0ef5a103f 100644
--- a/liblwgeom/lwgeom_api.c
+++ b/liblwgeom/lwgeom_api.c
@@ -647,9 +647,7 @@ deparse_hex(uint8_t str, char *result)
void
interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F)
{
-#if PARANOIA_LEVEL > 0
- if (F < 0 || F > 1) lwerror("interpolate_point4d: invalid F (%g)", F);
-#endif
+ assert(F >= 0 && F <= 1);
I->x=A->x+((B->x-A->x)*F);
I->y=A->y+((B->y-A->y)*F);
I->z=A->z+((B->z-A->z)*F);
diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c
index ea4506ca7..368a53b55 100644
--- a/liblwgeom/lwgeom_geos.c
+++ b/liblwgeom/lwgeom_geos.c
@@ -29,7 +29,6 @@
#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
#include "lwrandom.h"
-#include "profile.h"
#include <stdarg.h>
#include <stdlib.h>
diff --git a/liblwgeom/lwgeom_geos_split.c b/liblwgeom/lwgeom_geos_split.c
index 83038a485..901a1ac14 100644
--- a/liblwgeom/lwgeom_geos_split.c
+++ b/liblwgeom/lwgeom_geos_split.c
@@ -414,7 +414,7 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWGEOM* blade_in)
return NULL;
}
-#if PARANOIA_LEVEL > 0
+#ifndef NDEBUG
if ( GEOSGeomTypeId(polygons) != COLLECTIONTYPE )
{
GEOSGeom_destroy(g1);
diff --git a/liblwgeom/lwgeom_median.c b/liblwgeom/lwgeom_median.c
index 0ff90f66a..5db5d2a78 100644
--- a/liblwgeom/lwgeom_median.c
+++ b/liblwgeom/lwgeom_median.c
@@ -171,12 +171,11 @@ init_guess(const POINT4D* points, uint32_t npoints)
POINT4D*
lwmpoint_extract_points_4d(const LWMPOINT* g, uint32_t* npoints, int* input_empty)
{
- uint32_t i;
uint32_t n = 0;
POINT4D* points = lwalloc(g->ngeoms * sizeof(POINT4D));
int has_m = lwgeom_has_m((LWGEOM*) g);
- for (i = 0; i < g->ngeoms; i++)
+ for (uint32_t i = 0; i < g->ngeoms; i++)
{
LWGEOM* subg = lwcollection_getsubgeom((LWCOLLECTION*) g, i);
if (!lwgeom_is_empty(subg))
@@ -217,9 +216,11 @@ lwmpoint_extract_points_4d(const LWMPOINT* g, uint32_t* npoints, int* input_empt
}
}
-#if PARANOIA_LEVEL > 0
- /* check Z=0 for 2D inputs*/
- if (!lwgeom_has_z((LWGEOM*) g)) for (i = 0; i < n; i++) assert(points[i].z == 0);
+#ifndef NDEBUG
+ /* check Z=0 for 2D inputs */
+ if (!lwgeom_has_z((LWGEOM*) g))
+ for (uint32_t i = 0; i < n; i++)
+ assert(points[i].z == 0);
#endif
*npoints = n;
diff --git a/liblwgeom/lwinline.h b/liblwgeom/lwinline.h
index 47e6aaeb9..0d874cb13 100644
--- a/liblwgeom/lwinline.h
+++ b/liblwgeom/lwinline.h
@@ -27,9 +27,7 @@
*
**********************************************************************/
-#if PARANOIA_LEVEL > 0
#include <assert.h>
-#endif
inline static double
distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
@@ -79,11 +77,9 @@ getPoint_internal(const POINTARRAY *pa, uint32_t n)
size_t size;
uint8_t *ptr;
-#if PARANOIA_LEVEL > 0
assert(pa);
assert(n <= pa->npoints);
assert(n <= pa->maxpoints);
-#endif
size = ptarray_point_size(pa);
ptr = pa->serialized_pointlist + size * n;
diff --git a/liblwgeom/lwlinearreferencing.c b/liblwgeom/lwlinearreferencing.c
index 35628bf19..610f0cf4e 100644
--- a/liblwgeom/lwlinearreferencing.c
+++ b/liblwgeom/lwlinearreferencing.c
@@ -327,22 +327,10 @@ point_interpolate(const POINT4D *p1,
double proportion;
int i = 0;
-#if PARANOIA_LEVEL > 0
- if (!(ordinate == 'X' || ordinate == 'Y' || ordinate == 'Z' || ordinate == 'M'))
- {
- lwerror("Cannot interpolate over %c ordinate.", ordinate);
- return LW_FAILURE;
- }
-
- if (FP_MIN(p1_value, p2_value) > interpolation_value || FP_MAX(p1_value, p2_value) < interpolation_value)
- {
- lwerror("Cannot interpolate to a value (%g) not between the input points (%g, %g).",
- interpolation_value,
- p1_value,
- p2_value);
- return LW_FAILURE;
- }
-#endif
+ assert(ordinate == 'X' || ordinate == 'Y' ||
+ ordinate == 'Z' || ordinate == 'M');
+ assert(FP_MIN(p1_value, p2_value) <= interpolation_value &&
+ FP_MAX(p1_value, p2_value) >= interpolation_value);
proportion = (interpolation_value - p1_value) / (p2_value - p1_value);
diff --git a/liblwgeom/profile.h b/liblwgeom/profile.h
deleted file mode 100644
index d4b57e390..000000000
--- a/liblwgeom/profile.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "liblwgeom.h"
-#include <time.h>
-
-static clock_t start_time, end_time;
-static double cpu_time_used;
-
-/*
- * A convenience macro for performance testing and breaking
- * down what time is spent where.
- */
-
-#define START_PROFILING() do { start_time = clock(); } while(0)
-#define END_PROFILING(name) do { \
- end_time = clock(); \
- cpu_time_used = ((double) (end_time - start_time)) / CLOCKS_PER_SEC; \
- lwnotice("Time used for " #name ": %f secs\n", cpu_time_used); \
-} while(0)
diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c
index 86454313c..e4bb380ce 100644
--- a/liblwgeom/ptarray.c
+++ b/liblwgeom/ptarray.c
@@ -578,20 +578,8 @@ ptarray_removePoint(POINTARRAY *pa, uint32_t which)
LWDEBUGF(3, "pa %x which %d", pa, which);
-#if PARANOIA_LEVEL > 0
- if ( which > pa->npoints-1 )
- {
- lwerror("%s [%d] offset (%d) out of range (%d..%d)", __FILE__, __LINE__,
- which, 0, pa->npoints-1);
- return NULL;
- }
-
- if ( pa->npoints < 3 )
- {
- lwerror("%s [%d] can't remove a point from a 2-vertex POINTARRAY", __FILE__, __LINE__);
- return NULL;
- }
-#endif
+ assert(which <= pa->npoints-1);
+ assert(pa->npoints >= 3);
ret = ptarray_construct(FLAGS_GET_Z(pa->flags),
FLAGS_GET_M(pa->flags), pa->npoints-1);
diff --git a/postgis_config.h.in b/postgis_config.h.in
index a439f55cc..f94d5a061 100644
--- a/postgis_config.h.in
+++ b/postgis_config.h.in
@@ -7,9 +7,6 @@
configure process */
#define POSTGIS_DEBUG_LEVEL 0
-/* Define to 1 to enable memory checks in pointarray management. */
-#undef PARANOIA_LEVEL
-
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
-----------------------------------------------------------------------
Summary of changes:
ci/github/run_debug.sh | 5 +++--
configure.ac | 26 +++++++++++++++++---------
liblwgeom/lwcollection.c | 5 ++---
liblwgeom/lwgeom_api.c | 4 +---
liblwgeom/lwgeom_geos.c | 1 -
liblwgeom/lwgeom_geos_split.c | 2 +-
liblwgeom/lwgeom_median.c | 11 ++++++-----
liblwgeom/lwinline.h | 4 ----
liblwgeom/lwlinearreferencing.c | 20 ++++----------------
liblwgeom/profile.h | 17 -----------------
liblwgeom/ptarray.c | 16 ++--------------
postgis_config.h.in | 3 ---
12 files changed, 36 insertions(+), 78 deletions(-)
delete mode 100644 liblwgeom/profile.h
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list