aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-08-21 12:02:15 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-08-21 12:02:15 -0700
commit1e9dd32803afed8db333a02aeca000c9ededf2cb (patch)
tree715e14106d91f41c7022c8aa7a8fbcb997fbdec9 /src/core/support
parente13bfc0139b4ddb560ee3a0e085dbf518a5dabe5 (diff)
parent3c807eac69acd711620aaf7ab44fd79ce406b35e (diff)
Merge branch 'master' into node_method_name_conflicts
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/cpu_iphone.c8
-rw-r--r--src/core/support/cpu_linux.c2
-rw-r--r--src/core/support/env.h2
-rw-r--r--src/core/support/file.h2
-rw-r--r--src/core/support/histogram.c11
-rw-r--r--src/core/support/log_linux.c4
-rw-r--r--src/core/support/murmur_hash.h2
-rw-r--r--src/core/support/slice.c3
-rw-r--r--src/core/support/slice_buffer.c3
-rw-r--r--src/core/support/stack_lockfree.c20
-rw-r--r--src/core/support/string.c19
-rw-r--r--src/core/support/string.h4
-rw-r--r--src/core/support/string_win32.c8
-rw-r--r--src/core/support/string_win32.h4
-rw-r--r--src/core/support/sync_posix.c3
-rw-r--r--src/core/support/sync_win32.c3
-rw-r--r--src/core/support/thd.c4
-rw-r--r--src/core/support/thd_internal.h2
-rw-r--r--src/core/support/thd_posix.c14
-rw-r--r--src/core/support/thd_win32.c4
-rw-r--r--src/core/support/time.c3
-rw-r--r--src/core/support/tls_pthread.c2
22 files changed, 58 insertions, 69 deletions
diff --git a/src/core/support/cpu_iphone.c b/src/core/support/cpu_iphone.c
index d412a6d7ee..82b49b47bc 100644
--- a/src/core/support/cpu_iphone.c
+++ b/src/core/support/cpu_iphone.c
@@ -36,9 +36,7 @@
#ifdef GPR_CPU_IPHONE
/* Probably 2 instead of 1, but see comment on gpr_cpu_current_cpu. */
-unsigned gpr_cpu_num_cores(void) {
- return 1;
-}
+unsigned gpr_cpu_num_cores(void) { return 1; }
/* Most code that's using this is using it to shard across work queues. So
unless profiling shows it's a problem or there appears a way to detect the
@@ -46,8 +44,6 @@ unsigned gpr_cpu_num_cores(void) {
Note that the interface in cpu.h lets gpr_cpu_num_cores return 0, but doing
it makes it impossible for gpr_cpu_current_cpu to satisfy its stated range,
and some code might be relying on it. */
-unsigned gpr_cpu_current_cpu(void) {
- return 0;
-}
+unsigned gpr_cpu_current_cpu(void) { return 0; }
#endif /* GPR_CPU_IPHONE */
diff --git a/src/core/support/cpu_linux.c b/src/core/support/cpu_linux.c
index 282d4daab1..7af6a8f009 100644
--- a/src/core/support/cpu_linux.c
+++ b/src/core/support/cpu_linux.c
@@ -33,7 +33,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
-#endif /* _GNU_SOURCE */
+#endif /* _GNU_SOURCE */
#include <grpc/support/port_platform.h>
diff --git a/src/core/support/env.h b/src/core/support/env.h
index 4f2e394d14..24172d8673 100644
--- a/src/core/support/env.h
+++ b/src/core/support/env.h
@@ -57,4 +57,4 @@ void gpr_setenv(const char *name, const char *value);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_ENV_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_ENV_H */
diff --git a/src/core/support/file.h b/src/core/support/file.h
index 1dafe390e3..d8b7cea44f 100644
--- a/src/core/support/file.h
+++ b/src/core/support/file.h
@@ -60,4 +60,4 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_FILE_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_FILE_H */
diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c
index 9029703891..78dbf98684 100644
--- a/src/core/support/histogram.c
+++ b/src/core/support/histogram.c
@@ -191,15 +191,18 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
break;
}
}
- return (bucket_start(h, (double)lower_idx) + bucket_start(h, (double)upper_idx)) / 2.0;
+ return (bucket_start(h, (double)lower_idx) +
+ bucket_start(h, (double)upper_idx)) /
+ 2.0;
} else {
/* treat values as uniform throughout the bucket, and find where this value
should lie */
lower_bound = bucket_start(h, (double)lower_idx);
upper_bound = bucket_start(h, (double)(lower_idx + 1));
- return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) *
- (count_so_far - count_below) /
- h->buckets[lower_idx],
+ return GPR_CLAMP(upper_bound -
+ (upper_bound - lower_bound) *
+ (count_so_far - count_below) /
+ h->buckets[lower_idx],
h->min_seen, h->max_seen);
}
}
diff --git a/src/core/support/log_linux.c b/src/core/support/log_linux.c
index 5ac36e7b95..02f64d8b7e 100644
--- a/src/core/support/log_linux.c
+++ b/src/core/support/log_linux.c
@@ -93,8 +93,8 @@ void gpr_default_log(gpr_log_func_args *args) {
}
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);
+ gpr_log_severity_string(args->severity), time_buffer,
+ (int)(now.tv_nsec), gettid(), display_file, args->line);
fprintf(stderr, "%-60s %s\n", prefix, args->message);
gpr_free(prefix);
diff --git a/src/core/support/murmur_hash.h b/src/core/support/murmur_hash.h
index 85ab2fe4bf..343fcb99f7 100644
--- a/src/core/support/murmur_hash.h
+++ b/src/core/support/murmur_hash.h
@@ -41,4 +41,4 @@
/* compute the hash of key (length len) */
gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed);
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */
diff --git a/src/core/support/slice.c b/src/core/support/slice.c
index e4196a48c6..53024e88f1 100644
--- a/src/core/support/slice.c
+++ b/src/core/support/slice.c
@@ -284,7 +284,8 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) {
head.refcount = NULL;
head.data.inlined.length = (gpr_uint8)split;
memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split);
- source->data.inlined.length = (gpr_uint8)(source->data.inlined.length - split);
+ source->data.inlined.length =
+ (gpr_uint8)(source->data.inlined.length - split);
memmove(source->data.inlined.bytes, source->data.inlined.bytes + split,
source->data.inlined.length);
} else if (split < sizeof(head.data.inlined.bytes)) {
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 6e6c72a2bf..987d5cb9b5 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -116,7 +116,8 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) {
GPR_SLICE_INLINED_SIZE) {
memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, s.data.inlined.length);
- back->data.inlined.length = (gpr_uint8)(back->data.inlined.length + s.data.inlined.length);
+ back->data.inlined.length =
+ (gpr_uint8)(back->data.inlined.length + s.data.inlined.length);
} else {
size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length,
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index bc741f8c70..27ecf62280 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -67,7 +67,7 @@ typedef union lockfree_node {
#define ENTRY_ALIGNMENT_BITS 3 /* make sure that entries aligned to 8-bytes */
#define INVALID_ENTRY_INDEX \
((1 << 16) - 1) /* reserve this entry as invalid \
- */
+ */
struct gpr_stack_lockfree {
lockfree_node *entries;
@@ -75,7 +75,7 @@ struct gpr_stack_lockfree {
#ifndef NDEBUG
/* Bitmap of pushed entries to check for double-push or pop */
- gpr_atm pushed[(INVALID_ENTRY_INDEX+1)/(8*sizeof(gpr_atm))];
+ gpr_atm pushed[(INVALID_ENTRY_INDEX + 1) / (8 * sizeof(gpr_atm))];
#endif
};
@@ -123,13 +123,13 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) {
#ifndef NDEBUG
/* Check for double push */
{
- int pushed_index = entry / (8*sizeof(gpr_atm));
- int pushed_bit = entry % (8*sizeof(gpr_atm));
+ int pushed_index = entry / (8 * sizeof(gpr_atm));
+ int pushed_bit = entry % (8 * sizeof(gpr_atm));
gpr_atm old_val;
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
- (gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (1UL<<pushed_bit)) == 0);
+ (gpr_atm)(1UL << pushed_bit));
+ GPR_ASSERT((old_val & (1UL << pushed_bit)) == 0);
}
#endif
@@ -161,13 +161,13 @@ int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack) {
#ifndef NDEBUG
/* Check for valid pop */
{
- int pushed_index = head.contents.index / (8*sizeof(gpr_atm));
- int pushed_bit = head.contents.index % (8*sizeof(gpr_atm));
+ int pushed_index = head.contents.index / (8 * sizeof(gpr_atm));
+ int pushed_bit = head.contents.index % (8 * sizeof(gpr_atm));
gpr_atm old_val;
old_val = gpr_atm_no_barrier_fetch_add(&stack->pushed[pushed_index],
- -(gpr_atm)(1UL << pushed_bit));
- GPR_ASSERT((old_val & (1UL<<pushed_bit)) != 0);
+ -(gpr_atm)(1UL << pushed_bit));
+ GPR_ASSERT((old_val & (1UL << pushed_bit)) != 0);
}
#endif
diff --git a/src/core/support/string.c b/src/core/support/string.c
index 9babbd910a..af0389ea83 100644
--- a/src/core/support/string.c
+++ b/src/core/support/string.c
@@ -125,7 +125,6 @@ char *gpr_dump_slice(gpr_slice s, gpr_uint32 flags) {
flags);
}
-
int gpr_parse_bytes_to_uint32(const char *buf, size_t len, gpr_uint32 *result) {
gpr_uint32 out = 0;
gpr_uint32 new;
@@ -187,9 +186,9 @@ char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
for (i = 0; i < nstrs; i++) {
out_length += strlen(strs[i]);
}
- out_length += 1; /* null terminator */
+ out_length += 1; /* null terminator */
if (nstrs > 0) {
- out_length += sep_len * (nstrs - 1); /* separators */
+ out_length += sep_len * (nstrs - 1); /* separators */
}
out = gpr_malloc(out_length);
out_length = 0;
@@ -214,10 +213,8 @@ char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep,
* str.
*
* Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */
-static int slice_find_separator_offset(const gpr_slice str,
- const char *sep,
- const size_t read_offset,
- size_t *begin,
+static int slice_find_separator_offset(const gpr_slice str, const char *sep,
+ const size_t read_offset, size_t *begin,
size_t *end) {
size_t i;
const gpr_uint8 *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
@@ -255,9 +252,7 @@ void gpr_slice_split(gpr_slice str, const char *sep, gpr_slice_buffer *dst) {
}
}
-void gpr_strvec_init(gpr_strvec *sv) {
- memset(sv, 0, sizeof(*sv));
-}
+void gpr_strvec_init(gpr_strvec *sv) { memset(sv, 0, sizeof(*sv)); }
void gpr_strvec_destroy(gpr_strvec *sv) {
size_t i;
@@ -270,11 +265,11 @@ void gpr_strvec_destroy(gpr_strvec *sv) {
void gpr_strvec_add(gpr_strvec *sv, char *str) {
if (sv->count == sv->capacity) {
sv->capacity = GPR_MAX(sv->capacity + 8, sv->capacity * 2);
- sv->strs = gpr_realloc(sv->strs, sizeof(char*) * sv->capacity);
+ sv->strs = gpr_realloc(sv->strs, sizeof(char *) * sv->capacity);
}
sv->strs[sv->count++] = str;
}
char *gpr_strvec_flatten(gpr_strvec *sv, size_t *final_length) {
- return gpr_strjoin((const char**)sv->strs, sv->count, final_length);
+ return gpr_strjoin((const char **)sv->strs, sv->count, final_length);
}
diff --git a/src/core/support/string.h b/src/core/support/string.h
index 3ac4abeef8..a28e00fd3e 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -47,7 +47,7 @@ extern "C" {
/* String utility functions */
/* Flags for gpr_dump function. */
-#define GPR_DUMP_HEX 0x00000001
+#define GPR_DUMP_HEX 0x00000001
#define GPR_DUMP_ASCII 0x00000002
/* Converts array buf, of length len, into a C string according to the flags.
@@ -108,4 +108,4 @@ char *gpr_strvec_flatten(gpr_strvec *strs, size_t *total_length);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_H */
diff --git a/src/core/support/string_win32.c b/src/core/support/string_win32.c
index 27b9f3637a..8ffb0a225e 100644
--- a/src/core/support/string_win32.c
+++ b/src/core/support/string_win32.c
@@ -99,13 +99,9 @@ LPSTR gpr_tchar_to_char(LPCTSTR input) {
return ret;
}
#else
-char *gpr_tchar_to_char(LPTSTR input) {
- return gpr_strdup(input);
-}
+char *gpr_tchar_to_char(LPTSTR input) { return gpr_strdup(input); }
-char *gpr_char_to_tchar(LPTSTR input) {
- return gpr_strdup(input);
-}
+char *gpr_char_to_tchar(LPTSTR input) { return gpr_strdup(input); }
#endif
#endif /* GPR_WIN32 */
diff --git a/src/core/support/string_win32.h b/src/core/support/string_win32.h
index 1260aa55c1..e3043656fb 100644
--- a/src/core/support/string_win32.h
+++ b/src/core/support/string_win32.h
@@ -42,6 +42,6 @@
LPTSTR gpr_char_to_tchar(LPCSTR input);
LPSTR gpr_tchar_to_char(LPCTSTR input);
-#endif /* GPR_WIN32 */
+#endif /* GPR_WIN32 */
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H */
diff --git a/src/core/support/sync_posix.c b/src/core/support/sync_posix.c
index 61572b9a8e..6f078cd4bb 100644
--- a/src/core/support/sync_posix.c
+++ b/src/core/support/sync_posix.c
@@ -63,7 +63,8 @@ void gpr_cv_destroy(gpr_cv *cv) { GPR_ASSERT(pthread_cond_destroy(cv) == 0); }
int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
int err = 0;
- if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) == 0) {
+ if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) ==
+ 0) {
err = pthread_cond_wait(cv, mu);
} else {
struct timespec abs_deadline_ts;
diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c
index 54f84a46ac..df23492171 100644
--- a/src/core/support/sync_win32.c
+++ b/src/core/support/sync_win32.c
@@ -83,7 +83,8 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
int timeout = 0;
DWORD timeout_max_ms;
mu->locked = 0;
- if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) == 0) {
+ if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) ==
+ 0) {
SleepConditionVariableCS(cv, &mu->cs, INFINITE);
} else {
gpr_timespec now = gpr_now(abs_deadline.clock_type);
diff --git a/src/core/support/thd.c b/src/core/support/thd.c
index ec308f3119..32c0db5b66 100644
--- a/src/core/support/thd.c
+++ b/src/core/support/thd.c
@@ -37,9 +37,7 @@
#include <grpc/support/thd.h>
-enum {
- GPR_THD_JOINABLE = 1
-};
+enum { GPR_THD_JOINABLE = 1 };
gpr_thd_options gpr_thd_options_default(void) {
gpr_thd_options options;
diff --git a/src/core/support/thd_internal.h b/src/core/support/thd_internal.h
index 4683c37742..1508c4691f 100644
--- a/src/core/support/thd_internal.h
+++ b/src/core/support/thd_internal.h
@@ -36,4 +36,4 @@
/* Internal interfaces between modules within the gpr support library. */
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H */
+#endif /* GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H */
diff --git a/src/core/support/thd_posix.c b/src/core/support/thd_posix.c
index fa4eb50556..c36d94d044 100644
--- a/src/core/support/thd_posix.c
+++ b/src/core/support/thd_posix.c
@@ -69,9 +69,11 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
GPR_ASSERT(pthread_attr_init(&attr) == 0);
if (gpr_thd_options_is_detached(options)) {
- GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) == 0);
+ GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) ==
+ 0);
} else {
- GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) == 0);
+ GPR_ASSERT(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ==
+ 0);
}
thread_started = (pthread_create(&p, &attr, &thread_body, a) == 0);
GPR_ASSERT(pthread_attr_destroy(&attr) == 0);
@@ -82,12 +84,8 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
return thread_started;
}
-gpr_thd_id gpr_thd_currentid(void) {
- return (gpr_thd_id)pthread_self();
-}
+gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)pthread_self(); }
-void gpr_thd_join(gpr_thd_id t) {
- pthread_join((pthread_t)t, NULL);
-}
+void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, NULL); }
#endif /* GPR_POSIX_SYNC */
diff --git a/src/core/support/thd_win32.c b/src/core/support/thd_win32.c
index 4fa3907444..a9db180c1b 100644
--- a/src/core/support/thd_win32.c
+++ b/src/core/support/thd_win32.c
@@ -105,9 +105,7 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
return handle != NULL;
}
-gpr_thd_id gpr_thd_currentid(void) {
- return (gpr_thd_id)g_thd_info;
-}
+gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)g_thd_info; }
void gpr_thd_join(gpr_thd_id t) {
struct thd_info *info = (struct thd_info *)t;
diff --git a/src/core/support/time.c b/src/core/support/time.c
index b523ae01cc..929adac918 100644
--- a/src/core/support/time.c
+++ b/src/core/support/time.c
@@ -315,5 +315,6 @@ gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type) {
return gpr_time_add(gpr_now(clock_type), t);
}
- return gpr_time_add(gpr_now(clock_type), gpr_time_sub(t, gpr_now(t.clock_type)));
+ return gpr_time_add(gpr_now(clock_type),
+ gpr_time_sub(t, gpr_now(t.clock_type)));
}
diff --git a/src/core/support/tls_pthread.c b/src/core/support/tls_pthread.c
index f2e76a553f..2d28226fc4 100644
--- a/src/core/support/tls_pthread.c
+++ b/src/core/support/tls_pthread.c
@@ -38,7 +38,7 @@
#include <grpc/support/tls.h>
gpr_intptr gpr_tls_set(struct gpr_pthread_thread_local *tls, gpr_intptr value) {
- GPR_ASSERT(0 == pthread_setspecific(tls->key, (void*)value));
+ GPR_ASSERT(0 == pthread_setspecific(tls->key, (void *)value));
return value;
}