summaryrefslogtreecommitdiffstats
path: root/src/common/mythread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/mythread.h')
-rw-r--r--src/common/mythread.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/common/mythread.h b/src/common/mythread.h
index 4495e01..10ea2d4 100644
--- a/src/common/mythread.h
+++ b/src/common/mythread.h
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: 0BSD
+
///////////////////////////////////////////////////////////////////////////////
//
/// \file mythread.h
@@ -5,9 +7,6 @@
//
// Author: Lasse Collin
//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
///////////////////////////////////////////////////////////////////////////////
#ifndef MYTHREAD_H
@@ -112,6 +111,25 @@ mythread_sigmask(int how, const sigset_t *restrict set,
# include <sys/time.h>
#endif
+// MinGW-w64 with winpthreads:
+//
+// NOTE: Typical builds with MinGW-w64 don't use this code (MYTHREAD_POSIX).
+// Instead, native Windows threading APIs are used (MYTHREAD_VISTA or
+// MYTHREAD_WIN95).
+//
+// MinGW-w64 has _sigset_t (an integer type) in <sys/types.h>.
+// If _POSIX was #defined, the header would add the alias sigset_t too.
+// Let's keep this working even without _POSIX.
+//
+// There are no functions that actually do something with sigset_t
+// because signals barely exist on Windows. The sigfillset macro below
+// is just to silence warnings. There is no sigfillset() in MinGW-w64.
+#ifdef __MINGW32__
+# include <sys/types.h>
+# define sigset_t _sigset_t
+# define sigfillset(set_ptr) do { *(set_ptr) = 0; } while (0)
+#endif
+
#define MYTHREAD_RET_TYPE void *
#define MYTHREAD_RET_VALUE NULL
@@ -140,11 +158,13 @@ typedef struct timespec mythread_condtime;
// Use pthread_sigmask() to set the signal mask in multi-threaded programs.
// Do nothing on OpenVMS since it lacks pthread_sigmask().
+// Do nothing on MinGW-w64 too to silence warnings (its pthread_sigmask()
+// is #defined to 0 so it's a no-op).
static inline void
mythread_sigmask(int how, const sigset_t *restrict set,
sigset_t *restrict oset)
{
-#ifdef __VMS
+#if defined(__VMS) || defined(__MINGW32__)
(void)how;
(void)set;
(void)oset;
@@ -180,7 +200,7 @@ mythread_join(mythread thread)
}
-// Initiatlizes a mutex. Returns zero on success and non-zero on error.
+// Initializes a mutex. Returns zero on success and non-zero on error.
static inline int
mythread_mutex_init(mythread_mutex *mutex)
{