Blame SOURCES/ElectricFence-2.2.2-posix_memalign.patch

94c734
diff -up /home/petr/fedora/ElectricFence/devel/ElectricFence-2.2.2/efence.c\~ /home/petr/fedora/ElectricFence/devel/ElectricFence-2.2.2/efence.c
94c734
--- ElectricFence-2.2.2/efence.c~	2010-01-11 20:58:43.000000000 +0100
94c734
+++ ElectricFence-2.2.2/efence.c	2010-06-24 14:38:54.000000000 +0200
94c734
@@ -38,6 +38,7 @@
94c734
 # include <pthread.h>
94c734
 # include <semaphore.h>
94c734
 #endif
94c734
+#include <errno.h>
94c734
 
94c734
 #ifdef	malloc
94c734
 #undef	malloc
94c734
@@ -703,6 +704,27 @@ memalign(size_t alignment, size_t userSi
94c734
 	return address;
94c734
 }
94c734
 
94c734
+extern C_LINKAGE int
94c734
+posix_memalign(void **memptr, size_t alignment, size_t userSize)
94c734
+{
94c734
+	/*
94c734
+	 * Per standard, posix_memalign returns EINVAL when alignment
94c734
+	 * is not a power of two or power of sizeof(void*).  efence
94c734
+	 * doesn't check the value of alignment in memalign, but then
94c734
+	 * again, memalign was never specified very well, and on some
94c734
+	 * systems odd alignments could indeed have been allowed.
94c734
+	 */
94c734
+	if ((alignment & (alignment - 1))
94c734
+	    || alignment % sizeof (void *))
94c734
+		return EINVAL;
94c734
+
94c734
+	void *ptr = memalign (alignment, userSize);
94c734
+	if (ptr == NULL)
94c734
+		return ENOMEM;
94c734
+	*memptr = ptr;
94c734
+	return 0;
94c734
+}
94c734
+
94c734
 /*
94c734
  * Find the slot structure for a user address.
94c734
  */
94c734
94c734
Diff finished.  Thu Jun 24 14:52:24 2010