Ajout du Makefile & essai de compilation

This commit is contained in:
augustin64 2024-03-29 23:16:43 +01:00
parent 9ebfa43a07
commit ce8fd5f3a5
4 changed files with 15 additions and 17 deletions

View File

@ -1,16 +1,14 @@
SRC = $(wildcard *.c)
OBJ = $(filter-out build/main.o build/test.o, $(SRC:%.c=build/%.o))
FLAGS = -Wall -Wextra -g -O3
all: build/test
build/test: test.c build/vmap.o build/mmap.o build/linked_list.o
gcc -o test test.c vmap.o mmap.o linked_list.o -w
build/test: test.c $(OBJ)
gcc $^ -o $@ $(FLAGS)
build/mmap.o: mmap.c mmap.h linked_list.c linked_list.h
gcc -c mmap.c
build/vmap.o: vmap.c vmap.h
gcc -c vmap.c
build/linked_list.o: linked_list.c linked_list.h
gcc -c linked_list.c
build/%.o: %.c %.h
gcc -c $< -o $@ $(FLAGS)
clean:
rm -f build/*

View File

@ -3,7 +3,7 @@
typedef struct node {
void *data;
int key;
node *next;
struct node *next;
} node;
typedef struct linkedList {

View File

@ -103,7 +103,7 @@ PageInfo* read_from_swap(MMap* mmap, PageInfo *page) {
CHECK_FERROR(mmap->swap);
for (int i=0; i < 100; i++) {
int ret = fread(&key, sizeof(int), 1, mmap->swap);
(void)fread(&key, sizeof(int), 1, mmap->swap);
CHECK_FERROR(mmap->swap);
if (key != page->key)

View File

@ -3,6 +3,11 @@
#include "linked_list.h"
typedef struct PageInfo {
int key;
void *data;
} PageInfo;
typedef struct MMap {
void *memory;
int size;
@ -13,11 +18,6 @@ typedef struct MMap {
FILE *swap;
} MMap;
typedef struct PageInfo {
int key;
void *data;
} PageInfo;
MMap* mmap_init();
void mmap_clean(MMap *mmap);
PageInfo* page_alloc(MMap *mmap);