#include <fcntl.h>
#include <signal.h>
+#include "sysdep.h"
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
# endif
#endif
+#ifdef HAVE_SYSCALL_H
+# include <syscall.h>
+#else
+# if HAVE_SYS_SYSCALL_H
+# include <sys/syscall.h>
+# endif
+#endif
+
#include <libcitadel.h>
#include "threads.h"
* remove the need for the calls to eCrashRegisterThread and friends
*/
-static int next_tid = 3; /* offset LWPID to PID */
static int num_threads = 0; /* Current number of threads */
static int num_workers = 0; /* Current number of worker threads */
long statcount = 0; /* are we doing a stats check? */
#endif
// Tell the world we are here
+#if defined(HAVE_SYSCALL_H) && defined (SYS_gettid)
+ this_thread->reltid = syscall(SYS_gettid);
+#endif
CtdlLogPrintf(CTDL_NOTICE, "Created a new thread \"%s\" (0x%08lx).\n",
this_thread->name, this_thread->tid);
free(this_thread);
return NULL;
}
- this_thread->reltid = next_tid;
- next_tid++;
num_threads++; // Increase the count of threads in the system.
if(this_thread->flags & CTDLTHREAD_WORKER)
num_workers++;