[ElectricFence] Add a patch that implements posix_memalign

Petr Machata pmachata at fedoraproject.org
Fri Mar 11 09:57:07 UTC 2011


commit f818814fc06b6f20d173bd705ed7d1b184339dc6
Author: Petr Machata <pmachata at redhat.com>
Date:   Fri Mar 11 10:56:46 2011 +0100

    Add a patch that implements posix_memalign

 ElectricFence-2.2.2-posix_memalign.patch |   41 ++++++++++++++++++++++++++++++
 ElectricFence.spec                       |    8 +++++-
 2 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/ElectricFence-2.2.2-posix_memalign.patch b/ElectricFence-2.2.2-posix_memalign.patch
new file mode 100644
index 0000000..94d7a65
--- /dev/null
+++ b/ElectricFence-2.2.2-posix_memalign.patch
@@ -0,0 +1,41 @@
+diff -up /home/petr/fedora/ElectricFence/devel/ElectricFence-2.2.2/efence.c\~ /home/petr/fedora/ElectricFence/devel/ElectricFence-2.2.2/efence.c
+--- ElectricFence-2.2.2/efence.c~	2010-01-11 20:58:43.000000000 +0100
++++ ElectricFence-2.2.2/efence.c	2010-06-24 14:38:54.000000000 +0200
+@@ -38,6 +38,7 @@
+ # include <pthread.h>
+ # include <semaphore.h>
+ #endif
++#include <errno.h>
+ 
+ #ifdef	malloc
+ #undef	malloc
+@@ -703,6 +704,27 @@ memalign(size_t alignment, size_t userSi
+ 	return address;
+ }
+ 
++extern C_LINKAGE int
++posix_memalign(void **memptr, size_t alignment, size_t userSize)
++{
++	/*
++	 * Per standard, posix_memalign returns EINVAL when alignment
++	 * is not a power of two or power of sizeof(void*).  efence
++	 * doesn't check the value of alignment in memalign, but then
++	 * again, memalign was never specified very well, and on some
++	 * systems odd alignments could indeed have been allowed.
++	 */
++	if ((alignment & (alignment - 1))
++	    || alignment % sizeof (void *))
++		return EINVAL;
++
++	void *ptr = memalign (alignment, userSize);
++	if (ptr == NULL)
++		return ENOMEM;
++	*memptr = ptr;
++	return 0;
++}
++
+ /*
+  * Find the slot structure for a user address.
+  */
+
+Diff finished.  Thu Jun 24 14:52:24 2010
diff --git a/ElectricFence.spec b/ElectricFence.spec
index 26f3546..52b1c0c 100644
--- a/ElectricFence.spec
+++ b/ElectricFence.spec
@@ -1,7 +1,7 @@
 Summary: A debugger which detects memory allocation violations
 Name: ElectricFence
 Version: 2.2.2
-Release: 31%{?dist}
+Release: 32%{?dist}
 License: GPLv2
 Group: Development/Tools
 URL: http://perens.com/FreeSoftware/ElectricFence/
@@ -18,6 +18,7 @@ Patch6: ElectricFence-2.2.2-banner.patch
 Patch7: ElectricFence-2.2.2-ef.patch
 Patch8: ElectricFence-2.2.2-builtins.patch
 Patch9: ElectricFence-2.2.2-sse.patch
+Patch10: ElectricFence-2.2.2-posix_memalign.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 %description
@@ -43,6 +44,7 @@ violations.
 %patch7 -p1
 %patch8 -p1
 %patch9 -p1
+%patch10 -p1
 
 %build
 make CFLAGS='${RPM_OPT_FLAGS} -DUSE_SEMAPHORE -fpic'
@@ -75,6 +77,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/*/*
 
 %changelog
+* Fri Mar 11 2011 Petr Machata <pmachata at redhat.com> - 2.2.2-32
+- Add a patch that implements posix_memalign
+- Resolves: #684019
+
 * Mon Feb 07 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.2.2-31
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list