posix: don't segfault when calling ThreadsWait() without a valid thread
[deb_libcec.git] / src / lib / platform / posix / os-threads.h
index fc28fc9017235fcb4804797dbf217cd2da8897c3..89f822b0dec300a89aee85d2f55e62871fac9080 100644 (file)
@@ -52,8 +52,8 @@ namespace PLATFORM
     #ifdef __APPLE__
     struct timeval tv;
     gettimeofday(&tv, NULL);
-    now.tv_sec  = tv.tv_sec + 0;
-    now.tv_nsec = 0;
+    now.tv_sec  = tv.tv_sec;
+    now.tv_nsec = tv.tv_usec * 1000;
     #else
     clock_gettime(CLOCK_REALTIME, &now);
     #endif
@@ -66,7 +66,7 @@ namespace PLATFORM
   typedef pthread_t thread_t;
 
   #define ThreadsCreate(thread, func, arg)         (pthread_create(&thread, NULL, (void *(*) (void *))func, (void *)arg) == 0)
-  #define ThreadsWait(thread, retval)              (pthread_join(thread, retval) == 0)
+  #define ThreadsWait(thread, retval)              (thread ? pthread_join(thread, retval) == 0 : true)
 
   typedef pthread_mutex_t mutex_t;
   #define MutexCreate(mutex)                       pthread_mutex_init(&mutex, GetRecursiveMutexAttribute());