summaryrefslogtreecommitdiff
path: root/meson-cc-tests
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2020-07-31 07:26:11 +0000
committerAkira TAGOH <akira@tagoh.org>2020-07-31 07:26:11 +0000
commit57a224f51d6c019e4ce5d75efb22f34a8330423e (patch)
treee3d7acfe511c07650db57c485c6dcf134e2c78a5 /meson-cc-tests
parent03aa12c75e117acb0d160212536f6f832e0dc8d9 (diff)
downloadfontconfig-57a224f51d6c019e4ce5d75efb22f34a8330423e.tar.gz
Add Meson build system
See https://mesonbuild.com
Diffstat (limited to 'meson-cc-tests')
-rw-r--r--meson-cc-tests/flexible-array-member-test.c14
-rw-r--r--meson-cc-tests/intel-atomic-primitives-test.c6
-rw-r--r--meson-cc-tests/solaris-atomic-operations.c8
3 files changed, 28 insertions, 0 deletions
diff --git a/meson-cc-tests/flexible-array-member-test.c b/meson-cc-tests/flexible-array-member-test.c
new file mode 100644
index 0000000..5f96756
--- /dev/null
+++ b/meson-cc-tests/flexible-array-member-test.c
@@ -0,0 +1,14 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+
+struct s { int n; double d[]; };
+
+int main(void)
+{
+ int m = getchar ();
+ struct s *p = malloc (offsetof (struct s, d)
+ + m * sizeof (double));
+ p->d[0] = 0.0;
+ return p->d != (double *) NULL;
+}
diff --git a/meson-cc-tests/intel-atomic-primitives-test.c b/meson-cc-tests/intel-atomic-primitives-test.c
new file mode 100644
index 0000000..a5c8040
--- /dev/null
+++ b/meson-cc-tests/intel-atomic-primitives-test.c
@@ -0,0 +1,6 @@
+void memory_barrier (void) { __sync_synchronize (); }
+int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
+int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
+void mutex_unlock (int *m) { __sync_lock_release (m); }
+
+int main(void) { return 0;}
diff --git a/meson-cc-tests/solaris-atomic-operations.c b/meson-cc-tests/solaris-atomic-operations.c
new file mode 100644
index 0000000..fae0acd
--- /dev/null
+++ b/meson-cc-tests/solaris-atomic-operations.c
@@ -0,0 +1,8 @@
+#include <atomic.h>
+/* This requires Solaris Studio 12.2 or newer: */
+#include <mbarrier.h>
+void memory_barrier (void) { __machine_rw_barrier (); }
+int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
+void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }
+
+int main(void) { return 0; }