diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-10-27 21:24:33 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-10-27 21:24:33 +0300 |
commit | af75c70b42fb851ee605c40e1cd950f8c5bcf90d (patch) | |
tree | 08058632950a054436e64ccc27283b2061c1d599 | |
parent | 60cdf5f9e638e0831eda1feac857e8a940e155a6 (diff) | |
download | libmicrohttpd-af75c70b42fb851ee605c40e1cd950f8c5bcf90d.tar.gz libmicrohttpd-af75c70b42fb851ee605c40e1cd950f8c5bcf90d.zip |
Further improved PAGESIZE macro detection
-rw-r--r-- | configure.ac | 74 | ||||
-rw-r--r-- | src/microhttpd/memorypool.c | 9 |
2 files changed, 80 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index b922e2c3..169a4019 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1393,7 +1393,42 @@ choke me now | |||
1393 | ] | 1393 | ] |
1394 | ) | 1394 | ) |
1395 | AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]], | 1395 | AS_VAR_IF([[mhd_cv_macro_pagesize_usable]], [["yes"]], |
1396 | [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro])], | 1396 | [ |
1397 | AC_DEFINE([[MHD_USE_PAGESIZE_MACRO]],[[1]],[Define if you have usable PAGESIZE macro]) | ||
1398 | AC_CACHE_CHECK([whether PAGESIZE macro could be used for static init], [mhd_cv_macro_pagesize_usable_static], | ||
1399 | [ | ||
1400 | AC_LINK_IFELSE( | ||
1401 | [ | ||
1402 | AC_LANG_PROGRAM( | ||
1403 | [[ | ||
1404 | #ifdef HAVE_UNISTD_H | ||
1405 | #include <unistd.h> | ||
1406 | #endif | ||
1407 | #ifdef HAVE_LIMITS_H | ||
1408 | #include <limits.h> | ||
1409 | #endif | ||
1410 | #ifdef HAVE_SYS_PARAM_H | ||
1411 | #include <sys/param.h> | ||
1412 | #endif | ||
1413 | #ifndef PAGESIZE | ||
1414 | #error No PAGESIZE macro defined | ||
1415 | choke me now | ||
1416 | #endif | ||
1417 | static long ac_pgsz = PAGESIZE + 0; | ||
1418 | ]], | ||
1419 | [[ | ||
1420 | if (1 > ac_pgsz) return 1; | ||
1421 | ]] | ||
1422 | ) | ||
1423 | ], | ||
1424 | [[mhd_cv_macro_pagesize_usable_static="yes"]], [[mhd_cv_macro_pagesize_usable_static="no"]] | ||
1425 | ) | ||
1426 | ] | ||
1427 | ) | ||
1428 | AS_VAR_IF([[mhd_cv_macro_pagesize_usable_static]], [["yes"]], | ||
1429 | [AC_DEFINE([[MHD_USE_PAGESIZE_MACRO_STATIC]],[[1]],[Define if you have PAGESIZE macro usable for static init])] | ||
1430 | ) | ||
1431 | ], | ||
1397 | [ | 1432 | [ |
1398 | AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable], | 1433 | AC_CACHE_CHECK([for usable PAGE_SIZE macro], [mhd_cv_macro_page_size_usable], |
1399 | [ | 1434 | [ |
@@ -1426,7 +1461,42 @@ choke me now | |||
1426 | ] | 1461 | ] |
1427 | ) | 1462 | ) |
1428 | AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]], | 1463 | AS_VAR_IF([[mhd_cv_macro_page_size_usable]], [["yes"]], |
1429 | [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro])] | 1464 | [ |
1465 | AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO]],[[1]],[Define if you have usable PAGE_SIZE macro]) | ||
1466 | AC_CACHE_CHECK([whether PAGE_SIZE macro could be used for static init], [mhd_cv_macro_page_size_usable_static], | ||
1467 | [ | ||
1468 | AC_LINK_IFELSE( | ||
1469 | [ | ||
1470 | AC_LANG_PROGRAM( | ||
1471 | [[ | ||
1472 | #ifdef HAVE_UNISTD_H | ||
1473 | #include <unistd.h> | ||
1474 | #endif | ||
1475 | #ifdef HAVE_LIMITS_H | ||
1476 | #include <limits.h> | ||
1477 | #endif | ||
1478 | #ifdef HAVE_SYS_PARAM_H | ||
1479 | #include <sys/param.h> | ||
1480 | #endif | ||
1481 | #ifndef PAGE_SIZE | ||
1482 | #error No PAGE_SIZE macro defined | ||
1483 | choke me now | ||
1484 | #endif | ||
1485 | static long ac_pgsz = PAGE_SIZE + 0; | ||
1486 | ]], | ||
1487 | [[ | ||
1488 | if (1 > ac_pgsz) return 1; | ||
1489 | ]] | ||
1490 | ) | ||
1491 | ], | ||
1492 | [[mhd_cv_macro_page_size_usable_static="yes"]], [[mhd_cv_macro_page_size_usable_static="no"]] | ||
1493 | ) | ||
1494 | ] | ||
1495 | ) | ||
1496 | AS_VAR_IF([[mhd_cv_macro_page_size_usable_static]], [["yes"]], | ||
1497 | [AC_DEFINE([[MHD_USE_PAGE_SIZE_MACRO_STATIC]],[[1]],[Define if you have PAGE_SIZE macro usable for static init])] | ||
1498 | ) | ||
1499 | ] | ||
1430 | ) | 1500 | ) |
1431 | ] | 1501 | ] |
1432 | ) | 1502 | ) |
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c index cf0b897e..f963031e 100644 --- a/src/microhttpd/memorypool.c +++ b/src/microhttpd/memorypool.c | |||
@@ -120,7 +120,14 @@ | |||
120 | /** | 120 | /** |
121 | * Size of memory page | 121 | * Size of memory page |
122 | */ | 122 | */ |
123 | static size_t MHD_sys_page_size_ = _MHD_FALLBACK_PAGE_SIZE; /* Default fallback value */ | 123 | static size_t MHD_sys_page_size_ = |
124 | #if defined(MHD_USE_PAGESIZE_MACRO_STATIC) | ||
125 | PAGESIZE; | ||
126 | #elif defined(MHD_USE_PAGE_SIZE_MACRO_STATIC) | ||
127 | PAGE_SIZE; | ||
128 | #else /* ! MHD_USE_PAGE_SIZE_MACRO_STATIC */ | ||
129 | _MHD_FALLBACK_PAGE_SIZE; /* Default fallback value */ | ||
130 | #endif /* ! MHD_USE_PAGE_SIZE_MACRO_STATIC */ | ||
124 | 131 | ||
125 | /** | 132 | /** |
126 | * Initialise values for memory pools | 133 | * Initialise values for memory pools |