summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2018-05-31 13:03:41 +0000
committerEmmanuele Bassi <ebassi@gmail.com>2018-05-31 13:03:41 +0000
commit54db9d3fc398c55e09f21d2b1a8073419fe7e629 (patch)
treee779c7a7e2a1da777b1ceddcd2cfbf31480b7192
parentdd4f44fd04f10ad184ec8adbda8f95af9151209e (diff)
parentfe59a18f8985383d2baf1796342304714bfb6983 (diff)
downloadglib-54db9d3fc398c55e09f21d2b1a8073419fe7e629.tar.gz
Merge branch 'remove-posix-memalign-compl-check' into 'master'
Remove posix_memalign() checks for an old glibc bug See merge request GNOME/glib!47
-rw-r--r--config.h.meson3
-rw-r--r--config.h.win32.in3
-rw-r--r--configure.ac42
-rw-r--r--glib/gslice.c15
4 files changed, 5 insertions, 58 deletions
diff --git a/config.h.meson b/config.h.meson
index f134cac35..f7f43d6ca 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -686,9 +686,6 @@
/* Define to the version of this package. */
#mesondefine PACKAGE_VERSION
-/* define if posix_memalign() can allocate any size */
-#mesondefine POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS
-
/* The size of `char', as computed by sizeof. */
#mesondefine SIZEOF_CHAR
diff --git a/config.h.win32.in b/config.h.win32.in
index c8e393b2f..a3e9781b9 100644
--- a/config.h.win32.in
+++ b/config.h.win32.in
@@ -701,9 +701,6 @@
/* Define to the version of this package. */
#define PACKAGE_VERSION "@GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@.@GLIB_MICRO_VERSION@"
-/* define if posix_memalign() can allocate any size */
-/* #undef POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS */
-
/* The size of `char', as computed by sizeof. */
#define SIZEOF_CHAR 1
diff --git a/configure.ac b/configure.ac
index 6df0dfa82..fd6c0d953 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1317,48 +1317,6 @@ if test x$glib_cv_langinfo_abaltmon = xyes; then
fi
AC_LANG_RESTORE
-dnl ****************************************
-dnl *** posix_memalign ***
-dnl ****************************************
-AC_MSG_CHECKING(for a compliant posix_memalign() implementation)
-AC_CACHE_VAL(glib_cv_compliant_posix_memalign,[
- glib_cv_compliant_posix_memalign=0
- if test "$ac_cv_func_posix_memalign" = "yes" ; then
- AC_TRY_RUN([
- #define _XOPEN_SOURCE 600
- #include <stdlib.h> /* posix_memalign() should be defined here */
- /* some systems break if #include <malloc.h> used */
- static void test_memalign (size_t boundary, size_t size) {
- void *mem = 0;
- if (posix_memalign (&mem, boundary, size) != 0 || !mem)
- exit (1);
- else
- free (mem);
- }
- int main() {
- test_memalign ( 128, 128 - 2 * sizeof (void*));
- test_memalign ( 256, 256 - 2 * sizeof (void*));
- test_memalign ( 512, 512 - 2 * sizeof (void*));
- test_memalign ( 1024, 1024 - 2 * sizeof (void*));
- test_memalign ( 2048, 2048 - 2 * sizeof (void*));
- test_memalign ( 4096, 4096 - 2 * sizeof (void*));
- test_memalign ( 8192, 8192 - 2 * sizeof (void*));
- test_memalign (16384, 16384 - 2 * sizeof (void*));
- test_memalign (32768, 32768 - 2 * sizeof (void*));
- exit (0); /* success */
- }
- ],
- [glib_cv_compliant_posix_memalign=1], [], [:])
- :
- fi
- ])
-AS_IF([test "$glib_cv_compliant_posix_memalign" = "1"], [
- AC_MSG_RESULT(yes)
- AC_DEFINE(POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS, 1, [define if posix_memalign() can allocate any size])
-], [
- AC_MSG_RESULT(no)
-])
-
dnl ****************************************
dnl *** strlcpy/strlcat ***
diff --git a/glib/gslice.c b/glib/gslice.c
index 48e4c5a33..d1b1fc639 100644
--- a/glib/gslice.c
+++ b/glib/gslice.c
@@ -19,11 +19,7 @@
#include "config.h"
#include "glibconfig.h"
-#if defined HAVE_POSIX_MEMALIGN && defined POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS
-# define HAVE_COMPLIANT_POSIX_MEMALIGN 1
-#endif
-
-#if defined(HAVE_COMPLIANT_POSIX_MEMALIGN) && !defined(_XOPEN_SOURCE)
+#if defined(HAVE_POSIX_MEMALIGN) && !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 600 /* posix_memalign() */
#endif
#include <stdlib.h> /* posix_memalign() */
@@ -416,7 +412,7 @@ g_slice_init_nomessage (void)
mem_assert ((sys_page_size & (sys_page_size - 1)) == 0);
slice_config_init (&allocator->config);
allocator->min_page_size = sys_page_size;
-#if HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN
+#if HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN
/* allow allocation of pages up to 8KB (with 8KB alignment).
* this is useful because many medium to large sized structures
* fit less than 8 times (see [4]) into 4KB pages.
@@ -1394,13 +1390,12 @@ slab_allocator_free_chunk (gsize chunk_size,
/* from config.h:
* define HAVE_POSIX_MEMALIGN 1 // if free(posix_memalign(3)) works, <stdlib.h>
- * define HAVE_COMPLIANT_POSIX_MEMALIGN 1 // if free(posix_memalign(3)) works for sizes != 2^n, <stdlib.h>
* define HAVE_MEMALIGN 1 // if free(memalign(3)) works, <malloc.h>
* define HAVE_VALLOC 1 // if free(valloc(3)) works, <stdlib.h> or <malloc.h>
* if none is provided, we implement malloc(3)-based alloc-only page alignment
*/
-#if !(HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC)
+#if !(HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC)
static GTrashStack *compat_valloc_trash = NULL;
#endif
@@ -1410,7 +1405,7 @@ allocator_memalign (gsize alignment,
{
gpointer aligned_memory = NULL;
gint err = ENOMEM;
-#if HAVE_COMPLIANT_POSIX_MEMALIGN
+#if HAVE_POSIX_MEMALIGN
err = posix_memalign (&aligned_memory, alignment, memsize);
#elif HAVE_MEMALIGN
errno = 0;
@@ -1454,7 +1449,7 @@ static void
allocator_memfree (gsize memsize,
gpointer mem)
{
-#if HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC
+#if HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC
free (mem);
#else
mem_assert (memsize <= sys_page_size);