[AC_TRY_RUN([
#include <pthread.h>
#include <sys/types.h>
-#include <unistd.h>
+#include <linux/unistd.h>
+#include <unistd.h>
+_syscall0(pid_t,gettid)
+
pid_t other_pid = 0;
-void* func(void* data) {other_pid = getpid();}
+void* func(void* data) {other_pid = gettid();}
main()
{ pthread_t t;
void *ret;
pthread_create (&t, 0, func, NULL);
pthread_join (t, &ret);
- exit (getpid()==other_pid ||
+ exit (gettid()==other_pid ||
$posix_priority_min != $posix_priority_max);
} ],
[glib_cv_use_pid_surrogate=yes],
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>
+#include <linux/unistd.h>
+_syscall0(pid_t,gettid)
#endif /* G_THREAD_USE_PID_SURROGATE */
#ifdef HAVE_UNISTD_H
gpointer retval;
GSystemThread system_thread;
#ifdef G_THREAD_USE_PID_SURROGATE
- pid_t pid;
+ pid_t tid;
#endif /* G_THREAD_USE_PID_SURROGATE */
};
#ifdef G_THREAD_USE_PID_SURROGATE
static gint priority_map[4];
static gboolean prio_warned = FALSE;
-# define SET_PRIO(pid, prio) G_STMT_START{ \
- gint error = setpriority (PRIO_PROCESS, (pid), priority_map[prio]); \
+# define SET_PRIO(tid, prio) G_STMT_START{ \
+ gint error = setpriority (PRIO_PROCESS, (tid), priority_map[prio]); \
if (error == -1 && errno == EACCES && !prio_warned) \
{ \
prio_warned = TRUE; \
#ifdef G_THREAD_USE_PID_SURROGATE
priority_map[G_THREAD_PRIORITY_NORMAL] =
- getpriority (PRIO_PROCESS, (getpid ()));
+ getpriority (PRIO_PROCESS, (gettid ()));
priority_map[G_THREAD_PRIORITY_LOW] =
MIN (20, priority_map[G_THREAD_PRIORITY_NORMAL] + 10);
priority_map[G_THREAD_PRIORITY_HIGH] =
g_assert (data);
#ifdef G_THREAD_USE_PID_SURROGATE
- thread->pid = getpid ();
+ thread->tid = gettid ();
#endif /* G_THREAD_USE_PID_SURROGATE */
/* This has to happen before G_LOCK, as that might call g_thread_self */
#ifdef G_THREAD_USE_PID_SURROGATE
if (g_thread_use_default_impl)
- SET_PRIO (thread->pid, thread->thread.priority);
+ SET_PRIO (thread->tid, thread->thread.priority);
#endif /* G_THREAD_USE_PID_SURROGATE */
thread->retval = thread->thread.func (thread->thread.data);
#ifdef G_THREAD_USE_PID_SURROGATE
if (g_thread_use_default_impl)
- SET_PRIO (real->pid, priority);
+ SET_PRIO (real->tid, priority);
else
#endif /* G_THREAD_USE_PID_SURROGATE */
G_THREAD_CF (thread_set_priority, (void)0,
G_THREAD_UF (thread_self, (&thread->system_thread));
#ifdef G_THREAD_USE_PID_SURROGATE
- thread->pid = getpid ();
+ thread->tid = gettid ();
#endif /* G_THREAD_USE_PID_SURROGATE */
g_private_set (g_thread_specific_private, thread);