summaryrefslogtreecommitdiff
path: root/test cases/common/99 threads/threadprog.c
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2018-08-18 23:58:49 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2018-08-18 23:58:49 +0300
commit1521e11e1d50b3c46260f3d3457d27fb51a2279a (patch)
treeed17817547da3e20c5c3080075c8924c24f6b3f9 /test cases/common/99 threads/threadprog.c
parent42e7412a64f596ff347887dd8cc2544a56111fbc (diff)
downloadmeson-condense.tar.gz
Condense test dirs.condense
Diffstat (limited to 'test cases/common/99 threads/threadprog.c')
-rw-r--r--test cases/common/99 threads/threadprog.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test cases/common/99 threads/threadprog.c b/test cases/common/99 threads/threadprog.c
new file mode 100644
index 000000000..47a5d1805
--- /dev/null
+++ b/test cases/common/99 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) {
+ DWORD id;
+ HANDLE th;
+ printf("Starting thread.\n");
+ 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