Commits

mattip  committed 1c7e961 Merge

merge heads

  • Participants
  • Parent commits 84ff285, 9ed36ac

Comments (0)

Files changed (5)

File pypy/module/__pypy__/interp_time.py

             ret = c_clock_gettime(clk_id, tp)
             if ret != 0:
                 raise exception_from_errno(space, space.w_IOError)
-            return space.wrap(tp.c_tv_sec + tp.c_tv_nsec * 1e-9)
+            return space.wrap(int(tp.c_tv_sec) + 1e-9 * int(tp.c_tv_nsec))
 
     @unwrap_spec(clk_id="c_int")
     def clock_getres(space, clk_id):
             ret = c_clock_getres(clk_id, tp)
             if ret != 0:
                 raise exception_from_errno(space, space.w_IOError)
-            return space.wrap(tp.c_tv_sec + tp.c_tv_nsec * 1e-9)
+            return space.wrap(int(tp.c_tv_sec) + 1e-9 * int(tp.c_tv_nsec))

File rpython/jit/metainterp/blackhole.py

 
     @arguments("r")
     def bhimpl_debug_fatalerror(msg):
+        from rpython.rtyper.lltypesystem import rstr
+        msg = lltype.cast_opaque_ptr(lltype.Ptr(rstr.STR), msg)
         llop.debug_fatalerror(lltype.Void, msg)
 
     @arguments("r", "i", "i", "i", "i")

File rpython/jit/metainterp/test/test_blackhole.py

 
     assert BlackholeInterpreter.bhimpl_int_lshift.im_func(100, 3) == 100<<3
     assert BlackholeInterpreter.bhimpl_int_rshift.im_func(100, 3) == 100>>3
-    assert BlackholeInterpreter.bhimpl_uint_rshift.im_func(100, 3) == 100>>3        
-    
+    assert BlackholeInterpreter.bhimpl_uint_rshift.im_func(100, 3) == 100>>3
+
+def test_debug_fatalerror():
+    from rpython.rtyper.lltypesystem import lltype, llmemory, rstr
+    from rpython.rtyper.llinterp import LLFatalError
+    msg = rstr.mallocstr(1)
+    msg.chars[0] = "!"
+    msg = lltype.cast_opaque_ptr(llmemory.GCREF, msg)
+    e = py.test.raises(LLFatalError,
+                       BlackholeInterpreter.bhimpl_debug_fatalerror.im_func,
+                       msg)
+    assert str(e.value) == '!'

File rpython/rtyper/lltypesystem/lloperation.py

     'debug_offset':         LLOp(canrun=True),
     'debug_flush':          LLOp(canrun=True),
     'debug_assert':         LLOp(tryfold=True),
-    'debug_fatalerror':     LLOp(),
+    'debug_fatalerror':     LLOp(canrun=True),
     'debug_llinterpcall':   LLOp(canraise=(Exception,)),
                                     # Python func call 'res=arg[0](*arg[1:])'
                                     # in backends, abort() or whatever is fine

File rpython/rtyper/lltypesystem/opimpl.py

     from rpython.rlib.rtimer import read_timestamp
     return read_timestamp()
 
+def op_debug_fatalerror(ll_msg):
+    from rpython.rtyper.lltypesystem import lltype, rstr
+    from rpython.rtyper.llinterp import LLFatalError
+    assert lltype.typeOf(ll_msg) == lltype.Ptr(rstr.STR)
+    msg = ''.join(ll_msg.chars)
+    raise LLFatalError(msg)
+
 # ____________________________________________________________
 
 def get_op_impl(opname):