Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / regress / lib / libpthread / once1 / once1.c
blob603edaca4d2a05faf124b614450c5123709ed98d
1 /* $NetBSD$ */
3 #include <assert.h>
4 #include <err.h>
5 #include <pthread.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 pthread_once_t once = PTHREAD_ONCE_INIT;
10 static int x;
12 void ofunc(void);
14 int
15 main(int argc, char *argv[])
18 printf("1: Test 1 of pthread_once()\n");
20 pthread_once(&once, ofunc);
21 pthread_once(&once, ofunc);
23 printf("1: X has value %d\n",x );
24 assert(x == 1);
26 return 0;
29 void
30 ofunc(void)
33 printf("Variable x has value %d\n", x);
34 x++;