Blame SOURCES/ElectricFence-2.2.2-posix_memalign.patch

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