From ce8fd5f3a54db83f61bcc82bf58b71ce563f0ccd Mon Sep 17 00:00:00 2001 From: augustin64 Date: Fri, 29 Mar 2024 23:16:43 +0100 Subject: [PATCH] Ajout du Makefile & essai de compilation --- TP/TP1/rendu/Makefile | 18 ++++++++---------- TP/TP1/rendu/linked_list.h | 2 +- TP/TP1/rendu/mmap.c | 2 +- TP/TP1/rendu/mmap.h | 10 +++++----- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/TP/TP1/rendu/Makefile b/TP/TP1/rendu/Makefile index ea42c7d..8b54c7f 100644 --- a/TP/TP1/rendu/Makefile +++ b/TP/TP1/rendu/Makefile @@ -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/* diff --git a/TP/TP1/rendu/linked_list.h b/TP/TP1/rendu/linked_list.h index 8578c1a..cfeae99 100644 --- a/TP/TP1/rendu/linked_list.h +++ b/TP/TP1/rendu/linked_list.h @@ -3,7 +3,7 @@ typedef struct node { void *data; int key; - node *next; + struct node *next; } node; typedef struct linkedList { diff --git a/TP/TP1/rendu/mmap.c b/TP/TP1/rendu/mmap.c index 9b0e9f9..babef1c 100644 --- a/TP/TP1/rendu/mmap.c +++ b/TP/TP1/rendu/mmap.c @@ -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) diff --git a/TP/TP1/rendu/mmap.h b/TP/TP1/rendu/mmap.h index 3164147..1b3fc21 100644 --- a/TP/TP1/rendu/mmap.h +++ b/TP/TP1/rendu/mmap.h @@ -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);