From 597c9950a34801ed80f3cdcb030c20950cb55e9b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 5 Dec 2022 12:55:15 +0100 Subject: adapt build to latest GNUnet without gnunet/platform.h --- configure.ac | 80 +++++-------- contrib/gana | 2 +- src/exchange-tools/taler-crypto-worker.c | 2 +- src/include/platform.h | 187 +++++++++++++++++++++++++++++-- src/testing/testing_api_loop.c | 2 +- src/util/amount.c | 4 +- src/util/util.c | 2 +- 7 files changed, 214 insertions(+), 65 deletions(-) diff --git a/configure.ac b/configure.ac index 2df8674eb..c80c2e8f0 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,13 @@ AS_IF([test "x$doc_only" != xyes],[ # Force some CFLAGS CFLAGS="-Wall -Wno-address-of-packed-member $CFLAGS" +TALER_LIB_LDFLAGS="-export-dynamic -no-undefined" +TALER_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined" + +AC_SUBST(TALER_LIB_LDFLAGS) +AC_SUBST(TALER_PLUGIN_LDFLAGS) + + # Checks for header files. AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h sys/socket.h sys/un.h netinet/in.h netinet/ip.h]) @@ -76,6 +83,7 @@ AC_DEFINE_UNQUOTED([NEED_LIBGCRYPT_VERSION], ["$need_libgcrypt_version"], AM_PATH_LIBGCRYPT([$need_libgcrypt_version]) + # should expensive tests be run? AC_MSG_CHECKING(whether to run expensive tests) AC_ARG_ENABLE([expensivetests], @@ -133,20 +141,12 @@ AS_CASE([$with_gnunet], [no], [AC_MSG_ERROR([--with-gnunet is required])], [LDFLAGS="-L$with_gnunet/lib $LDFLAGS" CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"]) -AC_CHECK_HEADERS([gnunet/platform.h gnunet/gnunet_util_lib.h], - [AC_CHECK_LIB([gnunetutil], [GNUNET_SCHEDULER_run], libgnunetutil=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif - #include - #if GNUNET_UTIL_VERSION < 0x00A0104 - #fail libgnunetutil is too old - #endif]) +AC_CHECK_HEADERS([gnunet/gnunet_util_lib.h], + [AC_CHECK_LIB([gnunetutil], [GNUNET_SCHEDULER_run], libgnunetutil=1)]) AS_IF([test $libgnunetutil != 1], [AC_MSG_ERROR([[ *** -*** You need libgnunetutil > 0.14.0 to build this program. -*** (Yes, ">", libgnunetutil 0.14.0 is NOT enough.) +*** You need libgnunetutil >= 0.19.0 to build this program. *** This library is part of GNUnet, available at *** https://gnunet.org *** ]])]) @@ -165,11 +165,8 @@ AS_CASE([$with_gnunet], [no], [AC_MSG_ERROR([--with-gnunet is required])], [LDFLAGS="-L$with_gnunet/lib $LDFLAGS" CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"]) -AC_CHECK_HEADERS([gnunet/platform.h gnunet/gnunet_json_lib.h], - [AC_CHECK_LIB([gnunetjson], [GNUNET_JSON_parse], libgnunetjson=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif]) +AC_CHECK_HEADERS([gnunet/gnunet_json_lib.h], + [AC_CHECK_LIB([gnunetjson], [GNUNET_JSON_parse], libgnunetjson=1)]) AS_IF([test $libgnunetjson != 1], [AC_MSG_ERROR([[ *** @@ -231,11 +228,8 @@ AS_CASE([$with_gnunet], [no], [AC_MSG_ERROR([--with-gnunet is required])], [LDFLAGS="-L$with_gnunet/lib $LDFLAGS" CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"]) -AC_CHECK_HEADERS([gnunet/platform.h gnunet/gnunet_curl_lib.h], - [AC_CHECK_LIB([gnunetcurl], [GNUNET_CURL_get_select_info], libgnunetcurl=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif]) +AC_CHECK_HEADERS([gnunet/gnunet_curl_lib.h], + [AC_CHECK_LIB([gnunetcurl], [GNUNET_CURL_get_select_info], libgnunetcurl=1)]) AS_IF([test $libgnunetcurl != 1], [AC_MSG_ERROR([[ *** @@ -250,6 +244,12 @@ CFLAGS=$CFLAGS_SAVE LDFLAGS=$LDFLAGS_SAVE LIBS=$LIBS_SAVE +# test for postgres +AX_LIB_POSTGRESQL([13.0]) +AS_IF([test "x$found_postgresql" = "xyes"],[postgres=true]) + +AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) + # Check for GNUnet's libgnunetpq. libgnunetpq=0 AC_MSG_CHECKING([for libgnunetpq]) @@ -262,12 +262,9 @@ AS_CASE([$with_gnunet], [yes], [], [no], [AC_MSG_ERROR([--with-gnunet is required])], [LDFLAGS="-L$with_gnunet/lib $LDFLAGS" - CPPFLAGS="-I$with_gnunet/include $CPPFLAGS"]) -AC_CHECK_HEADERS([gnunet/platform.h gnunet/gnunet_pq_lib.h], - [AC_CHECK_LIB([gnunetpq], [GNUNET_PQ_result_spec_string], libgnunetpq=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif]) + CPPFLAGS="-I$with_gnunet/include ${CPPFLAGS} ${POSTGRESQL_CPPFLAGS}"]) +AC_CHECK_HEADERS([gnunet/gnunet_pq_lib.h], + [AC_CHECK_LIB([gnunetpq], [GNUNET_PQ_result_spec_string], libgnunetpq=1)]) AS_IF([test $libgnunetpq != 1], [AC_MSG_ERROR([[ *** @@ -277,15 +274,15 @@ AS_IF([test $libgnunetpq != 1], *** is recent!) *** ]])]) +CFLAGS_SAVE=$CFLAGS +LDFLAGS_SAVE=$LDFLAGS +LIBS_SAVE="$LIBS" # Check for GNUnet's libgnunetsq libgnunetsq=0 AC_MSG_CHECKING([for libgnunetsq]) AC_CHECK_HEADERS([gnunet/gnunet_sq_lib.h], - [AC_CHECK_LIB([gnunetsq], [GNUNET_SQ_result_spec_string], libgnunetsq=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif]) + [AC_CHECK_LIB([gnunetsq], [GNUNET_SQ_result_spec_string], libgnunetsq=1)]) # check for libmicrohttpd @@ -324,22 +321,6 @@ AS_IF([test $jansson = 0], *** ]])]) -# test for postgres -AX_LIB_POSTGRESQL([13.0]) -AS_IF([test "x$found_postgresql" = "xyes"],[postgres=true]) - -TALER_LIB_LDFLAGS="-export-dynamic -no-undefined" -TALER_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined" - -AC_SUBST(TALER_LIB_LDFLAGS) -AC_SUBST(TALER_PLUGIN_LDFLAGS) - -CFLAGS_SAVE=$CFLAGS -LDFLAGS_SAVE=$LDFLAGS -LIBS_SAVE="$LIBS" - - -AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) CFLAGS=$CFLAGS_SAVE LDFLAGS=$LDFLAGS_SAVE @@ -389,10 +370,7 @@ AS_CASE([$with_twister], CPPFLAGS="-I$with_twister/include $CPPFLAGS"]) AC_CHECK_HEADERS([taler/taler_twister_service.h], - [AC_CHECK_LIB([talertwister], [TALER_TWISTER_connect], talertwister=1)], - [], [#ifdef HAVE_GNUNET_PLATFORM_H - #include - #endif]) + [AC_CHECK_LIB([talertwister], [TALER_TWISTER_connect], talertwister=1)]) AM_CONDITIONAL(HAVE_TWISTER, test x$talertwister = x1) # should developer logic be compiled (not-for-production code)? diff --git a/contrib/gana b/contrib/gana index 212ee0a78..20f8eb7a7 160000 --- a/contrib/gana +++ b/contrib/gana @@ -1 +1 @@ -Subproject commit 212ee0a78adc43cb5c04d6ea96ccc2fe74fed62b +Subproject commit 20f8eb7a72e2160409f0f78264ec5198e9caa193 diff --git a/src/exchange-tools/taler-crypto-worker.c b/src/exchange-tools/taler-crypto-worker.c index 8c3a123c3..c3abfa548 100644 --- a/src/exchange-tools/taler-crypto-worker.c +++ b/src/exchange-tools/taler-crypto-worker.c @@ -21,7 +21,7 @@ #include "platform.h" #include "taler_util.h" #include -#include +#include #include "taler_error_codes.h" #include "taler_json_lib.h" #include "taler_signatures.h" diff --git a/src/include/platform.h b/src/include/platform.h index b2c286b74..d4d2c80e7 100644 --- a/src/include/platform.h +++ b/src/include/platform.h @@ -20,17 +20,17 @@ * rest of the modules * @author Sree Harsha Totakura */ - #ifndef PLATFORM_H_ #define PLATFORM_H_ /* Include our configuration header */ #ifndef HAVE_USED_CONFIG_H -# define HAVE_USED_CONFIG_H -# ifdef HAVE_CONFIG_H -# include "taler_config.h" -# endif +#define HAVE_USED_CONFIG_H +#ifdef HAVE_CONFIG_H +#include "taler_config.h" +#endif #endif + /* For the exchange build, we do NOT want gettext, even if it is available! */ #undef ENABLE_NLS @@ -45,9 +45,6 @@ /* Include the features available for GNU source */ #define _GNU_SOURCE -/* Include GNUnet's platform file */ -#include - /* Do not use shortcuts for gcrypt mpi */ #define GCRYPT_NO_MPI_MACROS 1 @@ -67,6 +64,171 @@ #define ENABLE_SANITY_CHECKS 1 +#include +#include +#include +#if HAVE_NETINET_IN_H +#include +#endif +#if HAVE_NETINET_IN_SYSTM_H +#include +#endif +#if HAVE_NETINET_IP_H +#include /* superset of previous */ +#endif +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_MALLOC_H +#include /* for mallinfo on GNU */ +#endif +#include /* KLB_FIX */ +#include +#include +#include /* KLB_FIX */ +#include +#include +#if HAVE_SYS_PARAM_H +#include +#endif +#if HAVE_SYS_TIME_H +#include +#endif +#include +#ifdef BSD +#include +#endif +#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) +#include +#endif +#ifdef DARWIN +#include +#include +#include +#endif +#if defined(__linux__) || defined(GNU) +#include +#endif +#ifdef SOLARIS +#include +#include +#include +#include +#endif +#if HAVE_UCRED_H +#include +#endif +#if HAVE_SYS_UCRED_H +#include +#endif +#if HAVE_IFADDRS_H +#include +#endif +#include +#include + +#if HAVE_VFORK_H +#include +#endif + +#include +#if HAVE_SYS_RESOURCE_H +#include +#endif + +#if HAVE_ENDIAN_H +#include +#endif +#if HAVE_SYS_ENDIAN_H +#include +#endif + +#define DIR_SEPARATOR '/' +#define DIR_SEPARATOR_STR "/" +#define PATH_SEPARATOR ':' +#define PATH_SEPARATOR_STR ":" +#define NEWLINE "\n" + + +#include +#include "gettext.h" +/** + * GNU gettext support macro. + */ +#define _(String) dgettext (PACKAGE, String) + + +#include + +/* FreeBSD_kernel is not defined on the now discontinued kFreeBSD */ +#if defined(BSD) && defined(__FreeBSD__) && defined(__FreeBSD_kernel__) +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +#endif + +#ifdef DARWIN +#define __BYTE_ORDER BYTE_ORDER +#define __BIG_ENDIAN BIG_ENDIAN +/* not available on darwin, override configure */ +#undef HAVE_STAT64 +#undef HAVE_MREMAP +#endif + +#if ! HAVE_ATOLL +long long +atoll (const char *nptr); + +#endif + +#if ENABLE_NLS +#include "langinfo.h" +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t) (-1)) +#endif + +#ifndef O_LARGEFILE +#define O_LARGEFILE 0 +#endif + + +#if defined(__sparc__) +#define MAKE_UNALIGNED(val) ({ __typeof__((val)) __tmp; memmove (&__tmp, &(val), \ + sizeof((val))); \ + __tmp; }) +#else +#define MAKE_UNALIGNED(val) val +#endif + + +#ifndef PATH_MAX +/** + * Assumed maximum path length. + */ +#define PATH_MAX 4096 +#endif + +#if HAVE_THREAD_LOCAL_GCC +#define TALER_THREAD_LOCAL __thread +#else +#define TALER_THREAD_LOCAL +#endif + + /* LSB-style exit status codes */ #ifndef EXIT_INVALIDARGUMENT #define EXIT_INVALIDARGUMENT 2 @@ -92,6 +254,15 @@ #define EXIT_NOTRUNNING 7 #endif +/** + * clang et al do not have such an attribute + */ +#if __has_attribute (__nonstring__) +# define __nonstring __attribute__((__nonstring__)) +#else +# define __nonstring +#endif + #endif /* PLATFORM_H_ */ diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 190e20928..986358ed3 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -827,7 +827,7 @@ TALER_TESTING_setup (TALER_TESTING_Main main_cb, sigpipe = GNUNET_DISK_pipe (GNUNET_DISK_PF_NONE); GNUNET_assert (NULL != sigpipe); shc_chld = GNUNET_SIGNAL_handler_install ( - GNUNET_SIGCHLD, + SIGCHLD, &sighandler_child_death); is.ctx = GNUNET_CURL_init ( &GNUNET_CURL_gnunet_scheduler_reschedule, diff --git a/src/util/amount.c b/src/util/amount.c index 43116af85..d5698e8b6 100644 --- a/src/util/amount.c +++ b/src/util/amount.c @@ -553,8 +553,8 @@ const char * TALER_amount2s (const struct TALER_Amount *amount) { /* 24 is sufficient for a uint64_t value in decimal; 3 is for ":.\0" */ - static GNUNET_THREAD_LOCAL char result[TALER_AMOUNT_FRAC_LEN - + TALER_CURRENCY_LEN + 3 + 24]; + static TALER_THREAD_LOCAL char result[TALER_AMOUNT_FRAC_LEN + + TALER_CURRENCY_LEN + 3 + 24]; struct TALER_Amount norm; if (GNUNET_YES != TALER_amount_is_valid (amount)) diff --git a/src/util/util.c b/src/util/util.c index 2b8c9d952..5321b31ed 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -28,7 +28,7 @@ const char * TALER_b2s (const void *buf, size_t buf_size) { - static GNUNET_THREAD_LOCAL char ret[9]; + static TALER_THREAD_LOCAL char ret[9]; struct GNUNET_HashCode hc; char *tmp; -- cgit v1.2.3