diff --git a/libitm/ChangeLog b/libitm/ChangeLog index decdad3c68c..130c9efbd85 100644 --- a/libitm/ChangeLog +++ b/libitm/ChangeLog @@ -1,3 +1,8 @@ +2012-02-14 Torvald Riegel + + * util.cc (GTM::xcalloc): New. + * common.h (GTM::xcalloc): Declare. + 2012-02-14 Eric Botcazou * config/sparc/target.h (cpu_relax): Read from CC register. diff --git a/libitm/common.h b/libitm/common.h index 14d0efb40ba..b1ef2d4e63a 100644 --- a/libitm/common.h +++ b/libitm/common.h @@ -54,6 +54,8 @@ namespace GTM HIDDEN { // cache lines that are not shared with any object used by another thread. extern void * xmalloc (size_t s, bool separate_cl = false) __attribute__((malloc, nothrow)); +extern void * xcalloc (size_t s, bool separate_cl = false) + __attribute__((malloc, nothrow)); extern void * xrealloc (void *p, size_t s, bool separate_cl = false) __attribute__((malloc, nothrow)); diff --git a/libitm/util.cc b/libitm/util.cc index afd37e41731..48a1bf88d7c 100644 --- a/libitm/util.cc +++ b/libitm/util.cc @@ -70,6 +70,18 @@ xmalloc (size_t size, bool separate_cl) return r; } +void * +xcalloc (size_t size, bool separate_cl) +{ + // TODO Use posix_memalign if separate_cl is true, or some other allocation + // method that will avoid sharing cache lines with data used by other + // threads. + void *r = calloc (1, size); + if (r == 0) + GTM_fatal ("Out of memory allocating %lu bytes", (unsigned long) size); + return r; +} + void * xrealloc (void *old, size_t size, bool separate_cl) {