class signal_h(c.Test): header = c.header_test('signal.h') sig_atomic_t = c.type_test() SIG_DFL = c.macro_test() SIG_ERR = c.macro_test() SIG_IGN = c.macro_test() SIGABRT = c.macro_test() SIGFPE = c.macro_test() SIGILL = c.macro_test() SIGINT = c.macro_test() SIGSEGV = c.macro_test() SIGTERM = c.macro_test() signal = c.function_test(c.Function('void', 'int'), 'int', c.Function('void', 'int'), test=''' #include <signal.h> void foo(int x) {} int main() { void (*f)(int) = signal(SIGTERM, foo); return 0; } ''') raise_ = c.function_test('int', 'int', name='raise', test=''' #include <signal.h> int main() { signal(SIGTERM, SIG_IGN); return raise(SIGTERM) == 0 ? 0 : 1; } ''')
class float_h(c.Test): header = c.header_test('float.h') DBL_DIG = c.macro_test() DBL_EPSILON = c.macro_test() DBL_MANT_DIG = c.macro_test() DBL_MAX = c.macro_test() DBL_MAX_10_EXP = c.macro_test() DBL_MAX_EXP = c.macro_test() DBL_MIN = c.macro_test() DBL_MIN_10_EXP = c.macro_test() DBL_MIN_EXP = c.macro_test() FLT_DIG = c.macro_test() FLT_EPSILON = c.macro_test() FLT_MANT_DIG = c.macro_test() FLT_MAX = c.macro_test() FLT_MAX_10_EXP = c.macro_test() FLT_MAX_EXP = c.macro_test() FLT_MIN = c.macro_test() FLT_MIN_10_EXP = c.macro_test() FLT_MIN_EXP = c.macro_test() FLT_RADIX = c.macro_test() FLT_ROUNDS = c.macro_test() LDBL_DIG = c.macro_test() LDBL_EPSILON = c.macro_test() LDBL_MANT_DIG = c.macro_test() LDBL_MAX = c.macro_test() LDBL_MAX_10_EXP = c.macro_test() LDBL_MAX_EXP = c.macro_test() LDBL_MIN = c.macro_test() LDBL_MIN_10_EXP = c.macro_test() LDBL_MIN_EXP = c.macro_test()
class unistd_h(c.Test): header = c.header_test('unistd.h') getcwd = c.function_test('char*', 'char*', 'size_t') getopt = c.function_test('int', 'int', 'char**', 'char*', test=''' #include <unistd.h> int main(int argc, char** argv) { int ch, ret = 0; while ((ch = getopt(argc, argv, "f")) != -1) { switch (ch) { case 'f': break; default: ret = 1; } } return ret; } ''') getpagesize = c.function_test('int', 'void') isatty = c.function_test('int', 'int') sysconf = c.function_test('long', 'int', default_args=('0', )) ttyname = c.function_test('char*', 'int')
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*')
class stddef_h(c.Test): header = c.header_test('stddef.h') NULL = c.macro_test() offsetof = c.macro_test() ptrdiff_t = c.int_type_test() size_t = c.int_type_test() wchar_t = c.int_type_test()
class strings_h(c.Test): header = c.header_test('strings.h') bcmp = c.function_test('int', 'const void*', 'const void*', 'size_t') bcopy = c.function_test('void', 'const void*', 'void*', 'size_t', default_args=(0, 0, 0)) bzero = c.function_test('void', 'void*', 'size_t')
class stdlib_h(c.Test): header = c.header_test('stdlib.h') ecvt = c.function_test('char*', 'double', 'int', 'int*', 'int*', test=''' #include <stdlib.h> int main() { int decpt; int sign; char* s = ecvt(0.0, 1, &decpt, &sign); return s[0] == '0' && s[1] == '\\0' ? 0 : 1; } ''') fcvt = c.function_test('char*', 'double', 'int', 'int*', 'int*', test=''' #include <stdlib.h> int main() { int decpt; int sign; char* s = fcvt(0.0, 1, &decpt, &sign); return s[0] == '0' && s[1] == '\\0' ? 0 : 1; } ''') gcvt = c.function_test('char*', 'double', 'int', 'char*', test=''' #include <stdlib.h> int main() { char s[50] = {0}; int decpt; int sign; gcvt(0.0, 1, s); return s[0] == '0' && s[1] == '\\0' ? 0 : 1; } ''') mktemp = c.function_test('char*', 'char*', test=''' #include <stdlib.h> int main() { char s[] = "XXXXXX"; return mktemp(s) == NULL ? 1 : 0; } ''')
class malloc_malloc_h(c.Test): header = c.header_test('malloc/malloc.h') malloc_zone_statistics = c.function_test('void', 'malloc_zone_t*', 'malloc_statistics_t*', test=''' #include <malloc/malloc.h> int main() { malloc_statistics_t stats; malloc_zone_statistics(malloc_default_zone(), &stats); return 0; } ''')
class port_h(c.Test): header = c.header_test('port.h') port_create = c.function_test('int', 'void', test=''' #include <port.h> int main(int argc, char** argv) { int port = port_create(); if (port < 0) { return 1; } if (close(port) < 0) { return 1; } return 0; } ''')
class assert_h(c.Test): header = c.header_test('assert.h') @c.cacheproperty def assert_(self): self.ctx.logger.check("checking assert in 'assert.h'") if not self.builder.try_run(''' #include <assert.h> int main() { assert(1); return 0; } '''): self.ctx.logger.failed() return None if self.builder.try_run(''' #include <assert.h> #ifdef _WIN32 #include <windows.h> #endif int main() { #ifdef _WIN32 /* Turn off the windows error box */ DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX); SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX); #endif assert(0); return 0; } '''): self.ctx.logger.failed() return None if not self.builder.try_run(''' #include <assert.h> int main() { assert(0); return 0; } ''', ckwargs={'macros': ['NDEBUG']}): self.ctx.logger.failed() return None self.ctx.logger.passed() return c.Macro()
class sys_event_h(c.Test): header = c.header_test('sys/event.h') kqueue = c.function_test('int', 'void', test=''' #include <sys/types.h> // from the kqueue manpage #include <sys/event.h> // kernel events #include <sys/time.h> // timespec (kevent timeout) int main(int argc, char** argv) { int kq = kqueue(); return (-1 == kq) ? 1 : 0; } ''')
class ctype_h(c.Test): header = c.header_test('ctype.h') isalnum = c.function_test('int', 'int') isalpha = c.function_test('int', 'int') iscntrl = c.function_test('int', 'int') isdigit = c.function_test('int', 'int') isgraph = c.function_test('int', 'int') islower = c.function_test('int', 'int') isprint = c.function_test('int', 'int') ispunct = c.function_test('int', 'int') isspace = c.function_test('int', 'int') isupper = c.function_test('int', 'int') isxdigit = c.function_test('int', 'int') tolower = c.function_test('int', 'int') toupper = c.function_test('int', 'int')
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')
class math_h(c.Test): header = c.header_test('math.h') HUGE_VAL = c.macro_test() acos = c.function_test('double', 'double') asin = c.function_test('double', 'double') atan = c.function_test('double', 'double') atan2 = c.function_test('double', 'double', 'double') cos = c.function_test('double', 'double') sin = c.function_test('double', 'double') tan = c.function_test('double', 'double') cosh = c.function_test('double', 'double') sinh = c.function_test('double', 'double') tanh = c.function_test('double', 'double') exp = c.function_test('double', 'double') frexp = c.function_test('double', 'double', 'int*', test=''' #include <math.h> int main() { int d0; double d1 = frexp(0., &d0); return 0; } ''') ldexp = c.function_test('double', 'double', 'int') log = c.function_test('double', 'double') log10 = c.function_test('double', 'double') modf = c.function_test('double', 'double', 'double*', test=''' #include <math.h> int main() { double d0; double d1 = modf(0., &d0); return 0; } ''') pow = c.function_test('double', 'double', 'double') sqrt = c.function_test('double', 'double') ceil = c.function_test('double', 'double') fabs = c.function_test('double', 'double') floor = c.function_test('double', 'double') fmod = c.function_test('double', 'double', 'double')
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*')
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*')
class limits_h(c.Test): header = c.header_test('limits.h') CHAR_BIT = c.macro_test() CHAR_MAX = c.macro_test() CHAR_MIN = c.macro_test() INT_MAX = c.macro_test() INT_MIN = c.macro_test() LONG_MAX = c.macro_test() LONG_MIN = c.macro_test() MB_LEN_MAX = c.macro_test() SCHAR_MAX = c.macro_test() SCHAR_MIN = c.macro_test() SHRT_MAX = c.macro_test() SHRT_MIN = c.macro_test() UCHAR_MAX = c.macro_test() UINT_MAX = c.macro_test() ULONG_MAX = c.macro_test() USHRT_MAX = c.macro_test()
class ieeefp_h(c.Test): header = c.header_test('ieeefp.h') fp_rnd = c.type_test() fpclass_t = c.type_test() FP_CLEAR = c.macro_test() FP_DISABLE = c.macro_test() FP_ENABLE = c.macro_test() FP_SET = c.macro_test() FP_X_DNML = c.macro_test() FP_X_DZ = c.macro_test() FP_X_DZ = c.macro_test() FP_X_IMP = c.macro_test() FP_X_IMP = c.macro_test() FP_X_INV = c.macro_test() FP_X_INV = c.macro_test() FP_X_OFL = c.macro_test() FP_X_OFL = c.macro_test() FP_X_UFL = c.macro_test() FP_X_UFL = c.macro_test() fp_except = c.macro_test() finite = c.function_test('int', 'double') finitef = c.function_test('int', 'float') finitel = c.function_test('int', 'long double') fpclass = c.function_test('fpclass', 'double') fpgetmask = c.function_test('fp_except', 'void') fpgetround = c.function_test('fp_rnd', 'void') fpgetsticky = c.function_test('fp_except', 'void') fpsetmask = c.function_test('fp_except', 'fp_except') fpsetround = c.function_test('fp_rnd', 'fp_rnd') fpsetsticky = c.function_test('fp_except', 'fp_except') isinf = c.function_test('int', 'double') isinff = c.function_test('int', 'float') isinfl = c.function_test('int', 'long double') isnan = c.function_test('int', 'double') isnand = c.function_test('int', 'double') isnanf = c.function_test('int', 'float') isnanl = c.function_test('int', 'long double') unordered = c.function_test('int', 'double', 'double')
class execinfo_h(c.Test): header = c.header_test('execinfo.h') backtrace = c.function_test('int', 'void**', 'int', test=''' #include <execinfo.h> int main() { void* callstack[128]; int frames = backtrace(callstack, 128); char** strs = backtrace_symbols(callstack, frames); return 0; } ''') backtrace_symbols = c.function_test('char**', 'void* const*', 'int', test=backtrace.test) backtrace_symbols_fd = c.function_test('void', 'void* const*', 'int', 'int')
class sys_types_h(c.Test): header = c.header_test('sys/types.h') blkcnt_t = c.int_type_test() blksize_t = c.int_type_test() clock_t = c.type_test() clockid_t = c.int_type_test() dev_t = c.int_type_test() fsblkcnt_t = c.int_type_test() fsfilcnt_t = c.int_type_test() gid_t = c.int_type_test() id_t = c.int_type_test() key_t = c.type_test() mode_t = c.int_type_test() nlink_t = c.int_type_test() off_t = c.int_type_test() pid_t = c.int_type_test() pthread_attr_t = c.type_test() pthread_barrier_t = c.type_test() pthread_barrierattr_t = c.type_test() pthread_cond_t = c.type_test() pthread_condattr_t = c.type_test() pthread_mutex_t = c.type_test() pthread_mutexattr_t = c.type_test() pthread_rwlock_t = c.type_test() pthread_rwlockattr_t = c.type_test() pthread_spinlock_t = c.type_test() pthread_t = c.type_test() size_t = c.int_type_test() ssize_t = c.int_type_test() suseconds_t = c.int_type_test() time_t = c.type_test() timer_t = c.int_type_test() trace_attr_t = c.type_test() trace_event_id_t = c.type_test() trace_event_set_t = c.type_test() trace_id_t = c.type_test() uid_t = c.int_type_test() useconds_t = c.int_type_test()
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')
class sys_time_h(c.Test): header = c.header_test('sys/time.h') gettimeofday = c.function_test('int', 'struct timeval*', 'void*', test=''' #include <sys/time.h> int main() { struct timeval tp; return gettimeofday(&tp, 0) == 0 ? 0 : 1; } ''') settimeofday = c.function_test('int', 'struct timeval*', 'void*', test=''' #include <sys/time.h> /* Don't actually call settimeofday because it modifies the global * time. */ void foo() { settimeofday(0, 0); } int main() { return 0; } ''')
class stdarg_h(c.Test): header = c.header_test('stdarg.h') va_list = c.type_test() va_start = c.macro_test(test=''' #include <stdarg.h> int f(int x, ...) { int res = 0; va_list ap; va_start(ap, x); res = x == 1 && va_arg(ap, int) == 3 && va_arg(ap, int) == 'a' && va_arg(ap, double) == 4.5; va_end(ap); return res; } int main() { return f(1, 3, 'a', 4.5) == 1 ? 0 : 1; } ''') va_arg = c.macro_test(test=va_list.test) va_end = c.macro_test(test=va_list.test)
class setjmp_h(c.Test): header = c.header_test('setjmp.h') jmp_buf = c.type_test() longjmp = c.function_test('void', 'jmp_buf', 'int', test=''' #include <setjmp.h> int main() { jmp_buf env; int i = setjmp(env); if (i == 2) return 0; longjmp(env, 2); return 2; } ''') @property def setjmp(self): if self.longjmp: return c.Function('int', 'jmp_buf')
class unistd_h(c.Test): header = c.header_test('unistd.h') brk = c.function_test('void*', 'void*') getopt = c.function_test('int', 'int', 'char**', 'char*', test=''' #include <unistd.h> int main(int argc, char** argv) { int ch, ret = 0; while ((ch = getopt(argc, argv, "f")) != -1) { switch (ch) { case 'f': break; default: ret = 1; } } return ret; } ''') getwd = c.function_test('char*', 'char*', test=''' #include <unistd.h> #include <sys/param.h> int main() { char arg[MAXPATHLEN]; char* res = getwd(arg); return 0; } ''') sbrk = c.function_test('void*', 'intptr_t') ttyslot = c.function_test('int', 'void')
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()
class SDL_SDL_h(c.Test): header = c.header_test('SDL/SDL.h')
class libelf(Test): libelf_h = header_test('libelf.h') gelf_h = header_test('gelf.h')
class readline_h(c.Test): header = c.header_test('readline/readline.h')
class mpi_h(c.Test): header = c.header_test('mpi.h')