Esempio n. 1
0
class aio_h(c.Test):
    header = c.header_test('aio.h')

    aiocb = c.struct_test(('int', 'aio_fildes'), ('off_t', 'aio_offset'),
                          ('volatile void*', 'aio_buf'),
                          ('size_t', 'aio_nbytes'), ('int', 'aio_reqprio'),
                          ('struct sigevent', 'aio_sigevent'),
                          ('int', 'aio_lio_opcode'))

    AIO_ALLDONE = c.variable_test()
    AIO_CANCELED = c.variable_test()
    AIO_NOTCANCELED = c.variable_test()
    LIO_NOP = c.variable_test()
    LIO_NOWAIT = c.variable_test()
    LIO_READ = c.variable_test()
    LIO_WAIT = c.variable_test()
    LIO_WRITE = c.variable_test()
    aio_cancel = c.function_test('int', 'int', 'struct aiocb*')
    aio_error = c.function_test('int', 'const struct aiocb*')
    aio_fsync = c.function_test('int', 'int, struct aiocb*')
    aio_read = c.function_test('int', 'struct aiocb*')
    aio_return = c.function_test('ssize_t', 'struct aiocb*')
    aio_suspend = c.function_test('int', 'const struct aiocb**', 'int',
                                  'const struct timespec*')
    aio_write = c.function_test('int', 'struct aiocb*')
    lio_listio = c.function_test('int', 'int', 'struct aiocb* const', 'int',
                                 'struct sigevent*')
Esempio n. 2
0
class sys_epoll_h(c.Test):
    header = c.header_test('sys/epoll.h')

    EPOLLIN = c.macro_test()
    EPOLLPRI = c.macro_test()
    EPOLLOUT = c.macro_test()
    EPOLLRDNORM = c.macro_test()
    EPOLLRDBAND = c.macro_test()
    EPOLLWRNORM = c.macro_test()
    EPOLLWRBAND = c.macro_test()
    EPOLLMSG = c.macro_test()
    EPOLLERR = c.macro_test()
    EPOLLHUP = c.macro_test()
    EPOLLONESHOT = c.macro_test()
    EPOLLET = c.macro_test()
    EPOLL_CTL_ADD = c.macro_test()
    EPOLL_CTL_DEL = c.macro_test()
    EPOLL_CTL_MOD = c.macro_test()
    epoll_data_t = c.type_test()
    epoll_event = c.struct_test(('uint32_t', 'events'),
                                ('epoll_data_t', 'data'))
    epoll_create = c.function_test('int',
                                   'int',
                                   test='''
        #include <sys/epoll.h>
        int main(int argc, char** argv) {
            int efd = epoll_create(20);
            return (-1 == efd) ? 1 : 0;
        }
        ''')
    epoll_ctl = c.function_test('int',
                                'int',
                                'int',
                                'int',
                                'struct epoll_event*',
                                test='''
        #include <stdio.h>
        #include <sys/epoll.h>
        int main(int argc, char** argv) {
            int efd = epoll_create(20);
            struct epoll_event event;
            return epoll_ctl(efd, EPOLL_CTL_ADD, fileno(stdin), &event) == 0 ? 0 : 1;
        }
        ''')
    epoll_wait = c.function_test('int', 'int', 'struct epoll_event*', 'int',
                                 'int')
