diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 14:42:46 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-03 14:47:11 +0100 |
| commit | cc2adbf09541c0d9309d66f719c86e7fe5d351d7 (patch) | |
| tree | f9d61b11e57dcdfebc9092554df1a64d0d4958c5 /philo_two/common.h | |
| parent | e874ad94a31a8259b8eb7ad2865767c081bcd279 (diff) | |
| download | philosophers-rendu.tar.gz philosophers-rendu.tar.bz2 philosophers-rendu.zip | |
Updated philo directories for correctionrendu
Diffstat (limited to 'philo_two/common.h')
| -rw-r--r-- | philo_two/common.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/philo_two/common.h b/philo_two/common.h new file mode 100644 index 0000000..617db1a --- /dev/null +++ b/philo_two/common.h @@ -0,0 +1,67 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* common.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 22:58:35 by cacharle #+# #+# */ +/* Updated: 2021/01/03 14:02:38 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef COMMON_H +# define COMMON_H + +# include <unistd.h> +# include <stdlib.h> +# include <stdbool.h> +# include <pthread.h> +# include <sys/time.h> +# include <limits.h> + +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); +int h_err(int ret, const char *format, char *str); + +/* +** io.c +*/ + +void philo_put_set_initial_time(void); +void philo_put( + size_t id, t_philo_event event, t_time initial_time); + +#endif |
