Exemplo n.º 1
0
 def realize_struct(self, struct):
     type_name = struct.get_type_name()
     entry = rffi_platform.Struct(type_name, struct.fields)
     self._config_entries[entry] = struct.TYPE
     return struct.TYPE
Exemplo n.º 2
0
class CConfig:
    _compilation_info_ = eci

    if WIN32:
        DWORD_PTR = rffi_platform.SimpleType("DWORD_PTR", rffi.LONG)
        WORD = rffi_platform.SimpleType("WORD", rffi.UINT)
        DWORD = rffi_platform.SimpleType("DWORD", rffi.UINT)
        BOOL = rffi_platform.SimpleType("BOOL", rffi.LONG)
        BYTE = rffi_platform.SimpleType("BYTE", rffi.UCHAR)
        WCHAR = rffi_platform.SimpleType("WCHAR", rffi.UCHAR)
        INT = rffi_platform.SimpleType("INT", rffi.INT)
        LONG = rffi_platform.SimpleType("LONG", rffi.LONG)
        PLONG = rffi_platform.SimpleType("PLONG", rffi.LONGP)
        LPVOID = rffi_platform.SimpleType("LPVOID", rffi.INTP)
        LPCVOID = rffi_platform.SimpleType("LPCVOID", rffi.VOIDP)
        LPSTR = rffi_platform.SimpleType("LPSTR", rffi.CCHARP)
        LPCSTR = rffi_platform.SimpleType("LPCSTR", rffi.CCHARP)
        LPWSTR = rffi_platform.SimpleType("LPWSTR", rffi.CWCHARP)
        LPCWSTR = rffi_platform.SimpleType("LPCWSTR", rffi.CWCHARP)
        LPDWORD = rffi_platform.SimpleType("LPDWORD", rffi.UINTP)
        SIZE_T = rffi_platform.SimpleType("SIZE_T", rffi.SIZE_T)
        ULONG_PTR = rffi_platform.SimpleType("ULONG_PTR", rffi.ULONG)

        HRESULT = rffi_platform.SimpleType("HRESULT", rffi.LONG)
        HLOCAL = rffi_platform.SimpleType("HLOCAL", rffi.VOIDP)

        FILETIME = rffi_platform.Struct('FILETIME',
                                        [('dwLowDateTime', rffi.UINT),
                                         ('dwHighDateTime', rffi.UINT)])
        SYSTEMTIME = rffi_platform.Struct('SYSTEMTIME', [])

        OSVERSIONINFOEX = rffi_platform.Struct('OSVERSIONINFOEX', [
            ('dwOSVersionInfoSize', rffi.UINT),
            ('dwMajorVersion', rffi.UINT),
            ('dwMinorVersion', rffi.UINT),
            ('dwBuildNumber', rffi.UINT),
            ('dwPlatformId', rffi.UINT),
            ('szCSDVersion', rffi.CFixedArray(lltype.Char, 1)),
            ('wServicePackMajor', rffi.USHORT),
            ('wServicePackMinor', rffi.USHORT),
            ('wSuiteMask', rffi.USHORT),
            ('wProductType', rffi.UCHAR),
        ])

        LPSECURITY_ATTRIBUTES = rffi_platform.SimpleType(
            "LPSECURITY_ATTRIBUTES", rffi.CCHARP)

        DEFAULT_LANGUAGE = rffi_platform.ConstantInteger(
            "MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)")

        defines = """FORMAT_MESSAGE_ALLOCATE_BUFFER FORMAT_MESSAGE_FROM_SYSTEM
                       MAX_PATH _MAX_ENV FORMAT_MESSAGE_IGNORE_INSERTS
                       WAIT_OBJECT_0 WAIT_TIMEOUT INFINITE
                       ERROR_INVALID_HANDLE
                       DELETE READ_CONTROL SYNCHRONIZE WRITE_DAC
                       WRITE_OWNER PROCESS_ALL_ACCESS
                       PROCESS_CREATE_PROCESS PROCESS_CREATE_THREAD
                       PROCESS_DUP_HANDLE PROCESS_QUERY_INFORMATION
                       PROCESS_SET_QUOTA
                       PROCESS_SUSPEND_RESUME PROCESS_TERMINATE
                       PROCESS_VM_OPERATION PROCESS_VM_READ
                       PROCESS_VM_WRITE
                       CTRL_C_EVENT CTRL_BREAK_EVENT
                       MB_ERR_INVALID_CHARS ERROR_NO_UNICODE_TRANSLATION
                       WC_NO_BEST_FIT_CHARS
                    """
        from rpython.translator.platform import host_factory
        static_platform = host_factory()
        if static_platform.name == 'msvc':
            defines += ' PROCESS_QUERY_LIMITED_INFORMATION'
        for name in defines.split():
            locals()[name] = rffi_platform.ConstantInteger(name)
Exemplo n.º 3
0
class CConfig:
    _compilation_info_ = eci
    ADLER32_CTX = platform.Struct('ADLER32_CTX', [])
Exemplo n.º 4
0
class CConfig:
    _compilation_info_ = eci
    JOAAT_CTX = platform.Struct('JOAAT_CTX', [])
Exemplo n.º 5
0
 class CConfig:
     _compilation_info_ = compilation_info
     STAT_STRUCT = platform.Struct('struct %s' % _name_struct_stat,
                                   LL_STAT_FIELDS)
     STATVFS_STRUCT = platform.Struct('struct statvfs', STATVFS_FIELDS)
Exemplo n.º 6
0
class CConfigForFTime:
    _compilation_info_ = ExternalCompilationInfo(
        includes=[TIME_H, 'sys/timeb.h'], libraries=libraries)
    TIMEB = rffi_platform.Struct(STRUCT_TIMEB, [('time', rffi.INT),
                                                ('millitm', rffi.INT)])
Exemplo n.º 7
0
import sys

eci = ExternalCompilationInfo(
    includes=["sys/types.h", "sys/event.h", "sys/time.h"], )


class CConfig:
    _compilation_info_ = eci


if "openbsd" in sys.platform:
    IDENT_UINT = True
    CConfig.kevent = rffi_platform.Struct("struct kevent", [
        ("ident", rffi.UINT),
        ("filter", rffi.SHORT),
        ("flags", rffi.USHORT),
        ("fflags", rffi.UINT),
        ("data", rffi.INT),
        ("udata", rffi.VOIDP),
    ])
else:
    IDENT_UINT = False
    CConfig.kevent = rffi_platform.Struct("struct kevent", [
        ("ident", rffi.UINTPTR_T),
        ("filter", rffi.SHORT),
        ("flags", rffi.USHORT),
        ("fflags", rffi.UINT),
        ("data", rffi.INTPTR_T),
        ("udata", rffi.VOIDP),
    ])

