From ad7ed73c124c8fcda6629350307f0f4f41b87fe3 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 8 Jan 2021 14:35:53 +0100 Subject: Updated Makefile, restructuring common files --- common/inc/common.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 common/inc/common.h (limited to 'common/inc') diff --git a/common/inc/common.h b/common/inc/common.h new file mode 100644 index 0000000..6d36e35 --- /dev/null +++ b/common/inc/common.h @@ -0,0 +1,69 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* common.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 22:58:35 by cacharle #+# #+# */ +/* Updated: 2021/01/04 13:06:52 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef COMMON_H +# define COMMON_H + +# define _XOPEN_SOURCE 500 +# include +# include +# include +# include +# include +# include + +typedef long int t_time; + +typedef enum e_philo_event +{ + EVENT_FORK, + EVENT_EAT, + EVENT_SLEEP, + EVENT_THINK, + EVENT_DIE +} t_philo_event; + +typedef struct +{ + long int philo_num; + t_time timeout_death; + t_time timeout_eat; + t_time timeout_sleep; + long int meal_num; +} t_philo_args; + +typedef void *(*t_routine)(void *arg); + +/* +** args.c +*/ + +bool parse_args(t_philo_args *args, int argc, char **argv); + +/* +** helper.c +*/ + +long int h_atou_strict(char *s); +t_time h_time_now(void); +void h_sleep(t_time sleep_time); + +/* +** io.c +*/ + +void philo_put( + size_t id, t_philo_event event, t_time initial_time); +void philo_put_flush(void); +int h_err(int ret, const char *format, char *str); + +#endif -- cgit