コード例 #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*')
コード例 #2
0
ファイル: c90.py プロジェクト: rjeschmi/fbuild
class stdio_h(c.Test):
    header = c.header_test('stdio.h')

    _IOFBF = c.macro_test()
    _IOLBF = c.macro_test()
    _IONBF = c.macro_test()
    BUFSIZ = c.macro_test()
    EOF = c.macro_test()
    FILE = c.type_test()
    FILENAME_MAX = c.macro_test()
    FOPEN_MAX = c.macro_test()
    fpos_t = c.type_test()
    L_tmpnam = c.macro_test()
    NULL = c.macro_test()
    SEEK_CUR = c.macro_test()
    SEEK_END = c.macro_test()
    SEEK_SET = c.macro_test()
    size_t = c.int_type_test()
    stderr = c.variable_test()
    stdin = c.variable_test()
    stdout = c.variable_test()
    TMP_MAX = c.macro_test()
    remove = c.function_test('int', 'const char*', default_args=('""', ))
    rename = c.function_test('int', 'const char*', 'const char*')
    tmpfile = c.function_test('FILE*', 'void')
    tmpnam = c.function_test('char*', 'char*', default_args=('NULL', ))

    @c.cacheproperty
    def fclose(self):
        if self.fopen:
            return c.Function('int', 'FILE*')

    fflush = c.function_test('int',
                             'FILE*',
                             test='''
        #include <stdio.h>
        int main() {
            return fflush(stdout) == 0 ? 0 : 1;
        }
        ''')

    @c.cacheproperty
    def fopen(self):
        with tempfile.NamedTemporaryFile() as f:
            test = '''
                #include <errno.h>
                #include <stdio.h>
                int main() {
                    FILE* f;
                    fpos_t p;
                    if (!(f = fopen("%s", "r"))) return 1;
                    if (ftell(f) != 0) return 1;
                    if (fgetpos(f, &p) != 0) return 1;
                    if (fseek(f, 1L, SEEK_CUR) != 0) return 1;
                    if (ftell(f) != 1) return 1;
                    if (fsetpos(f, &p) != 0) return 1;
                    if (ftell(f) != 0) return 1;
                    if (fflush(NULL) != 0) return 1;
                    if (!(f = freopen(NULL, "r", f))) return 1;
                    errno = 0;
                    rewind(f);
                    if (errno) return 1;
                    if (ferror(f) != 0) return 1;
                    if (feof(f) != 0) return 1;
                    if (fclose(f) != 0) return 1;
                    return 0;
                }
                ''' % f.name

            if self.builder.check_run(test, "checking fopen in 'stdio.h'"):
                return c.Function('FILE*', 'const char*', 'const char*')

    @c.cacheproperty
    def freopen(self):
        if self.fopen:
            return c.Function('FILE*', 'const char*', 'const char*', 'FILE*')

    setbuf = c.function_test('void',
                             'FILE*',
                             'char*',
                             test='''
        #include <stdio.h>
        int main() {
            setbuf(stdout, "");
            return 0;
        }
        ''')
    setvbuf = c.function_test('int',
                              'FILE*',
                              'char*',
                              'int',
                              'size_t',
                              test='''
        #include <stdio.h>
        int main() {
            setvbuf(stdout, "", _IONBF, 0);
            return 0;
        }
        ''')
    fprintf = c.function_test('int',
                              'FILE*',
                              'const char*',
                              test='''
        #include <stdio.h>
        int main() {
            return fprintf(stdout, "%d %d", 5, 6) ? 0 : 1;
        }
        ''',
                              stdout=b'5 6')
    fscanf = c.function_test('int',
                             'FILE*',
                             'const char*',
                             test='''
        #include <stdio.h>
        int main() {
            int x = 0, y = 0;
            return fscanf(stdin, "%d %d", &x, &y) &&
                x == 5 &&
                y == 6 ? 0 : 1;
        }
        ''',
                             stdin=b'5 6')
    printf = c.function_test('int',
                             'const char*',
                             test='''
        #include <stdio.h>
        int main() {
            return printf("%d %d", 5, 6) ? 0 : 1;
        }
        ''',
                             stdout=b'5 6')
    scanf = c.function_test('int',
                            'const char*',
                            test='''
        #include <stdio.h>
        int main() {
            int x = 0, y = 0;
            return scanf("%d %d", &x, &y) &&
                x == 5 &&
                y == 6 ? 0 : 1;
        }
        ''',
                            stdin=b'5 6')
    sprintf = c.function_test('int',
                              'char*',
                              'const char*',
                              test='''
        #include <stdio.h>
        int main() {
            char s[50];
            return sprintf(s, "%d%d", 5, 6) &&
                s[0] == '5' &&
                s[1] == '6' ? 0 : 1;
        }
        ''')
    sscanf = c.function_test('int',
                             'const char*',
                             'const char*',
                             test='''
        #include <stdio.h>
        int main() {
            int x = 0, y = 0;
            return sscanf("5 6", "%d %d", &x, &y) &&
                x == 5 && y == 6 ? 0 : 1;
        }
        ''')
    vfprintf = c.function_test('int',
                               'FILE*',
                               'const char*',
                               'va_list',
                               test='''
        #include <stdarg.h>
        #include <stdio.h>
        int f(char* s, ...) {
            int rc;
            va_list ap;
            va_start(ap, s);
            rc = vfprintf(stdout, s, ap);
            va_end(ap);
            return rc;
        }
        int main() {
            return f("%d %d", 5, 6) ? 0 : 1;
        }
        ''',
                               stdout=b'5 6')
    vprintf = c.function_test('int',
                              'const char*',
                              'va_list',
                              test='''
        #include <stdarg.h>
        #include <stdio.h>
        int f(char* s, ...) {
            int rc;
            va_list ap;
            va_start(ap, s);
            rc = vprintf(s, ap);
            va_end(ap);
            return rc;
        }
        int main() {
            return f("%d %d", 5, 6) ? 0 : 1;
        }
        ''',
                              stdout=b'5 6')
    vsprintf = c.function_test('int',
                               'char*',
                               'const char*',
                               'va_list',
                               test='''
        #include <stdarg.h>
        #include <stdio.h>
        int f(char* s, ...) {
            int rc;
            va_list ap;
            va_start(ap, s);
            rc = vsprintf(s, "%d %d", ap);
            va_end(ap);
            return rc;
        }
        int main() {
            char s[50] = {0};
            return f(s, 5, 6) &&
                s[0] == '5' &&
                s[1] == ' ' &&
                s[2] == '6' &&
                s[3] == '\\0' ? 0 : 1;
        }
        ''')
    fgetc = c.function_test('int',
                            'FILE*',
                            test='''
        #include <stdio.h>
        int main() {
            return fgetc(stdin) == '5' ? 0 : 1;
        }
        ''',
                            stdin=b'5')
    fgets = c.function_test('char*',
                            'char*',
                            'int',
                            'FILE*',
                            test='''
        #include <stdio.h>
        int main() {
            char s[50] = {0};
            return fgets(s, 4, stdin) &&
                s[0] == '5' &&
                s[1] == ' ' &&
                s[2] == '6' &&
                s[3] == '\\0' ? 0 : 1;
        }
        ''',
                            stdin=b'5 6')
    fputc = c.function_test('int',
                            'int',
                            'FILE*',
                            test='''
        #include <stdio.h>
        int main() {
            return fputc('5', stdout) == '5' ? 0 : 1;
        }
        ''',
                            stdout=b'5')
    fputs = c.function_test('int',
                            'const char*',
                            'FILE*',
                            test='''
        #include <stdio.h>
        int main() {
            return fputs("5 6", stdout) ? 0 : 1;
        }
        ''',
                            stdout=b'5 6')
    getc = c.function_test('int',
                           'FILE*',
                           test='''
        #include <stdio.h>
        int main() {
            return getc(stdin) == '5' ? 0 : 1;
        }
        ''',
                           stdin=b'5')
    getchar = c.function_test('int',
                              'void',
                              test='''
        #include <stdio.h>
        int main() {
            return getchar() == '5' ? 0 : 1;
        }
        ''',
                              stdin=b'5')
    gets = c.function_test('char*',
                           'char*',
                           test='''
        #include <stdio.h>
        int main() {
            char s[50] = {0};
            return s == gets(s) &&
                s[0] == '5' &&
                s[1] == ' ' &&
                s[2] == '6' &&
                s[3] == '\\0' ? 0 : 1;
        }
        ''',
                           stdin=b'5 6')
    putc = c.function_test('int',
                           'int',
                           'FILE*',
                           test='''
        #include <stdio.h>
        int main() {
            return putc('5', stdout) == '5' ? 0 : 1;
        }
        ''',
                           stdout=b'5')
    putchar = c.function_test('int',
                              'int',
                              test='''
        #include <stdio.h>
        int main() {
            return putchar('5') == '5' ? 0 : 1;
        }
        ''',
                              stdout=b'5')
    puts = c.function_test('int',
                           'const char*',
                           test='''
        #include <stdio.h>
        int main() {
            return puts("5 6") ? 0 : 1;
        }
        ''',
                           stdout=b'5 6\n')
    ungetc = c.function_test('int',
                             'int',
                             'FILE*',
                             test='''
        #include <stdio.h>
        int main() {
            if (ungetc('5', stdin) != '5') return 1;
            return getc(stdin) == '5' ? 0 : 1;
        }
        ''')
    fread = c.function_test('size_t',
                            'void*',
                            'size_t',
                            'size_t',
                            'FILE*',
                            test='''
        #include <stdio.h>
        int main() {
            char s[50] = {0};
            return fread(s, sizeof(char), 3, stdin) == 3 &&
                s[0] == '5' &&
                s[1] == ' ' &&
                s[2] == '6' ? 0 : 1;
        }
        ''',
                            stdin=b'5 6')
    fwrite = c.function_test('size_t',
                             'const void*',
                             'size_t',
                             'size_t',
                             'FILE*',
                             test='''
        #include <stdio.h>
        int main() {
            return fwrite("5 6", sizeof(char), 3, stdout) == 3 ? 0 : 1;
        }
        ''',
                             stdout=b'5 6')

    @c.cacheproperty
    def fgetpos(self):
        if self.fopen:
            return c.Function('int', 'FILE*', 'fpos_t*', 'fgetpos')

    @c.cacheproperty
    def fseek(self):
        if self.fopen:
            return c.Function('int', 'FILE*', 'long int', 'int', 'fseek')

    @c.cacheproperty
    def fsetpos(self):
        if self.fopen:
            return c.Function('int', 'FILE*', 'const fpos_t*', 'fsetpos')

    @c.cacheproperty
    def ftell(self):
        if self.fopen:
            return c.Function('long int', 'FILE*', 'ftell')

    @c.cacheproperty
    def rewind(self):
        if self.fopen:
            return c.Function('void', 'FILE*', 'rewind')

    clearerr = c.function_test('void',
                               'FILE*',
                               test='''
        #include <stdio.h>
        int main() {
            clearerr(stdout);
            return 0;
        }
        ''')

    @property
    def feof(self):
        if self.fopen:
            return c.function_test('int', 'FILE*')

    @property
    def ferror(self):
        if self.fopen:
            return c.Function('int', 'FILE*')

    perror = c.function_test('void', 'const char*', default_args=('""', ))
