qmsk/net/libc.pxd
author Tero Marttila <terom@fixme.fi>
Sun, 16 Aug 2009 20:18:39 +0300
changeset 10 94b0d5a208c1
parent 7 74fde84264b1
child 12 314d47bdd4d9
permissions -rw-r--r--
split up socket.platform
7
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    Libc stuff
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
cdef extern from "stdint.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
    # yes, these are "wrong"
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
    ctypedef unsigned char uint8_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
    ctypedef unsigned short uint16_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
    ctypedef unsigned int uint32_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
    ctypedef signed char int8_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    ctypedef signed short int16_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
    ctypedef signed int int32_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
cdef extern from "sys/types.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    16
    # potentially wrong...
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    17
    ctypedef signed long ssize_t
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
# <linux/types.h>
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
cdef extern from "linux/types.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
    ctypedef uint8_t __u8
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
    ctypedef uint16_t __u16
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
    ctypedef uint32_t __u32
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    24
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    25
    ctypedef int8_t __s8
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    26
    ctypedef int16_t __s16
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    27
    ctypedef int32_t __s32
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
cdef extern from "errno.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    30
    int errno
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
    
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
cdef extern from "string.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
    void* memcpy (void *dest, void *src, size_t n)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
    void* memset (void *s, int c, size_t n)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
    char* strerror (int errno)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
cdef extern from "alloca.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
    void* alloca (size_t size)
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
cdef extern from "sys/uio.h" :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
    struct iovec :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
        void *iov_base
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
        size_t iov_len
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    45
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    46
## general errno-based errors
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    47
#cdef class Errno (py.OSError) :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    49
#        Some libc function returned an error code:
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    50
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
#            func        - the name of the function called
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    52
#            err         - the system error code
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
#            strerror    - human-readable error code -> message
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
#    cdef readonly char *func
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
#    cdef readonly int err
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
#    cdef readonly object strerror
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
#cdef class GAIError (py.OSError) :
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    62
#        Some libc GAI function returnd an error code:
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
#            func        - the name of the function called
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
#            err         - the GAI_* error code
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
#            strerror    - human-readable error code -> message
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    67
#    """
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    68
#
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
#    cdef readonly char *func
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    70
#    cdef readonly int err
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    71
#    cdef readonly object strerror
74fde84264b1 broke Cython with this package magic
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    72
#