aboutsummaryrefslogtreecommitdiffstats
path: root/comms/libfec/files/patch-fec.c
blob: 47fd34954eb98576279b360270ab044809bbbcc4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- fec.c.orig  Sat Dec  9 22:04:49 2006
+++ fec.c   Sat Dec  9 22:01:43 2006
@@ -3,6 +3,10 @@
  */
 
 #include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/param.h>
+
 #include "fec.h"
 
 unsigned char Partab[256];
@@ -64,3 +68,30 @@
  5, 6, 6, 7, 6, 7, 7, 8,
 };
 
+#if __FreeBSD_version <700000
+
+int
+posix_memalign(void **memptr, size_t alignment, size_t size)
+{
+    int err;
+    void *result;
+
+    /* Make sure that alignment is a large enough power of 2. */
+    if (((alignment - 1) & alignment) != 0 || alignment < sizeof(void *))
+       return (EINVAL);
+
+    /* 
+     * (size | alignment) is enough to assure the requested alignment, since
+     * the allocator always allocates power-of-two blocks.
+     */
+    err = errno; /* Protect errno against changes in pubrealloc(). */
+    result = malloc(size | alignment);
+    errno = err;
+
+    if (result == NULL)
+   return (ENOMEM);
+
+    *memptr = result;
+    return (0);
+}
+#endif