28 #ifdef MHD_USE_W32_THREADS 32 #ifdef MHD_USE_THREAD_NAME_ 34 #ifdef HAVE_PTHREAD_NP_H 35 #include <pthread_np.h> 42 #if defined(MHD_USE_POSIX_THREADS) 43 typedef pthread_t MHD_thread_ID_;
44 #elif defined(MHD_USE_W32_THREADS) 45 typedef DWORD MHD_thread_ID_;
49 #ifndef MHD_USE_THREAD_NAME_ 51 #define MHD_set_thread_name_(t, n) (void) 52 #define MHD_set_cur_thread_name_(n) (void) 56 #if defined(MHD_USE_POSIX_THREADS) 57 #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) \ 58 || defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) 69 const char *thread_name)
71 if (
NULL == thread_name)
74 #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) 75 return !pthread_setname_np (thread_id, thread_name);
76 #elif defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) 78 pthread_set_name_np (thread_id, thread_name);
80 #elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) 86 return !pthread_setname_np (thread_id, thread_name, 0);
97 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_(pthread_self(),(n)) 99 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_(0,(n)) 101 #elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) 108 #define MHD_set_cur_thread_name_(n) (!(pthread_setname_np((n)))) 111 #elif defined(MHD_USE_W32_THREADS) 112 #ifndef _MSC_FULL_VER 124 const char *thread_name)
126 static const DWORD VC_SETNAME_EXC = 0x406D1388;
128 struct thread_info_struct
137 if (
NULL == thread_name)
140 thread_info.type = 0x1000;
141 thread_info.name = thread_name;
142 thread_info.ID = thread_id;
143 thread_info.flags = 0;
147 RaiseException (VC_SETNAME_EXC,
149 sizeof (thread_info) /
sizeof(ULONG_PTR),
150 (ULONG_PTR *) &thread_info);
152 __except (EXCEPTION_EXECUTE_HANDLER)
164 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_(-1,(n)) 186 #if defined(MHD_USE_POSIX_THREADS) 192 res = pthread_attr_init (&attr);
195 res = pthread_attr_setstacksize (&attr,
198 res = pthread_create (thread,
202 pthread_attr_destroy (&attr);
206 res = pthread_create (thread,
215 #elif defined(MHD_USE_W32_THREADS) 216 #if SIZE_MAX != UINT_MAX 224 *thread = (HANDLE) _beginthreadex (
NULL,
225 (
unsigned int) stack_size,
230 if ((MHD_thread_handle_)-1 == (*thread))
237 #ifdef MHD_USE_THREAD_NAME_ 239 struct MHD_named_helper_param_
258 static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_
259 named_thread_starter (
void *
data)
261 struct MHD_named_helper_param_ *
const param =
262 (
struct MHD_named_helper_param_ *) data;
267 return (MHD_THRD_RTRN_TYPE_)0;
272 thr_func = param->start_routine;
275 return thr_func(arg);
291 const char* thread_name,
296 struct MHD_named_helper_param_ *param;
298 if (
NULL == thread_name)
304 param = malloc (
sizeof (
struct MHD_named_helper_param_));
308 param->start_routine = start_routine;
310 param->name = thread_name;
317 &named_thread_starter,
#define MHD_set_thread_name_(t, n)
int MHD_create_thread_(MHD_thread_handle_ *thread, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg)
#define MHD_create_named_thread_(t, n, s, r, a)
#define MHD_set_cur_thread_name_(n)
limits values definitions
Header for platform-independent threads abstraction.
MHD_THRD_RTRN_TYPE_(MHD_THRD_CALL_SPEC_ * MHD_THREAD_START_ROUTINE_)(void *cls)