summaryrefslogtreecommitdiff
path: root/multimedia/cmrt/files/patch-memalign
blob: f1d69bb1154712728f4c9d24f8ed9c012a6e27b4 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
memalign is Linux-specific, so use C11 aligned_alloc instead

In file included from decode_hybrid_vp9.cpp:67:
In file included from ./cmrt_api.h:35:
In file included from /usr/local/include/cm_rt.h:41:
In file included from /usr/local/include/cm_rt_linux.h:51:
/usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
#error "<malloc.h> has been replaced by <stdlib.h>"
 ^
/usr/local/include/cm_rt_linux.h:337:9: error: use of undeclared identifier 'memalign'
        return memalign(alignment, size);
               ^
In file included from os_utilities.c:43:
/usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
#error "<malloc.h> has been replaced by <stdlib.h>"
 ^
os_utilities.c:66:8: warning: implicit declaration of function 'memalign' is invalid in C99
      [-Wimplicit-function-declaration]
        ptr = _aligned_malloc(size, alignment);
              ^
os_utilities.c:59:43: note: expanded from macro '_aligned_malloc'
#define _aligned_malloc(size, alignment)  memalign(alignment, size)
                                          ^
os_utilities.c:66:6: warning: incompatible integer to pointer conversion assigning to 'PVOID' (aka 'void *') from
      'int' [-Wint-conversion]
        ptr = _aligned_malloc(size, alignment);
            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- src/cm_rt_linux.h.orig	2016-09-07 23:51:38 UTC
+++ src/cm_rt_linux.h
@@ -48,7 +48,6 @@ extern "C" {
 #include <stdlib.h>
 #include <stdint.h>
 #include <math.h>
-#include <malloc.h>
 #include <string.h>
 #include <sys/time.h>
 #include <pthread.h>
@@ -334,7 +333,7 @@ template <> inline const char *CM_TYPE_NAME_UNMANGLED 
 
 inline void *CM_ALIGNED_MALLOC(size_t size, size_t alignment)
 {
-	return memalign(alignment, size);
+	return aligned_alloc(alignment, size);
 }
 
 inline void CM_ALIGNED_FREE(void *memory)
--- src/os_utilities.c.orig	2016-09-07 23:51:38 UTC
+++ src/os_utilities.c
@@ -40,7 +40,6 @@
 #include <sys/types.h>
 #include <sys/sem.h>
 #include <signal.h>
-#include <malloc.h>
 #include "string.h"
 #include <unistd.h>
 
@@ -56,7 +55,7 @@ INT32 GenOsMemAllocCounter;
    GENOS_OS_VERBOSEMESSAGE("GenOsMemAllocCounter = %d, Addr = 0x%x.", GenOsMemAllocCounter, ptr);   \
    GENOS_OS_VERBOSEMESSAGE("<MemNinjaSysFreePtr memPtr = \"%d\" memType = \"Sys\"/>.", ptr);
 
-#define _aligned_malloc(size, alignment)  memalign(alignment, size)
+#define _aligned_malloc(size, alignment)  aligned_alloc(alignment, size)
 #define _aligned_free(ptr)                free(ptr)
 
 PVOID GENOS_AlignedAllocMemory(SIZE_T size, SIZE_T alignment)