check_c_source_runs(<code> <resultVar>)
check_c_source_runs(<code> <resultVar>)
check_c_source_runs("
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
int main(void) {
return poll((void *)0, 0, 10 /*ms*/);
}" HAVE_POLL_FINE)
check_c_source_runs("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_attr_t type;
pthread_attr_init(&type);
return 0;
}" HAVE_PTHREADS)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs ("${source}" ${testname})
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("
#include <stdbool.h>
bool foo(int a, int b, int *c) {
return __builtin_mul_overflow(a, b, c);
}
int main() {
int out;
if (foo(1, 2, &out)) {
return 0;
}
return 0;
}" AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS)
check_c_source_runs("${_CHECK_FOR_JUDY1_BUG}" JUDY_HAVE_WORKING_JUDY1)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
check_c_source_runs("
static int notsupported = 1;
void test_ctor (void) __attribute__((constructor));
void test_ctor (void) { notsupported = 0; }
int main(void) { return (notsupported); }
"
ALLEGRO_USE_CONSTRUCTOR)
check_c_source_runs("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_attr_t type;
pthread_attr_init(&type);
return 0;
}" HAVE_PTHREADS)
check_c_source_runs("
#define METIS_EXPORT
#include \"metis.h\"
int main( int argc, char* argv[] )
{
// FIXME: Find a simple but sensible test for METIS
return 0;
}
" METIS_TEST_RUNS)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("
#include <time.h>
int main() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return 0;
}" HAVE_CLOCK_GETTIME_MONOTONIC)
check_c_source_runs("
#include <lz4.h>
int main() {
int good = (LZ4_VERSION_MAJOR > 1) ||
((LZ4_VERSION_MAJOR == 1) && (LZ4_VERSION_MINOR >= 7));
return !good;
}" LZ4_GOOD_VERSION)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("
int main(int argc, char **argv)
{
(void)argc;
argv[0][0] = ' ';
return (argv[0][0] == ' ')?0:1;
}" HAVE_WRITABLE_ARGV)
check_c_source_runs("
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
int main(void) {
return poll((void *)0, 0, 10 /*ms*/);
}" HAVE_POLL_FINE)
check_c_source_runs("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_attr_t type;
pthread_attr_init(&type);
return 0;
}" HAVE_PTHREADS)
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
return(s == -1);
}
"
ZMQ_HAVE_SOCK_CLOEXEC)
CHECK_C_SOURCE_RUNS("
int main()
{
__asm__ __volatile__ (\"pause\");
return 0;
}" HAVE_PAUSE_INSTRUCTION)
check_c_source_runs(
"#include <gc.h>
int main() {
int i= GC_get_parallel();
return 0;
}
"
GC_GET_PARALLEL_WORKS)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
static int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= 0xFFFFFFFFL << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
CHECK_C_SOURCE_RUNS("${_test_source}" ${_RESULT})
check_c_source_runs("
#include <stdlib.h>
#include <sys/time.h>
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#elif HAVE_POLL_H
# include <poll.h>
#endif
int main(void)
{
if(0 != poll(0, 0, 10)) {
return 1; /* fail */
}
else {
/* detect the 10.12 poll() breakage */
struct timeval before, after;
int rc;
size_t us;
gettimeofday(&before, NULL);
rc = poll(NULL, 0, 500);
gettimeofday(&after, NULL);
us = (after.tv_sec - before.tv_sec) * 1000000 +
(after.tv_usec - before.tv_usec);
if(us < 400000) {
return 1;
}
}
return 0;
}" HAVE_POLL_FINE)
check_c_source_runs("
#include <stdbool.h>
bool foo(int a, int b, int *c) {
return __builtin_mul_overflow(a, b, c);
}
int main() {
int out;
if (foo(1, 2, &out)) {
return 0;
}
return 0;
}" AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS)
check_c_source_runs("
#include <zfp.h>
int main()
{
zfp_stream* stream = zfp_stream_open(NULL);
return !zfp_stream_set_execution(stream, zfp_exec_cuda);
}"
ADIOS2_HAVE_ZFP_CUDA)
check_c_source_runs ("${source}" ${testname})
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= (~0L) << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
return(s == -1);
}
"
ZMQ_HAVE_SOCK_CLOEXEC)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
check_c_source_runs("${source}" ${outputVar})
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("${${type}_CODE}" HAS_${type}_${__FLAG_I})
check_c_source_runs ("${source}" ${testname})
check_c_source_runs("int main(int argc, char** argv){return 0;}" CHECK_M32_SUPPORT)
check_c_source_runs("
#include <nmmintrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
int main(void) {
__m128i v = _mm_setzero_si128();
v = _mm_cmpgt_epi64(v,v);
if (_mm_test_all_zeros(v, v)) return 0;
return 1;
}"
SUPPORT_SSE42_BUILD)
check_c_source_runs (${PROG_SRC} PROG_OUTPUT)
check_c_source_runs("${${type}_CODE}" HAS_${type}_${__FLAG_I})
check_c_source_runs(
"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/event.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int
main(int argc, char **argv)
{
int kq;
int n;
int fd[2];
struct kevent ev;
struct timespec ts;
char buf[80000];
if (pipe(fd) == -1)
exit(1);
if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
exit(1);
while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
;
if ((kq = kqueue()) == -1)
exit(1);
memset(&ev, 0, sizeof(ev));
ev.ident = fd[1];
ev.filter = EVFILT_WRITE;
ev.flags = EV_ADD | EV_ENABLE;
n = kevent(kq, &ev, 1, NULL, 0, NULL);
if (n == -1)
exit(1);
read(fd[0], buf, sizeof(buf));
ts.tv_sec = 0;
ts.tv_nsec = 0;
n = kevent(kq, NULL, 0, &ev, 1, &ts);
if (n == -1 || n == 0)
exit(1);
exit(0);
}
" EVENT__HAVE_WORKING_KQUEUE)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
CHECK_C_SOURCE_RUNS("
int main()
{
__asm__ __volatile__ (\"pause\");
return 0;
}" HAVE_PAUSE_INSTRUCTION)
check_c_source_runs("
int main(int argc, char **argv)
{
(void)argc;
argv[0][0] = ' ';
return (argv[0][0] == ' ')?0:1;
}" HAVE_WRITABLE_ARGV)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs("${UDUNITS2_TEST_SRC}" UDUNITS2_WORKS_WITHOUT_LEXPAT)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= (~0L) << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
CHECK_C_SOURCE_RUNS("
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sched.h>
int main()
{
(void)setns(0, 0);
return 0;
}" HAVE_SETNS)
CHECK_C_SOURCE_RUNS("
static inline int static_foo()
{
return 0;
}
int main(int argc, char *argv[])
{
static_foo();
return 0;
}" C_HAS_${KEYWORD})
check_c_source_runs(
"
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = 1.0 * 0x7FFFFFFF ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != 127)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_POSITIVE)
check_c_source_runs(
"
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int
main(int argc, char** argv)
{
pid_t pid;
int status;
if ((pid = fork()) == 0) _exit(0);
_exit(waitpid(pid, &status, WNOWAIT) == -1);
}"
EVENT__HAVE_WAITPID_WITH_WNOWAIT)
CHECK_C_SOURCE_RUNS("${SAMPLE_SOURCE}" ${VAR})
check_c_source_runs("${SCOTCH_C_TEST_SCOTCH_Num_4}" SCOTCH_Num_4)
check_c_source_runs("
#include <pthread.h>
int main(int argc, char** argv) {
pthread_attr_t type;
pthread_attr_init(&type);
return 0;
}" HAVE_PTHREADS)
CHECK_C_SOURCE_RUNS("int main() { return 0;}" ${_RESULT})
check_c_source_runs("
#include <stdbool.h>
bool foo(int a, int b, int *c) {
return __builtin_mul_overflow(a, b, c);
}
int main() {
int out;
if (foo(1, 2, &out)) {
return 0;
}
return 0;
}" AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS)
check_c_source_runs("
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
int main(void) {
return poll((void *)0, 0, 10 /*ms*/);
}" HAVE_POLL_FINE)
check_c_source_runs ("${source}" ${testname})
check_c_source_runs("
int main(int argc, char **argv)
{
(void)argc;
argv[0][0] = ' ';
return (argv[0][0] == ' ')?0:1;
}" HAVE_WRITABLE_ARGV)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= (~0L) << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
check_c_source_runs("#include <stdio.h>\nint main(){char o[8];sprintf(o, \"%zu\", (size_t)7);return o[0] != '7';}" HAVE_PRINTF_Z)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= (~0L) << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
CHECK_C_SOURCE_RUNS(
"#include <gc.h>
int main() {
int i= GC_get_parallel();
return 0;
}
" GC_GET_PARALLEL_WORKS)
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
return(s == -1);
}
"
ZMQ_HAVE_SOCK_CLOEXEC)
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
return(s == -1);
}
"
ZMQ_HAVE_SOCK_CLOEXEC)
check_c_source_runs("${PTSCOTCH_C_TEST_SCOTCH_Num_4}" PTSCOTCH_Num_4)
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/time.h>
#include <sys/event.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int
main(int argc, char **argv)
{
int kq;
int n;
int fd[2];
struct kevent ev;
struct timespec ts;
char buf[80000];
if (pipe(fd) == -1)
exit(1);
if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
exit(1);
while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
;
if ((kq = kqueue()) == -1)
exit(1);
memset(&ev, 0, sizeof(ev));
ev.ident = fd[1];
ev.filter = EVFILT_WRITE;
ev.flags = EV_ADD | EV_ENABLE;
n = kevent(kq, &ev, 1, NULL, 0, NULL);
if (n == -1)
exit(1);
read(fd[0], buf, sizeof(buf));
ts.tv_sec = 0;
ts.tv_nsec = 0;
n = kevent(kq, NULL, 0, &ev, 1, &ts);
if (n == -1 || n == 0)
exit(1);
exit(0);
}
" EVENT__HAVE_WORKING_KQUEUE)
check_c_source_runs("
#include <emmintrin.h>
#include <smmintrin.h>
int main()
{
__m128i a = _mm_setzero_si128();
__m128i b = _mm_minpos_epu16(a);
return 0;
}"
HAVE_SSE)
CHECK_C_SOURCE_RUNS("
int main()
{
__asm__ __volatile__ (\"pause\");
return 0;
}" HAVE_PAUSE_INSTRUCTION)
CHECK_C_SOURCE_RUNS("
int main()
{
__asm__ __volatile__ (\"pause\");
return 0;
}" HAVE_PAUSE_INSTRUCTION)
check_c_source_runs ("${source}" ${testname})
check_c_source_runs("int main(void) { return 0; }" CMAKE_HOST_CAN_RUN_EXECUTABLES_BUILT_FOR_TARGET)
check_c_source_runs("${avx_prog}" proc_found_avx)
check_c_source_runs(
"
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int
main(int argc, char** argv)
{
pid_t pid;
int status;
if ((pid = fork()) == 0) _exit(0);
_exit(waitpid(pid, &status, WNOWAIT) == -1);
}"
EVENT__HAVE_WAITPID_WITH_WNOWAIT)
check_c_source_runs(
"
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = 1.0 * 0x7FFFFFFF ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != 127)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_POSITIVE)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
static int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= 0xFFFFFFFFL << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
CHECK_C_SOURCE_RUNS("#define ICONV_DETECT_BUILD_DIR \"${_binary_dir_with_separator}\"
#include \"${CMAKE_SOURCE_DIR}/iconv-detect.c\"" _correct_iconv)
CHECK_C_SOURCE_RUNS("
#include <sys/types.h>
#define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
int main (int argc, char **argv) {
int big_off_t=((BIG_OFF_T%2147483629==721) &&
(BIG_OFF_T%2147483647==1));
return big_off ? 0 : 1;
}
" HAVE_LARGE_FILE_SUPPORT)