Esempio n. 3
0
class sys_mman_h(c.Test):
    header = c.header_test('sys/mman.h')

    MAP_FAILED = c.macro_test()
    MAP_FIXED = c.macro_test()
    MAP_PRIVATE = c.macro_test()
    MAP_SHARED = c.macro_test()
    MCL_CURRENT = c.macro_test()
    MCL_FUTURE = c.macro_test()
    MS_ASYNC = c.macro_test()
    MS_INVALIDATE = c.macro_test()
    MS_SYNC = c.macro_test()
    POSIX_MADV_DONTNEED = c.macro_test()
    POSIX_MADV_NORMAL = c.macro_test()
    POSIX_MADV_RANDOM = c.macro_test()
    POSIX_MADV_SEQUENTIAL = c.macro_test()
    POSIX_MADV_WILLNEED = c.macro_test()
    POSIX_TYPED_MEM_ALLOCATE = c.macro_test()
    POSIX_TYPED_MEM_ALLOCATE_CONTIG = c.macro_test()
    POSIX_TYPED_MEM_MAP_ALLOCATABLE = c.macro_test()
    PROT_EXEC = c.macro_test()
    PROT_NONE = c.macro_test()
    PROT_READ = c.macro_test()
    PROT_WRITE = c.macro_test()
    mode_t = c.type_test()
    off_t = c.type_test()
    size_t = c.type_test()
    posix_typed_mem_info = c.struct_test(('size_t', 'posix_tmi_length'))
    mlock = c.function_test('int', 'const void*', 'size_t')
    mlockall = c.function_test('int', 'int')
    mmap = c.function_test('void*', 'size_t', 'int', 'int', 'int', 'off_t')
    mprotect = c.function_test('int', 'void*', 'size_t', 'int')
    msync = c.function_test('int', 'void*', 'size_t', 'int')
    munlock = c.function_test('int', 'const void*', 'size_t')
    munlockall = c.function_test('int', 'void')
    munmap = c.function_test('int', 'void*', 'size_t')
    posix_madvise = c.function_test('int', 'void*', 'size_t', 'int')
    posix_mem_offset = c.function_test('int', 'const void*', 'size_t',
                                       'off_t*', 'size_t*', 'int*')
    posix_typed_mem_get_info = c.function_test('int', 'int',
                                               'struct posix_typed_mem_info*')
    posix_typed_mem_open = c.function_test('int', 'const char*', 'int', 'int')
    shm_open = c.function_test('int', 'const char*', 'int', 'mode_t')
    shm_unlink = c.function_test('int', 'const char*')
Esempio n. 4
0
class arpa_inet_h(c.Test):
    header = c.header_test('arpa/inet.h')

    in_port_t = c.type_test()
    in_addr_t = c.type_test()
    in_addr = c.struct_test(('sa_family_t', 'sin_family'),
                            ('in_port_t', 'sin_port'),
                            ('struct in_addr', 'sin_addr'))
    INET_ADDRSTRLEN = c.macro_test()
    INET6_ADDRSTRLEN = c.macro_test()
    htonl = c.function_test('uint32_t', 'uint32_t')
    htons = c.function_test('uint16_t', 'uint16_t')
    ntohl = c.function_test('uint32_t', 'uint32_t')
    ntohs = c.function_test('uint16_t', 'uint16_t')
    inet_addr = c.function_test('in_addr_t', 'constchar*')
    inet_ntoa = c.function_test('char*', 'struct in_addr')
    inet_ntop = c.function_test('const char*', 'int', 'const void*', 'char*',
                                'socklen_t')
    inet_pton = c.function_test('int', 'int', 'const char*', 'void*')
Esempio n. 5
0
class locale_h(c.Test):
    header = c.header_test('locale.h')

    LC_ALL = c.macro_test()
    LC_COLLATE = c.macro_test()
    LC_CTYPE = c.macro_test()
    LC_MONETARY = c.macro_test()
    LC_NUMERIC = c.macro_test()
    LC_TIME = c.macro_test()
    NULL = c.macro_test()
    lconv = c.struct_test(
        ('char*', 'decimal_point'), ('char*', 'thousands_sep'),
        ('char*', 'grouping'), ('char*', 'int_curr_symbol'),
        ('char*', 'currency_symbol'), ('char*', 'mon_decimal_point'),
        ('char*', 'mon_thousands_sep'), ('char*', 'mon_grouping'),
        ('char*', 'positive_sign'), ('char*', 'negative_sign'),
        ('char', 'int_frac_digits'), ('char', 'frac_digits'),
        ('char', 'p_cs_precedes'), ('char', 'p_sep_by_space'),
        ('char', 'n_cs_precedes'), ('char', 'n_sep_by_space'),
        ('char', 'p_sign_posn'), ('char', 'n_sign_posn'))
    setlocale = c.function_test('char*', 'int', 'const char*')
    localeconv = c.function_test('struct lconv*', 'void')
