mirror of
https://github.com/curl/curl.git
synced 2026-07-15 21:07:18 +03:00
tidy-up: Curl_thread_create() callback return type
Replace repeat `#ifdef` code with a macro for the return type of the thread function. Also: - always define `CURL_STDCALL`, allowing to use it without guards. - lib1307: drop single-use macro `CAINFO`. Closes #17889
This commit is contained in:
parent
8ae93a95f8
commit
ee232917dc
4 changed files with 20 additions and 48 deletions
|
|
@ -203,13 +203,7 @@ err_exit:
|
|||
* For builds without ARES, but with USE_IPV6, create a resolver thread
|
||||
* and wait on it.
|
||||
*/
|
||||
static
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
DWORD
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
CURL_STDCALL getaddrinfo_thread(void *arg)
|
||||
static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg)
|
||||
{
|
||||
struct async_thrdd_addr_ctx *addr_ctx = arg;
|
||||
char service[12];
|
||||
|
|
@ -263,13 +257,7 @@ CURL_STDCALL getaddrinfo_thread(void *arg)
|
|||
/*
|
||||
* gethostbyname_thread() resolves a name and then exits.
|
||||
*/
|
||||
static
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
DWORD
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
CURL_STDCALL gethostbyname_thread(void *arg)
|
||||
static CURL_THREAD_RETURN_T CURL_STDCALL gethostbyname_thread(void *arg)
|
||||
{
|
||||
struct async_thrdd_addr_ctx *addr_ctx = arg;
|
||||
bool all_gone;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ static void *curl_thread_create_thunk(void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
curl_thread_t Curl_thread_create(unsigned int (*func) (void *), void *arg)
|
||||
curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
|
||||
(CURL_STDCALL *func) (void *), void *arg)
|
||||
{
|
||||
curl_thread_t t = malloc(sizeof(pthread_t));
|
||||
struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call));
|
||||
|
|
@ -101,14 +102,8 @@ int Curl_thread_join(curl_thread_t *hnd)
|
|||
|
||||
#elif defined(USE_THREADS_WIN32)
|
||||
|
||||
curl_thread_t Curl_thread_create(
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
DWORD
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
(CURL_STDCALL *func) (void *),
|
||||
void *arg)
|
||||
curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
|
||||
(CURL_STDCALL *func) (void *), void *arg)
|
||||
{
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
typedef HANDLE curl_win_thread_handle_t;
|
||||
|
|
|
|||
|
|
@ -48,18 +48,20 @@
|
|||
# define Curl_mutex_acquire(m) EnterCriticalSection(m)
|
||||
# define Curl_mutex_release(m) LeaveCriticalSection(m)
|
||||
# define Curl_mutex_destroy(m) DeleteCriticalSection(m)
|
||||
#else
|
||||
# define CURL_STDCALL
|
||||
#endif
|
||||
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
#define CURL_THREAD_RETURN_T DWORD
|
||||
#else
|
||||
#define CURL_THREAD_RETURN_T unsigned int
|
||||
#endif
|
||||
|
||||
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
|
||||
|
||||
curl_thread_t Curl_thread_create(
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
DWORD
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
(CURL_STDCALL *func) (void *),
|
||||
void *arg);
|
||||
curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
|
||||
(CURL_STDCALL *func) (void *), void *arg);
|
||||
|
||||
void Curl_thread_destroy(curl_thread_t *hnd);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,12 @@
|
|||
|
||||
#include "memdebug.h"
|
||||
|
||||
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
|
||||
#if defined(USE_THREADS_POSIX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include "curl_threads.h"
|
||||
#endif
|
||||
|
||||
#define CAINFO libtest_arg2
|
||||
#include "curl_threads.h"
|
||||
|
||||
#define THREAD_SIZE 16
|
||||
#define PER_THREAD_SIZE 8
|
||||
|
||||
|
|
@ -70,18 +68,7 @@ static size_t write_memory_callback(char *contents, size_t size,
|
|||
return realsize;
|
||||
}
|
||||
|
||||
static
|
||||
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
|
||||
#if defined(CURL_WINDOWS_UWP) || defined(UNDER_CE)
|
||||
DWORD
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
CURL_STDCALL
|
||||
#else
|
||||
unsigned int
|
||||
#endif
|
||||
test_thread(void *ptr)
|
||||
static CURL_THREAD_RETURN_T CURL_STDCALL test_thread(void *ptr)
|
||||
{
|
||||
struct Ctx *ctx = (struct Ctx *)ptr;
|
||||
CURLcode res = CURLE_OK;
|
||||
|
|
@ -97,7 +84,7 @@ test_thread(void *ptr)
|
|||
|
||||
/* use the share object */
|
||||
curl_easy_setopt(curl, CURLOPT_SHARE, ctx->share);
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, CAINFO);
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, libtest_arg2);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_memory_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue