diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-01-12 17:31:34 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2023-01-12 17:31:34 +0800 |
commit | 3678251af38f04882f55515036b8fbbe27760a40 (patch) | |
tree | 231161dd2ed3261b4b177f79cda63b90975528d5 | |
parent | ce009bb7577b37fa2e0f6a1fb262f23803b0681e (diff) |
Drop C11 threads
Pthreads is portable anyway. This simplifies the code too.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | request.c | 26 |
2 files changed, 1 insertions, 27 deletions
diff --git a/configure.ac b/configure.ac index 01e576b..c66d35f 100644 --- a/configure.ac +++ b/configure.ac @@ -25,8 +25,6 @@ case $host in esac AM_CONDITIONAL([IOS], [test "x$ios" = xtrue]) AC_CHECK_HEADERS([stddef.h, locale.h]) -AC_CHECK_HEADERS([threads.h], - [AC_DEFINE([HAVE_THREADS_H])]) AC_CHECK_HEADERS([langinfo.h], [AC_DEFINE([HAVE_LANGINFO_H])]) AC_CHECK_HEADER_STDBOOL @@ -13,12 +13,8 @@ extern emscripten_fetch_attr_t attr; #else -#ifdef HAVE_THREADS_H -#include <threads.h> -#else #include <pthread.h> typedef pthread_t thrd_t; -#endif #include <curl/curl.h> extern char *sampleurl; @@ -40,17 +36,8 @@ static size_t append(char *data, size_t size, size_t nmemb, interchange_response return realsize; } -static -#ifdef HAVE_THREADS_H -int -#else -void * -#endif -async(void *arg) +static void *async(void *arg) { -#ifdef HAVE_THREADS_H - int ret = thrd_success; -#endif struct container *container = (struct container *)arg; CURLcode res = curl_easy_perform(container->response->curl); if (container->post) @@ -58,9 +45,6 @@ async(void *arg) if (res == CURLE_OK && container->handler) container->handler(container->response); else { -#ifdef HAVE_THREADS_H - ret = thrd_error; -#endif #ifdef DEBUG const char *error = curl_easy_strerror(res); #ifdef __ANDROID__ @@ -71,11 +55,7 @@ async(void *arg) #endif } free(container); -#ifdef HAVE_THREADS_H - return ret; -#else return NULL; -#endif } #endif @@ -201,10 +181,6 @@ void request(void (*handler)(interchange_response *), void (*callback)(void *), container->handler = handler; container->response = response; thrd_t thread; -#ifdef HAVE_THREADS_H - thrd_create(&thread, async, container); -#else pthread_create(&thread, NULL, async, container); #endif -#endif } |