Commit 14d85244 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

add missing include to ThreadId.h

Summary:
The syscall() function is defined in <unistd.h>
<sys/syscall.h> apparently only defines IDs to be used with syscall(), but does
not define the syscall() function itself.

This caused build failures for files that included ThreadId.h before unistd.h

Reviewed By: Orvid

Differential Revision: D5189658

fbshipit-source-id: 2ec8ea1d58f3fc14cf458a53ecaa811978527398
parent 7cf58370
......@@ -530,6 +530,7 @@ if (BUILD_TESTS)
TEST synchronized_test SOURCES SynchronizedTest.cpp
TEST thread_cached_arena_test SOURCES ThreadCachedArenaTest.cpp
TEST thread_cached_int_test SOURCES ThreadCachedIntTest.cpp
TEST thread_id_test SOURCES ThreadIdTest.cpp
TEST thread_local_test SOURCES ThreadLocalTest.cpp
TEST thread_name_test SOURCES ThreadNameTest.cpp
TEST timeout_queue_test SOURCES TimeoutQueueTest.cpp
......
......@@ -20,6 +20,7 @@
#include <folly/portability/PThread.h>
#include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h>
#include <folly/portability/Windows.h>
namespace folly {
......
......@@ -96,6 +96,9 @@ TESTS += fbstring_test_using_jemalloc
thread_cached_int_test_SOURCES = ThreadCachedIntTest.cpp
thread_cached_int_test_LDADD = libfollytestmain.la $(top_builddir)/libfollybenchmark.la
thread_id_test_SOURCES = ThreadIdTest.cpp
thread_id_test_LDADD = libfollytestmain.la
thread_local_test_SOURCES = ThreadLocalTest.cpp
thread_local_test_LDADD = libfollytestmain.la $(top_builddir)/libfollybenchmark.la
thread_local_test_LDFLAGS = -ldl
......
/*
* Copyright 2017 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.
*/
// Make sure we include ThreadId.h before anything else.
// There is no ThreadId.cpp file, so this test is the only thing that verifies
// that ThreadId.h compiles by itself when included first.
#include <folly/ThreadId.h>
#include <thread>
#include <folly/portability/GTest.h>
TEST(ThreadId, getCurrentID) {
auto thisThreadID = folly::getCurrentThreadID();
uint64_t otherThreadID;
std::thread otherThread{[&] { otherThreadID = folly::getCurrentThreadID(); }};
otherThread.join();
EXPECT_NE(thisThreadID, otherThreadID);
}
TEST(ThreadId, getOSThreadID) {
auto thisThreadID = folly::getOSThreadID();
uint64_t otherThreadID;
std::thread otherThread{[&] { otherThreadID = folly::getOSThreadID(); }};
otherThread.join();
EXPECT_NE(thisThreadID, otherThreadID);
}
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