Remi Meier avatar Remi Meier committed 9885e1b

stm: temporarily replace pypysig_getaddr_occurred with a get/set function for the counter.
this was necessary because a getfield() on the returned struct turned inevitable and I don't think we have a good way to avoid that currently.

Comments (0)

Files changed (4)


 from pypy.rlib import jit, rposix
 from pypy.rlib.rarithmetic import intmask
-from pypy.rlib.rsignal import (pypysig_getaddr_occurred, pypysig_setflag,
+from pypy.rlib.rsignal import (pypysig_setflag,
     pypysig_poll, pypysig_reinstall, pypysig_ignore, pypysig_default,
     pypysig_set_wakeup_fd, c_alarm, c_pause, c_getitimer, c_setitimer,
     c_siginterrupt, itimervalP, NSIG, SIG_DFL, SIG_IGN, ITIMER_REAL,
-    ITIMER_PROF, ITIMER_VIRTUAL, signal_values)
+    ITIMER_PROF, ITIMER_VIRTUAL, signal_values,
+    pypysig_get_counter, pypysig_set_counter)
 from pypy.rpython.lltypesystem import lltype, rffi
     # be called.
     def get_ticker(self):
-        p = pypysig_getaddr_occurred()
-        return p.c_value
+        return pypysig_get_counter()
     def reset_ticker(self, value):
-        p = pypysig_getaddr_occurred()
-        p.c_value = value
+        pypysig_set_counter(value)
     def decrement_ticker(self, by):
-        p = pypysig_getaddr_occurred()
-        value = p.c_value
+        value = pypysig_get_counter()
         if self.has_bytecode_counter:    # this 'if' is constant-folded
             if jit.isconstant(by) and by == 0:
                 pass     # normally constant-folded too
                 value -= by
-                p.c_value = value
+                pypysig_set_counter(value)
         return value
     """Sets the fd to be written to (with '\0') when a signal
     comes in.  Returns the old fd.  A library can use this to
     wakeup select or poll.  The previous fd is returned.
     The fd must be non-blocking.
     if space.config.objspace.usemodules.thread:
 @unwrap_spec(which=int, first=float, interval=float)
 def setitimer(space, which, first, interval=0):
     """setitimer(which, seconds[, interval])
     Sets given itimer (one of ITIMER_REAL, ITIMER_VIRTUAL
     or ITIMER_PROF) to fire after value seconds and after
     that every interval seconds.
     The itimer can be cleared by setting seconds to zero.
     Returns old values as a tuple: (delay, interval).
     with lltype.scoped_alloc(itimervalP.TO, 1) as new:
 def getitimer(space, which):
     Returns current value of given itimer.
     with lltype.scoped_alloc(itimervalP.TO, 1) as old:


                       'pypysig_ignore', 'pypysig_setflag',
-                      'pypysig_getaddr_occurred'],
+                      'pypysig_getaddr_occurred',
+                      'pypysig_get_counter',
+                      'pypysig_set_counter'],
 class CConfig:
                             hints={'c_name' : struct_name, 'external' : 'C'})
 del struct_name
+pypysig_get_counter = external('pypysig_get_counter', [],
+                               lltype.Signed, _nowrapper=True,
+                               transactionsafe=True, elidable_function=True)
+pypysig_set_counter = external('pypysig_set_counter', [lltype.Signed],
+                               lltype.Void, _nowrapper=True,
+                               transactionsafe=True, elidable_function=True)
 pypysig_getaddr_occurred = external('pypysig_getaddr_occurred', [],
                                     lltype.Ptr(LONG_STRUCT), _nowrapper=True,


     return (void *)(&pypysig_counter); 
+long pypysig_get_counter(void)
+  return pypysig_counter.value;
+void pypysig_set_counter(long v)
+  pypysig_counter.value = v;
 void pypysig_ignore(int signum)
 #ifdef SA_RESTART


 void *pypysig_getaddr_occurred(void);
 #define pypysig_getaddr_occurred()   ((void *)(&pypysig_counter))
+long pypysig_get_counter(void);
+void pypysig_set_counter(long v);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.