1 /* System thread definitions
2 Copyright (C) 2012-2018 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
22 #ifdef THREADS_ENABLED
28 /* A system mutex is just a pthread mutex. This is only used for the
30 typedef pthread_mutex_t sys_mutex_t
;
32 typedef pthread_cond_t sys_cond_t
;
34 /* A system thread. */
35 typedef pthread_t sys_thread_t
;
37 #else /* HAVE_PTHREAD */
41 /* This header is indirectly included in every source file. We don't
42 want to include windows.h in every source file, so we repeat
43 declarations of the few necessary data types here (under different
44 names, to avoid conflicts with files that do include
48 struct _CRITICAL_SECTION_DEBUG
*DebugInfo
;
53 unsigned long SpinCount
;
56 enum { CONDV_SIGNAL
= 0, CONDV_BROADCAST
= 1, CONDV_MAX
= 2 };
59 /* Count of threads that are waiting for this condition variable. */
61 /* Critical section to protect changes to the count above. */
62 w32thread_critsect wait_count_lock
;
63 /* Handles of events used for signal and broadcast. */
64 void *events
[CONDV_MAX
];
68 typedef w32thread_critsect sys_mutex_t
;
70 typedef w32thread_cond_t sys_cond_t
;
72 typedef unsigned long sys_thread_t
;
74 #else /* !WINDOWSNT */
78 #endif /* WINDOWSNT */
79 #endif /* HAVE_PTHREAD */
81 #else /* THREADS_ENABLED */
83 /* For the no-threads case we can simply use dummy definitions. */
84 typedef int sys_mutex_t
;
85 typedef int sys_cond_t
;
86 typedef int sys_thread_t
;
88 #endif /* THREADS_ENABLED */
90 typedef void *(thread_creation_function
) (void *);
92 extern void sys_mutex_init (sys_mutex_t
*);
93 extern void sys_mutex_lock (sys_mutex_t
*);
94 extern void sys_mutex_unlock (sys_mutex_t
*);
96 extern void sys_cond_init (sys_cond_t
*);
97 extern void sys_cond_wait (sys_cond_t
*, sys_mutex_t
*);
98 extern void sys_cond_signal (sys_cond_t
*);
99 extern void sys_cond_broadcast (sys_cond_t
*);
100 extern void sys_cond_destroy (sys_cond_t
*);
102 extern sys_thread_t
sys_thread_self (void);
104 extern int sys_thread_create (sys_thread_t
*, const char *,
105 thread_creation_function
*,
108 extern void sys_thread_yield (void);
110 #endif /* SYSTHREAD_H */