| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #ifndef __APPLE__ | ||
| 8 | # include <malloc.h> | ||
| 9 | #else | ||
| 10 | # include <stdlib.h> | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include "custom_malloc.h" | ||
| 14 | |||
| 15 | #define VECTOR_ALIGNEMENT 64lu | ||
| 16 | |||
| 17 | #ifdef __APPLE__ | ||
| 18 | ///Alloc an aligned vector | ||
| 19 | /** @param sizeOfVectorInBytes : size of the vector xe want to allocate | ||
| 20 | * @param alignementInBytes : alignement of the vector we want to allocate | ||
| 21 | * @return aligned pointor of the vector | ||
| 22 | */ | ||
| 23 | void * memalign(long unsigned int alignementInBytes, long unsigned int sizeOfVectorInBytes){ | ||
| 24 | void * ptr = NULL; | ||
| 25 | posix_memalign(&ptr, alignementInBytes, sizeOfVectorInBytes); | ||
| 26 | return ptr; | ||
| 27 | } | ||
| 28 | #endif | ||
| 29 | |||
| 30 | ///Do the aligned allocation of a pointer | ||
| 31 | /** @param sizeOfVectorInBytes : number of bytes to be allocated | ||
| 32 | * @return allocated pointer | ||
| 33 | */ | ||
| 34 | ✗ | void * custom_aligned_malloc(long unsigned int sizeOfVectorInBytes){ | |
| 35 | ✗ | return memalign(VECTOR_ALIGNEMENT, sizeOfVectorInBytes); | |
| 36 | } | ||
| 37 | |||
| 38 | ///Free an aligned pointer | ||
| 39 | /** @param ptr : ptr to be freed | ||
| 40 | */ | ||
| 41 | ✗ | void custom_aligned_free(void* ptr){ | |
| 42 | ✗ | free(ptr); | |
| 43 | ✗ | } | |
| 44 | |||
| 45 | |||
| 46 | |||
| 47 |