X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-sysdeps-pthread.c;h=e1c14f9913f701aca805affd4fdf333f31567b10;hb=1962bd7b478b21ae054b836f41e944f2a45f6621;hp=c60457beec3a441c09c93ab02cb60e85ffea2fe0;hpb=c27c5004132e597a8f386be6f9e4235519096398;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index c60457b..e1c14f9 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -28,6 +28,7 @@ #include #include +#include #include #ifdef HAVE_ERRNO_H @@ -36,12 +37,14 @@ #include +#ifdef HAVE_MONOTONIC_CLOCK /* Whether we have a "monotonic" clock; i.e. a clock not affected by * changes in system time. * This is initialized once in check_monotonic_clock below. * https://bugs.freedesktop.org/show_bug.cgi?id=18121 */ static dbus_bool_t have_monotonic_clock = 0; +#endif struct DBusRMutex { pthread_mutex_t lock; /**< the lock */ @@ -70,7 +73,7 @@ struct DBusCondVar { #define PTHREAD_CHECK(func_name, result_or_call) do { \ int tmp = (result_or_call); \ if (tmp != 0) { \ - _dbus_warn_check_failed ("pthread function %s failed with %d %s in %s\n", \ + _dbus_warn_check_failed ("pthread function %s failed with %d %s in %s", \ func_name, tmp, strerror(tmp), _DBUS_FUNCTION_NAME); \ } \ } while (0) @@ -281,5 +284,37 @@ _dbus_threads_init_platform_specific (void) */ check_monotonic_clock (); (void) _dbus_check_setuid (); - return dbus_threads_init (NULL); + + return TRUE; +} + +static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; + +void +_dbus_threads_lock_platform_specific (void) +{ + pthread_mutex_lock (&init_mutex); +} + +void +_dbus_threads_unlock_platform_specific (void) +{ + pthread_mutex_unlock (&init_mutex); +} + +#ifdef DBUS_ENABLE_VERBOSE_MODE +/* + * If we can identify the current process and/or thread, print them to stderr followed by a colon. + */ +void +_dbus_print_thread (void) +{ +#ifdef __linux__ + /* we know a pthread_t is numeric on Linux */ + fprintf (stderr, "%lu: 0x%lx: ", _dbus_pid_for_log (), (unsigned long) pthread_self ()); +#else + /* in principle pthread_t isn't required to be printable */ + fprintf (stderr, "%lu: ", _dbus_pid_for_log ()); +#endif } +#endif