aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-03-02 17:19:40 -0800
committerGravatar Jorge Canizales <jcanizales@google.com>2015-03-02 17:19:40 -0800
commit7b1bb8b69d7a9b37fc547d5dfd9b5b2740238860 (patch)
tree59de2483717fbe0a03e92181b7159d256300c757 /src/core
parentfa054b37a19bb063121d2e3dd1bc9530a12c8c35 (diff)
Makes cpu_posix.c portable by removing thread-local storage.
Thread-local variables aren’t supported on iOS.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/support/cpu_posix.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/core/support/cpu_posix.c b/src/core/support/cpu_posix.c
index 5f45fb0bc3..1844e9a622 100644
--- a/src/core/support/cpu_posix.c
+++ b/src/core/support/cpu_posix.c
@@ -42,8 +42,6 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
-static __thread char magic_thread_local;
-
static int ncpus = 0;
static void init_ncpus() {
@@ -60,18 +58,10 @@ unsigned gpr_cpu_num_cores(void) {
return ncpus;
}
-/* This is a cheap, but good enough, pointer hash for sharding things: */
-static size_t shard_ptr(const void *info) {
- size_t x = (size_t)info;
- return ((x >> 4) ^ (x >> 9) ^ (x >> 14)) % gpr_cpu_num_cores();
-}
-
unsigned gpr_cpu_current_cpu(void) {
/* NOTE: there's no way I know to return the actual cpu index portably...
- most code that's using this is using it to shard across work queues though,
- so here we use thread identity instead to achieve a similar though not
- identical effect */
- return shard_ptr(&magic_thread_local);
+ most code that's using this is using it to shard across work queues though */
+ return 0;
}
#endif /* GPR_CPU_LINUX */