Esempio n. 6
0
class time_h(c.Test):
    header = c.header_test('time.h')

    CLK_TCK = c.macro_test()
    NULL = c.macro_test()
    clock_t = c.int_type_test()
    time_t = c.int_type_test()
    size_t = c.int_type_test()
    tm = c.struct_test(
        ('int', 'tm_sec'), ('int', 'tm_min'), ('int', 'tm_hour'),
        ('int', 'tm_mday'), ('int', 'tm_mon'), ('int', 'tm_year'),
        ('int', 'tm_wday'), ('int', 'tm_yday'), ('int', 'tm_isdst'))
    clock = c.function_test('clock_t', 'void')
    difftime = c.function_test('double', 'time_t', 'time_t')
    mktime = c.function_test('time_t',
                             'struct tm*',
                             test='''
        #include <time.h>
        int main() {
            struct tm a;
            time_t b = mktime(&a);
            return 0;
        }
        ''')
    time = c.function_test('time_t', 'time_t*', default_args=('NULL', ))
    asctime = c.function_test('char*',
                              'const struct tm*',
                              test='''
        #include <time.h>
        int main() {
            struct tm t = { 0, 0, 0, 1, 0, 70, 4, 0, 0 };
            char* s = asctime(&t);
            return 0;
        }
        ''')
    ctime = c.function_test('char*',
                            'const time_t*',
                            test='''
        #include <time.h>
        int main() {
            time_t t = 0;
            char* s = ctime(&t);
            return 0;
        }
        ''')
    gmtime = c.function_test('struct tm*',
                             'const time_t*',
                             test='''
        #include <time.h>
        int main() {
            time_t t = 0;
            struct tm* tm = gmtime(&t);
            return 0;
        }
        ''')
    localtime = c.function_test('struct tm*',
                                'const time_t*',
                                test='''
        #include <time.h>
        int main() {
            time_t t = 0;
            struct tm* tm = localtime(&t);
            return 0;
        }
        ''')
    strftime = c.function_test('size_t',
                               'char*',
                               'size_t',
                               'const char*',
                               'const struct tm*',
                               test='''
        #include <time.h>
        int main() {
            struct tm t = { 0, 0, 0, 1, 0, 70, 4, 0, 0 };
            char s[50] = {0};
            return strftime(s, 50, " ", &t) == 1 ? 0 : 1;
        }
        ''')
