diff options
Diffstat (limited to 'src/core/lib/support')
-rw-r--r-- | src/core/lib/support/log_posix.c | 12 | ||||
-rw-r--r-- | src/core/lib/support/sync_posix.c | 7 | ||||
-rw-r--r-- | src/core/lib/support/time_windows.c | 8 |
3 files changed, 22 insertions, 5 deletions
diff --git a/src/core/lib/support/log_posix.c b/src/core/lib/support/log_posix.c index f972da0887..79458dd7a3 100644 --- a/src/core/lib/support/log_posix.c +++ b/src/core/lib/support/log_posix.c @@ -37,6 +37,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/log.h> +#include <grpc/support/string_util.h> #include <grpc/support/time.h> #include <pthread.h> #include <stdarg.h> @@ -93,10 +94,13 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09d %7tu %s:%d] %s\n", - gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line, - args->message); + char *prefix; + gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]", + gpr_log_severity_string(args->severity), time_buffer, + (int)(now.tv_nsec), gettid(), display_file, args->line); + + fprintf(stderr, "%-70s %s\n", prefix, args->message); + gpr_free(prefix); } #endif /* defined(GPR_POSIX_LOG) */ diff --git a/src/core/lib/support/sync_posix.c b/src/core/lib/support/sync_posix.c index dcb0969a4e..de0f0484b5 100644 --- a/src/core/lib/support/sync_posix.c +++ b/src/core/lib/support/sync_posix.c @@ -42,11 +42,18 @@ #include <time.h> #include "src/core/lib/profiling/timers.h" +#ifdef GPR_MU_COUNTERS +gpr_atm grpc_mu_locks = 0; +#endif + void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); } void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); } void gpr_mu_lock(gpr_mu* mu) { +#ifdef GPR_MU_COUNTERS + gpr_atm_no_barrier_fetch_add(&grpc_mu_locks, 1); +#endif GPR_TIMER_BEGIN("gpr_mu_lock", 0); GPR_ASSERT(pthread_mutex_lock(mu) == 0); GPR_TIMER_END("gpr_mu_lock", 0); diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/support/time_windows.c index 6459732879..7b94a5b7bf 100644 --- a/src/core/lib/support/time_windows.c +++ b/src/core/lib/support/time_windows.c @@ -56,7 +56,7 @@ void gpr_time_init(void) { g_time_scale = 1.0 / (double)frequency.QuadPart; } -gpr_timespec gpr_now(gpr_clock_type clock) { +static gpr_timespec now_impl(gpr_clock_type clock) { gpr_timespec now_tv; LONGLONG diff; struct _timeb now_tb; @@ -84,6 +84,12 @@ gpr_timespec gpr_now(gpr_clock_type clock) { return now_tv; } +gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl; + +gpr_timespec gpr_now(gpr_clock_type clock_type) { + return gpr_now_impl(clock_type); +} + void gpr_sleep_until(gpr_timespec until) { gpr_timespec now; gpr_timespec delta; |