Beispiel #1
0
 def test_calling_convention2(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types
     kernel = WinDLL('Kernel32.dll')
     sleep = kernel.getfunc('Sleep', [types.uint], types.void)
     sleep(10)
Beispiel #2
0
 def main(libc_name, n):
     import time
     import os
     from threading import Thread
     #
     if os.name == 'nt':
         from _ffi import WinDLL, types
         libc = WinDLL(libc_name)
         sleep = libc.getfunc('Sleep', [types.uint], types.uint)
         delays = [0]*n + [1000]
     else:
         from _ffi import CDLL, types
         libc = CDLL(libc_name)
         sleep = libc.getfunc('sleep', [types.uint], types.uint)
         delays = [0]*n + [1]
     #
     def loop_of_sleeps(i, delays):
         for delay in delays:
             sleep(delay)    # ID: sleep
     #
     threads = [Thread(target=loop_of_sleeps, args=[i, delays]) for i in range(5)]
     start = time.time()
     for i, thread in enumerate(threads):
         thread.start()
     for thread in threads:
         thread.join()
     end = time.time()
     return end - start
Beispiel #3
0
 def test_calling_convention2(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types
     kernel = WinDLL('Kernel32.dll')
     sleep = kernel.getfunc('Sleep', [types.uint], types.void)
     sleep(10)
Beispiel #4
0
 def test_func_fromaddr3(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types, FuncPtr
     from _rawffi import FUNCFLAG_STDCALL
     kernel = WinDLL('Kernel32.dll')
     sleep_addr = kernel.getaddressindll('Sleep')
     sleep = FuncPtr.fromaddr(sleep_addr, 'sleep', [types.uint], 
                         types.void, FUNCFLAG_STDCALL)
     sleep(10)
Beispiel #5
0
 def test_calling_convention1(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types
     libm = WinDLL(self.libm_name)
     pow = libm.getfunc('pow', [types.double, types.double], types.double)
     try:
         pow(2, 3)
     except ValueError, e:
         assert e.message.startswith('Procedure called with')
Beispiel #6
0
 def test_func_fromaddr3(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types, FuncPtr
     from _rawffi import FUNCFLAG_STDCALL
     kernel = WinDLL('Kernel32.dll')
     sleep_addr = kernel.getaddressindll('Sleep')
     sleep = FuncPtr.fromaddr(sleep_addr, 'sleep', [types.uint], types.void,
                              FUNCFLAG_STDCALL)
     sleep(10)
Beispiel #7
0
 def test_calling_convention1(self):
     if not self.iswin32:
         skip("windows specific")
     from _ffi import WinDLL, types
     libm = WinDLL(self.libm_name)
     pow = libm.getfunc('pow', [types.double, types.double], types.double)
     try:
         pow(2, 3)
     except ValueError, e:
         assert e.message.startswith('Procedure called with')