Sha256: b54361daed5ce8136fb5dee18637eb0fee6704b67b041e631744e17693b9b378
Contents?: true
Size: 966 Bytes
Versions: 1
Compression:
Stored size: 966 Bytes
Contents
#include <stdlib.h> // Allocate a 128-byte aligned pointer void *bones_malloc_128(size_t bones_size) { char *bones_pointer; char *bones_pointer2; char *bones_aligned_pointer; // Allocate the memory plus a little bit extra bones_pointer = (char *)malloc(bones_size + 128 + sizeof(int)); if(bones_pointer==NULL) { return(NULL); } // Create the aligned pointer bones_pointer2 = bones_pointer + sizeof(int); bones_aligned_pointer = bones_pointer2 + (128 - ((size_t)bones_pointer2 & 127)); // Set the padding size bones_pointer2 = bones_aligned_pointer - sizeof(int); *((int *)bones_pointer2) = (int)(bones_aligned_pointer - bones_pointer); // Return the 128-byte aligned pointer return (bones_aligned_pointer); } // Free the 128-byte aligned pointer void bones_free_128(void *bones_pointer) { int *bones_pointer2 = (int *)bones_pointer - 1; bones_pointer = (char *)bones_pointer - *bones_pointer2; free(bones_pointer); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bones-compiler-1.1.0 | skeletons/CPU-OPENCL-INTEL/common/header.c |