pypy-improvebigint / lib_pypy /

""" This file provides some support for things like standard_c_lib and
errno access, as portable as possible

import ctypes
import ctypes.util
import sys

# __________ the standard C library __________

if sys.platform == 'win32':
    import _ffi
    standard_c_lib = ctypes.CDLL('msvcrt', handle=_ffi.get_libc())
elif sys.platform == 'cygwin':
    standard_c_lib = ctypes.CDLL(ctypes.util.find_library('cygwin'))
    standard_c_lib = ctypes.CDLL(ctypes.util.find_library('c'))

if sys.platform == 'win32':
    standard_c_lib._errno.restype = ctypes.POINTER(ctypes.c_int)
    def _where_is_errno():
        return standard_c_lib._errno()
elif sys.platform in ('linux2', 'freebsd6'):
    standard_c_lib.__errno_location.restype = ctypes.POINTER(ctypes.c_int)
    def _where_is_errno():
        return standard_c_lib.__errno_location()

elif sys.platform in ('darwin', 'freebsd7', 'freebsd8', 'freebsd9'):
    standard_c_lib.__error.restype = ctypes.POINTER(ctypes.c_int)
    def _where_is_errno():
        return standard_c_lib.__error()

def get_errno():
    errno_p = _where_is_errno()
    return errno_p.contents.value

def set_errno(value):
    errno_p = _where_is_errno()
    errno_p.contents.value = value
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.