USER_O=userprog.o
USER_H=libthreads.h libatomic.h
-MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc threads.cc tree.cc librace.cc action.cc nodestack.cc clockvector.cc main.cc snapshot-interface.cc mallocwrap.cc
-MODEL_O=libthreads.o schedule.o libatomic.o model.o threads.o tree.o librace.o action.o nodestack.o clockvector.o main.o snapshot-interface.o mallocwrap.o
+MODEL_CC=libthreads.cc schedule.cc libatomic.cc model.cc threads.cc tree.cc librace.cc action.cc nodestack.cc clockvector.cc main.cc snapshot-interface.cc
+MODEL_O=libthreads.o schedule.o libatomic.o model.o threads.o tree.o librace.o action.o nodestack.o clockvector.o main.o snapshot-interface.o
MODEL_H=libthreads.h schedule.h common.h libatomic.h model.h threads.h tree.h librace.h action.h nodestack.h clockvector.h snapshot-interface.h
SHMEM_CC=snapshot.cc malloc.c mymemory.cc
num_threads = parent ? parent->num_threads : 1;
if (act && act->get_type() == THREAD_CREATE)
num_threads++;
- clock = (int *)myMalloc(num_threads * sizeof(int));
+ clock = (int *)MYMALLOC(num_threads * sizeof(int));
if (parent)
std::memcpy(clock, parent->clock, parent->num_threads * sizeof(int));
else
ClockVector::~ClockVector()
{
- myFree(clock);
+ MYFREE(clock);
}
void ClockVector::merge(ClockVector *cv)
if (cv->num_threads > num_threads) {
resize = true;
- clk = (int *)myMalloc(cv->num_threads * sizeof(int));
+ clk = (int *)MYMALLOC(cv->num_threads * sizeof(int));
}
/* Element-wise maximum */
for (int i = num_threads; i < cv->num_threads; i++)
clk[i] = cv->clock[i];
num_threads = cv->num_threads;
- myFree(clock);
+ MYFREE(clock);
}
clock = clk;
}
#include <stdio.h>
#include <stdlib.h>
+#include "mymemory.h"
#define CONFIG_DEBUG
} while (0);
-void * myMalloc(size_t size);
-void myFree(void *ptr);
-
#define userMalloc(size) malloc(size)
#define userFree(ptr) free(ptr)
+++ /dev/null
-#include "common.h"
-
-/* for RTLD_NEXT */
-#ifndef __USE_GNU
-#define __USE_GNU
-#endif
-
-#include <dlfcn.h>
-#include <new>
-
-static void * (*real_malloc)(size_t) = NULL;
-static void (*real_free)(void *ptr) = NULL;
-
-static void __my_alloc_init(void) {
- real_malloc = (void *(*)(size_t))dlsym(RTLD_NEXT, "malloc");
- real_free = (void (*)(void *))dlsym(RTLD_NEXT, "free");
- if (real_malloc == NULL || real_free == NULL) {
- fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
- return;
- }
-}
-
-void * myMalloc(size_t size) {
- if (real_malloc == NULL)
- __my_alloc_init();
-
- return real_malloc(size);
-}
-
-void myFree(void *ptr)
-{
- if (real_free == NULL)
- __my_alloc_init();
-
- real_free(ptr);
-}
-
-void * operator new(size_t size) throw(std::bad_alloc)
-{
- return myMalloc(size);
-}
-
-void operator delete(void *p) throw()
-{
- myFree(p);
-}