From 596a82f2d185b101bd74645492821fe2f9e0daa0 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 21 May 2018 20:08:22 +0200 Subject: Add meson build definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored by: Nirbheek Chauhan lb90 Tim-Philipp Müller --- meson-cc-tests/atomic-ops-cxx11.c | 3 +++ meson-cc-tests/atomic-ops-gcc-legacy.c | 3 +++ meson-cc-tests/ft_has_color.c | 7 ++++++ meson-cc-tests/ipc_rmid_deferred_release.c | 18 +++++++++++++++ meson-cc-tests/mkdir-variant-1.c | 12 ++++++++++ meson-cc-tests/mkdir-variant-2.c | 12 ++++++++++ meson-cc-tests/pthread.c | 35 ++++++++++++++++++++++++++++++ 7 files changed, 90 insertions(+) create mode 100644 meson-cc-tests/atomic-ops-cxx11.c create mode 100644 meson-cc-tests/atomic-ops-gcc-legacy.c create mode 100644 meson-cc-tests/ft_has_color.c create mode 100644 meson-cc-tests/ipc_rmid_deferred_release.c create mode 100644 meson-cc-tests/mkdir-variant-1.c create mode 100644 meson-cc-tests/mkdir-variant-2.c create mode 100644 meson-cc-tests/pthread.c (limited to 'meson-cc-tests') 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 +#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 +#include +#include +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 +#endif +#ifdef HAVE_IO_H +#include +#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 +#endif +#ifdef HAVE_IO_H +#include +#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_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; +} -- cgit v1.2.1