From 5fe21c3e2b88e8248c79311401db03124e88bc52 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Tue, 17 Sep 2019 10:29:53 -0400 Subject: Add atanh, copysign, cbrt, remainder, remquo to math.cpp. The supported C99 math functions provided by math.cpp are thus hypot log1p asinh atanh copysign cbrt remainder remquo round lround Make compiler checks in CMakeLists.txt and configure.ac consistent with this set. Make geodesic.c use the math.cpp defined (instead of the internally defined) versions of hypot atanh copysign cbrt This is keyed off the presence of the PROJ_LIB macro. I had at one time https://github.com/OSGeo/PROJ/pull/1425 suggested supplying an additional macro PROJ_COMPILATION when compiling geodesic.c. However, PROJ_LIB seems to fill the bill OK. The *next* version of geodesic.c (due out in a few weeks) will also use remainder remquo All of this is only of concern for C compilers without C99 support. So this may become an historical footnote at some point. --- src/geodesic.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/geodesic.c') diff --git a/src/geodesic.c b/src/geodesic.c index 5504cb3b..887edb42 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -23,8 +23,19 @@ * https://geographiclib.sourceforge.io/ */ +/* The PROJ_COMPILATION flag indicates that this is part of the compilation of + * the PROJ library (keyed off the presence of the PROJ_LIB macro which points + * to the data directory for PROJ). If this is set, we use the PROJ supplied + * implementations of the C99 math functions instead of the ones defined here. + */ +#if defined(PROJ_LIB) +#define PROJ_COMPILATION 1 +#else +#define PROJ_COMPILATION 0 +#endif + #include "geodesic.h" -#ifdef PJ_LIB__ +#if PROJ_COMPILAION #include "proj_math.h" #else #include @@ -122,7 +133,7 @@ enum captype { }; static real sq(real x) { return x * x; } -#if HAVE_C99_MATH +#if HAVE_C99_MATH || PROJ_COMPILATION #define atanhx atanh #define copysignx copysign #define hypotx hypot -- cgit v1.2.3 From b154e42c917288124ef64c458b91a0efabd4e568 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Tue, 17 Sep 2019 11:19:23 -0400 Subject: Fix typo in geodesic.c --- src/geodesic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/geodesic.c') diff --git a/src/geodesic.c b/src/geodesic.c index 887edb42..5183311e 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -35,7 +35,7 @@ #endif #include "geodesic.h" -#if PROJ_COMPILAION +#if PROJ_COMPILATION #include "proj_math.h" #else #include -- cgit v1.2.3 From 9f41f427d0fe6966d187f746f523e84892f240a5 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Wed, 18 Sep 2019 07:16:30 -0400 Subject: Let geodesic.c use its own versions of C99 math functions if necessary. --- src/geodesic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/geodesic.c') diff --git a/src/geodesic.c b/src/geodesic.c index 5183311e..beb841a0 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -28,7 +28,7 @@ * to the data directory for PROJ). If this is set, we use the PROJ supplied * implementations of the C99 math functions instead of the ones defined here. */ -#if defined(PROJ_LIB) +#if 0 && defined(PROJ_LIB) #define PROJ_COMPILATION 1 #else #define PROJ_COMPILATION 0 -- cgit v1.2.3 From 329e7a9be67c15936488ef37739df065a4b81bf7 Mon Sep 17 00:00:00 2001 From: Charles Karney Date: Wed, 18 Sep 2019 13:27:06 -0400 Subject: Get rid of dead code. The end result of this chain of commits is to eliminate most of math.cpp. All that is left is the handling of isnan (and I've this because math.cpp notes that gie.c uses pj_isnan). geodesic.c now handles supplying C99 math functions internally and this can go away once C99 support is mandated. --- src/geodesic.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'src/geodesic.c') diff --git a/src/geodesic.c b/src/geodesic.c index beb841a0..49c9823e 100644 --- a/src/geodesic.c +++ b/src/geodesic.c @@ -23,23 +23,8 @@ * https://geographiclib.sourceforge.io/ */ -/* The PROJ_COMPILATION flag indicates that this is part of the compilation of - * the PROJ library (keyed off the presence of the PROJ_LIB macro which points - * to the data directory for PROJ). If this is set, we use the PROJ supplied - * implementations of the C99 math functions instead of the ones defined here. - */ -#if 0 && defined(PROJ_LIB) -#define PROJ_COMPILATION 1 -#else -#define PROJ_COMPILATION 0 -#endif - #include "geodesic.h" -#if PROJ_COMPILATION -#include "proj_math.h" -#else #include -#endif #if !defined(HAVE_C99_MATH) #define HAVE_C99_MATH 0 @@ -133,7 +118,7 @@ enum captype { }; static real sq(real x) { return x * x; } -#if HAVE_C99_MATH || PROJ_COMPILATION +#if HAVE_C99_MATH #define atanhx atanh #define copysignx copysign #define hypotx hypot -- cgit v1.2.3