Move detail/FunctionalExcept to portability/BitsFunctexcept
authorChristopher Dykes <cdykes@fb.com>
Fri, 19 Aug 2016 20:45:00 +0000 (13:45 -0700)
committerFacebook Github Bot 7 <facebook-github-bot-7-bot@fb.com>
Fri, 19 Aug 2016 20:54:13 +0000 (13:54 -0700)
Summary: Because it is a portability header, but was created before portability headers were cool.

Reviewed By: mzlee

Differential Revision: D3743475

fbshipit-source-id: 5d2fe23ce08f0425ce48b4871fa660e69f57cc39

folly/Makefile.am
folly/Malloc.h
folly/Portability.h
folly/detail/FunctionalExcept.cpp [deleted file]
folly/detail/FunctionalExcept.h [deleted file]
folly/portability/BitsFunctexcept.cpp [new file with mode: 0644]
folly/portability/BitsFunctexcept.h [new file with mode: 0644]

index 0691344b705eec9a601886c75963148cf7da22ca..5df00b826a62c785510f2795cf3b8f31986fcc7d 100644 (file)
@@ -59,7 +59,6 @@ nobase_follyinclude_HEADERS = \
        detail/ExceptionWrapper.h \
        detail/FileUtilDetail.h \
        detail/FingerprintPolynomial.h \
-       detail/FunctionalExcept.h \
        detail/Futex.h \
        detail/GroupVarintDetail.h \
        detail/IPAddress.h \
@@ -267,6 +266,7 @@ nobase_follyinclude_HEADERS = \
        Portability.h \
        portability/Asm.h \
        portability/Atomic.h \
+       portability/BitsFunctexcept.h \
        portability/Builtins.h \
        portability/Config.h \
        portability/Constexpr.h \
@@ -437,6 +437,7 @@ libfolly_la_SOURCES = \
        detail/SocketFastOpen.cpp \
        MacAddress.cpp \
        MemoryMapping.cpp \
+       portability/BitsFunctexcept.cpp \
        portability/Dirent.cpp \
        portability/Environment.cpp \
        portability/Fcntl.cpp \
index e7616da53cbafd7cbc5b16e2610ccceadcd2714a..64fd393ddd7ac592cfbdc0f6961d54130fb1ceb6 100644 (file)
@@ -20,6 +20,8 @@
 #pragma once
 #define FOLLY_MALLOC_H_
 
+#include <folly/portability/BitsFunctexcept.h>
+
 /**
  * Define various MALLOCX_* macros normally provided by jemalloc.  We define
  * them so that we don't have to include jemalloc.h, in case the program is
@@ -85,7 +87,6 @@ extern "C" int mallctlbymib(const size_t*, size_t, void*, size_t*, void*,
                             size_t)
 __attribute__((__weak__));
 
-#include <bits/functexcept.h>
 #define FOLLY_HAVE_MALLOC_H 1
 #else
 #include <folly/detail/Malloc.h> /* nolint */
index a780eedc08e7964fe5a0f3f4cd04fe4429bd68e8..12cff605f58128841d4a8f6967ca7f6037bc4905 100644 (file)
@@ -238,13 +238,6 @@ namespace std { typedef ::max_align_t max_align_t; }
 # define FOLLY_GLIBCXX_NAMESPACE_CXX11_END
 #endif
 
-// Provide our own std::__throw_* wrappers for platforms that don't have them
-#if FOLLY_HAVE_BITS_FUNCTEXCEPT_H
-#include <bits/functexcept.h>
-#else
-#include <folly/detail/FunctionalExcept.h>
-#endif
-
 // MSVC specific defines
 // mainly for posix compat
 #ifdef _MSC_VER
diff --git a/folly/detail/FunctionalExcept.cpp b/folly/detail/FunctionalExcept.cpp
deleted file mode 100644 (file)
index 13a7b7d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-#include <folly/Portability.h>
-
-// If FOLLY_HAVE_BITS_FUNCTEXCEPT_H is set, this file compiles to
-// nothing.
-
-#if !FOLLY_HAVE_BITS_FUNCTEXCEPT_H
-
-#include <folly/detail/FunctionalExcept.h>
-
-#include <stdexcept>
-
-FOLLY_NAMESPACE_STD_BEGIN
-
-void __throw_length_error(const char* msg) {
-  throw std::length_error(msg);
-}
-
-void __throw_logic_error(const char* msg) {
-  throw std::logic_error(msg);
-}
-
-void __throw_out_of_range(const char* msg) {
-  throw std::out_of_range(msg);
-}
-
-#if defined(_MSC_VER)
-void __throw_bad_alloc() {
-  throw std::bad_alloc();
-}
-#endif
-
-FOLLY_NAMESPACE_STD_END
-
-#endif
diff --git a/folly/detail/FunctionalExcept.h b/folly/detail/FunctionalExcept.h
deleted file mode 100644 (file)
index 643c8eb..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <folly/Portability.h>
-
-#if !FOLLY_HAVE_BITS_FUNCTEXCEPT_H
-
-FOLLY_NAMESPACE_STD_BEGIN
-
-[[noreturn]] void __throw_length_error(const char* msg);
-[[noreturn]] void __throw_logic_error(const char* msg);
-[[noreturn]] void __throw_out_of_range(const char* msg);
-
-#ifdef _MSC_VER
-[[noreturn]] void __throw_bad_alloc();
-#endif
-
-FOLLY_NAMESPACE_STD_END
-
-#else
-#error This file should never be included if FOLLY_HAVE_BITS_FUNCTEXCEPT_H is set
-#endif
diff --git a/folly/portability/BitsFunctexcept.cpp b/folly/portability/BitsFunctexcept.cpp
new file mode 100644 (file)
index 0000000..55b9561
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#include <folly/portability/BitsFunctexcept.h>
+
+#if !FOLLY_HAVE_BITS_FUNCTEXCEPT_H
+#include <stdexcept>
+
+FOLLY_NAMESPACE_STD_BEGIN
+
+void __throw_length_error(const char* msg) {
+  throw std::length_error(msg);
+}
+
+void __throw_logic_error(const char* msg) {
+  throw std::logic_error(msg);
+}
+
+void __throw_out_of_range(const char* msg) {
+  throw std::out_of_range(msg);
+}
+
+void __throw_bad_alloc() {
+  throw std::bad_alloc();
+}
+
+FOLLY_NAMESPACE_STD_END
+#endif
diff --git a/folly/portability/BitsFunctexcept.h b/folly/portability/BitsFunctexcept.h
new file mode 100644 (file)
index 0000000..80b2cb2
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <folly/portability/Config.h>
+
+#if FOLLY_HAVE_BITS_FUNCTEXCEPT_H
+#include <bits/functexcept.h>
+#else
+#include <folly/Portability.h>
+FOLLY_NAMESPACE_STD_BEGIN
+
+[[noreturn]] void __throw_length_error(const char* msg);
+[[noreturn]] void __throw_logic_error(const char* msg);
+[[noreturn]] void __throw_out_of_range(const char* msg);
+[[noreturn]] void __throw_bad_alloc();
+
+FOLLY_NAMESPACE_STD_END
+#endif