Make semaphore.h a non-portable header
authorChristopher Dykes <cdykes@fb.com>
Mon, 19 Jun 2017 21:34:21 +0000 (14:34 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 19 Jun 2017 21:39:55 +0000 (14:39 -0700)
Summary: On Windows it has include order requirements.

Reviewed By: yfeldblum

Differential Revision: D5277151

fbshipit-source-id: a6cf923d78e5944ac34e885e32a7cf072f904720

folly/Makefile.am
folly/futures/test/Benchmark.cpp
folly/portability/Semaphore.h [new file with mode: 0644]
folly/test/AtomicUnorderedMapTest.cpp
folly/test/BatonBenchmark.cpp
folly/test/DeterministicSchedule.h
folly/test/IndexedMemPoolTest.cpp
folly/test/LifoSemTests.cpp

index b2bad52a79d01b83428d01cd968a9407b46c98ec..37d47db443cd2c76385481e75fce38643c7aaf90 100644 (file)
@@ -336,6 +336,7 @@ nobase_follyinclude_HEADERS = \
        portability/Memory.h \
        portability/OpenSSL.h \
        portability/PThread.h \
+       portability/Semaphore.h \
        portability/Sockets.h \
        portability/Stdio.h \
        portability/Stdlib.h \
index 64d4a44f7e2422fce3e7e06af5c8318db5366ff0..e09546ff2130e491539c201dc623280e8463098d 100644 (file)
@@ -20,8 +20,8 @@
 #include <folly/futures/InlineExecutor.h>
 #include <folly/futures/Promise.h>
 #include <folly/portability/GFlags.h>
+#include <folly/portability/Semaphore.h>
 
-#include <semaphore.h>
 #include <vector>
 
 using namespace folly;
diff --git a/folly/portability/Semaphore.h b/folly/portability/Semaphore.h
new file mode 100644 (file)
index 0000000..6cfb8d3
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+// On Windows, the include order matters, as the pthread implementation we
+// support attempts to use a different definition of `mode_t` than everything
+// else, so we have to make sure our definition of it is first.
+#include <folly/portability/SysTypes.h>
+
+#include <semaphore.h>
index 69b51e5e1c348b95da8a4c9b77c583acd01243e3..957b6063330dfb102e09cfdaa98c2004486e4edc 100644 (file)
 
 #include <folly/AtomicUnorderedMap.h>
 
-#include <semaphore.h>
 #include <thread>
 #include <unordered_map>
 
 #include <folly/Benchmark.h>
 #include <folly/portability/GFlags.h>
 #include <folly/portability/GTest.h>
+#include <folly/portability/Semaphore.h>
 #include <folly/test/DeterministicSchedule.h>
 
 using namespace folly;
index 11fb747c15855adf0f38eaf485b8b3a94757290b..82e3b5e306ae2ee0d5d7437d128e0d35e8c71dc8 100644 (file)
 
 #include <folly/Baton.h>
 
-#include <semaphore.h>
 #include <thread>
 
 #include <folly/Benchmark.h>
 #include <folly/portability/GFlags.h>
 #include <folly/portability/GTest.h>
+#include <folly/portability/Semaphore.h>
 #include <folly/test/BatonTestHelpers.h>
 #include <folly/test/DeterministicSchedule.h>
 
index 876734239e6ec0fa17092ea49a1d54ff79914659..5ec444e6a2b3c672164e55a21918708106a8c3dd 100644 (file)
 
 #pragma once
 
-// This needs to be above semaphore.h due to the windows
-// libevent implementation needing mode_t to be defined,
-// but defining it differently than our portability
-// headers do.
-#include <folly/portability/SysTypes.h>
-
 #include <assert.h>
 #include <boost/noncopyable.hpp>
 #include <errno.h>
 #include <glog/logging.h>
-#include <semaphore.h>
 #include <atomic>
 #include <functional>
 #include <mutex>
@@ -38,6 +31,7 @@
 #include <folly/detail/AtomicUtils.h>
 #include <folly/detail/CacheLocality.h>
 #include <folly/detail/Futex.h>
+#include <folly/portability/Semaphore.h>
 
 namespace folly {
 namespace test {
index cb2e258bf1e2f388c5c43af6a6b810aeb32b01dc..a5faa43ada334c3c3fc215d4958c0078f7307675 100644 (file)
 #include <folly/IndexedMemPool.h>
 #include <folly/portability/GMock.h>
 #include <folly/portability/GTest.h>
+#include <folly/portability/Semaphore.h>
 #include <folly/portability/Unistd.h>
 #include <folly/test/DeterministicSchedule.h>
 
 #include <string>
 #include <thread>
-#include <semaphore.h>
 
 using namespace folly;
 using namespace folly::test;
index 69e69eeebd0ffcf6ed974210e0910acbc51b5c2c..02c112b2a1f16cbed4e91da2e4ca872de7b1c335 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <folly/LifoSem.h>
 
-#include <semaphore.h>
 #include <thread>
 
 #include <folly/Benchmark.h>
@@ -24,6 +23,7 @@
 #include <folly/portability/Asm.h>
 #include <folly/portability/GFlags.h>
 #include <folly/portability/GTest.h>
+#include <folly/portability/Semaphore.h>
 #include <folly/test/DeterministicSchedule.h>
 
 using namespace folly;