Example #1
0
 def lazy_getsize(cache={}):
     from pypy.rpython.tool import rffi_platform
     try:
         return cache[name]
     except KeyError:
         val = rffi_platform.sizeof(name, compilation_info)
         cache[name] = val
         return val
Example #2
0
def test_sizeof():
    assert rffi_platform.sizeof("char", ExternalCompilationInfo()) == 1
Example #3
0
    except thread.error:
        ident = -1
    return rffi.cast(rffi.LONG, ident)

CALLBACK = lltype.Ptr(lltype.FuncType([], lltype.Void))
c_thread_start = llexternal('RPyThreadStart', [CALLBACK], rffi.LONG,
                            _callable=_emulated_start_new_thread,
                            threadsafe=True)  # release the GIL, but most
                                              # importantly, reacquire it
                                              # around the callback
c_thread_get_ident = llexternal('RPyThreadGetIdent', [], rffi.LONG,
                                _nowrapper=True)    # always call directly

TLOCKP = rffi.COpaquePtr('struct RPyOpaque_ThreadLock',
                          compilation_info=eci)
TLOCKP_SIZE = rffi_platform.sizeof('struct RPyOpaque_ThreadLock', eci)
c_thread_lock_init = llexternal('RPyThreadLockInit', [TLOCKP], rffi.INT,
                                threadsafe=False)   # may add in a global list
c_thread_lock_dealloc_NOAUTO = llexternal('RPyOpaqueDealloc_ThreadLock',
                                          [TLOCKP], lltype.Void,
                                          _nowrapper=True)
c_thread_acquirelock = llexternal('RPyThreadAcquireLock', [TLOCKP, rffi.INT],
                                  rffi.INT,
                                  threadsafe=True)    # release the GIL
c_thread_releaselock = llexternal('RPyThreadReleaseLock', [TLOCKP], lltype.Void,
                                  threadsafe=True)    # release the GIL

# another set of functions, this time in versions that don't cause the
# GIL to be released.  To use to handle the GIL lock itself.
c_thread_acquirelock_NOAUTO = llexternal('RPyThreadAcquireLock',
                                         [TLOCKP, rffi.INT], rffi.INT,
Example #4
0
def test_sizeof():
    assert rffi_platform.sizeof("char", ExternalCompilationInfo()) == 1
Example #5
0
    return rffi.cast(rffi.LONG, ident)


CALLBACK = lltype.Ptr(lltype.FuncType([], lltype.Void))
c_thread_start = llexternal('RPyThreadStart', [CALLBACK],
                            rffi.LONG,
                            _callable=_emulated_start_new_thread,
                            threadsafe=True)  # release the GIL, but most
# importantly, reacquire it
# around the callback
c_thread_get_ident = llexternal('RPyThreadGetIdent', [],
                                rffi.LONG,
                                _nowrapper=True)  # always call directly

TLOCKP = rffi.COpaquePtr('struct RPyOpaque_ThreadLock', compilation_info=eci)
TLOCKP_SIZE = rffi_platform.sizeof('struct RPyOpaque_ThreadLock', eci)
c_thread_lock_init = llexternal('RPyThreadLockInit', [TLOCKP],
                                rffi.INT,
                                threadsafe=False)  # may add in a global list
c_thread_lock_dealloc_NOAUTO = llexternal('RPyOpaqueDealloc_ThreadLock',
                                          [TLOCKP],
                                          lltype.Void,
                                          _nowrapper=True)
c_thread_acquirelock = llexternal('RPyThreadAcquireLock', [TLOCKP, rffi.INT],
                                  rffi.INT,
                                  threadsafe=True)  # release the GIL
c_thread_releaselock = llexternal('RPyThreadReleaseLock', [TLOCKP],
                                  lltype.Void,
                                  threadsafe=True)  # release the GIL

# another set of functions, this time in versions that don't cause the
Example #6
0
 def lazy_getsize():
     from pypy.rpython.tool import rffi_platform
     k = {}
     return rffi_platform.sizeof(name, compilation_info)