gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 03/06: Added check at configure time for PAGESIZE and PA


From: gnunet
Subject: [libmicrohttpd] 03/06: Added check at configure time for PAGESIZE and PAGE_SIZE macros
Date: Sun, 24 Oct 2021 13:45:06 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 66f273f4d5705eb5c841e2992330d3c221e2949b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Oct 23 22:03:06 2021 +0300

    Added check at configure time for PAGESIZE and PAGE_SIZE macros
    
    Some platforms may have them defined as call of function so compile-time 
check for
    valid number may not work.
---
 configure.ac                | 69 +++++++++++++++++++++++++++++++++++++++++++++
 src/microhttpd/memorypool.c | 35 ++++++++++++++++-------
 2 files changed, 94 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index c9d9f767..7b363d6d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1362,6 +1362,75 @@ int main(void)
   ]
 )
 
+AC_CACHE_CHECK([for usable PAGESIZE macro], [mhd_cv_macro_pagesize_usable],
+  [
+    AC_LINK_IFELSE(
+      [
+        AC_LANG_PROGRAM(
+          [[
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifndef PAGESIZE
+#error No PAGESIZE macro defined
+choke me now
+#endif
+          ]],
+          [[
+            long pgsz = PAGESIZE + 0;
+            if (1 > pgsz) return 1;
+          ]]
+        )
+      ],
+      [[mhd_cv_macro_pagesize_usable="yes"]], 
[[mhd_cv_macro_pagesize_usable="no"]]
+    )
+  ]
+)
+AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]],
+  [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable 
PAGESIZE macro])],
+  [
+    AC_CACHE_CHECK([for usable PAGE_SIZE macro], 
[mhd_cv_macro_page_size_usable],
+      [
+        AC_LINK_IFELSE(
+          [
+            AC_LANG_PROGRAM(
+              [[
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifndef PAGE_SIZE
+#error No PAGE_SIZE macro defined
+choke me now
+#endif
+              ]],
+              [[
+                long pgsz = PAGE_SIZE + 0;
+                if (1 > pgsz) return 1;
+              ]]
+            )
+          ],
+          [[mhd_cv_macro_page_size_usable="yes"]], 
[[mhd_cv_macro_page_size_usable="no"]]
+        )
+      ]
+    )
+    AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]],
+      [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable 
PAGE_SIZE macro])]
+    )
+  ]
+)
+
 # Check for inter-thread signaling type
 AC_ARG_ENABLE([[itc]],
   [AS_HELP_STRING([[--enable-itc=TYPE]], [use TYPE of inter-thread 
communication (pipe, socketpair, eventfd) [auto]])], [],
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index ffcaab43..cf0b897e 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -45,7 +45,30 @@
 #define MHD_SC_PAGESIZE _SC_PAGESIZE
 #endif /* _SC_PAGESIZE */
 #endif /* HAVE_SYSCONF */
-#include "mhd_limits.h" /* for SIZE_MAX */
+#include "mhd_limits.h" /* for SIZE_MAX, PAGESIZE / PAGE_SIZE */
+
+#if defined(MHD_USE_PAGESIZE_MACRO) || defined (MHD_USE_PAGE_SIZE_MACRO)
+#ifndef HAVE_SYSCONF /* Avoid duplicate include */
+#include <unistd.h>
+#endif /* HAVE_SYSCONF */
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
+#endif /* MHD_USE_PAGESIZE_MACRO || MHD_USE_PAGE_SIZE_MACRO */
+
+/**
+ * Fallback value of page size
+ */
+#define _MHD_FALLBACK_PAGE_SIZE (4096)
+
+#if defined(MHD_USE_PAGESIZE_MACRO)
+#define MHD_DEF_PAGE_SIZE_ PAGESIZE
+#elif defined(MHD_USE_PAGE_SIZE_MACRO)
+#define MHD_DEF_PAGE_SIZE_ PAGE_SIZE
+#else  /* ! PAGESIZE */
+#define MHD_DEF_PAGE_SIZE_ _MHD_FALLBACK_PAGE_SIZE
+#endif /* ! PAGESIZE */
+
 
 #ifdef MHD_ASAN_POISON_ACTIVE
 #include <sanitizer/asan_interface.h>
@@ -94,18 +117,10 @@
   ASAN_UNPOISON_MEMORY_REGION ((pointer), (size))
 #endif /* MHD_ASAN_POISON_ACTIVE */
 
-#if defined(PAGE_SIZE) && (0 < (PAGE_SIZE + 0))
-#define MHD_DEF_PAGE_SIZE_ PAGE_SIZE
-#elif defined(PAGESIZE) && (0 < (PAGESIZE + 0))
-#define MHD_DEF_PAGE_SIZE_ PAGESIZE
-#else  /* ! PAGESIZE */
-#define MHD_DEF_PAGE_SIZE_ (4096)
-#endif /* ! PAGESIZE */
-
 /**
  * Size of memory page
  */
-static size_t MHD_sys_page_size_ = MHD_DEF_PAGE_SIZE_; /* Default fallback 
value */
+static size_t MHD_sys_page_size_ = _MHD_FALLBACK_PAGE_SIZE; /* Default 
fallback value */
 
 /**
  * Initialise values for memory pools

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]