+#ifndef _GL_PTHREAD_H_
+#define _GL_PTHREAD_H_
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <sys/types.h>
+#include <time.h>
+
+#if ! @HAVE_PTHREAD_T@
+ typedef int pthread_t;
+ typedef int pthread_attr_t;
+ typedef int pthread_barrier_t;
+ typedef int pthread_barrierattr_t;
+ typedef int pthread_cond_t;
+ typedef int pthread_condattr_t;
+ typedef int pthread_key_t;
+ typedef int pthread_mutex_t;
+ typedef int pthread_mutexattr_t;
+ typedef int pthread_once_t;
+ typedef int pthread_rwlock_t;
+ typedef int pthread_rwlockattr_t;
+#endif
+
+#ifndef PTHREAD_COND_INITIALIZER
+#define PTHREAD_COND_INITIALIZER { 0 }
+#define PTHREAD_MUTEX_INITIALIZER { 0 }
+#define PTHREAD_ONCE_INIT { 0 }
+#define PTHREAD_RWLOCK_INITIALIZER { 0 }
+
+#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
+
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 1
+
+#define PTHREAD_CANCEL_ENABLE 0
+#define PTHREAD_CANCEL_DISABLE 1
+
+#define PTHREAD_CANCELED ((void *) -1)
+
+#define PTHREAD_CREATE_JOINABLE 0
+#define PTHREAD_CREATE_DETACHED 1
+
+#define PTHREAD_INHERIT_SCHED 0
+#define PTHREAD_EXPLICIT_SCHED 1
+
+#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
+#define PTHREAD_MUTEX_NORMAL 0
+#define PTHREAD_MUTEX_ERRORCHECK 1
+#define PTHREAD_MUTEX_RECURSIVE 2
+
+#define PTHREAD_MUTEX_STALLED 0
+#define PTHREAD_MUTEX_ROBUST 1
+
+#define PTHREAD_PRIO_NONE 0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
+
+#define PTHREAD_PROCESS_PRIVATE 0
+#define PTHREAD_PROCESS_SHARED 1
+
+#define PTHREAD_SCOPE_SYSTEM 0
+#define PTHREAD_SCOPE_PROCESS 1
+#endif
+
+#if ! @HAVE_PTHREAD_T@
+
+/* Provide substitutes for the thread functions that should work
+ adequately on a single-threaded implementation, where
+ pthread_create always fails. The goal is to let programs compile
+ on non-pthread hosts with minimal runtime overhead.
+
+ Omit interfaces that have not been analyzed and for which we do not
+ know what to do, so that they elicit a compile-time error for
+ now. */
+
+static inline int
+pthread_cond_destroy (pthread_cond_t *cond)
+{
+ /* COND is never seriously used. */
+ return 0;
+}
+
+static inline int
+pthread_cond_init (pthread_cond_t *restrict cond,
+ pthread_condattr_t const *restrict attr)
+{
+ /* COND is never seriously used. */
+ return 0;
+}
+
+static inline int
+pthread_cond_signal (pthread_cond_t *cond)
+{
+ /* No threads can currently be blocked on COND. */
+ return 0;
+}
+
+static inline int
+pthread_cond_wait (pthread_cond_t *restrict cond,
+ pthread_mutex_t *restrict mutex)
+{
+ /* Properly-written applications never come here. */
+ abort ();
+ return 0;
+}
+
+static inline int