diff --git a/lib/libkse/test/mutex_d.c b/lib/libkse/test/mutex_d.c index 801d7791e2dd..2aa3b1df661d 100644 --- a/lib/libkse/test/mutex_d.c +++ b/lib/libkse/test/mutex_d.c @@ -31,19 +31,20 @@ * * $FreeBSD$ */ + +#include +#include #include #include - -#include #include #include -#include "pthread.h" #include #include #include #include #include #include +#include "pthread.h" #if defined(_LIBC_R_) #include @@ -179,17 +180,17 @@ extern char *strtok_r(char *str, const char *sep, char **last); * Functions *----------------------------------------------------------*/ -#ifdef DEBUG +#if defined(_LIBC_R_) && defined(DEBUG) static void kern_switch (pthread_t pthread_out, pthread_t pthread_in) { if (pthread_out != NULL) - printf ("Swapping out thread 0x%x, ", (int) pthread_out); + printf ("Swapping out thread 0x%lx, ", (long) pthread_out); else printf ("Swapping out kernel thread, "); if (pthread_in != NULL) - printf ("swapping in thread 0x%x\n", (int) pthread_in); + printf ("swapping in thread 0x%lx\n", (long) pthread_in); else printf ("swapping in kernel thread.\n"); } @@ -465,8 +466,8 @@ waiter (void *arg) pthread_mutex_unlock (&waiter_mutex); } - log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id, - (int) pthread_self()); + log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id, + (long) pthread_self()); pthread_exit (arg); return (NULL); } @@ -512,8 +513,8 @@ lock_twice (void *arg) if (statep->ret == 0) pthread_mutex_unlock (statep->cmd.mutex); - log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id, - (int) pthread_self()); + log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id, + (long) pthread_self()); pthread_exit (arg); return (NULL); } @@ -522,8 +523,8 @@ lock_twice (void *arg) static void sighandler (int signo) { - log ("Signal handler caught signal %d, thread id 0x%x\n", - signo, (int) pthread_self()); + log ("Signal handler caught signal %d, thread id 0x%lx\n", + signo, (long) pthread_self()); if (signo == SIGINT) done = 1; @@ -1481,7 +1482,7 @@ int main (int argc, char *argv[]) /* Create a pipe to catch the results of thread wakeups. */ assert (pipe (pipefd) == 0); -#ifdef DEBUG +#if defined(_LIBC_R_) && defined(DEBUG) assert (pthread_switch_add_np (kern_switch) == 0); #endif diff --git a/lib/libpthread/test/mutex_d.c b/lib/libpthread/test/mutex_d.c index 801d7791e2dd..2aa3b1df661d 100644 --- a/lib/libpthread/test/mutex_d.c +++ b/lib/libpthread/test/mutex_d.c @@ -31,19 +31,20 @@ * * $FreeBSD$ */ + +#include +#include #include #include - -#include #include #include -#include "pthread.h" #include #include #include #include #include #include +#include "pthread.h" #if defined(_LIBC_R_) #include @@ -179,17 +180,17 @@ extern char *strtok_r(char *str, const char *sep, char **last); * Functions *----------------------------------------------------------*/ -#ifdef DEBUG +#if defined(_LIBC_R_) && defined(DEBUG) static void kern_switch (pthread_t pthread_out, pthread_t pthread_in) { if (pthread_out != NULL) - printf ("Swapping out thread 0x%x, ", (int) pthread_out); + printf ("Swapping out thread 0x%lx, ", (long) pthread_out); else printf ("Swapping out kernel thread, "); if (pthread_in != NULL) - printf ("swapping in thread 0x%x\n", (int) pthread_in); + printf ("swapping in thread 0x%lx\n", (long) pthread_in); else printf ("swapping in kernel thread.\n"); } @@ -465,8 +466,8 @@ waiter (void *arg) pthread_mutex_unlock (&waiter_mutex); } - log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id, - (int) pthread_self()); + log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id, + (long) pthread_self()); pthread_exit (arg); return (NULL); } @@ -512,8 +513,8 @@ lock_twice (void *arg) if (statep->ret == 0) pthread_mutex_unlock (statep->cmd.mutex); - log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id, - (int) pthread_self()); + log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id, + (long) pthread_self()); pthread_exit (arg); return (NULL); } @@ -522,8 +523,8 @@ lock_twice (void *arg) static void sighandler (int signo) { - log ("Signal handler caught signal %d, thread id 0x%x\n", - signo, (int) pthread_self()); + log ("Signal handler caught signal %d, thread id 0x%lx\n", + signo, (long) pthread_self()); if (signo == SIGINT) done = 1; @@ -1481,7 +1482,7 @@ int main (int argc, char *argv[]) /* Create a pipe to catch the results of thread wakeups. */ assert (pipe (pipefd) == 0); -#ifdef DEBUG +#if defined(_LIBC_R_) && defined(DEBUG) assert (pthread_switch_add_np (kern_switch) == 0); #endif