From fc0c07eb64f4bc22377c35d13c71de9e2ede8861 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Sat, 21 Jun 2014 14:26:21 +0200 Subject: [PATCH] small cleanup in src/compat .h and .cpp - add license header - fix include guards - fix indentation --- src/compat/glibc_compat.cpp | 17 +++++++++--- src/compat/glibc_sanity.cpp | 8 +++++- src/compat/glibcxx_compat.cpp | 50 ++++++++++++++++++++--------------- src/compat/glibcxx_sanity.cpp | 6 ++++- src/compat/sanity.h | 6 ++++- 5 files changed, 58 insertions(+), 29 deletions(-) diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp index 5b73e6051..bb870c01f 100644 --- a/src/compat/glibc_compat.cpp +++ b/src/compat/glibc_compat.cpp @@ -1,19 +1,28 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) #include "bitcoin-config.h" +#endif + #include +#if defined(HAVE_SYS_SELECT_H) #include +#endif // 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); + 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; + 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/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp index 1f64df9e3..6e5bae8a4 100644 --- a/src/compat/glibc_sanity.cpp +++ b/src/compat/glibc_sanity.cpp @@ -1,4 +1,10 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) #include "bitcoin-config.h" +#endif #include #if defined(HAVE_SYS_SELECT_H) @@ -8,7 +14,7 @@ extern "C" void* memcpy(void* a, const void* b, size_t c); void* memcpy_int(void* a, const void* b, size_t c) { - return memcpy(a,b,c); + return memcpy(a,b,c); } namespace { diff --git a/src/compat/glibcxx_compat.cpp b/src/compat/glibcxx_compat.cpp index e91376f81..417166aed 100644 --- a/src/compat/glibcxx_compat.cpp +++ b/src/compat/glibcxx_compat.cpp @@ -1,49 +1,55 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include #include #include #include #ifndef _GLIBCXX_USE_NOEXCEPT - #define _GLIBCXX_USE_NOEXCEPT throw() +#define _GLIBCXX_USE_NOEXCEPT throw() #endif namespace std { const char* bad_exception::what() const throw() { - return "std::bad_exception"; + return "std::bad_exception"; } const char* bad_cast::what() const throw() { - return "std::bad_cast"; + return "std::bad_cast"; } const char* bad_alloc::what() const throw() { - return "std::bad_alloc"; + 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; + 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 @@ -61,8 +67,8 @@ out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { } // Used with permission. // See: https://github.com/madlib/madlib/commit/c3db418c0d34d6813608f2137fef1012ce03043d -void -ctype::_M_widen_init() const { +void ctype::_M_widen_init() const +{ char __tmp[sizeof(_M_widen)]; for (unsigned __i = 0; __i < sizeof(_M_widen); ++__i) __tmp[__i] = __i; diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp index 2ff70948f..cd8da4fd6 100644 --- a/src/compat/glibcxx_sanity.cpp +++ b/src/compat/glibcxx_sanity.cpp @@ -1,5 +1,9 @@ -#include +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include +#include #include namespace{ diff --git a/src/compat/sanity.h b/src/compat/sanity.h index a221f69df..e7df44307 100644 --- a/src/compat/sanity.h +++ b/src/compat/sanity.h @@ -1,7 +1,11 @@ +// Copyright (c) 2009-2014 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #ifndef BITCON_COMPAT_SANITY_H #define BITCON_COMPAT_SANITY_H bool glibc_sanity_test(); bool glibcxx_sanity_test(); -#endif +#endif // BITCON_COMPAT_SANITY_H