+++ /dev/null
-/*
- * 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.
- */
-
-#include <folly/Assume.h>
-
-#include <glog/logging.h>
-
-namespace folly {
-
-namespace detail {
-
-void assume_check(bool cond) {
- CHECK(cond) << "compiler-hint assumption fails at runtime";
-}
-
-} // namespace detail
-
-} // namespace folly
* limitations under the License.
*/
-#pragma once
-
-#include <cstdlib>
-
-#include <folly/Portability.h>
-
-namespace folly {
-
-namespace detail {
-
-extern void assume_check(bool cond);
-
-} // namespace detail
-
-/**
- * Inform the compiler that the argument can be assumed true. It is
- * undefined behavior if the argument is not actually true, so use
- * with care.
- *
- * Implemented as a function instead of a macro because
- * __builtin_assume does not evaluate its argument at runtime, so it
- * cannot be used with expressions that have side-effects.
- */
-
-FOLLY_ALWAYS_INLINE void assume(bool cond) {
- if (kIsDebug) {
- detail::assume_check(cond);
- } else {
-#if defined(__clang__) // Must go first because Clang also defines __GNUC__.
- __builtin_assume(cond);
-#elif defined(__GNUC__)
- if (!cond) { __builtin_unreachable(); }
-#elif defined(_MSC_VER)
- __assume(cond);
-#else
- // Do nothing.
-#endif
- }
-}
-
-[[noreturn]] FOLLY_ALWAYS_INLINE void assume_unreachable() {
- assume(false);
- // Do a bit more to get the compiler to understand
- // that this function really will never return.
-#if defined(__GNUC__)
- __builtin_unreachable();
-#elif defined(_MSC_VER)
- __assume(0);
-#else
- // Well, it's better than nothing.
- std::abort();
-#endif
-}
-
-} // namespace folly
+#include <folly/lang/Assume.h> // @shim
#include <limits>
#include <type_traits>
-#include <folly/Assume.h>
#include <folly/Portability.h>
+#include <folly/lang/Assume.h>
#include <folly/portability/Builtins.h>
namespace folly {
#include <typeinfo>
#include <utility>
-#include <folly/Assume.h>
#include <folly/CPortability.h>
#include <folly/Demangle.h>
#include <folly/ExceptionString.h>
#include <folly/Portability.h>
#include <folly/Traits.h>
#include <folly/Utility.h>
+#include <folly/lang/Assume.h>
#ifdef __GNUC__
#pragma GCC diagnostic push
io/async/test/UndelayedDestruction.h \
io/async/test/Util.h \
json.h \
+ lang/Assume.h \
Launder.h \
Lazy.h \
LifoSem.h \
Unicode.cpp
libfolly_la_SOURCES = \
- Assume.cpp \
ClockGettimeWrappers.cpp \
compression/Compression.cpp \
compression/Zlib.cpp \
io/async/ssl/OpenSSLUtils.cpp \
io/async/ssl/SSLErrors.cpp \
json.cpp \
+ lang/Assume.cpp \
detail/MemoryIdler.cpp \
detail/SocketFastOpen.cpp \
MacAddress.cpp \
#include <glog/logging.h>
-#include <folly/Assume.h>
#include <folly/Conv.h>
#include <folly/Exception.h>
#include <folly/ScopeGuard.h>
#include <folly/String.h>
#include <folly/io/Cursor.h>
+#include <folly/lang/Assume.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Stdlib.h>
#include <folly/portability/SysSyscall.h>
#include <folly/dynamic.h>
-#include <folly/Assume.h>
#include <folly/Format.h>
#include <folly/Hash.h>
+#include <folly/lang/Assume.h>
#include <folly/portability/BitsFunctexcept.h>
namespace folly {
#include <limits>
#include <type_traits>
-#include <folly/Assume.h>
#include <folly/Bits.h>
#include <folly/Likely.h>
#include <folly/Portability.h>
#include <folly/experimental/CodingDetail.h>
#include <folly/experimental/Instructions.h>
#include <folly/experimental/Select64.h>
+#include <folly/lang/Assume.h>
#include <glog/logging.h>
#if !FOLLY_X64
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <folly/lang/Assume.h>
+
+#include <glog/logging.h>
+
+namespace folly {
+
+namespace detail {
+
+void assume_check(bool cond) {
+ CHECK(cond) << "compiler-hint assumption fails at runtime";
+}
+
+} // namespace detail
+
+} // namespace folly
--- /dev/null
+/*
+ * 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
+
+#include <cstdlib>
+
+#include <folly/Portability.h>
+
+namespace folly {
+
+namespace detail {
+
+extern void assume_check(bool cond);
+
+} // namespace detail
+
+/**
+ * Inform the compiler that the argument can be assumed true. It is
+ * undefined behavior if the argument is not actually true, so use
+ * with care.
+ *
+ * Implemented as a function instead of a macro because
+ * __builtin_assume does not evaluate its argument at runtime, so it
+ * cannot be used with expressions that have side-effects.
+ */
+
+FOLLY_ALWAYS_INLINE void assume(bool cond) {
+ if (kIsDebug) {
+ detail::assume_check(cond);
+ } else {
+#if defined(__clang__) // Must go first because Clang also defines __GNUC__.
+ __builtin_assume(cond);
+#elif defined(__GNUC__)
+ if (!cond) { __builtin_unreachable(); }
+#elif defined(_MSC_VER)
+ __assume(cond);
+#else
+ // Do nothing.
+#endif
+ }
+}
+
+[[noreturn]] FOLLY_ALWAYS_INLINE void assume_unreachable() {
+ assume(false);
+ // Do a bit more to get the compiler to understand
+ // that this function really will never return.
+#if defined(__GNUC__)
+ __builtin_unreachable();
+#elif defined(_MSC_VER)
+ __assume(0);
+#else
+ // Well, it's better than nothing.
+ std::abort();
+#endif
+}
+
+} // namespace folly
#include <boost/operators.hpp>
#include <boost/type_traits.hpp>
-#include <folly/Assume.h>
#include <folly/ConstexprMath.h>
#include <folly/FormatTraits.h>
#include <folly/Portability.h>
#include <folly/SmallLocks.h>
#include <folly/Traits.h>
+#include <folly/lang/Assume.h>
#include <folly/memory/Malloc.h>
#include <folly/portability/BitsFunctexcept.h>
#include <folly/portability/Malloc.h>