diff --git a/Makefile b/Makefile index c4f0d23..0a4a811 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,7 @@ LIBFT = $(LIBFT_D)/libft.a SRCS = main.c \ init.c \ exec.c \ - time.c \ - message.c + generic.c DIR_OBJS = builds OBJS = $(SRCS:%.c=$(DIR_OBJS)/%.o) diff --git a/headers/philo_proto.h b/headers/philo_proto.h index dfef26e..0bc73b1 100644 --- a/headers/philo_proto.h +++ b/headers/philo_proto.h @@ -7,11 +7,9 @@ t_philo *init(int ac, char **av, pthread_t **id); // exec.c void *philo_exec(void *arg); -// time.c +// generic.c void init_time(t_philo *philo); void update_time(t_philo *philo); - -// message.c void print_message(t_philo *philo, char *msg); #endif diff --git a/srcs/message.c b/srcs/generic.c similarity index 64% rename from srcs/message.c rename to srcs/generic.c index 52e8b31..777ac95 100644 --- a/srcs/message.c +++ b/srcs/generic.c @@ -1,5 +1,26 @@ #include "philo.h" +void init_time(t_philo *philo) +{ + struct timeval stime; + + if (philo->global->t_start_s == 0) + { + gettimeofday(&stime, NULL); + philo->global->t_start_s = stime.tv_sec; + philo->global->t_start_u = stime.tv_usec; + } +} + +void update_time(t_philo *philo) +{ + struct timeval stime; + + gettimeofday(&stime, NULL); + philo->t_last_meal_s = stime.tv_sec; + philo->t_last_meal_u = stime.tv_usec; +} + void print_message(t_philo *philo, char *msg) { long int time_stamp; diff --git a/srcs/time.c b/srcs/time.c deleted file mode 100644 index 92a42de..0000000 --- a/srcs/time.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "philo.h" - -void init_time(t_philo *philo) -{ - struct timeval stime; - - if (philo->global->t_start_s == 0) - { - gettimeofday(&stime, NULL); - philo->global->t_start_s = stime.tv_sec; - philo->global->t_start_u = stime.tv_usec; - } -} - -void update_time(t_philo *philo) -{ - struct timeval stime; - - gettimeofday(&stime, NULL); - philo->t_last_meal_s = stime.tv_sec; - philo->t_last_meal_u = stime.tv_usec; -}