From: Christopher Dykes Date: Fri, 19 Aug 2016 20:45:00 +0000 (-0700) Subject: Move detail/FunctionalExcept to portability/BitsFunctexcept X-Git-Tag: v2016.08.22.00~9 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8e13f6e0579b52f250f065e3ad1185db94d47de4;p=folly.git Move detail/FunctionalExcept to portability/BitsFunctexcept 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 --- diff --git a/folly/Makefile.am b/folly/Makefile.am index 0691344b..5df00b82 100644 --- a/folly/Makefile.am +++ b/folly/Makefile.am @@ -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 \ diff --git a/folly/Malloc.h b/folly/Malloc.h index e7616da5..64fd393d 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -20,6 +20,8 @@ #pragma once #define FOLLY_MALLOC_H_ +#include + /** * 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 #define FOLLY_HAVE_MALLOC_H 1 #else #include /* nolint */ diff --git a/folly/Portability.h b/folly/Portability.h index a780eedc..12cff605 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -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 -#else -#include -#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 index 13a7b7d7..00000000 --- a/folly/detail/FunctionalExcept.cpp +++ /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 - -// If FOLLY_HAVE_BITS_FUNCTEXCEPT_H is set, this file compiles to -// nothing. - -#if !FOLLY_HAVE_BITS_FUNCTEXCEPT_H - -#include - -#include - -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 index 643c8eb2..00000000 --- a/folly/detail/FunctionalExcept.h +++ /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 - -#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 index 00000000..55b95616 --- /dev/null +++ b/folly/portability/BitsFunctexcept.cpp @@ -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 + +#if !FOLLY_HAVE_BITS_FUNCTEXCEPT_H +#include + +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 index 00000000..80b2cb2a --- /dev/null +++ b/folly/portability/BitsFunctexcept.h @@ -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 + +#if FOLLY_HAVE_BITS_FUNCTEXCEPT_H +#include +#else +#include +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