aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-04-22 16:24:35 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-04-22 16:24:43 +0200
commitbbe53f61db73237b8334207d696d99a4cf16a760 (patch)
treea6be54d8bcf25498be3db50aa2985508c7910c50 /src
parent91c601c54a097e467204285a728006a2b3c78eec (diff)
parent05c20a553a12d03b1512a75973674c6d25534259 (diff)
downloadbitcoin-bbe53f61db73237b8334207d696d99a4cf16a760.tar.xz
Merge pull request #4042
05c20a5 build: add symbol for upcoming gcc 4.9's libstdc++ (Cory Fields) 49a3352 gitian-linux: --enable-glibc-back-compat (Warren Togami) d5aab70 build: add an option for enabling glibc back-compat (Cory Fields) ffc6b67 build: add glibc/libstdc++ back-compat stubs (Cory Fields)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/compat/glibc_compat.cpp19
-rw-r--r--src/compat/glibcxx_compat.cpp87
3 files changed, 111 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b037ac2c98..215d0319f9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -136,6 +136,11 @@ libbitcoin_common_a_SOURCES = \
version.cpp \
$(BITCOIN_CORE_H)
+if GLIBC_BACK_COMPAT
+libbitcoin_common_a_SOURCES += compat/glibc_compat.cpp
+libbitcoin_common_a_SOURCES += compat/glibcxx_compat.cpp
+endif
+
libbitcoin_cli_a_SOURCES = \
rpcclient.cpp \
$(BITCOIN_CORE_H)
diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp
new file mode 100644
index 0000000000..5b73e6051a
--- /dev/null
+++ b/src/compat/glibc_compat.cpp
@@ -0,0 +1,19 @@
+#include "bitcoin-config.h"
+#include <cstddef>
+#include <sys/select.h>
+
+// Prior to GLIBC_2.14, memcpy was aliased to memmove.
+extern "C" void* memmove(void* a, const void* b, size_t c);
+extern "C" void* memcpy(void* a, const void* b, size_t c)
+{
+ return memmove(a, b, c);
+}
+
+extern "C" void __chk_fail (void) __attribute__((__noreturn__));
+extern "C" FDELT_TYPE __fdelt_warn(FDELT_TYPE a)
+{
+ if (a >= FD_SETSIZE)
+ __chk_fail ();
+ return a / __NFDBITS;
+}
+extern "C" FDELT_TYPE __fdelt_chk(FDELT_TYPE) __attribute__((weak, alias("__fdelt_warn")));
diff --git a/src/compat/glibcxx_compat.cpp b/src/compat/glibcxx_compat.cpp
new file mode 100644
index 0000000000..e91376f818
--- /dev/null
+++ b/src/compat/glibcxx_compat.cpp
@@ -0,0 +1,87 @@
+#include <cstddef>
+#include <istream>
+#include <stdexcept>
+#include <typeinfo>
+
+#ifndef _GLIBCXX_USE_NOEXCEPT
+ #define _GLIBCXX_USE_NOEXCEPT throw()
+#endif
+
+namespace std {
+
+const char* bad_exception::what() const throw()
+{
+ return "std::bad_exception";
+}
+
+const char* bad_cast::what() const throw()
+{
+ return "std::bad_cast";
+}
+
+const char* bad_alloc::what() const throw()
+{
+ return "std::bad_alloc";
+}
+
+namespace __detail
+{
+struct _List_node_base
+{
+ void _M_hook(std::__detail::_List_node_base* const __position) throw () __attribute__((used))
+ {
+ _M_next = __position;
+ _M_prev = __position->_M_prev;
+ __position->_M_prev->_M_next = this;
+ __position->_M_prev = this;
+ }
+ void _M_unhook() __attribute__((used))
+ {
+ _List_node_base* const __next_node = _M_next;
+ _List_node_base* const __prev_node = _M_prev;
+ __prev_node->_M_next = __next_node;
+ __next_node->_M_prev = __prev_node;
+ }
+ _List_node_base* _M_next;
+ _List_node_base* _M_prev;
+};
+} // namespace detail
+
+template ostream& ostream::_M_insert(bool);
+template ostream& ostream::_M_insert(long);
+template ostream& ostream::_M_insert(double);
+template ostream& ostream::_M_insert(unsigned long);
+template ostream& ostream::_M_insert(const void*);
+template ostream& __ostream_insert(ostream&, const char*, streamsize);
+template istream& istream::_M_extract(long&);
+template istream& istream::_M_extract(unsigned short&);
+
+out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { }
+
+// Used with permission.
+// See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d
+
+void
+ctype<char>::_M_widen_init() const {
+ char __tmp[sizeof(_M_widen)];
+ for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
+ __tmp[__i] = __i;
+ do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
+
+ _M_widen_ok = 1;
+ // Set _M_widen_ok to 2 if memcpy can't be used.
+ for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i)
+ if (__tmp[__i] != _M_widen[__i]) {
+ _M_widen_ok = 2;
+ break;
+ }
+}
+
+void __throw_out_of_range_fmt(const char*, ...) __attribute__((__noreturn__));
+void __throw_out_of_range_fmt(const char* err, ...)
+{
+ // Safe and over-simplified version. Ignore the format and print it as-is.
+ __throw_out_of_range(err);
+}
+
+}// namespace std