Ejemplo n.º 1
0
# ____________________________________________________________
# Access to the 'environ' external variable
prefix = ''
if sys.platform.startswith('darwin'):
    CCHARPPP = rffi.CArrayPtr(rffi.CCHARPP)
    _os_NSGetEnviron = llexternal(
        '_NSGetEnviron', [], CCHARPPP,
        compilation_info=ExternalCompilationInfo(includes=['crt_externs.h'])
        )
    def os_get_environ():
        return _os_NSGetEnviron()[0]
elif _WIN32:
    eci = ExternalCompilationInfo(includes=['stdlib.h'])
    CWCHARPP = lltype.Ptr(lltype.Array(rffi.CWCHARP, hints={'nolength': True}))

    os_get_environ, _os_set_environ = rffi.CExternVariable(
        rffi.CCHARPP, '_environ', eci)
    get__wenviron, _set__wenviron = rffi.CExternVariable(
        CWCHARPP, '_wenviron', eci, c_type='wchar_t **')
    prefix = '_'
else:
    os_get_environ, _os_set_environ = rffi.CExternVariable(
        rffi.CCHARPP, 'environ', ExternalCompilationInfo())

# ____________________________________________________________
#
# Lower-level interface: dummy placeholders and external registations

def r_envkeys():
    just_a_placeholder

def envkeys_llimpl():
Ejemplo n.º 2
0
        # NOTE: this doesn't seem to work on Macs, so I did a hack in the
        # build script as well to patch the binary later
        link_extra=['-Wl,-rpath,%s' % LIB_DIR])

    bool = rffi.UINT
    int_fast8_t = rffi.INT_FAST8_T
    uint_fast16_t = rffi.UINT_FAST16_T
    uint_fast32_t = rffi.UINT_FAST32_T
    uint_fast64_t = rffi.UINT_FAST64_T
    int_fast32_t = rffi.INT_FAST32_T
    int_fast64_t = rffi.INT_FAST64_T
    float32_t = rffi.ULONG
    float64_t = rffi.ULONGLONG

    _get_flags, set_flags = \
      rffi.CExternVariable( int_fast8_t, 'softfloat_exceptionFlags', eci )

    def get_flags():
        return r_ulonglong(_get_flags())

    def rffi_fn(name, arg_types, return_type):
        return rffi.llexternal(name,
                               arg_types,
                               return_type,
                               compilation_info=eci)

    f32_add = rffi_fn('f32_add', [float32_t, float32_t], float32_t)
    f32_sub = rffi_fn('f32_sub', [float32_t, float32_t], float32_t)
    f32_mul = rffi_fn('f32_mul', [float32_t, float32_t], float32_t)
    f32_div = rffi_fn('f32_div', [float32_t, float32_t], float32_t)
    f32_rem = rffi_fn('f32_rem', [float32_t, float32_t], float32_t)
Ejemplo n.º 3
0
c_fflush = llexternal('fflush', [FILEP], rffi.INT,
                      save_err=rffi.RFFI_SAVE_ERRNO)
c_ftruncate = llexternal(ftruncate, [rffi.INT, OFF_T], rffi.INT, macro=True,
                         save_err=rffi.RFFI_SAVE_ERRNO)

c_fseek = llexternal('fseek', [FILEP, rffi.LONG, rffi.INT], rffi.INT,
                     save_err=rffi.RFFI_SAVE_ERRNO)
c_ftell = llexternal('ftell', [FILEP], rffi.LONG,
                     save_err=rffi.RFFI_SAVE_ERRNO)
c_fileno = llexternal(fileno, [FILEP], rffi.INT)

c_feof = llexternal('feof', [FILEP], rffi.INT)
c_ferror = llexternal('ferror', [FILEP], rffi.INT)
c_clearerr = llexternal('clearerr', [FILEP], lltype.Void)

c_stdin = rffi.CExternVariable(FILEP, 'stdin', eci, c_type='FILE*',
                               getter_only=True)
c_stdout = rffi.CExternVariable(FILEP, 'stdout', eci, c_type='FILE*',
                                getter_only=True)
c_stderr = rffi.CExternVariable(FILEP, 'stderr', eci, c_type='FILE*',
                                getter_only=True)


def _error(ll_file):
    err = c_ferror(ll_file)
    c_clearerr(ll_file)
    raise IOError(err, os.strerror(err))


def _dircheck(ll_file):
    try:
        st = os.fstat(c_fileno(ll_file))
Ejemplo n.º 4
0
c_fflush = llexternal('fflush', [FILEP], rffi.INT,
                      save_err=rffi.RFFI_SAVE_ERRNO)
c_ftruncate = llexternal(ftruncate, [rffi.INT, OFF_T], rffi.INT, macro=True,
                         save_err=rffi.RFFI_SAVE_ERRNO)

c_fseek = llexternal('fseek', [FILEP, rffi.LONG, rffi.INT], rffi.INT,
                     save_err=rffi.RFFI_SAVE_ERRNO)
c_ftell = llexternal('ftell', [FILEP], rffi.LONG,
                     save_err=rffi.RFFI_SAVE_ERRNO)
c_fileno = llexternal(fileno, [FILEP], rffi.INT)

c_feof = llexternal('feof', [FILEP], rffi.INT)
c_ferror = llexternal('ferror', [FILEP], rffi.INT)
c_clearerr = llexternal('clearerr', [FILEP], lltype.Void)

c_stdin = rffi.CExternVariable(FILEP, 'stdin', eci, c_type='FILE*',
                               getter_only=True, declare_as_extern=False)
c_stdout = rffi.CExternVariable(FILEP, 'stdout', eci, c_type='FILE*',
                                getter_only=True, declare_as_extern=False)
c_stderr = rffi.CExternVariable(FILEP, 'stderr', eci, c_type='FILE*',
                                getter_only=True, declare_as_extern=False)


def _error(ll_file):
    err = c_ferror(ll_file)
    c_clearerr(ll_file)
    raise IOError(err, os.strerror(err))


def _dircheck(ll_file):
    try:
        st = os.fstat(c_fileno(ll_file))