|
@@ -6,6 +6,8 @@
|
|
// License. See LICENSE.TXT for details.
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
+
|
|
|
|
+#include "llvm/Support/Allocator.h"
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
#include "llvm/Support/ManagedStatic.h"
|
|
#include "llvm/Config/config.h"
|
|
#include "llvm/Config/config.h"
|
|
#ifdef HAVE_PTHREAD_H
|
|
#ifdef HAVE_PTHREAD_H
|
|
@@ -30,7 +32,7 @@ namespace test1 {
|
|
// Valgrind's leak checker complains glibc's stack allocation.
|
|
// Valgrind's leak checker complains glibc's stack allocation.
|
|
// To appease valgrind, we provide our own stack for each thread.
|
|
// To appease valgrind, we provide our own stack for each thread.
|
|
void *allocate_stack(pthread_attr_t &a, size_t n = 65536) {
|
|
void *allocate_stack(pthread_attr_t &a, size_t n = 65536) {
|
|
- void *stack = malloc(n);
|
|
|
|
|
|
+ void *stack = safe_malloc(n);
|
|
pthread_attr_init(&a);
|
|
pthread_attr_init(&a);
|
|
#if defined(__linux__)
|
|
#if defined(__linux__)
|
|
pthread_attr_setstack(&a, stack, n);
|
|
pthread_attr_setstack(&a, stack, n);
|
|
@@ -83,7 +85,7 @@ TEST(ManagedStaticTest, NestedStatics) {
|
|
namespace CustomCreatorDeletor {
|
|
namespace CustomCreatorDeletor {
|
|
struct CustomCreate {
|
|
struct CustomCreate {
|
|
static void *call() {
|
|
static void *call() {
|
|
- void *Mem = std::malloc(sizeof(int));
|
|
|
|
|
|
+ void *Mem = safe_malloc(sizeof(int));
|
|
*((int *)Mem) = 42;
|
|
*((int *)Mem) = 42;
|
|
return Mem;
|
|
return Mem;
|
|
}
|
|
}
|