summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbje <bje>1998-10-04 21:04:28 +0000
committerbje <bje>1998-10-04 21:04:28 +0000
commitd0aed2a7bfdad688de32a7c4d894590502e6bac4 (patch)
treef101dc214318f924a902a1e81986c6206415cc1a /tests
parent11b839f08794de0d090811580a09aa6db5b21f2c (diff)
1998-10-05 Ben Elliston <bje@cygnus.com>
* misc.c (pthread_once): Use the POSIX mutex primitives, not Win32. Remove irrelevant FIXME comment. * pthread.h (PTHREAD_ONCE_INIT): Define. * tests/once1.c: New file; test for pthread_once(). Passes.
Diffstat (limited to 'tests')
-rw-r--r--tests/once1.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/once1.c b/tests/once1.c
new file mode 100644
index 0000000..f4164ac
--- /dev/null
+++ b/tests/once1.c
@@ -0,0 +1,35 @@
+#include <pthread.h>
+#include <stdio.h>
+
+pthread_once_t once = PTHREAD_ONCE_INIT;
+
+void
+myfunc(void)
+{
+ printf("only see this once\n");
+}
+
+void *
+mythread(void * arg)
+{
+ int rc = pthread_once(&once, myfunc);
+ printf("returned %d\n", rc);
+
+ return 0;
+}
+
+int
+main()
+{
+ int rc;
+ pthread_t t1, t2;
+
+ rc = pthread_create(&t1, NULL, mythread, NULL);
+ printf("pthread_create returned %d\n", rc);
+
+ rc = pthread_create(&t2, NULL, mythread, NULL);
+ printf("pthread_create returned %d\n", rc);
+
+ Sleep(2000);
+ return 0;
+}