[cpl-plugin-hawki] 01/01: Make irplib gcc5 compatible. Closes: #777823
Ole Streicher
olebole at moszumanska.debian.org
Sun Apr 19 13:10:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
olebole pushed a commit to branch debian
in repository cpl-plugin-hawki.
commit 3b676202585a291716c2a6b12851bd0c3c47280d
Author: Ole Streicher <olebole at debian.org>
Date: Sun Apr 19 15:10:39 2015 +0200
Make irplib gcc5 compatible. Closes: #777823
---
debian/changelog | 1 +
debian/patches/fix_irplib_gcc5.patch | 110 +++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 112 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 2454a04..233a20a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,7 @@ cpl-plugin-hawki (1.8.18+dfsg-1) UNRELEASED; urgency=low
* Update maintainers e-mail address
* Update standards version to 3.9.6. No changes needed.
* Add simple CI test
+ * Make irplib gcc5 compatible. Closes: #777823
-- Ole Streicher <olebole at debian.org> Sat, 18 Apr 2015 17:26:45 +0200
diff --git a/debian/patches/fix_irplib_gcc5.patch b/debian/patches/fix_irplib_gcc5.patch
new file mode 100644
index 0000000..fa3b637
--- /dev/null
+++ b/debian/patches/fix_irplib_gcc5.patch
@@ -0,0 +1,110 @@
+From: jtaylor <jtaylor at 318c8218-2dab-440d-9263-6f70bac63e5b>
+Date: Fri, 31 Oct 2014 09:48:58 +0000
+Subject: [PATCH] make aligned allocator more robust to weird standard
+ requirements
+
+C11 requires size to be multiple of alignment, so extend the size
+internally. glibc does not require that and additionally does not require
+the alignment to be a power of two. In irplib requires this for all variants
+for consistency.
+--- a/irplib/irplib_utils.c
++++ b/irplib/irplib_utils.c
+@@ -1587,51 +1587,61 @@
+ /*----------------------------------------------------------------------------*/
+ void * irplib_aligned_malloc(size_t alignment, size_t size)
+ {
+-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
+- return aligned_alloc(alignment, size);
+-#elif defined HAVE_POSIX_MEMALIGN && defined HAVE_DECL_POSIX_MEMALIGN
+- void *ptr;
+- if (alignment == 1)
+- return malloc (size);
+- if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
+- alignment = sizeof (void *);
+- if (posix_memalign (&ptr, alignment, size) == 0)
+- return ptr;
+- else
+- return NULL;
+-#else
+- /* copied from gmm_malloc.h in gcc-4.8 */
+- void * malloc_ptr;
+- void * aligned_ptr;
+-
++ if (alignment == 0)
++ alignment = 1;
+ /* Error if align is not a power of two. */
+ if (alignment & (alignment - 1)) {
+ errno = EINVAL;
+ return NULL;
+ }
++ /* make size a multiple of alignment (required by C11) */
++ if ((size % alignment) != 0) {
++ size += alignment - (size % alignment);
++ }
+
+- if (size == 0)
+- return NULL;
+-
+- /* Assume malloc'd pointer is aligned at least to sizeof (void*).
+- If necessary, add another sizeof (void*) to store the value
+- returned by malloc. Effectively this enforces a minimum alignment
+- of sizeof double. */
+- if (alignment < 2 * sizeof (void *))
+- alignment = 2 * sizeof (void *);
+-
+- malloc_ptr = malloc (size + alignment);
+- if (!malloc_ptr)
+- return NULL;
+-
+- /* Align We have at least sizeof (void *) space below malloc'd ptr. */
+- aligned_ptr = (void *) (((size_t) malloc_ptr + alignment)
+- & ~((size_t) (alignment) - 1));
++#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L
++ return aligned_alloc(alignment, size);
++#elif defined HAVE_POSIX_MEMALIGN && defined HAVE_DECL_POSIX_MEMALIGN
++ {
++ void *ptr;
++ if (alignment == 1)
++ return malloc (size);
++ if (alignment == 2 || (sizeof (void *) == 8 && alignment == 4))
++ alignment = sizeof (void *);
++ if (posix_memalign (&ptr, alignment, size) == 0)
++ return ptr;
++ else
++ return NULL;
++ }
++#else
++ /* copied from gmm_malloc.h in gcc-4.8 */
++ {
++ void * malloc_ptr;
++ void * aligned_ptr;
++
++ if (size == 0)
++ return NULL;
++
++ /* Assume malloc'd pointer is aligned at least to sizeof (void*).
++ If necessary, add another sizeof (void*) to store the value
++ returned by malloc. Effectively this enforces a minimum alignment
++ of sizeof double. */
++ if (alignment < 2 * sizeof (void *))
++ alignment = 2 * sizeof (void *);
++
++ malloc_ptr = malloc (size + alignment);
++ if (!malloc_ptr)
++ return NULL;
++
++ /* Align We have at least sizeof (void *) space below malloc'd ptr. */
++ aligned_ptr = (void *) (((size_t) malloc_ptr + alignment)
++ & ~((size_t) (alignment) - 1));
+
+- /* Store the original pointer just before p. */
+- *(((void **) aligned_ptr) - 1) = malloc_ptr;
++ /* Store the original pointer just before p. */
++ *(((void **) aligned_ptr) - 1) = malloc_ptr;
+
+- return aligned_ptr;
++ return aligned_ptr;
++ }
+ #endif
+ }
+
diff --git a/debian/patches/series b/debian/patches/series
index 3a289c0..7f5a4e9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@ set_plugindir.patch
use-std-paths-for-cpl.patch
fix_test_fail.patch
force-serial-tests.patch
+fix_irplib_gcc5.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-astro/packages/cpl-plugin-hawki.git
More information about the debian-science-commits
mailing list