From: Nicholas Ormrod Date: Wed, 18 Jun 2014 16:35:10 +0000 (-0700) Subject: Make fbstring libgcc-safe X-Git-Tag: v0.22.0~506 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a97b3be50704647a2df0b36f54ad17b1e7151d31;p=folly.git Make fbstring libgcc-safe Summary: Some libgcc-incompatible code has been added to fbstring. Removed/reorganized it so that we can drop fbstring right into libgcc. Test Plan: fbconfig -r folly && fbmake runtests Copied FBString.h into libgcc's basic_fbstring.h, with no modifications. Successfully tp2_build libgcc/4.8.1. Adjusted symlink, then fbmake clean && fbconfig -r folly && fbmake dbg. The fbmake dbg failed with an assertion error, which is consistent with @lucian's observations in D1373725; the important part is that the error was at runtime, so the compile-time changes of this diff looks good. Reviewed By: lucian@fb.com Subscribers: folly@lists, sdwilsh, njormrod, lucian FB internal diff: D1382873 --- diff --git a/folly/FBString.h b/folly/FBString.h index 2f4c9a44..4b59ac9e 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -23,21 +23,11 @@ #include #include #include -#include - -#include "folly/Portability.h" -// libc++ doesn't provide this header, nor does msvc -#ifdef FOLLY_HAVE_BITS_CXXCONFIG_H // This file appears in two locations: inside fbcode and in the // libstdc++ source code (when embedding fbstring as std::string). -// To aid in this schizophrenic use, two macros are defined in -// c++config.h: -// _LIBSTDCXX_FBSTRING - Set inside libstdc++. This is useful to -// gate use inside fbcode v. libstdc++ -#include -#endif - +// To aid in this schizophrenic use, _LIBSTDCXX_FBSTRING is defined in +// libstdc++'s c++config.h, to gate use inside fbcode v. libstdc++. #ifdef _LIBSTDCXX_FBSTRING #pragma GCC system_header @@ -54,9 +44,17 @@ #else // !_LIBSTDCXX_FBSTRING +#include "folly/Portability.h" + +// libc++ doesn't provide this header, nor does msvc +#ifdef FOLLY_HAVE_BITS_CXXCONFIG_H +#include +#endif + #include #include #include +#include #include "folly/Traits.h" #include "folly/Malloc.h" @@ -1014,11 +1012,9 @@ public: /* implicit */ basic_fbstring(const value_type* s, const A& a = A()) : store_(s, s ? traits_type::length(s) - : [] { - std::__throw_logic_error( - "basic_fbstring: null pointer initializer not valid"); - return 0; - }()) { + : (std::__throw_logic_error( + "basic_fbstring: null pointer initializer not valid"), + 0)) { } basic_fbstring(const value_type* s, size_type n, const A& a = A()) @@ -2426,6 +2422,7 @@ struct hash< ::folly::fbstring> { } +#ifndef _LIBSTDCXX_FBSTRING #if FOLLY_HAVE_DEPRECATED_ASSOC #if defined(_GLIBCXX_SYMVER) && !defined(__BIONIC__) namespace __gnu_cxx { @@ -2447,6 +2444,7 @@ struct hash< ::folly::fbstring> { } #endif // _GLIBCXX_SYMVER && !__BIONIC__ #endif // FOLLY_HAVE_DEPRECATED_ASSOC +#endif // _LIBSTDCXX_FBSTRING #endif // _LIBSTDCXX_FBSTRING