Description: Use reentrant libqhull_r instead of deprecated libqh The non-reentrant version has been deprecated by upstream and is no longer built by default. . The reentrant version is available since qhull 2015.1. As the old-style qhull/* headers were removed with qhull 2011.1 these are no longer relevant. Author: Stefan Büns Bug-Debian: https://bugs.debian.org/990397 Origin: other, https://sourceforge.net/p/plplot/bugs/196/attachment/0001-Use-reentrant-libqhull_r-instead-of-deprecated-libqh.patch Bug: https://sourceforge.net/p/plplot/bugs/196/ Forwarded: not-needed Reviewed-By: Rafael Laboissière Last-Update: 2021-07-03 --- a/cmake/modules/FindQHULL.cmake +++ b/cmake/modules/FindQHULL.cmake @@ -16,27 +16,27 @@ # that is what is supplied by upstream qhull, and if the user is # finding a local install of the upstream library below, he wants to # access that same upstream version of the headers to be consistent. -find_file(QHULL_HEADER_FILE NAMES libqhull/qhull_a.h qhull/qhull_a.h) +find_file(QHULL_HEADER_FILE NAMES libqhull_r/qhull_ra.h) if(QHULL_HEADER_FILE) # message(STATUS "QHULL_HEADER_FILE = ${QHULL_HEADER_FILE}") - if(QHULL_HEADER_FILE MATCHES "libqhull") + if(QHULL_HEADER_FILE MATCHES "libqhull_r") set(HAS_LIBQHULL_INCLUDE ON) - else(QHULL_HEADER_FILE MATCHES "libqhull") + else() set(HAS_LIBQHULL_INCLUDE OFF) - endif(QHULL_HEADER_FILE MATCHES "libqhull") + endif() # Determine grandparent directory of header file get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_HEADER_FILE} DIRECTORY) get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_INCLUDE_DIRS} DIRECTORY) elseif(NOT QHULL_HEADER_FILE AND NOT QHULL_FIND_QUIETLY) - message(STATUS "Neither qhull/qhull_a.h header nor libqhull/qhull_a.h could be found") + message(STATUS "libqhull_r/qhull_ra.h could not be found") endif(QHULL_HEADER_FILE) -find_library(QHULL_LIBRARY qhull) +find_library(QHULL_LIBRARY qhull_r) if( QHULL_LIBRARY ) get_filename_component(QHULL_LIBRARY_DIRS ${QHULL_LIBRARY} DIRECTORY) set(QHULL_LIBRARIES ${QHULL_LIBRARY}) elseif(NOT QHULL_LIBRARY AND NOT QHULL_FIND_QUIETLY) - message(STATUS "qhull library could not be found") + message(STATUS "qhull_r library could not be found") endif(QHULL_LIBRARY) find_package_handle_standard_args(QHULL --- a/lib/nn/delaunay.c +++ b/lib/nn/delaunay.c @@ -34,11 +34,7 @@ #include #include #ifdef USE_QHULL -#ifdef HAS_LIBQHULL_INCLUDE -#include -#else -#include -#endif +#include #else #include "triangle.h" #endif @@ -388,7 +384,10 @@ // climax // - exitcode = qh_new_qhull( dim, np, qpoints, ismalloc, + qhT context = { 0 }; + qhT* qh = &context; + + exitcode = qh_new_qhull( qh, dim, np, qpoints, ismalloc, flags, outfile, errfile ); if ( !exitcode ) @@ -433,8 +432,8 @@ } } - qh_findgood_all( qh facet_list ); - qh_countfacets( qh facet_list, NULL, !qh_ALL, &numfacets, + qh_findgood_all( qh, qh->facet_list ); + qh_countfacets( qh, qh->facet_list, NULL, !qh_ALL, &numfacets, &numsimplicial, &totneighbors, &numridges, &numcoplanars, &numtricoplanars ); @@ -462,7 +461,7 @@ j = 0; FOREACHvertex_( facet->vertices ) - t->vids[j++] = qh_pointid( vertex->point ); + t->vids[j++] = qh_pointid( qh, vertex->point ); j = 0; FOREACHneighbor_( facet ) @@ -548,8 +547,8 @@ } free( qpoints ); - qh_freeqhull( !qh_ALL ); // free long memory - qh_memfreeshort( &curlong, &totlong ); // free short memory and memory allocator + qh_freeqhull( qh, !qh_ALL ); // free long memory + qh_memfreeshort( qh, &curlong, &totlong ); // free short memory and memory allocator if ( curlong || totlong ) fprintf( errfile, "qhull: did not free %d bytes of long memory (%d pieces)\n", --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -259,9 +259,9 @@ # No *.pc files for lib subdirectory libraries so must add relevant bits # to the plplot.pc file instead. if(QHULL_RPATH) - list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -L${QHULL_RPATH} -lqhull) + list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -L${QHULL_RPATH} -lqhull_r) else(QHULL_RPATH) - list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -lqhull) + list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -lqhull_r) endif(QHULL_RPATH) # Needed by plgridd.c. --- a/src/plgridd.c +++ b/src/plgridd.c @@ -32,11 +32,7 @@ #include "../lib/nn/nn.h" // PLPLOT_NONN not #defined or tested for more than a decade. #ifdef PLPLOT_NONN // another DTLI, based only on QHULL, not nn -#ifdef HAS_LIBQHULL_INCLUDE -#include -#else //#ifdef HAS_LIBQHULL_INCLUDE -#include -#endif //#ifdef HAS_LIBQHULL_INCLUDE +#include #endif //#ifdef PLPLOT_NONN #endif //#ifdef PL_HAVE_QHUL @@ -852,8 +848,11 @@ points[i * dim + 1] = y[i]; } + qhT context = { 0 }; + qhT* qh = &context; + #if 1 // easy way - exitcode = qh_new_qhull( dim, npts, points, ismalloc, + exitcode = qh_new_qhull( qh, dim, npts, points, ismalloc, flags, outfile, errfile ); #else qh_init_A( stdin, stdout, stderr, 0, NULL ); @@ -899,17 +898,17 @@ #endif // Without the setjmp(), Qhull will exit() after reporting an error - exitcode = setjmp( qh errexit ); + exitcode = setjmp( qh->errexit ); if ( !exitcode ) { - qh NOerrexit = False; + qh->NOerrexit = False; for ( i = 0; i < nptsx; i++ ) for ( j = 0; j < nptsy; j++ ) { l = 0; point[0] = xg[i]; point[1] = yg[j]; - qh_setdelaunay( 3, 1, point ); + qh_setdelaunay( qh, 3, 1, point ); // several ways to find the triangle given a point follow. @@ -942,7 +941,7 @@ // Another possibility is to implement the 'walking // triangle algorithm - facet = qh_findfacet_all( point, &bestdist, &isoutside, &totpart ); + facet = qh_findfacet_all( qh, point, &bestdist, &isoutside, &totpart ); if ( facet->upperdelaunay ) zops->set( zgp, i, j, NaN ); @@ -950,7 +949,7 @@ { FOREACHvertex_( facet->vertices ) { - k = qh_pointid( vertex->point ); + k = qh_pointid( qh, vertex->point ); xt[l] = x[k]; yt[l] = y[k]; zt[l] = z[k]; @@ -969,12 +968,12 @@ } } } - qh NOerrexit = True; + qh->NOerrexit = True; } free( points ); - qh_freeqhull( !qh_ALL ); // free long memory - qh_memfreeshort( &curlong, &totlong ); // free short memory and memory allocator + qh_freeqhull( qh, !qh_ALL ); // free long memory + qh_memfreeshort( qh, &curlong, &totlong ); // free short memory and memory allocator if ( curlong || totlong ) fprintf( errfile, "qhull: did not free %d bytes of long memory (%d pieces)\n", --- a/cmake/modules/csiro.cmake +++ b/cmake/modules/csiro.cmake @@ -83,11 +83,7 @@ message(STATUS "WARNING: function qh_new_qhull not found. Setting PL_HAVE_QHULL to OFF.") set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE) endif(NOT QH_NEW_EXIST) - if(HAS_LIBQHULL_INCLUDE) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include ") - else(HAS_LIBQHULL_INCLUDE) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include ") - endif(HAS_LIBQHULL_INCLUDE) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include ") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c " int main(void)