Ajout du Makefile & essai de compilation
This commit is contained in:
parent
9ebfa43a07
commit
ce8fd5f3a5
@ -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
|
all: build/test
|
||||||
|
|
||||||
build/test: test.c build/vmap.o build/mmap.o build/linked_list.o
|
build/test: test.c $(OBJ)
|
||||||
gcc -o test test.c vmap.o mmap.o linked_list.o -w
|
gcc $^ -o $@ $(FLAGS)
|
||||||
|
|
||||||
build/mmap.o: mmap.c mmap.h linked_list.c linked_list.h
|
build/%.o: %.c %.h
|
||||||
gcc -c mmap.c
|
gcc -c $< -o $@ $(FLAGS)
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f build/*
|
rm -f build/*
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
typedef struct node {
|
typedef struct node {
|
||||||
void *data;
|
void *data;
|
||||||
int key;
|
int key;
|
||||||
node *next;
|
struct node *next;
|
||||||
} node;
|
} node;
|
||||||
|
|
||||||
typedef struct linkedList {
|
typedef struct linkedList {
|
||||||
|
@ -103,7 +103,7 @@ PageInfo* read_from_swap(MMap* mmap, PageInfo *page) {
|
|||||||
CHECK_FERROR(mmap->swap);
|
CHECK_FERROR(mmap->swap);
|
||||||
|
|
||||||
for (int i=0; i < 100; i++) {
|
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);
|
CHECK_FERROR(mmap->swap);
|
||||||
|
|
||||||
if (key != page->key)
|
if (key != page->key)
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
|
||||||
|
typedef struct PageInfo {
|
||||||
|
int key;
|
||||||
|
void *data;
|
||||||
|
} PageInfo;
|
||||||
|
|
||||||
typedef struct MMap {
|
typedef struct MMap {
|
||||||
void *memory;
|
void *memory;
|
||||||
int size;
|
int size;
|
||||||
@ -13,11 +18,6 @@ typedef struct MMap {
|
|||||||
FILE *swap;
|
FILE *swap;
|
||||||
} MMap;
|
} MMap;
|
||||||
|
|
||||||
typedef struct PageInfo {
|
|
||||||
int key;
|
|
||||||
void *data;
|
|
||||||
} PageInfo;
|
|
||||||
|
|
||||||
MMap* mmap_init();
|
MMap* mmap_init();
|
||||||
void mmap_clean(MMap *mmap);
|
void mmap_clean(MMap *mmap);
|
||||||
PageInfo* page_alloc(MMap *mmap);
|
PageInfo* page_alloc(MMap *mmap);
|
||||||
|
Loading…
Reference in New Issue
Block a user