test whole program

This commit is contained in:
2025-08-28 11:57:15 +01:00
parent 32efa59d73
commit f6eb65f74d

View File

@@ -64,46 +64,46 @@ int MallocCounter;
size_t sizeUsed;
INITAlloc(void) {
// INITAlloc(void) {
size_t sz;
// Pre Allocate 600 MB
sz = 100000000;
// size_t sz;
// // Pre Allocate 600 MB
// sz = 100000000;
int fd = open(FILENAME, O_RDWR, 0600);
// int fd = open(FILENAME, O_RDWR, 0600);
if (fd < 0) {
perror("open");
exit(EXIT_FAILURE);
}
// if (fd < 0) {
// perror("open");
// exit(EXIT_FAILURE);
// }
off_t offset = 0; // offset to seek to.
// off_t offset = 0; // offset to seek to.
if (ftruncate(fd, sz) < 0) {
perror("ftruncate");
close(fd);
exit(EXIT_FAILURE);
}
// if (ftruncate(fd, sz) < 0) {
// perror("ftruncate");
// close(fd);
// exit(EXIT_FAILURE);
// }
// ptr = mmap(NULL, sz,
// PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON,-1,0);
// // ptr = mmap(NULL, sz,
// // PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON,-1,0);
ptr = mmap(NULL, sz,
PROT_READ|PROT_WRITE, MAP_SHARED,fd,0);
// ptr = mmap(NULL, sz,
// PROT_READ|PROT_WRITE, MAP_SHARED,fd,0);
// Added error handling
if(ptr == MAP_FAILED)
{
perror("mmap");
exit(EXIT_FAILURE);
}
// // Added error handling
// if(ptr == MAP_FAILED)
// {
// perror("mmap");
// exit(EXIT_FAILURE);
// }
MallocCounter = (int)sz;
// MallocCounter = (int)sz;
}
// }
// Quick malloc implementation with mmap
void* MALLOCCHERI(size_t sz)
static void* MALLOCCHERI(size_t sz)
{
printf("Malloc called lol");
printf("Malloc called lol");
@@ -125,7 +125,7 @@ void* MALLOCCHERI(size_t sz)
}
// Quick cheri free implementation
void FREECHERI(void *ptr) {
static void FREECHERI(void *ptr) {
// printf("free called \n");
@@ -155,7 +155,7 @@ pagesizes(size_t ps[MAXPAGESIZES])
}
__attribute__((constructor))
INITREGULARALLOC(void) {
static INITREGULARALLOC(void) {
size_t sz;
// Hard-coded for 1GB huge page
sz = 1073741824;