Esempio n. 7
0
class fcntl_h(c.Test):
    header = c.header_test('fcntl.h')

    F_DUPFD = c.variable_test()
    F_GETFD = c.variable_test()
    F_SETFD = c.variable_test()
    F_GETFL = c.variable_test()
    F_SETFL = c.variable_test()
    F_GETLK = c.variable_test()
    F_SETLK = c.variable_test()
    F_SETLKW = c.variable_test()
    F_GETOWN = c.variable_test()
    F_SETOWN = c.variable_test()
    FD_CLOEXEC = c.variable_test()
    F_RDLCK = c.variable_test()
    F_UNLCK = c.variable_test()
    F_WRLCK = c.variable_test()
    O_CREAT = c.variable_test()
    O_EXCL = c.variable_test()
    O_NOCTTY = c.variable_test()
    O_TRUNC = c.variable_test()
    O_APPEND = c.variable_test()
    SIO = c.variable_test()
    O_NONBLOCK = c.variable_test()
    SIO = c.variable_test()
    O_SYNC = c.variable_test()
    O_ACCMODE = c.variable_test()
    O_RDONLY = c.variable_test()
    O_RDWR = c.variable_test()
    O_WRONLY = c.variable_test()
    mode_t = c.type_test()
    off_t = c.type_test()
    pid_t = c.type_test()
    POSIX_FADV_NORMAL = c.variable_test()
    POSIX_FADV_SEQUENTIAL = c.variable_test()
    POSIX_FADV_RANDOM = c.variable_test()
    POSIX_FADV_WILLNEED = c.variable_test()
    POSIX_FADV_DONTNEED = c.variable_test()
    POSIX_FADV_NOREUSE = c.variable_test()
    flock = c.struct_test(('short', 'l_type'), ('short', 'l_whence'),
                          ('off_t', 'l_start'), ('off_t', 'l_len'),
                          ('pid_t', 'l_pid'))
    creat = c.function_test('int', 'const char*', 'mode_t')
    fcntl = c.function_test('int', 'int', 'int')

    @c.cacheproperty
    def open(self):
        with tempfile.NamedTemporaryFile() as f:
            test = '''
                #include <fcntl.h>
                int main() {
                    int fd;
                    if ((fd = open("%s", O_RDONLY)) == -1) return 1;
                    return 0;
                }
                ''' % f.name

            if self.builder.check_run(test, "checking open in 'fcntl.h'"):
                return c.function_test('int', 'const char*', 'int')

    posix_fadvise = c.function_test('int', 'int', 'off_t', 'off_t', 'int')
    posix_fallocate = c.function_test('int', 'int', 'off_t', 'off_t')
Esempio n. 8
0
class sys_socket_h(c.Test):
    header = c.header_test('sys/socket.h')

    socklen_t = c.int_type_test()
    sa_family_t = c.int_type_test()
    sockaddr = c.struct_test(('sa_family_t', 'sa_family'),
                             ('char*', 'sa_data'))
    sockaddr_storage = c.struct_test(('sa_family_t', 'ss_family'))
    msghdr = c.struct_test(('void*', 'msg_name'), ('socklen_t', 'msg_namelen'),
                           ('struct iovec*', 'msg_iov'), ('int', 'msg_iovlen'),
                           ('void*', 'msg_control'),
                           ('socklen_t', 'msg_controllen'),
                           ('int', 'msg_flags'))
    cmsghdr = c.struct_test(('socklen_t', 'cmsg_len'), ('int', 'cmsg_level'),
                            ('int', 'cmsg_type'))
    SCM_RIGHTS = c.macro_test()
    CMSG_DATA = c.macro_test()
    CMSG_NXTHDR = c.macro_test()
    CMSG_FIRSTHDR = c.macro_test()
    linger = c.struct_test(('int', 'l_onoff'), ('int', 'l_linger'))
    SOCK_DGRAM = c.macro_test()
    SOCK_RAW = c.macro_test()
    SOCK_SEQPACKET = c.macro_test()
    SOCK_STREAM = c.macro_test()
    SOL_SOCKET = c.macro_test()
    SO_ACCEPTCONN = c.macro_test()
    SO_BROADCAST = c.macro_test()
    SO_DEBUG = c.macro_test()
    SO_DONTROUTE = c.macro_test()
    SO_ERROR = c.macro_test()
    SO_KEEPALIVE = c.macro_test()
    SO_LINGER = c.macro_test()
    SO_OOBINLINE = c.macro_test()
    SO_RCVBUF = c.macro_test()
    SO_RCVLOWAT = c.macro_test()
    SO_RCVTIMEO = c.macro_test()
    SO_REUSEADDR = c.macro_test()
    SO_SNDBUF = c.macro_test()
    SO_SNDLOWAT = c.macro_test()
    SO_SNDTIMEO = c.macro_test()
    SO_TYPE = c.macro_test()
    SOMAXCONN = c.macro_test()
    MSG_CTRUNC = c.macro_test()
    MSG_DONTROUTE = c.macro_test()
    MSG_EOR = c.macro_test()
    MSG_OOB = c.macro_test()
    MSG_PEEK = c.macro_test()
    MSG_TRUNC = c.macro_test()
    MSG_WAITALL = c.macro_test()
    AF_INET = c.macro_test()
    AF_INET6 = c.macro_test()
    AF_UNIX = c.macro_test()
    AF_UNSPEC = c.macro_test()
    SHUT_RD = c.macro_test()
    SHUT_RDWR = c.macro_test()
    SHUT_WR = c.macro_test()
    accept = c.function_test('int', 'int', 'struct sockaddr*', 'socklen_t*')
    bind = c.function_test('int', 'int', 'const struct sockaddr*', 'socklen_t')
    connect = c.function_test('int', 'int', 'const struct sockaddr*',
                              'socklen_t')
    getpeername = c.function_test('int', 'int', 'struct sockaddr*',
                                  'socklen_t*')
    getsockname = c.function_test('int', 'int', 'struct sockaddr*',
                                  'socklen_t*')
    getsockopt = c.function_test('int', 'int', 'int', 'int', 'void*',
                                 'socklen_t*')
    listen = c.function_test('int', 'int', 'int')
    recv = c.function_test('ssize_t', 'int', 'void*', 'size_t', 'int')
    recvfrom = c.function_test('ssize_t', 'int', 'void*', 'size_t', 'int',
                               'struct sockaddr*', 'socklen_t*')
    recvmsg = c.function_test('ssize_t', 'int', 'struct msghdr*', 'int')
    send = c.function_test('ssize_t', 'int', 'const void*', 'size_t', 'int')
    sendmsg = c.function_test('ssize_t', 'int', 'const struct msghdr*', 'int')
    sendto = c.function_test('ssize_t', 'int', 'const void*', 'size_t', 'int',
                             'const struct sockaddr*', 'socklen_t')
    setsockopt = c.function_test('int', 'int', 'int', 'int', 'const void*',
                                 'socklen_t')
    shutdown = c.function_test('int', 'int', 'int')
    socket = c.function_test('int', 'int', 'int', 'int')
    sockatmark = c.function_test('int', 'int')
    socketpair = c.function_test('int',
                                 'int',
                                 'int',
                                 'int',
                                 'int[2]',
                                 test='''
        #include <sys/socket.h>
        int main() {
            int arg_0;
            int arg_1;
            int arg_2;
            int arg_3[2];
            int res = socketpair(arg_0, arg_1, arg_2, arg_3);
            return 0;
        }
        ''')
