1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
$NetBSD: patch-src_zm_thread_cpp,v 1.4 2022/09/27 01:20:39 gdt Exp $
pthread_mutex_timedlock() is not available on NetBSD 5.0, and not required
in ZoneMinder.
Work around varying notion of an undefined mpid on pthread/not.
--- src/zm_thread.cpp.orig 2019-02-22 15:38:47.000000000 +0000
+++ src/zm_thread.cpp
@@ -72,6 +72,7 @@ void Mutex::lock()
throw ThreadException( stringtf( "Unable to lock pthread mutex: %s", strerror(errno) ) );
}
+#if 0
void Mutex::lock( int secs )
{
struct timespec timeout = getTimeout( secs );
@@ -85,6 +86,7 @@ void Mutex::lock( double secs )
if ( pthread_mutex_timedlock( &mMutex, &timeout ) < 0 )
throw ThreadException( stringtf( "Unable to timedlock pthread mutex: %s", strerror(errno) ) );
}
+#endif
void Mutex::unlock()
{
@@ -232,9 +234,15 @@ template <class T> void ThreadData<T>::u
Debug( 9, "Updated value, %p", this );
}
+#ifndef USE_PTHREAD
+#define MPID_UNDEFINED -1
+#else /* USE_PTHREAD */
+#define MPID_UNDEFINED NULL
+#endif /* USE_PTHREAD */
+
Thread::Thread() :
mThreadCondition( mThreadMutex ),
- mPid( -1 ),
+ mPid( MPID_UNDEFINED ),
mStarted( false ),
mRunning( false )
{
@@ -307,7 +315,7 @@ void Thread::join()
if ( isThread() )
throw ThreadException( "Can't self join thread" );
mThreadMutex.lock();
- if ( mPid >= 0 )
+ if ( mPid != MPID_UNDEFINED )
{
if ( mStarted )
{
@@ -336,4 +344,5 @@ void Thread::kill( int signal )
}
// Some explicit template instantiations
-#include "zm_threaddata.cpp"
+template class ThreadData<bool>;
+template class ThreadData<int>;
|