xref: /aosp_15_r20/external/libxml2/include/private/threads.h (revision 7c5688314b92172186c154356a6374bf7684c3ca)
1 #ifndef XML_THREADS_H_PRIVATE__
2 #define XML_THREADS_H_PRIVATE__
3 
4 #include <libxml/threads.h>
5 
6 #ifdef LIBXML_THREAD_ENABLED
7   #ifdef _WIN32
8     #define WIN32_LEAN_AND_MEAN
9     #ifdef _WIN32_WINNT
10       #undef _WIN32_WINNT
11     #endif
12     #define _WIN32_WINNT 0x0600
13     #include <windows.h>
14     #define HAVE_WIN32_THREADS
15   #else
16     #include <pthread.h>
17     #define HAVE_POSIX_THREADS
18   #endif
19 #endif
20 
21 /*
22  * xmlMutex are a simple mutual exception locks
23  */
24 struct _xmlMutex {
25 #ifdef HAVE_POSIX_THREADS
26     pthread_mutex_t lock;
27 #elif defined HAVE_WIN32_THREADS
28     CRITICAL_SECTION cs;
29 #else
30     int empty;
31 #endif
32 };
33 
34 /*
35  * xmlRMutex are reentrant mutual exception locks
36  */
37 struct _xmlRMutex {
38 #ifdef HAVE_POSIX_THREADS
39     pthread_mutex_t lock;
40     unsigned int held;
41     unsigned int waiters;
42     pthread_t tid;
43     pthread_cond_t cv;
44 #elif defined HAVE_WIN32_THREADS
45     CRITICAL_SECTION cs;
46 #else
47     int empty;
48 #endif
49 };
50 
51 XML_HIDDEN void
52 xmlInitMutex(xmlMutexPtr mutex);
53 XML_HIDDEN void
54 xmlCleanupMutex(xmlMutexPtr mutex);
55 
56 XML_HIDDEN void
57 xmlInitRMutex(xmlRMutexPtr mutex);
58 XML_HIDDEN void
59 xmlCleanupRMutex(xmlRMutexPtr mutex);
60 
61 #endif /* XML_THREADS_H_PRIVATE__ */
62