put time.c and message.c into generic.c
This commit is contained in:
@@ -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;
|
||||
22
srcs/time.c
22
srcs/time.c
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user