summaryrefslogtreecommitdiff
path: root/meson-cc-tests
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2018-05-21 20:08:22 +0200
committerTim-Philipp Müller <tim@centricular.com>2020-07-31 12:21:50 +0100
commit596a82f2d185b101bd74645492821fe2f9e0daa0 (patch)
tree3a595c888df37054bebb989455e73ea3683c6477 /meson-cc-tests
parenta75f8df95761bf88b54c326c5312117ea5073010 (diff)
downloadcairo-596a82f2d185b101bd74645492821fe2f9e0daa0.tar.gz
Add meson build definitions
Co-Authored by: Nirbheek Chauhan <nirbheek@centricular.com> lb90 <luca.bacci982@gmail.com> Tim-Philipp Müller <tim@centricular.com>
Diffstat (limited to 'meson-cc-tests')
-rw-r--r--meson-cc-tests/atomic-ops-cxx11.c3
-rw-r--r--meson-cc-tests/atomic-ops-gcc-legacy.c3
-rw-r--r--meson-cc-tests/ft_has_color.c7
-rw-r--r--meson-cc-tests/ipc_rmid_deferred_release.c18
-rw-r--r--meson-cc-tests/mkdir-variant-1.c12
-rw-r--r--meson-cc-tests/mkdir-variant-2.c12
-rw-r--r--meson-cc-tests/pthread.c35
7 files changed, 90 insertions, 0 deletions
diff --git a/meson-cc-tests/atomic-ops-cxx11.c b/meson-cc-tests/atomic-ops-cxx11.c
new file mode 100644
index 000000000..aeef0d849
--- /dev/null
+++ b/meson-cc-tests/atomic-ops-cxx11.c
@@ -0,0 +1,3 @@
+int atomic_add(int i) { return __atomic_fetch_add(&i, 1, __ATOMIC_SEQ_CST); }
+int atomic_cmpxchg(int i, int j, int k) { return __atomic_compare_exchange_n(&i, &j, k, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
+int main(void) { return 0; }
diff --git a/meson-cc-tests/atomic-ops-gcc-legacy.c b/meson-cc-tests/atomic-ops-gcc-legacy.c
new file mode 100644
index 000000000..99331968d
--- /dev/null
+++ b/meson-cc-tests/atomic-ops-gcc-legacy.c
@@ -0,0 +1,3 @@
+int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
+int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
+int main(void) { return 0; }
diff --git a/meson-cc-tests/ft_has_color.c b/meson-cc-tests/ft_has_color.c
new file mode 100644
index 000000000..daeed7f35
--- /dev/null
+++ b/meson-cc-tests/ft_has_color.c
@@ -0,0 +1,7 @@
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+int main(void) {
+ FT_Long has_color = FT_HAS_COLOR(((FT_Face)NULL));
+ return 0;
+}
diff --git a/meson-cc-tests/ipc_rmid_deferred_release.c b/meson-cc-tests/ipc_rmid_deferred_release.c
new file mode 100644
index 000000000..2c9290d25
--- /dev/null
+++ b/meson-cc-tests/ipc_rmid_deferred_release.c
@@ -0,0 +1,18 @@
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+int main()
+{
+ char *shmaddr;
+ int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
+ if (id == -1) return 2;
+ shmaddr = shmat (id, 0, 0);
+ shmctl (id, IPC_RMID, 0);
+ if ((char*) shmat (id, 0, 0) == (char*) -1) {
+ shmdt (shmaddr);
+ return 1;
+ }
+ shmdt (shmaddr);
+ shmdt (shmaddr);
+ return 0;
+}
diff --git a/meson-cc-tests/mkdir-variant-1.c b/meson-cc-tests/mkdir-variant-1.c
new file mode 100644
index 000000000..88910d107
--- /dev/null
+++ b/meson-cc-tests/mkdir-variant-1.c
@@ -0,0 +1,12 @@
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+int main(int ac, char **av)
+{
+ mkdir("hello.world");
+ return 0;
+}
diff --git a/meson-cc-tests/mkdir-variant-2.c b/meson-cc-tests/mkdir-variant-2.c
new file mode 100644
index 000000000..d0ab7b298
--- /dev/null
+++ b/meson-cc-tests/mkdir-variant-2.c
@@ -0,0 +1,12 @@
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+int main(int ac, char **av)
+{
+ mkdir("hello.world", 0777);
+ return 0;
+}
diff --git a/meson-cc-tests/pthread.c b/meson-cc-tests/pthread.c
new file mode 100644
index 000000000..035cb3a94
--- /dev/null
+++ b/meson-cc-tests/pthread.c
@@ -0,0 +1,35 @@
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE /* for PTHREAD_MUTEX_INITIALIZER under linux */
+#endif
+#include <pthread.h>
+
+pthread_mutex_t test_mutex_initializer = PTHREAD_MUTEX_INITIALIZER;
+int test_mutex (void)
+{
+ int x = 0;
+ pthread_mutex_t mutex;
+ x |= pthread_mutex_init (&mutex, NULL);
+ x |= pthread_mutex_lock (&mutex);
+ x |= pthread_mutex_unlock (&mutex);
+ x |= pthread_mutex_destroy (&mutex);
+ return 0;
+}
+
+int test_mutex_attr (void)
+{
+ int x = 0;
+ pthread_mutexattr_t attr;
+ pthread_mutex_t mutex;
+ x |= pthread_mutexattr_init (&attr);
+ x |= pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+ x |= pthread_mutex_init (&mutex, &attr);
+ x |= pthread_mutex_lock (&mutex);
+ x |= pthread_mutex_unlock (&mutex);
+ x |= pthread_mutex_destroy (&mutex);
+ x |= pthread_mutexattr_destroy (&attr);
+ return x;
+}
+
+int main(void) {
+ return 0;
+}