Commit 07703627 authored by Ting-Wei Lan's avatar Ting-Wei Lan Committed by Jehan

libgimpbase: Find thread ID on FreeBSD with thr_self

https://bugzilla.gnome.org/show_bug.cgi?id=795510
parent a007ad4b
......@@ -568,7 +568,7 @@ AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(execinfo.h fcntl.h sys/param.h sys/prctl.h sys/time.h sys/times.h sys/wait.h unistd.h)
AC_CHECK_HEADERS(execinfo.h fcntl.h sys/param.h sys/prctl.h sys/thr.h sys/time.h sys/times.h sys/wait.h unistd.h)
AC_CHECK_FUNCS(backtrace, , AC_CHECK_LIB(execinfo, backtrace))
AC_TYPE_PID_T
......@@ -579,6 +579,7 @@ AC_FUNC_ALLOCA
# check some more funcs
AC_CHECK_FUNCS(fsync)
AC_CHECK_FUNCS(difftime mmap)
AC_CHECK_FUNCS(thr_self)
AM_BINRELOC
......
......@@ -62,6 +62,10 @@
#include <sys/prctl.h>
#endif
#ifdef HAVE_SYS_THR_H
#include <sys/thr.h>
#endif
#endif /* G_OS_WIN32 */
#include "gimpbasetypes.h"
......@@ -1180,6 +1184,9 @@ gimp_stack_trace_print (const gchar *prog_name,
DWORD tid = GetCurrentThreadId ();
#elif defined(SYS_gettid)
long tid = syscall (SYS_gettid);
#elif defined(HAVE_THR_SELF)
long tid = 0;
thr_self (&tid);
#endif
g_snprintf (gimp_pid, 16, "%u", (guint) pid);
......@@ -1272,7 +1279,7 @@ gimp_stack_trace_print (const gchar *prog_name,
{
if (! stack_printed)
{
#if defined(G_OS_WIN32) || defined(SYS_gettid)
#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)
if (stream)
g_fprintf (stream,
"\n# Stack traces obtained from PID %d - Thread %lu #\n\n",
......@@ -1281,7 +1288,7 @@ gimp_stack_trace_print (const gchar *prog_name,
if (trace)
{
gtrace = g_string_new (NULL);
#if defined(G_OS_WIN32) || defined(SYS_gettid)
#if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)
g_string_printf (gtrace,
"\n# Stack traces obtained from PID %d - Thread %lu #\n\n",
pid, tid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment