aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-12-25 17:22:57 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2015-12-25 17:22:57 +0200
commit489ca238c57a6246ce8867cfd9c611322abd7e5d (patch)
treee34b4a04e6000e3874cc3e4ece06ca26f2e79b90
parent6a5ec36aeba126feecf7f2d85daad90fbc0e4ec9 (diff)
downloadmeson-489ca238c57a6246ce8867cfd9c611322abd7e5d.zip
meson-489ca238c57a6246ce8867cfd9c611322abd7e5d.tar.gz
meson-489ca238c57a6246ce8867cfd9c611322abd7e5d.tar.bz2
Test threads with both C and C++.
-rw-r--r--test cases/common/102 threads/meson.build16
-rw-r--r--test cases/common/102 threads/threadprog.c40
2 files changed, 52 insertions, 4 deletions
diff --git a/test cases/common/102 threads/meson.build b/test cases/common/102 threads/meson.build
index ca3eee5..78e5fbe 100644
--- a/test cases/common/102 threads/meson.build
+++ b/test cases/common/102 threads/meson.build
@@ -1,7 +1,15 @@
-project('threads', 'cpp')
+project('threads', 'cpp', 'c')
-test('threadtest',
- executable('threadprog', 'threadprog.cpp',
- dependencies : dependency('threads')
+threaddep = dependency('threads')
+
+test('cppthreadtest',
+ executable('cppthreadprog', 'threadprog.cpp',
+ dependencies : threaddep
+ )
+)
+
+test('cthreadtest',
+ executable('cthreadprog', 'threadprog.c',
+ dependencies : threaddep
)
)
diff --git a/test cases/common/102 threads/threadprog.c b/test cases/common/102 threads/threadprog.c
new file mode 100644
index 0000000..2dff169
--- /dev/null
+++ b/test cases/common/102 threads/threadprog.c
@@ -0,0 +1,40 @@
+#if defined _WIN32
+
+#include<windows.h>
+#include<stdio.h>
+
+DWORD WINAPI thread_func(LPVOID ignored) {
+ printf("Printing from a thread.\n");
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ printf("Starting thread.\n");
+ HANDLE th;
+ DWORD id;
+ th = CreateThread(NULL, 0, thread_func, NULL, 0, &id);
+ WaitForSingleObject(th, INFINITE);
+ printf("Stopped thread.\n");
+ return 0;
+}
+#else
+
+#include<pthread.h>
+#include<stdio.h>
+
+void* main_func(void* ignored) {
+ printf("Printing from a thread.\n");
+ return NULL;
+}
+
+int main(int argc, char** argv) {
+ pthread_t thread;
+ int rc;
+ printf("Starting thread.\n");
+ rc = pthread_create(&thread, NULL, main_func, NULL);
+ rc = pthread_join(thread, NULL);
+ printf("Stopped thread.\n");
+ return rc;
+}
+
+#endif