mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 19:03:59 +08:00
libitm: Add xcalloc.
libitm/ * util.cc (GTM::xcalloc): New. * common.h (GTM::xcalloc): Declare. From-SVN: r184210
This commit is contained in:
parent
dd552284fd
commit
7d33bcb738
@ -1,3 +1,8 @@
|
||||
2012-02-14 Torvald Riegel <triegel@redhat.com>
|
||||
|
||||
* util.cc (GTM::xcalloc): New.
|
||||
* common.h (GTM::xcalloc): Declare.
|
||||
|
||||
2012-02-14 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* config/sparc/target.h (cpu_relax): Read from CC register.
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user