Cache-aligned memory allocation functions */
| 346 | |
| 347 | /* Cache-aligned memory allocation functions */ |
| 348 | void* cache_aligned_alloc(size_t size) { |
| 349 | #ifdef _WIN32 |
| 350 | return _aligned_malloc(size, CACHE_LINE_SIZE); |
| 351 | #else |
| 352 | void *ptr; |
| 353 | if (posix_memalign(&ptr, CACHE_LINE_SIZE, size) != 0) { |
| 354 | return NULL; |
| 355 | } |
| 356 | return ptr; |
| 357 | #endif |
| 358 | } |
| 359 | |
| 360 | void cache_aligned_free(void* ptr) { |
| 361 | #ifdef _WIN32 |