summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile')
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_32_test.c8
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_64_test.c8
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/c11threads_test.c14
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c27
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/dlopen_test.c11
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/libsasl2_test.c7
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_darwin_test.c6
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_freebsd_test.c7
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_gnu_test.c5
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rand_r_test.c7
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rdkafka_setup.cmake122
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/regex_test.c10
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/strndup_test.c5
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_32_test.c8
-rw-r--r--src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_64_test.c8
15 files changed, 253 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_32_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_32_test.c
new file mode 100644
index 000000000..b3373bb8b
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_32_test.c
@@ -0,0 +1,8 @@
+#include <inttypes.h>
+
+int32_t foo(int32_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}
+
+int main() {
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_64_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_64_test.c
new file mode 100644
index 000000000..31922b85c
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/atomic_64_test.c
@@ -0,0 +1,8 @@
+#include <inttypes.h>
+
+int64_t foo(int64_t i) {
+ return __atomic_add_fetch(&i, 1, __ATOMIC_SEQ_CST);
+}
+
+int main() {
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/c11threads_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/c11threads_test.c
new file mode 100644
index 000000000..31681ae61
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/c11threads_test.c
@@ -0,0 +1,14 @@
+#include <threads.h>
+
+static int start_func(void *arg) {
+ int iarg = *(int *)arg;
+ return iarg;
+}
+
+void main(void) {
+ thrd_t thr;
+ int arg = 1;
+ if (thrd_create(&thr, start_func, (void *)&arg) != thrd_success) {
+ ;
+ }
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c
new file mode 100644
index 000000000..e80097803
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/crc32c_hw_test.c
@@ -0,0 +1,27 @@
+#include <inttypes.h>
+#include <stdio.h>
+#define LONGx1 "8192"
+#define LONGx2 "16384"
+void main(void) {
+ const char *n = "abcdefghijklmnopqrstuvwxyz0123456789";
+ uint64_t c0 = 0, c1 = 1, c2 = 2;
+ uint64_t s;
+ uint32_t eax = 1, ecx;
+ __asm__("cpuid" : "=c"(ecx) : "a"(eax) : "%ebx", "%edx");
+ __asm__(
+ "crc32b\t"
+ "(%1), %0"
+ : "=r"(c0)
+ : "r"(n), "0"(c0));
+ __asm__(
+ "crc32q\t"
+ "(%3), %0\n\t"
+ "crc32q\t" LONGx1
+ "(%3), %1\n\t"
+ "crc32q\t" LONGx2 "(%3), %2"
+ : "=r"(c0), "=r"(c1), "=r"(c2)
+ : "r"(n), "0"(c0), "1"(c1), "2"(c2));
+ s = c0 + c1 + c2;
+ printf("avoiding unused code removal by printing %d, %d, %d\n", (int)s,
+ (int)eax, (int)ecx);
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/dlopen_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/dlopen_test.c
new file mode 100644
index 000000000..ecb478994
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/dlopen_test.c
@@ -0,0 +1,11 @@
+#include <string.h>
+#include <dlfcn.h>
+
+int main() {
+ void *h;
+ /* Try loading anything, we don't care if it works */
+ h = dlopen("__nothing_rdkafka.so", RTLD_NOW | RTLD_LOCAL);
+ if (h)
+ dlclose(h);
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/libsasl2_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/libsasl2_test.c
new file mode 100644
index 000000000..3f3ab3409
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/libsasl2_test.c
@@ -0,0 +1,7 @@
+#include <string.h>
+#include <sasl/sasl.h>
+
+int main() {
+ sasl_done();
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_darwin_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_darwin_test.c
new file mode 100644
index 000000000..73e31e069
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_darwin_test.c
@@ -0,0 +1,6 @@
+#include <pthread.h>
+
+int main() {
+ pthread_setname_np("abc");
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_freebsd_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_freebsd_test.c
new file mode 100644
index 000000000..329ace08e
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_freebsd_test.c
@@ -0,0 +1,7 @@
+#include <pthread.h>
+#include <pthread_np.h>
+
+int main() {
+ pthread_set_name_np(pthread_self(), "abc");
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_gnu_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_gnu_test.c
new file mode 100644
index 000000000..3be1b21bc
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/pthread_setname_gnu_test.c
@@ -0,0 +1,5 @@
+#include <pthread.h>
+
+int main() {
+ return pthread_setname_np(pthread_self(), "abc");
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rand_r_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rand_r_test.c
new file mode 100644
index 000000000..be722d0a0
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rand_r_test.c
@@ -0,0 +1,7 @@
+#include <stdlib.h>
+
+int main() {
+ unsigned int seed = 0xbeaf;
+ (void)rand_r(&seed);
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rdkafka_setup.cmake b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rdkafka_setup.cmake
new file mode 100644
index 000000000..5ea7f7dc6
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/rdkafka_setup.cmake
@@ -0,0 +1,122 @@
+try_compile(
+ HAVE_REGEX
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/regex_test.c"
+)
+
+try_compile(
+ HAVE_STRNDUP
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/strndup_test.c"
+)
+
+try_compile(
+ HAVE_RAND_R
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/rand_r_test.c"
+)
+
+try_compile(
+ HAVE_PTHREAD_SETNAME_GNU
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/pthread_setname_gnu_test.c"
+ COMPILE_DEFINITIONS "-D_GNU_SOURCE"
+ LINK_LIBRARIES "-lpthread"
+)
+
+try_compile(
+ HAVE_PTHREAD_SETNAME_DARWIN
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/pthread_setname_darwin_test.c"
+ COMPILE_DEFINITIONS "-D_DARWIN_C_SOURCE"
+ LINK_LIBRARIES "-lpthread"
+)
+
+try_compile(
+ HAVE_PTHREAD_SETNAME_FREEBSD
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/pthread_setname_freebsd_test.c"
+ LINK_LIBRARIES "-lpthread"
+)
+
+# Atomic 32 tests {
+set(LINK_ATOMIC NO)
+set(HAVE_ATOMICS_32 NO)
+set(HAVE_ATOMICS_32_SYNC NO)
+
+try_compile(
+ _atomics_32
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/atomic_32_test.c"
+)
+
+if(_atomics_32)
+ set(HAVE_ATOMICS_32 YES)
+else()
+ try_compile(
+ _atomics_32_lib
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/atomic_32_test.c"
+ LINK_LIBRARIES "-latomic"
+ )
+ if(_atomics_32_lib)
+ set(HAVE_ATOMICS_32 YES)
+ set(LINK_ATOMIC YES)
+ else()
+ try_compile(
+ HAVE_ATOMICS_32_SYNC
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/sync_32_test.c"
+ )
+ endif()
+endif()
+# }
+
+# Atomic 64 tests {
+set(HAVE_ATOMICS_64 NO)
+set(HAVE_ATOMICS_64_SYNC NO)
+
+try_compile(
+ _atomics_64
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/atomic_64_test.c"
+)
+
+if(_atomics_64)
+ set(HAVE_ATOMICS_64 YES)
+else()
+ try_compile(
+ _atomics_64_lib
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/atomic_64_test.c"
+ LINK_LIBRARIES "-latomic"
+ )
+ if(_atomics_64_lib)
+ set(HAVE_ATOMICS_64 YES)
+ set(LINK_ATOMIC YES)
+ else()
+ try_compile(
+ HAVE_ATOMICS_64_SYNC
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/sync_64_test.c"
+ )
+ endif()
+endif()
+# }
+
+# C11 threads
+try_compile(
+ WITH_C11THREADS
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/c11threads_test.c"
+ LINK_LIBRARIES "-pthread"
+)
+# }
+
+# CRC32C {
+try_compile(
+ WITH_CRC32C_HW
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${TRYCOMPILE_SRC_DIR}/crc32c_hw_test.c"
+)
+# }
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/regex_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/regex_test.c
new file mode 100644
index 000000000..329098d20
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/regex_test.c
@@ -0,0 +1,10 @@
+#include <stddef.h>
+#include <regex.h>
+
+int main() {
+ regcomp(NULL, NULL, 0);
+ regexec(NULL, NULL, 0, NULL, 0);
+ regerror(0, NULL, NULL, 0);
+ regfree(NULL);
+ return 0;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/strndup_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/strndup_test.c
new file mode 100644
index 000000000..a10b74526
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/strndup_test.c
@@ -0,0 +1,5 @@
+#include <string.h>
+
+int main() {
+ return strndup("hi", 2) ? 0 : 1;
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_32_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_32_test.c
new file mode 100644
index 000000000..2bc80ab4c
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_32_test.c
@@ -0,0 +1,8 @@
+#include <inttypes.h>
+
+int32_t foo(int32_t i) {
+ return __sync_add_and_fetch(&i, 1);
+}
+
+int main() {
+}
diff --git a/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_64_test.c b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_64_test.c
new file mode 100644
index 000000000..4b6ad6d38
--- /dev/null
+++ b/src/fluent-bit/lib/librdkafka-2.1.0/packaging/cmake/try_compile/sync_64_test.c
@@ -0,0 +1,8 @@
+#include <inttypes.h>
+
+int64_t foo(int64_t i) {
+ return __sync_add_and_fetch(&i, 1);
+}
+
+int main() {
+}