Commit 3f93d783 authored by Michael Lee's avatar Michael Lee Committed by facebook-github-bot-1

Switch back to SYS_gettid, and fix

Summary:
SYS_gettid is different on Linux vs. OSX.  `__NR_gettid` is
only sometimes present and `SYS_gettid` is only sometimes present, but
we can pick one name and just follow that one.

Reviewed By: dcolascione

Differential Revision: D2800515

fb-gh-sync-id: 4245de4b9184ac4233ade9da297409c1031869a3
parent 43db7ae3
...@@ -247,6 +247,7 @@ nobase_follyinclude_HEADERS = \ ...@@ -247,6 +247,7 @@ nobase_follyinclude_HEADERS = \
Padded.h \ Padded.h \
PicoSpinLock.h \ PicoSpinLock.h \
Portability.h \ Portability.h \
portability/Syscall.h \
Preprocessor.h \ Preprocessor.h \
ProducerConsumerQueue.h \ ProducerConsumerQueue.h \
Random.h \ Random.h \
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <folly/Portability.h> #include <folly/Portability.h>
#include <folly/experimental/fibers/BoostContextCompatibility.h> #include <folly/experimental/fibers/BoostContextCompatibility.h>
#include <folly/experimental/fibers/FiberManager.h> #include <folly/experimental/fibers/FiberManager.h>
#include <folly/portability/Syscall.h>
namespace folly { namespace fibers { namespace folly { namespace fibers {
...@@ -38,7 +39,7 @@ pid_t localThreadId() { ...@@ -38,7 +39,7 @@ pid_t localThreadId() {
// OSX doesn't support thread_local. // OSX doesn't support thread_local.
static FOLLY_TLS pid_t threadId = 0; static FOLLY_TLS pid_t threadId = 0;
if (UNLIKELY(threadId == 0)) { if (UNLIKELY(threadId == 0)) {
threadId = syscall(__NR_gettid); threadId = syscall(FOLLY_SYS_gettid);
} }
return threadId; return threadId;
} }
......
/*
* Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOLLY_SYSCALL_H_
#define FOLLY_SYSCALL_H_
#include <sys/syscall.h>
#if defined(__APPLE__)
#define FOLLY_SYS_gettid SYS_thread_selfid
#elif defined(SYS_gettid)
#define FOLLY_SYS_gettid SYS_gettid
#else
#define FOLLY_SYS_gettid __NR_gettid
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment