Changeset View
Changeset View
Standalone View
Standalone View
openmp/trunk/libomptarget/deviceRTLs/nvptx/src/supporti.h
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | INLINE unsigned long PadBytes(unsigned long size, | ||||
ASSERT(LT_FUSSY, (alignment & (alignment - 1)) == 0, | ASSERT(LT_FUSSY, (alignment & (alignment - 1)) == 0, | ||||
"alignment %ld is not a power of 2\n", alignment); | "alignment %ld is not a power of 2\n", alignment); | ||||
return (~(unsigned long)size + 1) & (alignment - 1); | return (~(unsigned long)size + 1) & (alignment - 1); | ||||
} | } | ||||
INLINE void *SafeMalloc(size_t size, const char *msg) // check if success | INLINE void *SafeMalloc(size_t size, const char *msg) // check if success | ||||
{ | { | ||||
void *ptr = malloc(size); | void *ptr = malloc(size); | ||||
PRINT(LD_MEM, "malloc data of size %d for %s: 0x%llx\n", size, msg, P64(ptr)); | PRINT(LD_MEM, "malloc data of size %zu for %s: 0x%llx\n", size, msg, P64(ptr)); | ||||
ASSERT(LT_SAFETY, ptr, "failed to allocate %d bytes for %s\n", size, msg); | ASSERT(LT_SAFETY, ptr, "failed to allocate %zu bytes for %s\n", size, msg); | ||||
return ptr; | return ptr; | ||||
} | } | ||||
INLINE void *SafeFree(void *ptr, const char *msg) { | INLINE void *SafeFree(void *ptr, const char *msg) { | ||||
PRINT(LD_MEM, "free data ptr 0x%llx for %s\n", P64(ptr), msg); | PRINT(LD_MEM, "free data ptr 0x%llx for %s\n", P64(ptr), msg); | ||||
free(ptr); | free(ptr); | ||||
return NULL; | return NULL; | ||||
} | } | ||||
Show All 27 Lines |