Use ptr-to-const in Futex
authorYedidya Feldblum <yfeldblum@fb.com>
Wed, 10 Jan 2018 06:39:10 +0000 (22:39 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 10 Jan 2018 06:51:03 +0000 (22:51 -0800)
Summary: [Folly] Use ptr-to-`const` in `Futex`.

Reviewed By: igorsugak

Differential Revision: D6673723

fbshipit-source-id: b828c2284b40ec8166e823eca7725beccd330f87

folly/detail/Futex.cpp
folly/detail/Futex.h
folly/test/DeterministicSchedule.cpp
folly/test/DeterministicSchedule.h

index 14fbe8a..26e8937 100644 (file)
@@ -97,11 +97,12 @@ timeSpecFromTimePoint(time_point<Clock> absTime)
   return result;
 }
 
-FutexResult nativeFutexWaitImpl(void* addr,
-                                uint32_t expected,
-                                time_point<system_clock>* absSystemTime,
-                                time_point<steady_clock>* absSteadyTime,
-                                uint32_t waitMask) {
+FutexResult nativeFutexWaitImpl(
+    void* addr,
+    uint32_t expected,
+    system_clock::time_point const* absSystemTime,
+    steady_clock::time_point const* absSteadyTime,
+    uint32_t waitMask) {
   assert(absSystemTime == nullptr || absSteadyTime == nullptr);
 
   int op = FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG;
@@ -180,8 +181,8 @@ template <typename F>
 FutexResult emulatedFutexWaitImpl(
     F* futex,
     uint32_t expected,
-    time_point<system_clock>* absSystemTime,
-    time_point<steady_clock>* absSteadyTime,
+    system_clock::time_point const* absSystemTime,
+    steady_clock::time_point const* absSteadyTime,
     uint32_t waitMask) {
   static_assert(
       std::is_same<F, Futex<std::atomic>>::value ||
@@ -240,11 +241,11 @@ Futex<EmulatedFutexAtomic>::futexWake(int count, uint32_t wakeMask) {
 }
 
 template <>
-FutexResult
-Futex<std::atomic>::futexWaitImpl(uint32_t expected,
-                                  time_point<system_clock>* absSystemTime,
-                                  time_point<steady_clock>* absSteadyTime,
-                                  uint32_t waitMask) {
+FutexResult Futex<std::atomic>::futexWaitImpl(
+    uint32_t expected,
+    system_clock::time_point const* absSystemTime,
+    steady_clock::time_point const* absSteadyTime,
+    uint32_t waitMask) {
 #ifdef __linux__
   return nativeFutexWaitImpl(
       this, expected, absSystemTime, absSteadyTime, waitMask);
@@ -255,12 +256,11 @@ Futex<std::atomic>::futexWaitImpl(uint32_t expected,
 }
 
 template <>
-FutexResult
-Futex<EmulatedFutexAtomic>::futexWaitImpl(
-        uint32_t expected,
-        time_point<system_clock>* absSystemTime,
-        time_point<steady_clock>* absSteadyTime,
-        uint32_t waitMask) {
+FutexResult Futex<EmulatedFutexAtomic>::futexWaitImpl(
+    uint32_t expected,
+    system_clock::time_point const* absSystemTime,
+    steady_clock::time_point const* absSteadyTime,
+    uint32_t waitMask) {
   return emulatedFutexWaitImpl(
       this, expected, absSystemTime, absSteadyTime, waitMask);
 }
index b8cbcd2..a2e3502 100644 (file)
@@ -125,8 +125,8 @@ struct Futex : Atom<uint32_t>, boost::noncopyable {
    *  is the same as system_clock on some platforms. */
   FutexResult futexWaitImpl(
       uint32_t expected,
-      std::chrono::time_point<std::chrono::system_clock>* absSystemTime,
-      std::chrono::time_point<std::chrono::steady_clock>* absSteadyTime,
+      std::chrono::system_clock::time_point const* absSystemTime,
+      std::chrono::steady_clock::time_point const* absSteadyTime,
       uint32_t waitMask);
 };
 
@@ -149,20 +149,20 @@ int Futex<std::atomic>::futexWake(int count, uint32_t wakeMask);
 
 template <>
 FutexResult Futex<std::atomic>::futexWaitImpl(
-      uint32_t expected,
-      std::chrono::time_point<std::chrono::system_clock>* absSystemTime,
-      std::chrono::time_point<std::chrono::steady_clock>* absSteadyTime,
-      uint32_t waitMask);
+    uint32_t expected,
+    std::chrono::system_clock::time_point const* absSystemTime,
+    std::chrono::steady_clock::time_point const* absSteadyTime,
+    uint32_t waitMask);
 
 template <>
 int Futex<EmulatedFutexAtomic>::futexWake(int count, uint32_t wakeMask);
 
 template <>
 FutexResult Futex<EmulatedFutexAtomic>::futexWaitImpl(
-      uint32_t expected,
-      std::chrono::time_point<std::chrono::system_clock>* absSystemTime,
-      std::chrono::time_point<std::chrono::steady_clock>* absSteadyTime,
-      uint32_t waitMask);
+    uint32_t expected,
+    std::chrono::system_clock::time_point const* absSystemTime,
+    std::chrono::steady_clock::time_point const* absSteadyTime,
+    uint32_t waitMask);
 
 } // namespace detail
 } // namespace folly
index e1c79d7..d4e8d2d 100644 (file)
@@ -289,8 +289,8 @@ using namespace std::chrono;
 template <>
 FutexResult Futex<DeterministicAtomic>::futexWaitImpl(
     uint32_t expected,
-    time_point<system_clock>* absSystemTimeout,
-    time_point<steady_clock>* absSteadyTimeout,
+    system_clock::time_point const* absSystemTimeout,
+    steady_clock::time_point const* absSteadyTimeout,
     uint32_t waitMask) {
   bool hasTimeout = absSystemTimeout != nullptr || absSteadyTimeout != nullptr;
   bool awoken = false;
index a9b1ca5..91b43fb 100644 (file)
@@ -496,8 +496,8 @@ int Futex<test::DeterministicAtomic>::futexWake(int count, uint32_t wakeMask);
 template <>
 FutexResult Futex<test::DeterministicAtomic>::futexWaitImpl(
     uint32_t expected,
-    std::chrono::time_point<std::chrono::system_clock>* absSystemTime,
-    std::chrono::time_point<std::chrono::steady_clock>* absSteadyTime,
+    std::chrono::system_clock::time_point const* absSystemTime,
+    std::chrono::steady_clock::time_point const* absSteadyTime,
     uint32_t waitMask);
 } // namespace detail