CConfig.timespec = rffi_platform.Struct("struct timespec", [
Exemplo n.º 8
0
class CConfig:
    _compilation_info_ = eci
    ripemd128_ctx = platform.Struct('ripemd128_ctx', [])
    ripemd160_ctx = platform.Struct('ripemd160_ctx', [])
    ripemd256_ctx = platform.Struct('ripemd256_ctx', [])
    ripemd320_ctx = platform.Struct('ripemd320_ctx', [])
Exemplo n.º 9
0
class CConfig:
    _compilation_info_ = eci

    loop_t = rffi_platform.Struct("uv_loop_t", [("data", rffi.VOIDP)])
    handle_t = rffi_platform.Struct("uv_handle_t", [("data", rffi.VOIDP)])
    timer_t = rffi_platform.Struct("uv_timer_t", [("data", rffi.VOIDP)])
    prepare_t = rffi_platform.Struct("uv_prepare_t", [("data", rffi.VOIDP)])
    idle_t = rffi_platform.Struct("uv_idle_t", [("data", rffi.VOIDP)])
    process_options_t = rffi_platform.Struct(
        "uv_process_options_t", [
            ("file", rffi.CCHARP),
            ("args", rffi.CCHARPP),
            ("env", rffi.CCHARPP),
            ("cwd", rffi.CCHARP),
            ("flags", rffi.UINT),
            ("stdio_count", rffi.INT),
            ("stdio", lltype.Ptr(lltype.ForwardReference()))])
    stdio_container_t = rffi_platform.Struct("uv_stdio_container_t",
                                             [("flags", rffi.INT)])
    process_t = rffi_platform.Struct("uv_process_t",
                                     [("data", rffi.VOIDP),
                                      ("pid", rffi.INT)])
    connect_t = rffi_platform.Struct("uv_connect_t",
                                     [("handle",
                                       lltype.Ptr(lltype.ForwardReference()))])
    stream_t = rffi_platform.Struct("uv_stream_t", [("data", rffi.VOIDP)])
    shutdown_t = rffi_platform.Struct("uv_shutdown_t", [])
    write_t = rffi_platform.Struct("uv_write_t", [("data", rffi.VOIDP)])
    tcp_t = rffi_platform.Struct("uv_tcp_t", [("data", rffi.VOIDP)])
    pipe_t = rffi_platform.Struct("uv_pipe_t", [("data", rffi.VOIDP)])
    signal_t = rffi_platform.Struct("uv_signal_t", [("data", rffi.VOIDP)])
    tty_t = rffi_platform.Struct("uv_tty_t", [("data", rffi.VOIDP)])
    fs_t = rffi_platform.Struct("uv_fs_t",
                                [("data", rffi.VOIDP),
                                 ("path", rffi.CONST_CCHARP),
                                 ("result", rffi.SSIZE_T),
                                 ("ptr", rffi.VOIDP)])
    getaddrinfo_t = rffi_platform.Struct("uv_getaddrinfo_t",
                                         [("data", rffi.VOIDP)])
    buf_t = rffi_platform.Struct("uv_buf_t",
                                 [("base", rffi.CCHARP),
                                  ("len", rffi.SIZE_T)])
Exemplo n.º 10
0
if _MSVC:
    socketfd_type = rffi.UINT
else:
    socketfd_type = rffi.INT

CConfig.uint16_t = platform.SimpleType('uint16_t', rffi.USHORT)
CConfig.uint32_t = platform.SimpleType('uint32_t', rffi.UINT)
CConfig.size_t = platform.SimpleType('size_t', rffi.INT)
CConfig.ssize_t = platform.SimpleType('ssize_t', rffi.INT)
CConfig.socklen_t = platform.SimpleType('socklen_t', rffi.INT)
sockaddr_ptr = lltype.Ptr(lltype.ForwardReference())
addrinfo_ptr = lltype.Ptr(lltype.ForwardReference())

# struct types
CConfig.sockaddr = platform.Struct(
    'struct sockaddr', [('sa_family', rffi.INT),
                        ('sa_data', rffi.CFixedArray(rffi.CHAR, 1))])
CConfig.in_addr = platform.Struct('struct in_addr', [('s_addr', rffi.UINT)])
CConfig.in6_addr = platform.Struct(
    'struct in6_addr', [('s6_addr', rffi.CFixedArray(rffi.CHAR, 16))])
CConfig.sockaddr_in = platform.Struct('struct sockaddr_in',
                                      [('sin_family', rffi.INT),
                                       ('sin_port', rffi.USHORT),
                                       ('sin_addr', CConfig.in_addr)])

CConfig.sockaddr_in6 = platform.Struct('struct sockaddr_in6',
                                       [('sin6_family', rffi.INT),
                                        ('sin6_port', rffi.USHORT),
                                        ('sin6_flowinfo', rffi.INT),
                                        ('sin6_addr', CConfig.in6_addr),
                                        ('sin6_scope_id', rffi.INT)])
Exemplo n.º 11
0

cconfig = rffi_platform.configure(CConfig)

HAS_CLOCK_GETTIME = cconfig["HAS_CLOCK_GETTIME"]

CLOCK_REALTIME = cconfig["CLOCK_REALTIME"]
CLOCK_MONOTONIC = cconfig["CLOCK_MONOTONIC"]
CLOCK_MONOTONIC_RAW = cconfig["CLOCK_MONOTONIC_RAW"]
CLOCK_PROCESS_CPUTIME_ID = cconfig["CLOCK_PROCESS_CPUTIME_ID"]
CLOCK_THREAD_CPUTIME_ID = cconfig["CLOCK_THREAD_CPUTIME_ID"]

if HAS_CLOCK_GETTIME:
    #redo it for timespec
    CConfig.TIMESPEC = rffi_platform.Struct("struct timespec", [
        ("tv_sec", rffi.TIME_T),
        ("tv_nsec", rffi.LONG),
    ])
    cconfig = rffi_platform.configure(CConfig)
    TIMESPEC = cconfig['TIMESPEC']

    c_clock_gettime = rffi.llexternal(
        "clock_gettime", [lltype.Signed, lltype.Ptr(TIMESPEC)],
        rffi.INT,
        compilation_info=CConfig._compilation_info_,
        releasegil=False,
        save_err=rffi.RFFI_SAVE_ERRNO)
    c_clock_getres = rffi.llexternal(
        "clock_getres", [lltype.Signed, lltype.Ptr(TIMESPEC)],
        rffi.INT,
        compilation_info=CConfig._compilation_info_,
        releasegil=False,
Exemplo n.º 12
0
class CConfigForClockGetTime:
    _compilation_info_ = ExternalCompilationInfo(includes=['time.h'],
                                                 libraries=libraries)
    TIMESPEC = rffi_platform.Struct('struct timespec',
                                    [('tv_sec', rffi.LONG),
                                     ('tv_nsec', rffi.LONG)])
Exemplo n.º 13
0
 class CConfig:
     _compilation_info_ = eci
     DIRENT = platform.Struct(
         "struct dirent", [("d_name", lltype.FixedSizeArray(rffi.CHAR, 1))])
Exemplo n.º 14
0
class CConfig:
    _compilation_info_ = eci
    TIMEVAL = platform.Struct("struct timeval", [("tv_sec", rffi.LONG),
                                                 ("tv_usec", rffi.LONG)])
    TIMEZONE = platform.Struct("struct timezone", [])
Exemplo n.º 15
0
    class CConfigGlobal:
        _compilation_info_ = ExternalCompilationInfo(
            includes = ['windows.h', 'winbase.h', 'sys/stat.h', 'fcntl.h'],
        )
        ERROR_FILE_NOT_FOUND = platform.ConstantInteger(
            'ERROR_FILE_NOT_FOUND')
        ERROR_NO_MORE_FILES = platform.ConstantInteger(
            'ERROR_NO_MORE_FILES')

        GetFileExInfoStandard = platform.ConstantInteger(
            'GetFileExInfoStandard')
        FILE_ATTRIBUTE_DIRECTORY = platform.ConstantInteger(
            'FILE_ATTRIBUTE_DIRECTORY')
        FILE_ATTRIBUTE_READONLY = platform.ConstantInteger(
            'FILE_ATTRIBUTE_READONLY')
        INVALID_FILE_ATTRIBUTES = platform.ConstantInteger(
            'INVALID_FILE_ATTRIBUTES')
        ERROR_SHARING_VIOLATION = platform.ConstantInteger(
            'ERROR_SHARING_VIOLATION')
        ERROR_ACCESS_DENIED = platform.ConstantInteger('ERROR_ACCESS_DENIED')
        ERROR_CANT_ACCESS_FILE = platform.ConstantInteger(
            'ERROR_CANT_ACCESS_FILE')
        ERROR_INVALID_PARAMETER = platform.ConstantInteger(
            'ERROR_INVALID_PARAMETER')
        ERROR_NOT_SUPPORTED = platform.ConstantInteger(
            'ERROR_NOT_SUPPORTED')
        ERROR_INVALID_FUNCTION = platform.ConstantInteger(
            'ERROR_INVALID_FUNCTION')
        MOVEFILE_REPLACE_EXISTING = platform.ConstantInteger(
            'MOVEFILE_REPLACE_EXISTING')
        _S_IFDIR = platform.ConstantInteger('_S_IFDIR')
        _S_IFREG = platform.ConstantInteger('_S_IFREG')
        _S_IFCHR = platform.ConstantInteger('_S_IFCHR')
        _S_IFIFO = platform.ConstantInteger('_S_IFIFO')
        _O_APPEND = platform.ConstantInteger('_O_APPEND')
        _O_CREAT  = platform.ConstantInteger('_O_CREAT')
        _O_EXCL   = platform.ConstantInteger('_O_EXCL')
        _O_RDONLY = platform.ConstantInteger('_O_RDONLY')
        _O_RDWR   = platform.ConstantInteger('_O_RDWR')
        _O_TRUNC  = platform.ConstantInteger('_O_TRUNC')
        _O_WRONLY = platform.ConstantInteger('_O_WRONLY')
        _O_BINARY = platform.ConstantInteger('_O_BINARY')
        FILE_TYPE_UNKNOWN = platform.ConstantInteger('FILE_TYPE_UNKNOWN')
        FILE_TYPE_CHAR = platform.ConstantInteger('FILE_TYPE_CHAR')
        FILE_TYPE_PIPE = platform.ConstantInteger('FILE_TYPE_PIPE')
        FILE_TYPE_DISK = platform.ConstantInteger('FILE_TYPE_DISK')
        FILE_READ_ATTRIBUTES = platform.ConstantInteger('FILE_READ_ATTRIBUTES')
        FILE_WRITE_ATTRIBUTES = platform.ConstantInteger(
            'FILE_WRITE_ATTRIBUTES')
        GENERIC_READ = platform.ConstantInteger('GENERIC_READ')
        FILE_SHARE_READ = platform.ConstantInteger('FILE_SHARE_READ')
        FILE_SHARE_WRITE = platform.ConstantInteger('FILE_SHARE_WRITE')
        OPEN_EXISTING = platform.ConstantInteger('OPEN_EXISTING')
        FILE_ATTRIBUTE_NORMAL = platform.ConstantInteger(
            'FILE_ATTRIBUTE_NORMAL')
        FILE_FLAG_BACKUP_SEMANTICS = platform.ConstantInteger(
            'FILE_FLAG_BACKUP_SEMANTICS')
        FILE_FLAG_OPEN_REPARSE_POINT = platform.ConstantInteger(
            'FILE_FLAG_OPEN_REPARSE_POINT')
        FILE_ATTRIBUTE_REPARSE_POINT = platform.ConstantInteger(
            'FILE_ATTRIBUTE_REPARSE_POINT')
        FileAttributeTagInfo = platform.ConstantInteger('FileAttributeTagInfo')
        VOLUME_NAME_DOS = platform.ConstantInteger('VOLUME_NAME_DOS')
        VOLUME_NAME_NT = platform.ConstantInteger('VOLUME_NAME_NT')

        WIN32_FILE_ATTRIBUTE_DATA = platform.Struct(
            'WIN32_FILE_ATTRIBUTE_DATA',
            [('dwFileAttributes', rwin32.DWORD),
             ('nFileSizeHigh', rwin32.DWORD),
             ('nFileSizeLow', rwin32.DWORD),
             ('ftCreationTime', rwin32.FILETIME),
             ('ftLastAccessTime', rwin32.FILETIME),
             ('ftLastWriteTime', rwin32.FILETIME)])

        BY_HANDLE_FILE_INFORMATION = platform.Struct(
            'BY_HANDLE_FILE_INFORMATION',
            [('dwFileAttributes', rwin32.DWORD),
             ('ftCreationTime', rwin32.FILETIME),
             ('ftLastAccessTime', rwin32.FILETIME),
             ('ftLastWriteTime', rwin32.FILETIME),
             ('dwVolumeSerialNumber', rwin32.DWORD),
             ('nFileSizeHigh', rwin32.DWORD),
             ('nFileSizeLow', rwin32.DWORD),
             ('nNumberOfLinks', rwin32.DWORD),
             ('nFileIndexHigh', rwin32.DWORD),
             ('nFileIndexLow', rwin32.DWORD)])

        FILE_ATTRIBUTE_TAG_INFO = platform.Struct(
            'FILE_ATTRIBUTE_TAG_INFO',
            [('FileAttributes', rwin32.DWORD),
             ('ReparseTag', rwin32.DWORD)])
Exemplo n.º 16
0
class CConfig(object):
    timelib_tzdb = platform.Struct('timelib_tzdb', ([
        ('version', rffi.CCHARP),
        ('index_size', rffi.INT),
        ('index', timelib_tzdb_index_entryP),
        ('data', rffi.CArrayPtr(rffi.UCHAR)),
    ]))
    timelib_error_container = platform.Struct(
        'timelib_error_container',
        [('error_count', lltype.Signed),
         ('error_messages', rffi.CArrayPtr(timelib_error_message)),
         ('warning_count', lltype.Signed)])
    timelib_time = platform.Struct('timelib_time', ([
        ('y', lltype.Signed),
        ('m', lltype.Signed),
        ('d', lltype.Signed),
        ('h', lltype.Signed),
        ('i', lltype.Signed),
        ('s', lltype.Signed),
        ('f', lltype.Float),
        ('z', lltype.Signed),
        ('tz_abbr', rffi.CCHARP),
        ('tz_info', timelib_tzinfo),
        ('dst', lltype.Signed),
        ('relative', timelib_rel_timeP.TO),
        ('sse', lltype.Signed),
        ('have_time', lltype.Unsigned),
        ('have_date', lltype.Unsigned),
        ('have_relative', lltype.Unsigned),
        ('have_weeknr_day', lltype.Unsigned),
        ('sse_uptodate', lltype.Unsigned),
        ('tim_uptodate', lltype.Unsigned),
        ('zone_type', lltype.Signed),
        ('is_localtime', lltype.Signed),
    ]))
    timelib_time_offset = platform.Struct(
        'timelib_time_offset', [('offset', lltype.Signed),
                                ('leap_secs', rffi.UINT),
                                ('is_dst', rffi.UINT), ('abbr', rffi.CCHARP),
                                ('transistion_time', lltype.Signed)])

    timelib_tz_lookup_table = platform.Struct('timelib_tz_lookup_table', [
        ('name', rffi.CCHARP),
        ('type', lltype.Signed),
        ('gmtoffset', lltype.SingleFloat),
        ('full_tz_name', rffi.CCHARP),
    ])

    timelib_tz_lookup_table = platform.Struct('timelib_tz_lookup_table', [
        ('name', rffi.CCHARP),
        ('type', lltype.Signed),
        ('gmtoffset', lltype.SingleFloat),
        ('full_tz_name', rffi.CCHARP),
    ])

    TIMELIB_NO_CLONE = platform.DefinedConstantInteger('TIMELIB_NO_CLONE')

    TIMELIB_ZONETYPE_ID = platform.DefinedConstantInteger(
        'TIMELIB_ZONETYPE_ID')
    TIMELIB_ZONETYPE_ABBR = platform.DefinedConstantInteger(
        'TIMELIB_ZONETYPE_ABBR')
    TIMELIB_ZONETYPE_OFFSET = platform.DefinedConstantInteger(
        'TIMELIB_ZONETYPE_OFFSET')

    _compilation_info_ = eci
Exemplo n.º 17
0
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper.tool import rffi_platform
from rpython.rlib._rsocket_rffi import socketclose, FD_SETSIZE
from rpython.rlib.rposix import get_saved_errno
from rpython.rlib.rarithmetic import intmask
from rpython.translator.tool.cbuild import ExternalCompilationInfo

eci = ExternalCompilationInfo(includes=['sys/epoll.h'])


class CConfig:
    _compilation_info_ = eci


CConfig.epoll_data = rffi_platform.Struct("union epoll_data", [
    ("fd", rffi.INT),
])
CConfig.epoll_event = rffi_platform.Struct("struct epoll_event",
                                           [("events", rffi.UINT),
                                            ("data", CConfig.epoll_data)])

public_symbols = dict.fromkeys([
    "EPOLLIN", "EPOLLOUT", "EPOLLPRI", "EPOLLERR", "EPOLLHUP", "EPOLLET",
    "EPOLLONESHOT", "EPOLLRDNORM", "EPOLLRDBAND", "EPOLLWRNORM", "EPOLLWRBAND",
    "EPOLLMSG"
])
for symbol in public_symbols:
    setattr(CConfig, symbol, rffi_platform.DefinedConstantInteger(symbol))

for symbol in ["EPOLL_CTL_ADD", "EPOLL_CTL_MOD", "EPOLL_CTL_DEL"]:
    setattr(CConfig, symbol, rffi_platform.ConstantInteger(symbol))
Exemplo n.º 18
0
class CConfig:
    _compilation_info_ = eci
    GOST_CTX = platform.Struct('GOST_CTX', [])
Exemplo n.º 19
0
def setup():
    INSPECT = {
        'b': 'signed char',
        'h': 'signed short',
        'i': 'signed int',
        'l': 'signed long',
        'q': 'signed long long',
        'n': 'ssize_t',
        'B': 'unsigned char',
        'H': 'unsigned short',
        'I': 'unsigned int',
        'L': 'unsigned long',
        'Q': 'unsigned long long',
        'N': 'size_t',
        'P': 'char *',
        'f': 'float',
        'd': 'double',
        '?': '_Bool',
    }

    pre_include_bits = [
        """
        #include <sys/types.h>
        #ifdef _MSC_VER
        #define _Bool char
        typedef int ssize_t; /* XXX fixme for 64 bit*/
        typedef unsigned int size_t; /* XXX fixme for 64 bit*/
        #endif"""
    ]
    field_names = dict.fromkeys(INSPECT)
    for fmtchar, ctype in INSPECT.iteritems():
        field_name = ctype.replace(" ", "_").replace("*", "star")
        field_names[fmtchar] = field_name
        pre_include_bits.append("""
            struct about_%s {
                char pad;
                %s field;
            };
        """ % (field_name, ctype))

    class CConfig:
        _compilation_info_ = ExternalCompilationInfo(
            pre_include_bits=pre_include_bits)

    for fmtchar, ctype in INSPECT.items():
        setattr(
            CConfig, field_names[fmtchar],
            rffi_platform.Struct(
                "struct about_%s" % (field_names[fmtchar], ),
                [('field', lltype.FixedSizeArray(rffi.CHAR, 1))]))

    cConfig = rffi_platform.configure(CConfig)

    for fmtchar, ctype in INSPECT.items():
        S = cConfig[field_names[fmtchar]]
        alignment = rffi.offsetof(S, 'c_field')
        size = rffi.sizeof(S.c_field)
        signed = 'a' <= fmtchar <= 'z'

        if fmtchar == 'f':
            pack = pack_float
            unpack = std.unpack_float
        elif fmtchar == 'd':
            pack = pack_double
            unpack = std.unpack_double
        elif fmtchar == '?':
            pack = std.pack_bool
            unpack = std.unpack_bool
        else:
            pack = std.make_int_packer(size, signed)
            unpack = std.make_int_unpacker(size, signed)

        native_fmttable[fmtchar] = {
            'size': size,
            'alignment': alignment,
            'pack': pack,
            'unpack': unpack
        }
Exemplo n.º 20
0
    _includes.append('mach/mach_time.h')


class CConfig:
    _compilation_info_ = ExternalCompilationInfo(includes=_includes,
                                                 libraries=rtime.libraries)
    CLOCKS_PER_SEC = platform.ConstantInteger("CLOCKS_PER_SEC")
    has_gettimeofday = platform.Has('gettimeofday')


HAS_TM_ZONE = False

if _POSIX:
    calling_conv = 'c'
    CConfig.timeval = platform.Struct("struct timeval",
                                      [("tv_sec", rffi.INT),
                                       ("tv_usec", rffi.INT)])
    if _CYGWIN:
        CConfig.tm = platform.Struct("struct tm", [("tm_sec", rffi.INT),
                                                   ("tm_min", rffi.INT),
                                                   ("tm_hour", rffi.INT),
                                                   ("tm_mday", rffi.INT),
                                                   ("tm_mon", rffi.INT),
                                                   ("tm_year", rffi.INT),
                                                   ("tm_wday", rffi.INT),
                                                   ("tm_yday", rffi.INT),
                                                   ("tm_isdst", rffi.INT)])
    else:
        CConfig.tm = platform.Struct("struct tm", [("tm_sec", rffi.INT),
                                                   ("tm_min", rffi.INT),
                                                   ("tm_hour", rffi.INT),
Exemplo n.º 21
0
 class CConfig:
     _compilation_info_ = eci
     STRUCT = rffi_platform.Struct("foobar_t", [("c1", Signed),
                                                ("s1", Signed),
                                                ("l3", Signed)])
Exemplo n.º 22
0
class CConfig:
    _compilation_info_ = eci

    SSLEAY_VERSION = rffi_platform.DefinedConstantString(
        "SSLEAY_VERSION", "SSLeay_version(SSLEAY_VERSION)")
    OPENSSL_NO_SSL2 = rffi_platform.Defined("OPENSSL_NO_SSL2")
    OPENSSL_NO_SSL3 = rffi_platform.Defined("OPENSSL_NO_SSL3")
    OPENSSL_NO_ECDH = rffi_platform.Defined("OPENSSL_NO_ECDH")
    OPENSSL_NPN_NEGOTIATED = rffi_platform.Defined("OPENSSL_NPN_NEGOTIATED")
    SSL_FILETYPE_PEM = rffi_platform.ConstantInteger("SSL_FILETYPE_PEM")
    SSL_FILETYPE_ASN1 = rffi_platform.ConstantInteger("SSL_FILETYPE_ASN1")
    SSL_OP_ALL = rffi_platform.ConstantInteger("SSL_OP_ALL")
    SSL_OP_NO_SSLv2 = rffi_platform.ConstantInteger("SSL_OP_NO_SSLv2")
    SSL_OP_NO_SSLv3 = rffi_platform.ConstantInteger("SSL_OP_NO_SSLv3")
    SSL_OP_NO_TLSv1 = rffi_platform.ConstantInteger("SSL_OP_NO_TLSv1")
    if HAVE_TLSv1_2:
        SSL_OP_NO_TLSv1_1 = rffi_platform.ConstantInteger("SSL_OP_NO_TLSv1_1")
        SSL_OP_NO_TLSv1_2 = rffi_platform.ConstantInteger("SSL_OP_NO_TLSv1_2")
    SSL_OP_CIPHER_SERVER_PREFERENCE = rffi_platform.ConstantInteger(
        "SSL_OP_CIPHER_SERVER_PREFERENCE")
    SSL_OP_SINGLE_DH_USE = rffi_platform.ConstantInteger(
        "SSL_OP_SINGLE_DH_USE")
    SSL_OP_SINGLE_ECDH_USE = rffi_platform.ConstantInteger(
        "SSL_OP_SINGLE_ECDH_USE")
    SSL_OP_NO_COMPRESSION = rffi_platform.DefinedConstantInteger(
        "SSL_OP_NO_COMPRESSION")
    SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = rffi_platform.ConstantInteger(
        "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS")
    HAS_SNI = rffi_platform.Defined("SSL_CTRL_SET_TLSEXT_HOSTNAME")
    HAS_NPN = rffi_platform.Defined("OPENSSL_NPN_NEGOTIATED")
    SSL_VERIFY_NONE = rffi_platform.ConstantInteger("SSL_VERIFY_NONE")
    SSL_VERIFY_PEER = rffi_platform.ConstantInteger("SSL_VERIFY_PEER")
    SSL_VERIFY_FAIL_IF_NO_PEER_CERT = rffi_platform.ConstantInteger(
        "SSL_VERIFY_FAIL_IF_NO_PEER_CERT")
    X509_V_FLAG_CRL_CHECK = rffi_platform.ConstantInteger(
        "X509_V_FLAG_CRL_CHECK")
    X509_V_FLAG_CRL_CHECK_ALL = rffi_platform.ConstantInteger(
        "X509_V_FLAG_CRL_CHECK_ALL")
    X509_V_FLAG_X509_STRICT = rffi_platform.ConstantInteger(
        "X509_V_FLAG_X509_STRICT")
    SSL_ERROR_WANT_READ = rffi_platform.ConstantInteger("SSL_ERROR_WANT_READ")
    SSL_ERROR_WANT_WRITE = rffi_platform.ConstantInteger(
        "SSL_ERROR_WANT_WRITE")
    SSL_ERROR_ZERO_RETURN = rffi_platform.ConstantInteger(
        "SSL_ERROR_ZERO_RETURN")
    SSL_ERROR_WANT_X509_LOOKUP = rffi_platform.ConstantInteger(
        "SSL_ERROR_WANT_X509_LOOKUP")
    SSL_ERROR_WANT_CONNECT = rffi_platform.ConstantInteger(
        "SSL_ERROR_WANT_CONNECT")
    SSL_ERROR_SYSCALL = rffi_platform.ConstantInteger("SSL_ERROR_SYSCALL")
    SSL_ERROR_SSL = rffi_platform.ConstantInteger("SSL_ERROR_SSL")
    SSL_RECEIVED_SHUTDOWN = rffi_platform.ConstantInteger(
        "SSL_RECEIVED_SHUTDOWN")
    SSL_MODE_AUTO_RETRY = rffi_platform.ConstantInteger("SSL_MODE_AUTO_RETRY")
    SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = rffi_platform.ConstantInteger(
        "SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER")
    SSL_TLSEXT_ERR_OK = rffi_platform.ConstantInteger("SSL_TLSEXT_ERR_OK")
    SSL_TLSEXT_ERR_ALERT_FATAL = rffi_platform.ConstantInteger(
        "SSL_TLSEXT_ERR_ALERT_FATAL")

    SSL_AD_INTERNAL_ERROR = rffi_platform.ConstantInteger(
        "SSL_AD_INTERNAL_ERROR")
    SSL_AD_HANDSHAKE_FAILURE = rffi_platform.ConstantInteger(
        "SSL_AD_HANDSHAKE_FAILURE")

    TLSEXT_NAMETYPE_host_name = rffi_platform.ConstantInteger(
        "TLSEXT_NAMETYPE_host_name")

    ERR_LIB_X509 = rffi_platform.ConstantInteger("ERR_LIB_X509")
    ERR_LIB_PEM = rffi_platform.ConstantInteger("ERR_LIB_PEM")
    ERR_LIB_ASN1 = rffi_platform.ConstantInteger("ERR_LIB_ASN1")
    PEM_R_NO_START_LINE = rffi_platform.ConstantInteger("PEM_R_NO_START_LINE")
    ASN1_R_HEADER_TOO_LONG = rffi_platform.ConstantInteger(
        "ASN1_R_HEADER_TOO_LONG")
    X509_R_CERT_ALREADY_IN_HASH_TABLE = rffi_platform.ConstantInteger(
        "X509_R_CERT_ALREADY_IN_HASH_TABLE")

    NID_undef = rffi_platform.ConstantInteger("NID_undef")
    NID_subject_alt_name = rffi_platform.ConstantInteger(
        "NID_subject_alt_name")
    NID_ad_OCSP = rffi_platform.ConstantInteger("NID_ad_OCSP")
    NID_ad_ca_issuers = rffi_platform.ConstantInteger("NID_ad_ca_issuers")
    NID_info_access = rffi_platform.ConstantInteger("NID_info_access")
    NID_X9_62_prime256v1 = rffi_platform.ConstantInteger(
        "NID_X9_62_prime256v1")
    NID_crl_distribution_points = rffi_platform.ConstantInteger(
        "NID_crl_distribution_points")
    GEN_DIRNAME = rffi_platform.ConstantInteger("GEN_DIRNAME")
    GEN_EMAIL = rffi_platform.ConstantInteger("GEN_EMAIL")
    GEN_DNS = rffi_platform.ConstantInteger("GEN_DNS")
    GEN_URI = rffi_platform.ConstantInteger("GEN_URI")
    GEN_OTHERNAME = rffi_platform.ConstantInteger("GEN_OTHERNAME")
    GEN_X400 = rffi_platform.ConstantInteger("GEN_X400")
    GEN_EDIPARTY = rffi_platform.ConstantInteger("GEN_EDIPARTY")
    GEN_IPADD = rffi_platform.ConstantInteger("GEN_IPADD")
    GEN_RID = rffi_platform.ConstantInteger("GEN_RID")

    CRYPTO_LOCK = rffi_platform.ConstantInteger("CRYPTO_LOCK")

    OBJ_NAME_TYPE_MD_METH = rffi_platform.ConstantInteger(
        "OBJ_NAME_TYPE_MD_METH")

    if OPENSSL_VERSION_NUMBER >= 0x10001000:
        X509_st = rffi_platform.Struct('struct x509_st',
                                       [('crldp', stack_st_DIST_POINT)])

    # Some structures, with only the fields used in the _ssl module
    X509_name_entry_st = rffi_platform.Struct('struct X509_name_entry_st',
                                              [('set', rffi.INT)])
    asn1_string_st = rffi_platform.Struct('struct asn1_string_st',
                                          [('length', rffi.INT),
                                           ('data', rffi.CCHARP)])
    X509_extension_st = rffi_platform.Struct('struct X509_extension_st',
                                             [('value', ASN1_STRING)])
    x509_store_st = rffi_platform.Struct('struct x509_store_st',
                                         [('objs', stack_st_X509_OBJECT),
                                          ('param', X509_VERIFY_PARAM)])
    x509_object_st = rffi_platform.Struct('struct x509_object_st',
                                          [('type', rffi.INT)])

    X509_LU_X509 = rffi_platform.ConstantInteger("X509_LU_X509")
    X509_LU_CRL = rffi_platform.ConstantInteger("X509_LU_CRL")

    X509V3_EXT_D2I = lltype.FuncType([rffi.VOIDP, rffi.CCHARPP, rffi.LONG],
                                     rffi.VOIDP)
    v3_ext_method = rffi_platform.Struct('struct v3_ext_method',
                                         [('it', ASN1_ITEM_EXP),
                                          ('d2i', lltype.Ptr(X509V3_EXT_D2I))])
    GENERAL_NAME_st = rffi_platform.Struct('struct GENERAL_NAME_st',
                                           [('type', rffi.INT)])
    EVP_MD_st = rffi_platform.Struct('EVP_MD', [('md_size', rffi.INT),
                                                ('block_size', rffi.INT)])
    EVP_MD_SIZE = rffi_platform.SizeOf('EVP_MD')
    EVP_MD_CTX_SIZE = rffi_platform.SizeOf('EVP_MD_CTX')

    OBJ_NAME_st = rffi_platform.Struct('OBJ_NAME', [
        ('alias', rffi.INT),
        ('name', rffi.CCHARP),
    ])

    COMP_METHOD_st = rffi_platform.Struct('struct comp_method_st', [
        ('type', rffi.INT),
    ])

    ACCESS_DESCRIPTION_st = rffi_platform.Struct(
        'struct ACCESS_DESCRIPTION_st', [
            ('method', ASN1_OBJECT),
            ('location', GENERAL_NAME),
        ])
Exemplo n.º 23
0
                                 _as_bytes0)

_WIN32 = sys.platform.startswith('win')
_LINUX = sys.platform.startswith('linux')

if _WIN32:
    from rpython.rlib import rwin32
    from rpython.rlib.rwin32file import make_win32_traits

# Support for float times is here.
# - ALL_STAT_FIELDS contains Float fields if the system can retrieve
#   sub-second timestamps.
# - TIMESPEC is defined when the "struct stat" contains st_atim field.

if sys.platform.startswith('linux') or sys.platform.startswith('openbsd'):
    TIMESPEC = platform.Struct('struct timespec', [('tv_sec', rffi.TIME_T),
                                                   ('tv_nsec', rffi.LONG)])
else:
    TIMESPEC = None

# all possible fields - some of them are not available on all platforms
ALL_STAT_FIELDS = [
    ("st_mode", lltype.Signed),
    ("st_ino", lltype.SignedLongLong),
    ("st_dev", lltype.SignedLongLong),
    ("st_nlink", lltype.Signed),
    ("st_uid", lltype.Signed),
    ("st_gid", lltype.Signed),
    ("st_size", lltype.SignedLongLong),
    ("st_atime", lltype.Float),
    ("st_mtime", lltype.Float),
    ("st_ctime", lltype.Float),
Exemplo n.º 24
0
RESULT_FAIL = 1
RESULT_SUCCESS = 0

Token = namedtuple('Token', 'token_id start end status')
INVALID_NEXT_STATE = -1

eci = ExternalCompilationInfo(includes=[
    'vm_headers.h',
],
                              include_dirs=[
                                  '/home/magniff/workspace/rere/rere/build',
                              ])

RegexTransition = rffi_platform.Struct('RegexTransition', [
    ('input', rffi.ULONGLONG),
    ('output', rffi.ULONGLONG),
    ('value', rffi.CHAR),
])

Regex = rffi_platform.Struct('Regex', [
    ('regex_id', rffi.ULONGLONG),
    ('init_state', rffi.ULONGLONG),
    ('count', rffi.ULONGLONG),
    ('transitions', rffi.VOIDP),
])

RegexList = rffi_platform.Struct('RegexList', [
    ('count', rffi.ULONGLONG),
    ('regex', rffi.VOIDP),
])
Exemplo n.º 25
0
    pre_include_bits=["#define PYPY_SIGINT_INTERRUPT_EVENT 1\n"],
)


class CConfig:
    _compilation_info_ = eci


if sys.platform != 'win32':
    for name in """
        ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF
        SIG_BLOCK SIG_UNBLOCK SIG_SETMASK""".split():
        setattr(CConfig, name, rffi_platform.DefinedConstantInteger(name))

    CConfig.timeval = rffi_platform.Struct('struct timeval',
                                           [('tv_sec', rffi.LONG),
                                            ('tv_usec', rffi.LONG)])

    CConfig.itimerval = rffi_platform.Struct(
        'struct itimerval', [('it_value', CConfig.timeval),
                             ('it_interval', CConfig.timeval)])

for k, v in rffi_platform.configure(CConfig).items():
    globals()[k] = v


def external(name, args, result, **kwds):
    return rffi.llexternal(name,
                           args,
                           result,
                           compilation_info=eci,
Exemplo n.º 26
0
class CConfig:
    _compilation_info_ = eci
    CRC32_CTX = platform.Struct('CRC32_CTX', [])
Exemplo n.º 27
0
_includes = ["time.h"]
if _POSIX:
    _includes.append('sys/time.h')


class CConfig:
    _compilation_info_ = ExternalCompilationInfo(includes=_includes)
    CLOCKS_PER_SEC = platform.ConstantInteger("CLOCKS_PER_SEC")
    clock_t = platform.SimpleType("clock_t", rffi.ULONG)
    has_gettimeofday = platform.Has('gettimeofday')


if _POSIX:
    calling_conv = 'c'
    CConfig.timeval = platform.Struct("struct timeval",
                                      [("tv_sec", rffi.INT),
                                       ("tv_usec", rffi.INT)])
    if _CYGWIN:
        CConfig.tm = platform.Struct("struct tm", [("tm_sec", rffi.INT),
                                                   ("tm_min", rffi.INT),
                                                   ("tm_hour", rffi.INT),
                                                   ("tm_mday", rffi.INT),
                                                   ("tm_mon", rffi.INT),
                                                   ("tm_year", rffi.INT),
                                                   ("tm_wday", rffi.INT),
                                                   ("tm_yday", rffi.INT),
                                                   ("tm_isdst", rffi.INT)])
    else:
        CConfig.tm = platform.Struct("struct tm", [("tm_sec", rffi.INT),
                                                   ("tm_min", rffi.INT),
                                                   ("tm_hour", rffi.INT),
Exemplo n.º 28
0
class CConfig:
    _compilation_info_ = eci

    timespec_t = rffi_platform.Struct("uv_timespec_t", [
        ("tv_sec",  rffi.LONG),
        ("tv_nsec", rffi.LONG)])

    stat_t = rffi_platform.Struct("uv_stat_t", [
        ("st_dev",      uint64_t  ),
        ("st_mode",     uint64_t  ),
        ("st_nlink",    uint64_t  ),
        ("st_uid",      uint64_t  ),
        ("st_gid",      uint64_t  ),
        ("st_rdev",     uint64_t  ),
        ("st_ino",      uint64_t  ),
        ("st_size",     uint64_t  ),
        ("st_blksize",  uint64_t  ),
        ("st_blocks",   uint64_t  ),
        ("st_flags",    uint64_t  ),
        ("st_gen",      uint64_t  ),
        ("st_atim",     timespec_t),
        ("st_mtim",     timespec_t),
        ("st_ctim",     timespec_t),
        ("st_birthtim", timespec_t)])

    #dirent_type_t = rffi_platform.SimpleType("uv_dirent_type_t", rffi.INT)
    dirent_t = rffi_platform.Struct("uv_dirent_t", [
        ("name", rffi.CCHARP),
        ("type", rffi.INT)])

    sockaddr = rffi_platform.Struct("struct sockaddr", [
        ("sa_family", rffi.USHORT)])

    handle_t = rffi_platform.Struct("uv_handle_t", [("data", rffi.VOIDP)])
    stream_t = rffi_platform.Struct("uv_stream_t", [("data", rffi.VOIDP)])
    tcp_t    = rffi_platform.Struct("uv_tcp_t",    [("data", rffi.VOIDP)])
    udp_t    = rffi_platform.Struct("uv_udp_t",    [("data", rffi.VOIDP)])
    pipe_t   = rffi_platform.Struct("uv_pipe_t",   [("data", rffi.VOIDP)])
    tty_t    = rffi_platform.Struct("uv_tty_t",    [("data", rffi.VOIDP)])
    poll_t   = rffi_platform.Struct("uv_poll_t",   [("data", rffi.VOIDP)])
    timer_t  = rffi_platform.Struct("uv_timer_t",  [("data", rffi.VOIDP)])
    prepare_t = rffi_platform.Struct("uv_prepare_t", [("data", rffi.VOIDP)])
    check_t   = rffi_platform.Struct("uv_check_t",   [("data", rffi.VOIDP)])
    idle_t    = rffi_platform.Struct("uv_idle_t",    [("data", rffi.VOIDP)])
    async_t   = rffi_platform.Struct("uv_async_t",   [("data", rffi.VOIDP)])
    process_t = rffi_platform.Struct("uv_process_t", [
        ("data", rffi.VOIDP),
        ("pid",  rffi.INT)])

    uid_t = rffi_platform.SimpleType("uv_uid_t", rffi.ULONG)
    gid_t = rffi_platform.SimpleType("uv_gid_t", rffi.ULONG)

    # the rffi of rpython doesn't seem to support unions.
    stdio_container_t = rffi_platform.Struct("uv_stdio_container_t", [
        ("flags", stdio_flags)])

    #loop_t = rffi_platform.Struct("uv_loop_t", [("data", rffi.VOIDP)])
    process_options_t = rffi_platform.Struct("uv_process_options_t", [
        ("exit_cb", exit_cb),
        ("file", rffi.CCHARP),
        ("args", rffi.CCHARPP),
        ("env", rffi.CCHARPP),
        ("cwd", rffi.CCHARP),
        ("flags", rffi.UINT),
        ("stdio_count", rffi.INT),
        ("stdio", lltype.Ptr(lltype.ForwardReference())),
        ("uid", rffi.ULONG),
        ("gid", rffi.ULONG)])

    connect_t  = rffi_platform.Struct("uv_connect_t",  [("data", rffi.VOIDP)])
    udp_send_t = rffi_platform.Struct("uv_udp_send_t", [("data", rffi.VOIDP)])
    #                                 [("handle",
    #                                   lltype.Ptr(lltype.ForwardReference()))])
    #shutdown_t = rffi_platform.Struct("uv_shutdown_t", [])
    fs_event_t  = rffi_platform.Struct("uv_fs_event_t", [("data", rffi.VOIDP)])
    fs_poll_t   = rffi_platform.Struct("uv_fs_poll_t",  [("data", rffi.VOIDP)])
    signal_t    = rffi_platform.Struct("uv_signal_t",   [("data", rffi.VOIDP)])

    shutdown_t = rffi_platform.Struct("uv_shutdown_t", [("data", rffi.VOIDP)])
    write_t = rffi_platform.Struct("uv_write_t", [("data", rffi.VOIDP)])

    fs_t = rffi_platform.Struct("uv_fs_t", [
        ("data", rffi.VOIDP),
        ("path", rffi.CONST_CCHARP),
        ("result", rffi.SSIZE_T),
        ("statbuf", stat_t),
        ("ptr", rffi.VOIDP)])
    uv_getaddrinfo_t = rffi_platform.Struct("uv_getaddrinfo_t", [("data", rffi.VOIDP)])
    uv_getnameinfo_t = rffi_platform.Struct("uv_getnameinfo_t", [("data", rffi.VOIDP)])
    buf_t = rffi_platform.Struct("uv_buf_t", [
        ("base", rffi.CCHARP),
        ("len", rffi.SIZE_T)])

    sockaddr_storage = rffi_platform.Struct("struct sockaddr_storage", [])
    addrinfo = rffi_platform.Struct("struct addrinfo", [
        ("ai_flags", rffi.INT),
        ("ai_family", rffi.INT),
        ("ai_socktype", rffi.INT),
        ("ai_protocol", rffi.INT),
        ("ai_addrlen", rffi.SIZE_T),
        ("ai_addr", rffi.VOIDP), # struct sockaddr*
        ("ai_canonname", rffi.CCHARP),
        ("ai_next", rffi.VOIDP),
    ])

    UV_EOF = rffi_platform.ConstantInteger("UV_EOF")
    UV_ECANCELED = rffi_platform.ConstantInteger("UV_ECANCELED")

    AF_UNSPEC = rffi_platform.ConstantInteger("AF_UNSPEC")
    AF_INET = rffi_platform.ConstantInteger("AF_INET")
    AF_INET6 = rffi_platform.ConstantInteger("AF_INET6")
    SOCK_STREAM = rffi_platform.ConstantInteger("SOCK_STREAM")
    SOCK_DGRAM = rffi_platform.ConstantInteger("SOCK_DGRAM")
    AI_V4MAPPED = rffi_platform.ConstantInteger("AI_V4MAPPED")
    AI_ADDRCONFIG = rffi_platform.ConstantInteger("AI_ADDRCONFIG")
    AI_NUMERICHOST = rffi_platform.ConstantInteger("AI_NUMERICHOST")
    AI_PASSIVE = rffi_platform.ConstantInteger("AI_PASSIVE")
    #TCP_IPV6ONLY = rffi_platform.ConstantInteger("TCP_IPV6ONLY")
    AI_NUMERICHOST = rffi_platform.ConstantInteger("AI_NUMERICHOST")
    AI_PASSIVE = rffi_platform.ConstantInteger("AI_PASSIVE")
    INADDR_ANY = rffi_platform.ConstantInteger("INADDR_ANY")
    #IN6ADDR_ANY_INIT = rffi_platform.ConstantInteger("IN6ADDR_ANY_INIT")
    INADDR_LOOPBACK = rffi_platform.ConstantInteger("INADDR_LOOPBACK")
    #IN6ADDR_LOOPBACK_INIT = rffi_platform.ConstantInteger("IN6ADDR_LOOPBACK_INIT")
    AI_NUMERICSERV = rffi_platform.ConstantInteger("AI_NUMERICSERV")
    AI_CANONNAME = rffi_platform.ConstantInteger("AI_CANONNAME")
    NI_NAMEREQD = rffi_platform.ConstantInteger("NI_NAMEREQD")
    NI_DGRAM = rffi_platform.ConstantInteger("NI_DGRAM")
    NI_NOFQDN = rffi_platform.ConstantInteger("NI_NOFQDN")
    NI_NUMERICHOST = rffi_platform.ConstantInteger("NI_NUMERICHOST")
    NI_NUMERICSERV = rffi_platform.ConstantInteger("NI_NUMERICSERV")

    # TODO: decide what to do for these (more below).
    #NI_IDN = rffi_platform.ConstantInteger("NI_IDN")
    #NI_IDN_ALLOW_UNASSIGNED = rffi_platform.ConstantInteger("NI_IDN_ALLOW_UNASSIGNED")
    #NI_IDN_USE_STD3_ASCII_RULES = rffi_platform.ConstantInteger("NI_IDN_USE_STD3_ASCII_RULES")
    #AI_IDN = rffi_platform.ConstantInteger("AI_IDN")
    #AI_CANONIDN = rffi_platform.ConstantInteger("AI_CANONIDN")
    #AI_IDN_ALLOW_UNASSIGNED = rffi_platform.ConstantInteger("AI_IDN_ALLOW_UNASSIGNED")
    #AI_IDN_USE_STD3_ASCII_RULES = rffi_platform.ConstantInteger("AI_IDN_USE_STD3_ASCII_RULES")

    INET6_ADDRSTRLEN = rffi_platform.ConstantInteger("INET6_ADDRSTRLEN")

    # Add _ in front if these aren't on the Win32
    O_RDONLY = rffi_platform.ConstantInteger("O_RDONLY")
    O_WRONLY = rffi_platform.ConstantInteger("O_WRONLY")
    O_RDWR = rffi_platform.ConstantInteger("O_RDWR")
    O_APPEND = rffi_platform.ConstantInteger("O_APPEND")
    O_CREAT = rffi_platform.ConstantInteger("O_CREAT")
    O_EXCL = rffi_platform.ConstantInteger("O_EXCL")
    O_TRUNC = rffi_platform.ConstantInteger("O_TRUNC")

    for name in error_names:
        locals()[name] = rffi_platform.ConstantInteger("UV_"+name)
Exemplo n.º 29
0
class CConfig:
    _compilation_info_ = eci

    if WIN32:
        DWORD_PTR = rffi_platform.SimpleType("DWORD_PTR", rffi.LONG)
        WORD = rffi_platform.SimpleType("WORD", rffi.USHORT)
        DWORD = rffi_platform.SimpleType("DWORD", rffi.UINT)
        BOOL = rffi_platform.SimpleType("BOOL", rffi.LONG)
        BYTE = rffi_platform.SimpleType("BYTE", rffi.UCHAR)
        WCHAR = rffi_platform.SimpleType("WCHAR", rffi.UCHAR)
        INT = rffi_platform.SimpleType("INT", rffi.INT)
        LONG = rffi_platform.SimpleType("LONG", rffi.LONG)
        PLONG = rffi_platform.SimpleType("PLONG", rffi.LONGP)
        LPVOID = rffi_platform.SimpleType("LPVOID", rffi.INTP)
        LPCVOID = rffi_platform.SimpleType("LPCVOID", rffi.VOIDP)
        LPSTR = rffi_platform.SimpleType("LPSTR", rffi.CCHARP)
        LPCSTR = rffi_platform.SimpleType("LPCSTR", rffi.CCHARP)
        LPWSTR = rffi_platform.SimpleType("LPWSTR", rffi.CWCHARP)
        LPCWSTR = rffi_platform.SimpleType("LPCWSTR", rffi.CWCHARP)
        LPDWORD = rffi_platform.SimpleType("LPDWORD", rffi.UINTP)
        LPWORD = rffi_platform.SimpleType("LPWORD", rffi.USHORTP)
        LPBOOL = rffi_platform.SimpleType("LPBOOL", rffi.LONGP)
        LPBYTE = rffi_platform.SimpleType("LPBYTE", rffi.UCHARP)
        SIZE_T = rffi_platform.SimpleType("SIZE_T", rffi.SIZE_T)
        ULONG_PTR = rffi_platform.SimpleType("ULONG_PTR", rffi.ULONG)

        HRESULT = rffi_platform.SimpleType("HRESULT", rffi.LONG)
        HLOCAL = rffi_platform.SimpleType("HLOCAL", rffi.VOIDP)

        FILETIME = rffi_platform.Struct('FILETIME',
                                        [('dwLowDateTime', rffi.UINT),
                                         ('dwHighDateTime', rffi.UINT)])
        SYSTEMTIME = rffi_platform.Struct('SYSTEMTIME', [])

        Struct = rffi_platform.Struct
        COORD = Struct("COORD", [("X", rffi.SHORT), ("Y", rffi.SHORT)])

        SMALL_RECT = Struct("SMALL_RECT", [("Left", rffi.SHORT),
                                           ("Top", rffi.SHORT),
                                           ("Right", rffi.SHORT),
                                           ("Bottom", rffi.SHORT)])

        CONSOLE_SCREEN_BUFFER_INFO = Struct("CONSOLE_SCREEN_BUFFER_INFO",
                                            [("dwSize", COORD),
                                             ("dwCursorPosition", COORD),
                                             ("wAttributes", WORD.ctype_hint),
                                             ("srWindow", SMALL_RECT),
                                             ("dwMaximumWindowSize", COORD)])

        OSVERSIONINFOEX = rffi_platform.Struct('OSVERSIONINFOEX', [
            ('dwOSVersionInfoSize', rffi.UINT),
            ('dwMajorVersion', rffi.UINT),
            ('dwMinorVersion', rffi.UINT),
            ('dwBuildNumber', rffi.UINT),
            ('dwPlatformId', rffi.UINT),
            ('szCSDVersion', rffi.CFixedArray(lltype.Char, 1)),
            ('wServicePackMajor', rffi.USHORT),
            ('wServicePackMinor', rffi.USHORT),
            ('wSuiteMask', rffi.USHORT),
            ('wProductType', rffi.UCHAR),
        ])

        LPSECURITY_ATTRIBUTES = rffi_platform.SimpleType(
            "LPSECURITY_ATTRIBUTES", rffi.CCHARP)

        DEFAULT_LANGUAGE = rffi_platform.ConstantInteger(
            "MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)")

        defines = """FORMAT_MESSAGE_ALLOCATE_BUFFER FORMAT_MESSAGE_FROM_SYSTEM
                       MAX_PATH _MAX_ENV FORMAT_MESSAGE_IGNORE_INSERTS
                       WAIT_OBJECT_0 WAIT_TIMEOUT INFINITE
                       ERROR_INVALID_HANDLE
                       DELETE READ_CONTROL SYNCHRONIZE WRITE_DAC
                       WRITE_OWNER PROCESS_ALL_ACCESS
                       PROCESS_CREATE_PROCESS PROCESS_CREATE_THREAD
                       PROCESS_DUP_HANDLE PROCESS_QUERY_INFORMATION
                       PROCESS_SET_QUOTA
                       PROCESS_SUSPEND_RESUME PROCESS_TERMINATE
                       PROCESS_VM_OPERATION PROCESS_VM_READ
                       PROCESS_VM_WRITE
                       CTRL_C_EVENT CTRL_BREAK_EVENT
                       MB_ERR_INVALID_CHARS ERROR_NO_UNICODE_TRANSLATION
                       WC_NO_BEST_FIT_CHARS STD_INPUT_HANDLE STD_OUTPUT_HANDLE
                       STD_ERROR_HANDLE HANDLE_FLAG_INHERIT FILE_TYPE_CHAR
                       LOAD_WITH_ALTERED_SEARCH_PATH CT_CTYPE3 C3_HIGHSURROGATE
                       CP_ACP CP_UTF8 CP_UTF7 CP_OEMCP MB_ERR_INVALID_CHARS
                    """
        from rpython.translator.platform import host_factory
        static_platform = host_factory()
        if static_platform.name == 'msvc':
            defines += ' PROCESS_QUERY_LIMITED_INFORMATION'
        for name in defines.split():
            locals()[name] = rffi_platform.ConstantInteger(name)
Exemplo n.º 30
0
class CConfig:
    _compilation_info_ = eci
    HAVAL_CTX = platform.Struct('HAVAL_CTX', [])