Esempio n. 9
0
class dirent_h(c.Test):
    header = c.header_test('dirent.h')

    DIR = c.type_test()
    dirent = c.struct_test(('ino_t', 'd_ino'), ('char*', 'd_name'))
    ino_t = c.type_test()
    closedir = c.function_test('int',
                               'DIR*',
                               test='''
        #include <dirent.h>
        int main() {
            DIR* d = opendir(".");
            struct dirent* s;
            long l;

            if (!d) return 1;
            s = readdir(d);
            seekdir(d, 0);
            l = telldir(d);
            rewinddir(d);

            return closedir(d);
        }
        ''')

    @property
    def opendir(self):
        if self.closedir:
            return c.Function('DIR*', 'const char*')

    @property
    def readdir(self):
        if self.closedir:
            return c.Function('struct dirent*', 'DIR*')

    readdir_r = c.function_test('int',
                                'DIR*',
                                'struct dirent*',
                                'struct dirent**',
                                test='''
        #include <dirent.h>
        int main() {
            DIR* d = opendir(".");
            struct dirent s;
            struct dirent* p;
            if (!d) return 1;
            if (readdir_r(d, &s, &p) != 0) return 1;
            return closedir(d);
        }
        ''')

    @property
    def rewinddir(self):
        if self.closedir:
            return c.Function('void', 'DIR*')

    @property
    def seekdir(self):
        if self.closedir:
            return c.Function('void', 'DIR*', 'long')

    @property
    def telldir(self):
        if self.closedir:
            return c.Function('long', 'DIR*')