28 #ifdef MHD_USE_W32_THREADS 29 #include "mhd_limits.h" 32 #ifdef MHD_USE_THREAD_NAME_ 34 #ifdef HAVE_PTHREAD_NP_H 35 #include <pthread_np.h> 41 #ifndef MHD_USE_THREAD_NAME_ 43 #define MHD_set_thread_name_(t, n) (void) 44 #define MHD_set_cur_thread_name_(n) (void) 48 #if defined(MHD_USE_POSIX_THREADS) 49 #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) || \ 50 defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) 51 # define MHD_USE_THREAD_ATTR_SETNAME 1 54 #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) || \ 55 defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) \ 56 || defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) 67 const char *thread_name)
69 if (
NULL == thread_name)
72 #if defined(HAVE_PTHREAD_SETNAME_NP_GNU) 73 return ! pthread_setname_np (thread_id, thread_name);
74 #elif defined(HAVE_PTHREAD_SET_NAME_NP_FREEBSD) 76 pthread_set_name_np (thread_id, thread_name);
78 #elif defined(HAVE_PTHREAD_SETNAME_NP_NETBSD) 84 return ! pthread_setname_np (thread_id, thread_name, 0);
95 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (pthread_self (),(n)) 98 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (0,(n)) 100 #elif defined(HAVE_PTHREAD_SETNAME_NP_DARWIN) 107 #define MHD_set_cur_thread_name_(n) (! (pthread_setname_np ((n)))) 110 #elif defined(MHD_USE_W32_THREADS) 111 #ifndef _MSC_FULL_VER 123 const char *thread_name)
125 static const DWORD VC_SETNAME_EXC = 0x406D1388;
127 struct thread_info_struct
136 if (
NULL == thread_name)
139 thread_info.type = 0x1000;
140 thread_info.name = thread_name;
141 thread_info.ID = thread_id;
142 thread_info.flags = 0;
146 RaiseException (VC_SETNAME_EXC,
148 sizeof (thread_info) /
sizeof(ULONG_PTR),
149 (ULONG_PTR *) &thread_info);
151 __except (EXCEPTION_EXECUTE_HANDLER)
163 #define MHD_set_cur_thread_name_(n) MHD_set_thread_name_ (-1,(n)) 185 #if defined(MHD_USE_POSIX_THREADS) 191 res = pthread_attr_init (&attr);
194 res = pthread_attr_setstacksize (&attr,
197 res = pthread_create (&(thread->handle),
201 pthread_attr_destroy (&attr);
205 res = pthread_create (&(thread->handle),
214 #elif defined(MHD_USE_W32_THREADS) 215 #if SIZE_MAX != UINT_MAX 223 thread->handle = (MHD_thread_handle_)
224 _beginthreadex (
NULL,
225 (
unsigned int) stack_size,
231 if ((MHD_thread_handle_) - 1 == thread->handle)
238 #ifdef MHD_USE_THREAD_NAME_ 240 #ifndef MHD_USE_THREAD_ATTR_SETNAME 241 struct MHD_named_helper_param_
260 static MHD_THRD_RTRN_TYPE_ MHD_THRD_CALL_SPEC_
261 named_thread_starter (
void *
data)
263 struct MHD_named_helper_param_ *
const param =
264 (
struct MHD_named_helper_param_ *)
data;
269 return (MHD_THRD_RTRN_TYPE_) 0;
274 thr_func = param->start_routine;
277 return thr_func (arg);
294 const char*thread_name,
299 #if defined(MHD_USE_THREAD_ATTR_SETNAME) 303 res = pthread_attr_init (&attr);
306 #if defined(HAVE_PTHREAD_ATTR_SETNAME_NP_NETBSD) 312 res = pthread_attr_setname_np (&attr, thread_name, 0);
313 #elif defined(HAVE_PTHREAD_ATTR_SETNAME_NP_IBMI) 314 res = pthread_attr_setname_np (&attr, thread_name);
316 #error No pthread_attr_setname_np() function. 318 if ((res == 0) &&(0 != stack_size) )
319 res = pthread_attr_setstacksize (&attr,
322 res = pthread_create (&(thread->handle),
326 pthread_attr_destroy (&attr);
333 struct MHD_named_helper_param_ *param;
335 if (
NULL == thread_name)
341 param = malloc (
sizeof (
struct MHD_named_helper_param_));
345 param->start_routine = start_routine;
347 param->name = thread_name;
354 &named_thread_starter,
#define MHD_set_cur_thread_name_(n)
#define MHD_set_thread_name_(t, n)
MHD_THRD_RTRN_TYPE_(MHD_THRD_CALL_SPEC_ * MHD_THREAD_START_ROUTINE_)(void *cls)
#define MHD_create_named_thread_(t, n, s, r, a)
int MHD_create_thread_(MHD_thread_handle_ID_ *thread, size_t stack_size, MHD_THREAD_START_ROUTINE_ start_routine, void *arg)