Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
implement xbt_os_thread_cancel() for windows and make a little changes (test pointer...
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 20 Jun 2008 10:20:23 +0000 (10:20 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 20 Jun 2008 10:20:23 +0000 (10:20 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5778 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/xbt_os_thread.c

index 71716e2..46196d6 100644 (file)
@@ -567,14 +567,15 @@ void xbt_os_thread_mod_exit(void) {
 
 static DWORD WINAPI  wrapper_start_routine(void *s) {
   xbt_os_thread_t t = (xbt_os_thread_t)s;
-  void* rv;
+  DWORD* rv;
 
     if(!TlsSetValue(xbt_self_thread_key,t))
      THROW0(system_error,(int)GetLastError(),"TlsSetValue of data describing the created thread failed");
 
-   rv = (*(t->start_routine))(t->param);
+   rv = (DWORD*)((t->start_routine)(t->param));
 
-   return *((DWORD*)rv);
+   return rv ? *rv : 0;
+   
 }
 
 
@@ -621,7 +622,10 @@ xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
        }
 
        CloseHandle(thread->handle);
-       free(thread->name);
+       
+       if(thread->name)
+               free(thread->name);
+       
        free(thread);
 }
 
@@ -646,7 +650,8 @@ void xbt_os_thread_yield(void) {
     Sleep(0);
 }
 void xbt_os_thread_cancel(xbt_os_thread_t t) {
-   THROW_UNIMPLEMENTED;
+  if(!TerminateThread(t->handle,0))
+               THROW0(system_error,(int)GetLastError(), "TerminateThread failed");
 }
 
 /****** mutex related functions ******/