]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
fix MacOS compile errors by replacing memalign() with posix_memalign() 313/head
authorpwpiwi <pwpiwi@users.noreply.github.com>
Thu, 8 Jun 2017 06:08:30 +0000 (08:08 +0200)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Thu, 8 Jun 2017 06:26:20 +0000 (08:26 +0200)
client/hardnested/hardnested_bf_core.c
client/hardnested/hardnested_bitarray_core.c
client/hardnested/hardnested_bruteforce.c

index c22a9a08bcd2fb3d1a98a200d5aedef3854e9c96..05246296c24a0b5340698459276a722c8efc7303 100644 (file)
@@ -52,8 +52,10 @@ THE SOFTWARE.
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdlib.h>
-#include <stdio.h>
+#ifndef __APPLE__
 #include <malloc.h>
 #include <malloc.h>
+#endif
+#include <stdio.h>
 #include <string.h>
 #include "crapto1/crapto1.h"
 #include "parity.h"
 #include <string.h>
 #include "crapto1/crapto1.h"
 #include "parity.h"
@@ -141,9 +143,19 @@ bitslice_test_nonces_t bitslice_test_nonces_MMX;
 bitslice_test_nonces_t bitslice_test_nonces_NOSIMD;
 bitslice_test_nonces_t bitslice_test_nonces_dispatch;
 
 bitslice_test_nonces_t bitslice_test_nonces_NOSIMD;
 bitslice_test_nonces_t bitslice_test_nonces_dispatch;
 
-#ifdef _WIN32
+#if defined (_WIN32)
 #define malloc_bitslice(x) __builtin_assume_aligned(_aligned_malloc((x), MAX_BITSLICES/8), MAX_BITSLICES/8)
 #define free_bitslice(x) _aligned_free(x)
 #define malloc_bitslice(x) __builtin_assume_aligned(_aligned_malloc((x), MAX_BITSLICES/8), MAX_BITSLICES/8)
 #define free_bitslice(x) _aligned_free(x)
+#elif defined (__APPLE__)
+static void *malloc_bitslice(size_t x) {
+       char *allocated_memory;
+       if (posix_memalign((void**)&allocated_memory, MAX_BITSLICES/8, x)) {
+               return NULL;
+       } else {
+               return __builtin_assume_aligned(allocated_memory, MAX_BITSLICES/8);
+       }
+}
+#define free_bitslice(x) free(x)
 #else
 #define malloc_bitslice(x) memalign(MAX_BITSLICES/8, (x))
 #define free_bitslice(x) free(x)
 #else
 #define malloc_bitslice(x) memalign(MAX_BITSLICES/8, (x))
 #define free_bitslice(x) free(x)
index 5b48a7353b1826017fdaf245a03401d8bd1d4525..320c4a96e7b6001faa7b174c317ca985a02699bf 100644 (file)
@@ -21,7 +21,9 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#ifndef __APPLE__
 #include <malloc.h>
 #include <malloc.h>
+#endif
 
 // this needs to be compiled several times for each instruction set. 
 // For each instruction set, define a dedicated function name:
 
 // this needs to be compiled several times for each instruction set. 
 // For each instruction set, define a dedicated function name:
@@ -143,8 +145,15 @@ count_bitarray_AND4_t count_bitarray_AND4_AVX512, count_bitarray_AND4_AVX2, coun
 
 inline uint32_t *MALLOC_BITARRAY(uint32_t x)
 {
 
 inline uint32_t *MALLOC_BITARRAY(uint32_t x)
 {
-#ifdef _WIN32
+#if defined (_WIN32)
        return __builtin_assume_aligned(_aligned_malloc((x), __BIGGEST_ALIGNMENT__), __BIGGEST_ALIGNMENT__);
        return __builtin_assume_aligned(_aligned_malloc((x), __BIGGEST_ALIGNMENT__), __BIGGEST_ALIGNMENT__);
+#elif defined (__APPLE__)
+       uint32_t *allocated_memory;
+       if (posix_memalign((void**)&allocated_memory, __BIGGEST_ALIGNMENT__, x)) {
+               return NULL;
+       } else {
+               return __builtin_assume_aligned(allocated_memory, __BIGGEST_ALIGNMENT__);
+       }
 #else
        return __builtin_assume_aligned(memalign(__BIGGEST_ALIGNMENT__, (x)), __BIGGEST_ALIGNMENT__);
 #endif
 #else
        return __builtin_assume_aligned(memalign(__BIGGEST_ALIGNMENT__, (x)), __BIGGEST_ALIGNMENT__);
 #endif
index 3b1c5071bbc1d34520f6913525d98cbffcf9a2bb..718b7c5d518ad1214ab58a4bc080fe5b2adf2da7 100644 (file)
@@ -54,7 +54,7 @@ THE SOFTWARE.
 #include <stdio.h>
 #include <pthread.h>
 #include <string.h>
 #include <stdio.h>
 #include <pthread.h>
 #include <string.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include "proxmark3.h"
 #include "cmdhfmfhard.h"
 #include "hardnested_bf_core.h"
 #include "proxmark3.h"
 #include "cmdhfmfhard.h"
 #include "hardnested_bf_core.h"
Impressum, Datenschutz