From f8fb1f6c7d66f02a89610905a8ef05bf33d4c2b0 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 5 Apr 2018 18:34:07 -0400 Subject: [PATCH] Remove unneeded macOS-specific code --- src/ripple/beast/core/CurrentThreadName.cpp | 52 +++++-------- src/ripple/beast/core/Memory.h | 81 --------------------- src/ripple/beast/core/core.unity.cpp | 10 --- src/ripple/beast/core/mac_SystemStats.mm | 38 ---------- src/ripple/beast/core/osx_ObjCHelpers.h | 54 -------------- 5 files changed, 19 insertions(+), 216 deletions(-) delete mode 100644 src/ripple/beast/core/Memory.h delete mode 100644 src/ripple/beast/core/mac_SystemStats.mm delete mode 100644 src/ripple/beast/core/osx_ObjCHelpers.h diff --git a/src/ripple/beast/core/CurrentThreadName.cpp b/src/ripple/beast/core/CurrentThreadName.cpp index f3c855dda0..cd3b495a83 100644 --- a/src/ripple/beast/core/CurrentThreadName.cpp +++ b/src/ripple/beast/core/CurrentThreadName.cpp @@ -87,51 +87,37 @@ void setCurrentThreadNameImpl (std::string const& name) } // detail } // beast -//------------------------------------------------------------------------------ +#elif BEAST_MAC -#else - -#include -#include -#include - -#include -#if BEAST_BSD - // ??? -#elif BEAST_MAC || BEAST_IOS -#include -#include -#import -#include -#include -#else -#include - -#endif +#include namespace beast { namespace detail { void setCurrentThreadNameImpl (std::string const& name) { - #if BEAST_IOS || (BEAST_MAC && defined (MAC_OS_X_VERSION_10_5) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5) - BEAST_AUTORELEASEPOOL - { - [[NSThread currentThread] setName: stringToNS (name)]; - } - #elif BEAST_LINUX - #if (__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2012 - pthread_setname_np (pthread_self(), name.c_str ()); - #else - prctl (PR_SET_NAME, name.c_str (), 0, 0, 0); - #endif - #endif + pthread_setname_np(name.c_str()); } } // detail } // beast -#endif +#else // BEAST_LINUX + +#include + +namespace beast { +namespace detail { + +void setCurrentThreadNameImpl (std::string const& name) +{ + pthread_setname_np(pthread_self(), name.c_str()); +} + +} // detail +} // beast + +#endif // BEAST_LINUX namespace beast { diff --git a/src/ripple/beast/core/Memory.h b/src/ripple/beast/core/Memory.h deleted file mode 100644 index 2e4bc3ab51..0000000000 --- a/src/ripple/beast/core/Memory.h +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_MEMORY_H_INCLUDED -#define BEAST_MEMORY_H_INCLUDED - -#include - -#include - -namespace beast { - -//============================================================================== -/** Fills a block of memory with zeros. */ -inline void zeromem (void* memory, size_t numBytes) noexcept - { memset (memory, 0, numBytes); } - -/** Overwrites a structure or object with zeros. */ -template -void zerostruct (Type& structure) noexcept - { memset (&structure, 0, sizeof (structure)); } - -//============================================================================== -#if BEAST_MAC || BEAST_IOS || DOXYGEN - - /** A handy C++ wrapper that creates and deletes an NSAutoreleasePool object using RAII. - You should use the BEAST_AUTORELEASEPOOL macro to create a local auto-release pool on the stack. - */ - class ScopedAutoReleasePool - { - public: - ScopedAutoReleasePool(); - ~ScopedAutoReleasePool(); - - - ScopedAutoReleasePool(ScopedAutoReleasePool const&) = delete; - ScopedAutoReleasePool& operator= (ScopedAutoReleasePool const&) = delete; - - private: - void* pool; - }; - - /** A macro that can be used to easily declare a local ScopedAutoReleasePool - object for RAII-based obj-C autoreleasing. - Because this may use the \@autoreleasepool syntax, you must follow the macro with - a set of braces to mark the scope of the pool. - */ -#if (BEAST_COMPILER_SUPPORTS_ARC && defined (__OBJC__)) || DOXYGEN - #define BEAST_AUTORELEASEPOOL @autoreleasepool -#else - #define BEAST_AUTORELEASEPOOL const beast::ScopedAutoReleasePool BEAST_JOIN_MACRO (autoReleasePool_, __LINE__); -#endif - -#else - #define BEAST_AUTORELEASEPOOL -#endif - -} - -#endif - diff --git a/src/ripple/beast/core/core.unity.cpp b/src/ripple/beast/core/core.unity.cpp index d2d1deb3b8..ada0112705 100644 --- a/src/ripple/beast/core/core.unity.cpp +++ b/src/ripple/beast/core/core.unity.cpp @@ -159,16 +159,6 @@ #undef _aligned_msize #endif -#include - -#if BEAST_MAC || BEAST_IOS -#include -#endif - -#if BEAST_MAC || BEAST_IOS -#include -#endif - #include #include #include diff --git a/src/ripple/beast/core/mac_SystemStats.mm b/src/ripple/beast/core/mac_SystemStats.mm deleted file mode 100644 index e25fb9a007..0000000000 --- a/src/ripple/beast/core/mac_SystemStats.mm +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== -#include - -namespace beast -{ - -ScopedAutoReleasePool::ScopedAutoReleasePool() -{ - pool = [[NSAutoreleasePool alloc] init]; -} - -ScopedAutoReleasePool::~ScopedAutoReleasePool() -{ - [((NSAutoreleasePool*) pool) release]; -} - -} // beast diff --git a/src/ripple/beast/core/osx_ObjCHelpers.h b/src/ripple/beast/core/osx_ObjCHelpers.h deleted file mode 100644 index aed00fb58d..0000000000 --- a/src/ripple/beast/core/osx_ObjCHelpers.h +++ /dev/null @@ -1,54 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_MODULE_CORE_NATIVE_OSX_OBJCHELPERS_H_INCLUDED -#define BEAST_MODULE_CORE_NATIVE_OSX_OBJCHELPERS_H_INCLUDED - -#include -#include - -namespace beast -{ - -/* This file contains a few helper functions that are used internally but which - need to be kept away from the public headers because they use obj-C symbols. -*/ -namespace -{ - static inline NSString* stringToNS (std::string const& s) - { -#ifndef NDEBUG - // The UTF-8 encoding function for ASCII characters - // in the range [0-127] is the identity. We are more - // strict and require only printable characters. - for (auto const& c : s) - assert (isprint(static_cast(c))); -#endif - - return [NSString stringWithUTF8String: s.c_str()]; - } -} - -} // beast - -#endif // BEAST_OSX_OBJCHELPERS_H_INCLUDED