From ce1e91d90f50f7c24ce9b92674525548da386f2a Mon Sep 17 00:00:00 2001 From: Nakidai Date: Fri, 24 Nov 2023 23:32:42 +0300 Subject: [PATCH] Switch back to pthread.h --- include/input.h | 2 +- src/input.c | 4 ++-- src/main.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/input.h b/include/input.h index 469b2df..fcb9e6f 100644 --- a/include/input.h +++ b/include/input.h @@ -9,6 +9,6 @@ typedef struct input_args_t bool *alive; } InputArgs; -int input(void *vargp); +void *input(void *vargp); #endif /* __INPUT_H__ */ diff --git a/src/input.c b/src/input.c index 8f1f857..0df48bd 100644 --- a/src/input.c +++ b/src/input.c @@ -30,7 +30,7 @@ int getch(void) } #endif -int input(void *vargp) +void *input(void *vargp) { int *out = ((InputArgs *)vargp)->out; bool *alive = ((InputArgs *)vargp)->alive; @@ -39,5 +39,5 @@ int input(void *vargp) { *out = getch(); } - return 0; + return NULL; } diff --git a/src/main.c b/src/main.c index 78f88bf..3caf612 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include "input.h" @@ -38,7 +38,7 @@ int main(int argc, char **argv) Player *player = playerCreate(DOWN, DEFX, DEFY, 0); Screen *screen = screenCreate(SIZE, SIZE, ' '); PlayerNode *node; - thrd_t input_thread; + pthread_t input_thread; int i; int head_x, head_y; Food food = generateFood(player); @@ -48,7 +48,7 @@ int main(int argc, char **argv) bool stopped = false; InputArgs input_args = (InputArgs){ key, running }; - thrd_create(&input_thread, input, &input_args); + pthread_create(&input_thread, NULL, input, &input_args); while (*running) { screenSet(screen, ' '); @@ -59,7 +59,7 @@ int main(int argc, char **argv) for (i = 0; i < SIZE*2; ++i) putchar('-'); printf("\nScore: %d\n", player->score); - thrd_sleep(&(struct timespec){.tv_sec=1}, NULL); + nanosleep(&(struct timespec){.tv_sec = 1}, NULL); switch (*key) { case 'q':