GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
counter.c
Go to the documentation of this file.
1#include <grass/config.h>
2#ifdef HAVE_PTHREAD_H
3#define _XOPEN_SOURCE 500
4#endif
5#include <grass/gis.h>
6
7#ifdef HAVE_PTHREAD_H
8#include <pthread.h>
10#endif
11
12#ifdef HAVE_PTHREAD_H
13static void make_mutex(void)
14{
16 static int initialized;
18
19 if (initialized)
20 return;
21
23
24 if (initialized) {
26 return;
27 }
28
32 initialized = 1;
33
35}
36#endif
37
38void G_init_counter(struct Counter *c, int v)
39{
40#ifdef HAVE_PTHREAD_H
41 make_mutex();
42#endif
43 c->value = v;
44}
45
46int G_counter_next(struct Counter *c)
47{
48 int v;
49
50#ifdef HAVE_PTHREAD_H
52#endif
53 v = c->value++;
54#ifdef HAVE_PTHREAD_H
56#endif
57 return v;
58}
59
61{
62 if (*p)
63 return 1;
64
65#ifdef HAVE_PTHREAD_H
66 make_mutex();
68
69 if (*p) {
71 return 1;
72 }
73#endif
74 return 0;
75}
76
78{
79 *p = 1;
80
81#ifdef HAVE_PTHREAD_H
83#endif
84}
void G_initialize_done(int *p)
Definition counter.c:77
void G_init_counter(struct Counter *c, int v)
Definition counter.c:38
int G_is_initialized(int *p)
Definition counter.c:60
int G_counter_next(struct Counter *c)
Definition counter.c:46
Definition gis.h:625
int value
Definition gis.h:626