Author: Armin Rigo <[email protected]>
Branch: c8-gil-like
Changeset: r1819:bf0dfe206de5
Date: 2015-06-12 16:23 +0200
http://bitbucket.org/pypy/stmgc/changeset/bf0dfe206de5/

Log:    Save and restore errno at the critical point

diff --git a/c8/stm/detach.c b/c8/stm/detach.c
--- a/c8/stm/detach.c
+++ b/c8/stm/detach.c
@@ -2,6 +2,9 @@
 # error "must be compiled via stmgc.c"
 #endif
 
+#include <errno.h>
+
+
 /* Idea: if stm_leave_transactional_zone() is quickly followed by
    stm_enter_transactional_zone() in the same thread, then we should
    simply try to have one inevitable transaction that does both sides.
@@ -32,6 +35,7 @@
 
 void _stm_leave_noninevitable_transactional_zone(void)
 {
+    int saved_errno = errno;
     dprintf(("leave_noninevitable_transactional_zone\n"));
     _stm_become_inevitable(MSG_INEV_DONT_SLEEP);
 
@@ -45,6 +49,7 @@
         dprintf(("leave_noninevitable_transactional_zone: commit\n"));
         _stm_commit_transaction();
     }
+    errno = saved_errno;
 }
 
 static void commit_external_inevitable_transaction(void)
@@ -56,6 +61,7 @@
 void _stm_reattach_transaction(stm_thread_local_t *tl)
 {
     intptr_t old;
+    int saved_errno = errno;
  restart:
     old = _stm_detached_inevitable_from_thread;
     if (old != 0) {
@@ -85,6 +91,7 @@
     }
     dprintf(("reattach_transaction: start a new transaction\n"));
     _stm_start_transaction(tl);
+    errno = saved_errno;
 }
 
 void stm_force_transaction_break(stm_thread_local_t *tl)
diff --git a/c8/stmgc.h b/c8/stmgc.h
--- a/c8/stmgc.h
+++ b/c8/stmgc.h
@@ -420,6 +420,9 @@
    stm_enter_transactional_zone() will try to reattach to it.  This is
    far more efficient than constantly starting and committing
    transactions.
+
+   stm_enter_transactional_zone() and stm_leave_transactional_zone()
+   preserve the value of errno.
 */
 #ifdef STM_DEBUGPRINT
 #include <stdio.h>
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to