
00001 /******************************************************** 00002 * Myricom VI-GM networking software and documentation * 00003 * Copyright (c) 2001 by Myricom, Inc. * 00004 * All rights reserved. * 00005 * See the file `COPYING' for copyright notice. * 00006 ********************************************************/ 00007 00013 #include <process.h> 00014 #include <windows.h> 00015 #include <winsock.h> 00016 #include "vipl_win_thread.h" 00017 00026 void vipl_win_init (void); 00027 00029 typedef struct thread_t 00030 { 00032 void *(*start_routine)(void*); 00034 void *arg; 00035 } thread_t; 00036 00037 00052 unsigned __stdcall 00053 vipl_win_thread_create_helper (void* p) 00054 { 00055 thread_t* t; 00056 00057 t = (thread_t*) p; 00058 t->start_routine (t->arg); 00059 return 0; 00060 } 00061 00079 int 00080 vipl_win_thread_create (vipl_win_thread_t *thread, 00081 void *(*start_routine)(void *), 00082 void *arg) 00083 { 00084 unsigned thrdaddr; 00085 00086 vipl_win_init (); 00087 00088 thread->ti = (struct threadinfo_t*) malloc (sizeof (*thread->ti)); 00089 thread->ti->start_routine = start_routine; 00090 thread->ti->arg = arg; 00091 thread->thread = (HANDLE) _beginthreadex (NULL, 0, 00092 vipl_win_thread_create_helper, 00093 thread->ti, 0, &thrdaddr); 00094 return 0; 00095 } 00096 00113 int 00114 vipl_win_thread_join (vipl_win_thread_t t, void **thread_return) 00115 { 00116 WaitForSingleObject (t.thread, INFINITE); 00117 free (t.ti); 00118 return 0; 00119 } 00120 00134 void 00135 vipl_win_thread_exit (void *retval) 00136 { 00137 _endthreadex (0); 00138 } 00139 00152 VIP_ENTRY_POINT unsigned long 00153 vipl_win_thread_self (void) 00154 { 00155 return (unsigned long) GetCurrentThreadId (); 00156 }
1.4.4.