harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ibere...@apache.org
Subject svn commit: r987283 - /harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c
Date Thu, 19 Aug 2010 19:50:20 GMT
Author: iberezhn
Date: Thu Aug 19 19:50:19 2010
New Revision: 987283

URL: http://svn.apache.org/viewvc?rev=987283&view=rev
Log:
Fixed thread start failures when libthr reuses threads on FreeBSD

Modified:
    harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c

Modified: harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c?rev=987283&r1=987282&r2=987283&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c (original)
+++ harmony/enhanced/java/trunk/drlvm/vm/port/src/thread/linux/thread_os.c Thu Aug 19 19:50:19
2010
@@ -226,7 +226,10 @@ int set_alt_stack(port_tls_data_t* tlsda
 //#else
 //    sigalt.ss_flags = set ? SS_ONSTACK : SS_DISABLE;
 //#endif
-    return sigaltstack(&sigalt, NULL);
+    if (sigaltstack(&sigalt, NULL) != 0)
+        return errno;
+
+    return 0;
 }
 
 static int set_guard_page(port_tls_data_t* tlsdata, Boolean set)
@@ -257,7 +260,7 @@ static int set_guard_page(port_tls_data_
         res = set_alt_stack(tlsdata, TRUE);
 
         if (res != 0)
-            return errno;
+            return res;
     }
 
     tlsdata->guard_page_set = set;
@@ -317,17 +320,17 @@ static int setup_stack(port_tls_data_t* 
     int res;
     void* ptr;
     stack_t sigalt;
-    size_t current_page_addr, mapping_addr, mapping_size;
+    size_t /*current_page_addr,*/ mapping_addr, mapping_size;
 
     if (!port_shared_data)
         return -1;
 
-    current_page_addr = ((size_t)&res) & ~(PSD->guard_page_size - 1);
+//    current_page_addr = ((size_t)&res) & ~(PSD->guard_page_size - 1);
     // leave place for mmap work
-    mapping_addr = current_page_addr - PSD->guard_page_size;
+//    mapping_addr = current_page_addr - PSD->guard_page_size;
     // found size of the stack area which should be maped
-    mapping_size = tlsdata->stack_size
-            - ((size_t)tlsdata->stack_addr - mapping_addr);
+//    mapping_size = tlsdata->stack_size
+//            - ((size_t)tlsdata->stack_addr - mapping_addr);
 
     if ((size_t)(&res) - PSD->mem_protect_size
             < (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
@@ -347,7 +350,7 @@ static int setup_stack(port_tls_data_t* 
     res = set_guard_page(tlsdata, TRUE);
 
     if (res != 0)
-        return errno;
+        return res;
 
     return 0;
 }
@@ -493,6 +496,12 @@ int port_thread_detach()
     if (res != 0)
         return res;
 
+    size_t mapping_addr = (size_t)tlsdata->stack_addr - tlsdata->stack_size;
+    size_t mapping_size =
+        (tlsdata->guard_stack_size + tlsdata->mem_protect_size + 2*PSD->guard_page_size
- 1) &
+            ~(PSD->guard_page_size - 1);
+    munmap((void*)mapping_addr, mapping_size);
+
     if (tlsdata->foreign)
         STD_FREE(tlsdata);
 



Mime
View raw message