liballeg/allegro5
cmake/Common.cmake
:28
check_c_source_compiles("${source}" ${var})
check_c_source_compiles("${source}" ${var})
CHECK_C_SOURCE_COMPILES("
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
int main() {
union semun filler;
return 0;
}" HAVE_UNION_SEMUN)
check_c_source_compiles("${_source_epilogue}
int main(void)
{
int flag = MSG_NOSIGNAL;
(void)flag;
return 0;
}" HAVE_MSG_NOSIGNAL)
check_c_source_compiles("${_source_epilogue}
#ifdef _MSC_VER
#include <winsock2.h>
#endif
#include <time.h>
int main(void)
{
struct timeval ts;
ts.tv_sec = 0;
ts.tv_usec = 0;
(void)ts;
return 0;
}" HAVE_STRUCT_TIMEVAL)
check_c_source_compiles("${_source_epilogue}
int main(void)
{
h_errno = 2;
return h_errno != 0 ? 1 : 0;
}" HAVE_H_ERRNO_ASSIGNABLE)
check_c_source_compiles ("#include <windows.h>\nstruct _EXCEPTION_REGISTRATION_RECORD r; int main() { return 0; }" HAVE_EXCEPTION_REGISTRATION_RECORD)
check_c_source_compiles("#include <unistd.h>\nmain(){getpgrp();}" GETPGRP_VOID)
check_c_source_compiles("__thread int a = 42;main(){a = a + 1;}" HAVE___THREAD)
check_c_source_compiles("
#include <wchar.h>
mbstate_t x;
int main() { return 0; }"
HAVE_MBSTATE)
CHECK_C_SOURCE_COMPILES("${_CHECK_PROTO_EXISTS_SOURCE_CODE}" ${_RESULT})
check_c_source_compiles(
"#include <glib.h>
int main(){
g_regex_error_quark();
}"
GLIB2_USES_PCRE2)
check_c_source_compiles("
#include <emmintrin.h>
#include <immintrin.h>
int main(){ __m128 a = _mm_set1_ps(0.0f); a = _mm_cos_ps(a); return 0;}" HAS_COS_INTRINSIC)
check_c_source_compiles("
#include <emmintrin.h>
#include <immintrin.h>
int main(){ __m128 a = _mm_set1_ps(0.0f); __m128 b = _mm_set1_ps(0.0f); a = _mm_atan2_ps(a,b); return 0;}" HAS_ATAN2_INTRINSIC)
CHECK_C_SOURCE_COMPILES(
"${find_standard_math_library_test_program}"
standard_math_library_linked_to_automatically
)
check_c_source_compiles(_c_source ${_CCSF_RESULT})
check_c_source_compiles(
"
#include <stddef.h>
#include <stdio.h>
#include \"jpeglib.h\"
int main()
{
jpeg_read_scanlines(0,0,0);
jpeg12_read_scanlines(0,0,0);
return 0;
}
"
HAVE_JPEGTURBO_DUAL_MODE_8_12)
check_c_source_compiles(
"
#define _GNU_SOURCE
#include <sys/mman.h>
int main() { return (mremap(0,0,0,0,0) != 0); }
"
HAVE_5ARGS_MREMAP)
check_c_source_compiles(
"
#define _LARGEFILE64_SOURCE
#include <stdio.h>
int main() { long long off=0; fseeko64(NULL, off, SEEK_SET); off = ftello64(NULL); return 0; }
"
VSI_NEED_LARGEFILE64_SOURCE)
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
int main() { pread(0, NULL, 0, 0); return 0; }
"
HAVE_PREAD_BSD)
check_c_source_compiles(
"
int visible() { return 0; } __attribute__ ((visibility(\"default\")))
int hidden() { return 0; }
int main() { return 0; }
"
HAVE_HIDE_INTERNAL_SYMBOLS)
check_c_source_compiles(
"
int main() { int i; __sync_add_and_fetch(&i, 1); __sync_sub_and_fetch(&i, 1); __sync_bool_compare_and_swap(&i, 0, 1); return 0; }
"
HAVE_GCC_ATOMIC_BUILTINS)
CHECK_C_SOURCE_COMPILES("${_c_code}" ${_RESULT}
# Some compilers do not fail with a bad flag
FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU
${_CheckCCompilerFlag_COMMON_PATTERNS}
)
check_c_source_compiles("${SQLITE3_AUTO_EXTENSION_CHECK}" SQLite3_HAS_NON_DEPRECATED_AUTO_EXTENSION)
check_c_source_compiles(
"int main() { return 0; }"
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
check_c_source_compiles(
"int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}"
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
check_c_source_compiles(
"int main(void) {
unsigned int zero = 0;
long test = __builtin_ctz(zero);
(void)test;
return 0;
}"
HAVE_BUILTIN_CTZ
)
check_c_source_compiles(
"int main() { return 0; }"
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#include <features.h>
int main() { return 0; }"
HAVE_FLOATABI_HARD)
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
check_c_source_compiles(
"int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}"
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
check_c_source_compiles(
"#include <sys/auxv.h>
#include <asm/hwcap.h>
int main() {
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
}"
ARM_HWCAP_HAS_CRC32
)
check_c_source_compiles("
#include <stddef.h>
#include <iconv.h>
int main() {
char *a, *b;
size_t i, j;
iconv_t ic;
ic = iconv_open(\"to\", \"from\");
iconv(ic, &a, &i, &b, &j);
iconv_close(ic);
}
"
Iconv_EXPLICITLY_AT_ENV)
check_c_source_compiles("#include<iconv.h>
extern size_t iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
int main() {}"
HIDAPI_ICONV_CONST)
check_c_source_compiles(
"int main() { return 0; }"
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#include <features.h>
int main() { return 0; }"
HAVE_FLOATABI_SOFTFP)
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
check_c_source_compiles(
"int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}"
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
check_c_source_compiles(
"int main(void) {
unsigned int zero = 0;
long test = __builtin_ctzll(zero);
(void)test;
return 0;
}"
HAVE_BUILTIN_CTZLL
)
check_c_source_compiles(
"#include <sys/auxv.h>
int main() {
return (getauxval(AT_HWCAP) & HWCAP_CRC32);
}"
ARM_AUXV_HAS_CRC32
)
check_c_source_compiles(
"#include <sys/auxv.h>
int main() {
return (getauxval(AT_HWCAP) & HWCAP_NEON);
}"
ARM_AUXV_HAS_NEON
)
check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
HAVE_BUILTIN_CTZL)
check_c_source_compiles(
"int main() { return 0; }"
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#include <features.h>
int main() { return 0; }"
HAVE_FLOATABI_SOFTFP)
check_c_source_compiles(
"#include <features.h>
int main() { return 0; }"
HAVE_FLOATABI_HARD)
check_c_source_compiles(
"#ifndef __AVX__
# error \"AVX is not enabled.\"
#endif
int main(void) { return 0; }"
MSVC_IS_ENABLED_AVX
)
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
check_c_source_compiles(
"int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}"
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
check_c_source_compiles(
"#include <stddef.h>
int main() {
ptrdiff_t *a;
(void)a;
return 0;
}"
HAVE_PTRDIFF_T
)
check_c_source_compiles(
"#include <sys/auxv.h>
#include <asm/hwcap.h>
int main() {
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
}"
ARM_HWCAP_HAS_CRC32
)
check_c_source_compiles(
"#include <sys/auxv.h>
int main() {
return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON);
}"
ARM_AUXV_HAS_NEON
)
check_c_source_compiles(
"#include <sys/auxv.h>
int main() {
return (getauxval(AT_HWCAP) & HWCAP_NEON);
}"
ARM_AUXV_HAS_NEON
)
check_c_source_compiles(
"unsigned int f(unsigned int a, unsigned int b) {
unsigned int c;
__asm__ __volatile__ ( \"uqsub16 %0, %1, %2\" : \"=r\" (c) : \"r\" (a), \"r\" (b) );
return (int)c;
}
int main(void) { return f(1,2); }"
HAVE_ARMV6_INLINE_ASM
)
check_c_source_compiles(
"#include <immintrin.h>
__m512i f(__m512i x, __m512i y) {
__m512i z = _mm512_setzero_epi32();
return _mm512_dpbusd_epi32(z, x, y);
}
int main(void) { return 0; }"
HAVE_AVX512VNNI_INTRIN
)
check_c_source_compiles(
"#if defined(_M_ARM64) || defined(_M_ARM64EC)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
int main() { return 0; }"
NEON_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
int32x4x4_t f(int var[16]) { return vld1q_s32_x4(var); }
int main(void) { return 0; }"
NEON_HAS_LD4)
check_c_source_compiles(
"#include <altivec.h>
int main(void)
{
vector int a = vec_splats(0);
vector int b = vec_splats(0);
a = vec_add(a, b);
return 0;
}"
HAVE_NOVSX
)
check_c_source_compiles(
"#include <sys/auxv.h>
#include <linux/auxvec.h>
int main() {
return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00);
}"
HAVE_POWER9_INTRIN2
)
check_c_source_compiles(
"#include <immintrin.h>
__m128i f(__m128i u) {
__m128i v = _mm_set1_epi32(1);
return _mm_hadd_epi32(u, v);
}
int main(void) { return 0; }"
HAVE_SSSE3_INTRIN
)
check_c_source_compiles(
"#include <vecintrin.h>
int main(void) {
unsigned long long a __attribute__((vector_size(16))) = { 0 };
unsigned long long b __attribute__((vector_size(16))) = { 0 };
unsigned char c __attribute__((vector_size(16))) = { 0 };
c = vec_gfmsum_accum_128(a, b, c);
return c[0];
}"
HAVE_VGFMA_INTRIN FAIL_REGEX "not supported")
check_c_source_compiles(
"#ifdef _MSC_VER
# include <intrin.h>
#elif __GNUC__ == 8 && __GNUC_MINOR__ > 1
# include <xsaveintrin.h>
#else
# include <immintrin.h>
#endif
unsigned int f(unsigned int a) { return (int) _xgetbv(a); }
int main(void) { return 0; }"
HAVE_XSAVE_INTRIN FAIL_REGEX "not supported")
check_c_source_compiles("int main() { return 0; }" HAVE_SANITIZER_${check}
FAIL_REGEX "not supported|unrecognized command|unknown option")
check_c_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
CHECK_C_SOURCE_COMPILES("${CHECK_CHECK_CODE}" CHECK_CHECK_TEST)
CHECK_C_SOURCE_COMPILES("${LIBXML_LIBXML_CODE}" LIBXML_LIBXML_TEST2)
check_c_source_compiles(
"int main(void) {return 0;}" FLAG_${SIMD_COMPILE_FLAG} FAIL_REGEX
"warning: argument unused during compilation:" ${COMMON_PATTERNS})
check_c_source_compiles(
"
int main(void) {
(void)__builtin_bswap16(0);
return 0;
}
"
HAVE_BUILTIN_BSWAP16)
check_c_source_compiles(
"
int main(void) {
(void)__builtin_bswap32(0);
return 0;
}
"
HAVE_BUILTIN_BSWAP32)
check_c_source_compiles(
"
int main(void) {
(void)__builtin_bswap64(0);
return 0;
}
"
HAVE_BUILTIN_BSWAP64)
check_c_source_compiles(
"
#include <math.h>
int main(int argc, char** argv) {
return (int)pow(argc, 2.5);
}
"
HAVE_MATH_LIBRARY)
check_c_source_compiles(
"
#include <gif_lib.h>
int main(void) {
(void)DGifOpenFileHandle;
return 0;
}
"
GIF_COMPILES)
check_c_source_compiles("
${_THREADLOCAL_KEY} int tls;
int main(void) {
return 0;
}" HAVE_THREAD_LOCAL_STORAGE)
check_c_source_compiles("
#if (__CET__ & 3) == 0
#error \"CET not enabled\"
#endif
int main(void) { return 0; }" HAVE_CET)
check_c_source_compiles("
#if defined(__ARM_NEON__) || (!defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__))
#error \"Neon run-time auto-detection will not be used\"
#endif
#if __ARM_PCS_VFP == 1
#error \"float ABI = hard\"
#endif
#if __SOFTFP__ != 1
#error \"float ABI = softfp\"
#endif
int main(void) { return 0; }" NEED_SOFTFP_FOR_INTRINSICS)
check_c_source_compiles("
#include <arm_neon.h>
int main(int argc, char **argv) {
uint8_t input[64];
uint8x16x4_t output;
int i;
for (i = 0; i < 64; i++) input[i] = (uint8_t)argc;
output = vld1q_u8_x4(input);
vst4q_u8(input, output);
return (int)input[0];
}" HAVE_VLD1Q_U8_X4)
check_c_source_compiles("
#if !(defined(__mips__) && __mips_isa_rev >= 2)
#error MIPS DSPr2 is currently only available on MIPS32r2 platforms.
#endif
int main(void) {
int c = 0, a = 0, b = 0;
__asm__ __volatile__ (
\"precr.qb.ph %[c], %[a], %[b]\"
: [c] \"=r\" (c)
: [a] \"r\" (a), [b] \"r\" (b)
);
return c;
}" HAVE_DSPR2)
check_c_source_compiles(
"int main() { return 0; }"
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
check_c_source_compiles(
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
int Z_INTERNAL foo;
int main() {
return 0;
}"
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
check_c_source_compiles(
"int main(void) {
__attribute__((aligned(8))) int test = 0;
(void)test;
return 0;
}"
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
check_c_source_compiles(
"int main(void) {
unsigned int zero = 0;
long test = __builtin_ctzll(zero);
(void)test;
return 0;
}"
HAVE_BUILTIN_CTZLL
)
check_c_source_compiles(
"#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <arm_acle.h>
#endif
unsigned int f(unsigned int a, unsigned int b) {
return __crc32w(a, b);
}
int main(void) { return 0; }"
HAVE_ACLE_FLAG
)
check_c_source_compiles(
"unsigned int f(unsigned int a, unsigned int b) {
unsigned int c;
__asm__ __volatile__ ( \"uqsub16 %0, %1, %2\" : \"=r\" (c) : \"r\" (a), \"r\" (b) );
return (int)c;
}
int main(void) { return f(1,2); }"
HAVE_ARMV6_INLINE_ASM
)
check_c_source_compiles(
"#if defined(_MSC_VER)
#include <intrin.h>
#else
#include <arm_acle.h>
#endif
unsigned int f(unsigned int a, unsigned int b) {
#if defined(_MSC_VER)
return _arm_uqsub16(a, b);
#else
return __uqsub16(a, b);
#endif
}
int main(void) { return f(1,2); }"
HAVE_ARMV6_INTRIN
)
check_c_source_compiles(
"#include <immintrin.h>
__m256i f(__m256i x) {
const __m256i y = _mm256_set1_epi16(1);
return _mm256_subs_epu16(x, y);
}
int main(void) { return 0; }"
HAVE_AVX2_INTRIN
)
check_c_source_compiles(
"#if defined(_M_ARM64) || defined(_M_ARM64EC)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
int main() { return 0; }"
NEON_AVAILABLE FAIL_REGEX "not supported")
check_c_source_compiles(
"#include <immintrin.h>
#include <wmmintrin.h>
__m512i f(__m512i a) {
__m512i b = _mm512_setzero_si512();
return _mm512_clmulepi64_epi128(a, b, 0x10);
}
int main(void) { return 0; }"
HAVE_VPCLMULQDQ_INTRIN
)
check_c_source_compiles(
"#include <sys/auxv.h>
#ifdef __FreeBSD__
#include <machine/cpu.h>
#endif
int main() {
#ifdef __FreeBSD__
unsigned long hwcap;
elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap));
return (hwcap & PPC_FEATURE2_ARCH_3_00);
#else
return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00);
#endif
}"
HAVE_POWER9_INTRIN
)
check_c_source_compiles(
"#include <nmmintrin.h>
unsigned int f(unsigned int a, unsigned int b) { return _mm_crc32_u32(a, b); }
int main(void) { return 0; }"
HAVE_SSE42_INTRIN
)
check_c_source_compiles(
"#include <vecintrin.h>
int main(void) {
unsigned long long a __attribute__((vector_size(16))) = { 0 };
unsigned long long b __attribute__((vector_size(16))) = { 0 };
unsigned char c __attribute__((vector_size(16))) = { 0 };
c = vec_gfmsum_accum_128(a, b, c);
return c[0];
}"
HAVE_VGFMA_INTRIN FAIL_REGEX "not supported")
check_c_source_compiles(
"#ifdef _MSC_VER
# include <intrin.h>
#elif __GNUC__ == 8 && __GNUC_MINOR__ > 1
# include <xsaveintrin.h>
#else
# include <immintrin.h>
#endif
unsigned int f(unsigned int a) { return (int) _xgetbv(a); }
int main(void) { return 0; }"
HAVE_XSAVE_INTRIN FAIL_REGEX "not supported")
check_c_source_compiles("int main() { return 0; }" HAVE_SANITIZER_${check}
FAIL_REGEX "not supported|unrecognized command|unknown option")
check_c_source_compiles("#include <arm_neon.h>
int main() {
float a[] = {1.0, 1.0};
vld1q_f32_x2(a);
return 0;
}" HAS_VLD1)
check_c_source_compiles("
enum matrix_type {
matrix_Byte __parsec_attribute_deprecated__(\"Use PARSEC_MATRIX_BYTE instead\") = 1, /**< unsigned char */
matrix_Integer __parsec_attribute_deprecated__(\"Use PARSEC_MATRIX_INTEGER instead\") = 2, /**< signed int */
};
int main() {
return 0;
}" PARSEC_HAVE_ENUM_ATTRIBUTE_DEPRECATED)
check_c_source_compiles("#include <mpi.h>
int main(int argc, char* argv[]) {
#if (3 == OMPI_MAJOR_VERSION && 1 >= OMPI_MINOR_VERSION && 4 >= OMPI_RELEASE_VERSION) || (4 == OMPI_MAJOR_VERSION && 0 == OMPI_MINOR_VERSION && 1 >= OMPI_RELEASE_VERSION)
#warning \"malfunctionning mpi_assert_enable_overtaking found\"
#endif
return 0;
}"
PARSEC_HAVE_MPI_OVERTAKE
FAIL_REGEX "malfunctionning mpi_assert_enable_overtaking")
CHECK_C_SOURCE_COMPILES("
#if defined __has_builtin
# if !__has_builtin (__sync_bool_compare_and_swap_4)
# error Missing builtin for __sync_bool_compare_and_swap_4
# endif
#else
# warning Cannot be used for testing
#endif
#include <stdint.h>
int main(void) {
int32_t where = 0;
if (!__sync_bool_compare_and_swap(&where, 0, 1))
return -1;
return 0;
}
" PARSEC_ATOMIC_USE_GCC_32_BUILTINS)