/*
* Threading primitives for CUPS.
*
- * Copyright 2009-2016 by Apple Inc.
+ * Copyright © 2009-2018 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
{
struct timespec abstime; /* Timeout */
- abstime.tv_sec = (long)timeout;
- abstime.tv_nsec = (long)(1000000000 * (timeout - (long)timeout));
+ clock_gettime(CLOCK_REALTIME, &abstime);
+
+ abstime.tv_sec += (long)timeout;
+ abstime.tv_nsec += (long)(1000000000 * (timeout - (long)timeout));
+
+ while (abstime.tv_nsec >= 1000000000)
+ {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec ++;
+ };
pthread_cond_timedwait(cond, mutex, &abstime);
}
}
+/*
+ * '_cupsThreadDetach()' - Tell the OS that the thread is running independently.
+ */
+
+void
+_cupsThreadDetach(_cups_thread_t thread)/* I - Thread ID */
+{
+ pthread_detach(thread);
+}
+
+
/*
* '_cupsThreadWait()' - Wait for a thread to exit.
*/
}
-#elif defined(WIN32)
+#elif defined(_WIN32)
# include <process.h>
+/*
+ * '_cupsCondBroadcast()' - Wake up waiting threads.
+ */
+
+void
+_cupsCondBroadcast(_cups_cond_t *cond) /* I - Condition */
+{
+ // TODO: Implement me
+}
+
+
+/*
+ * '_cupsCondInit()' - Initialize a condition variable.
+ */
+
+void
+_cupsCondInit(_cups_cond_t *cond) /* I - Condition */
+{
+ // TODO: Implement me
+}
+
+
+/*
+ * '_cupsCondWait()' - Wait for a condition with optional timeout.
+ */
+
+void
+_cupsCondWait(_cups_cond_t *cond, /* I - Condition */
+ _cups_mutex_t *mutex, /* I - Mutex */
+ double timeout) /* I - Timeout in seconds (0 or negative for none) */
+{
+ // TODO: Implement me
+}
+
+
/*
* '_cupsMutexInit()' - Initialize a mutex.
*/
}
+/*
+ * '_cupsThreadDetach()' - Tell the OS that the thread is running independently.
+ */
+
+void
+_cupsThreadDetach(_cups_thread_t thread)/* I - Thread ID */
+{
+ // TODO: Implement me
+ (void)thread;
+}
+
+
/*
* '_cupsThreadWait()' - Wait for a thread to exit.
*/
void * /* O - Return value */
_cupsThreadWait(_cups_thread_t thread) /* I - Thread ID */
+{
+ // TODO: Implement me
+ (void)thread;
+
+ return (NULL);
+}
+
+
+#else /* No threading */
+/*
+ * '_cupsCondBroadcast()' - Wake up waiting threads.
+ */
+
+void
+_cupsCondBroadcast(_cups_cond_t *cond) /* I - Condition */
+{
+ // TODO: Implement me
+}
+
+
+/*
+ * '_cupsCondInit()' - Initialize a condition variable.
+ */
+
+void
+_cupsCondInit(_cups_cond_t *cond) /* I - Condition */
+{
+ // TODO: Implement me
+}
+
+
+/*
+ * '_cupsCondWait()' - Wait for a condition with optional timeout.
+ */
+
+void
+_cupsCondWait(_cups_cond_t *cond, /* I - Condition */
+ _cups_mutex_t *mutex, /* I - Mutex */
+ double timeout) /* I - Timeout in seconds (0 or negative for none) */
{
// TODO: Implement me
}
-#else
/*
* '_cupsMutexInit()' - Initialize a mutex.
*/
_cups_thread_func_t func, /* I - Entry point */
void *arg) /* I - Entry point context */
{
- fputs("DEBUG: CUPS was compiled without threading support, no thread "
- "created.\n", stderr);
+ fputs("DEBUG: CUPS was compiled without threading support, no thread created.\n", stderr);
(void)func;
(void)arg;
}
+/*
+ * '_cupsThreadDetach()' - Tell the OS that the thread is running independently.
+ */
+
+void
+_cupsThreadDetach(_cups_thread_t thread)/* I - Thread ID */
+{
+ (void)thread;
+}
+
+
/*
* '_cupsThreadWait()' - Wait for a thread to exit.
*/