Setup up project
This commit is contained in:
parent
4bd4468c8f
commit
0c1de75aec
58
Makefile
Normal file
58
Makefile
Normal file
@ -0,0 +1,58 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: o_ :::::: ::: #
|
||||
# Makefile :+: / :+::+: :+: #
|
||||
# +:+ > +:++:+ +:+ #
|
||||
# By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ #
|
||||
# +#+ +#+#+ +#++#+ +#+ \o/ #
|
||||
# Created: 2024/10/15 11:48:46 by whaffman #+#+# #+#+# #+# #+# | #
|
||||
# Updated: 2024/11/07 15:28:08 by whaffman ### ### ### ### / \ #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME = fdf
|
||||
|
||||
SRC_PATH = src
|
||||
INC_PATH = inc
|
||||
|
||||
OBJ_PATH = obj
|
||||
|
||||
VPATH = src
|
||||
SOURCES = $(shell basename -a $(shell find $(SRC_PATH) -type f -name "*.c"))
|
||||
|
||||
OBJECTS = $(addprefix $(OBJ_PATH)/, $(SOURCES:.c=.o))
|
||||
DEPENDS = ${OBJECTS:.o=.d}
|
||||
|
||||
CC = cc
|
||||
RM = rm -rf
|
||||
|
||||
INCLUDES = -I./$(INC_PATH)
|
||||
CFLAGS = -Wall -Wextra -Werror -MMD
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
LDLIBS := -pthread
|
||||
endif
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJECTS)
|
||||
$(CC) $(CFLAGS) $(OBJECTS) $(LDLIBS) -o $(NAME)
|
||||
|
||||
-include ${DEPENDS}
|
||||
|
||||
$(OBJ_PATH):
|
||||
mkdir -p $@
|
||||
|
||||
$(OBJ_PATH)/%.o: %.c | $(OBJ_PATH)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJECTS) $(OBJ_PATH)
|
||||
|
||||
fclean: clean
|
||||
$(RM) $(NAME)
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: all clean fclean re
|
||||
34
inc/philo.h
Normal file
34
inc/philo.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef PHILO_H
|
||||
# define PHILO_H
|
||||
# include <pthread.h>
|
||||
# include <stdio.h>
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
|
||||
typedef struct s_rules
|
||||
{
|
||||
int time_to_die;
|
||||
int time_to_eat;
|
||||
int time_to_sleep;
|
||||
int nb_must_eat;
|
||||
pthread_mutex_t *print;
|
||||
pthread_mutex_t *death;
|
||||
|
||||
} t_rules;
|
||||
|
||||
typedef struct s_philo
|
||||
{
|
||||
pthread_t *pid;
|
||||
pthread_mutex_t *l_fork;
|
||||
pthread_mutex_t *r_fork;
|
||||
int last_meal;
|
||||
t_rules rules;
|
||||
} t_philo;
|
||||
// memset, printf, malloc, free, write,
|
||||
// usleep, gettimeofday, pthread_create,
|
||||
// pthread_detach, pthread_join, pthread_mutex_init,
|
||||
// pthread_mutex_destroy, pthread_mutex_lock,
|
||||
// pthread_mutex_unlock
|
||||
|
||||
|
||||
#endif
|
||||
7
src/main.c
Normal file
7
src/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include "philo.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user