コード例 #3
0
ファイル: c90.py プロジェクト: rjeschmi/fbuild
class errno_h(c.Test):
    header = c.header_test('errno.h')

    EDOM = c.macro_test()
    ERANGE = c.macro_test()
    errno = c.variable_test()
コード例 #4
0
class cpio_h(c.Test):
    header = c.header_test('cpio.h')

    C_IRUSR = c.variable_test()
    C_IWUSR = c.variable_test()
    C_IXUSR = c.variable_test()
    C_IRGRP = c.variable_test()
    C_IWGRP = c.variable_test()
    C_IXGRP = c.variable_test()
    C_IROTH = c.variable_test()
    C_IWOTH = c.variable_test()
    C_IXOTH = c.variable_test()
    C_ISUID = c.variable_test()
    C_ISGID = c.variable_test()
    C_ISVTX = c.variable_test()
    C_ISDIR = c.variable_test()
    C_ISFIFO = c.variable_test()
    C_ISREG = c.variable_test()
    C_ISBLK = c.variable_test()
    C_ISCHR = c.variable_test()
    C_ISCTG = c.variable_test()
    C_ISLNK = c.variable_test()
    C_ISSOCK = c.variable_test()
    MAGIC = c.variable_test()
コード例 #5
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')
コード例 #6
0
class errno_h(c99.errno_h):
    E2BIG = c.variable_test()
    EACCES = c.variable_test()
    EADDRINUSE = c.variable_test()
    EADDRNOTAVAIL = c.variable_test()
    EAFNOSUPPORT = c.variable_test()
    EAGAIN = c.variable_test()
    EWOULDBLOCK = c.variable_test()
    EALREADY = c.variable_test()
    EBADF = c.variable_test()
    EBADMSG = c.variable_test()
    EBUSY = c.variable_test()
    ECANCELED = c.variable_test()
    ECHILD = c.variable_test()
    ECONNABORTED = c.variable_test()
    ECONNREFUSED = c.variable_test()
    ECONNRESET = c.variable_test()
    EDEADLK = c.variable_test()
    EDESTADDRREQ = c.variable_test()
    EDQUOT = c.variable_test()
    EEXIST = c.variable_test()
    EFAULT = c.variable_test()
    EFBIG = c.variable_test()
    EHOSTUNREACH = c.variable_test()
    EIDRM = c.variable_test()
    EINPROGRESS = c.variable_test()
    EINTR = c.variable_test()
    EINVAL = c.variable_test()
    EIO = c.variable_test()
    EISCONN = c.variable_test()
    EISDIR = c.variable_test()
    ELOOP = c.variable_test()
    EMFILE = c.variable_test()
    EMLINK = c.variable_test()
    EMSGSIZE = c.variable_test()
    EMULTIHOP = c.variable_test()
    ENAMETOOLONG = c.variable_test()
    ENETDOWN = c.variable_test()
    ENETRESET = c.variable_test()
    ENETUNREACH = c.variable_test()
    ENFILE = c.variable_test()
    ENOBUFS = c.variable_test()
    ENODATA = c.variable_test()
    ENODEV = c.variable_test()
    ENOENT = c.variable_test()
    ENOEXEC = c.variable_test()
    ENOLCK = c.variable_test()
    ENOLINK = c.variable_test()
    ENOMEM = c.variable_test()
    ENOMSG = c.variable_test()
    ENOPROTOOPT = c.variable_test()
    ENOSPC = c.variable_test()
    ENOSP = c.variable_test()
    ENOSTP = c.variable_test()
    ENOSYS = c.variable_test()
    ENOTCONN = c.variable_test()
    ENOTDIR = c.variable_test()
    ENOTEMPTY = c.variable_test()
    ENOTSOCK = c.variable_test()
    ENOTSUP = c.variable_test()
    ENOTTY = c.variable_test()
    ENXIO = c.variable_test()
    EOPNOTSUPP = c.variable_test()
    EOVERFLOW = c.variable_test()
    EPERM = c.variable_test()
    EPIPE = c.variable_test()
    EPROTO = c.variable_test()
    EPROTONOSUPPORT = c.variable_test()
    EPROTOTYPE = c.variable_test()
    EROFS = c.variable_test()
    ESPIPE = c.variable_test()
    ESRCH = c.variable_test()
    ESTALE = c.variable_test()
    ETIME = c.variable_test()
    ETIMEDOUT = c.variable_test()
    ETXTBSY = c.variable_test()
    EWOULDBLOCK = c.variable_test()
    EXDEV = c.variable_test()