Reduce Beast public interface and eliminate unused code:

Beast includes a lot of code for encapsulating cross-platform differences
which are not used or needed by rippled. Additionally, a lot of that code
implements functionality that is available from the standard library.

This moves away from custom implementations of features that the standard
library provides and reduces the number of platform-specific interfaces
andfeatures that Beast makes available.

Highlights include:
* Use std:: instead of beast implementations when possible
* Reduce the use of beast::String in public interfaces
* Remove Windows-specific COM and Registry code
* Reduce the public interface of beast::File
* Reduce the public interface of beast::SystemStats
* Remove unused sysctl/getsysinfo functions
* Remove beast::Logger
This commit is contained in:
Nik Bougalis
2014-10-13 14:20:54 -07:00
committed by Vinnie Falco
parent fefdb32d08
commit 186ca9c235
82 changed files with 361 additions and 7762 deletions

View File

@@ -21,59 +21,37 @@
*/
//==============================================================================
// Some basic tests, to keep an eye on things and make sure these types work ok
// on all platforms.
static_assert (sizeof (std::intptr_t) == sizeof (void*), "std::intptr_t must be the same size as void*");
static_assert (sizeof (std::int8_t) == 1, "std::int8_t must be exactly 1 byte!");
static_assert (sizeof (std::int16_t) == 2, "std::int16_t must be exactly 2 bytes!");
static_assert (sizeof (std::int32_t) == 4, "std::int32_t must be exactly 4 bytes!");
static_assert (sizeof (std::int64_t) == 8, "std::int64_t must be exactly 8 bytes!");
static_assert (sizeof (std::uint8_t) == 1, "std::uint8_t must be exactly 1 byte!");
static_assert (sizeof (std::uint16_t) == 2, "std::uint16_t must be exactly 2 bytes!");
static_assert (sizeof (std::uint32_t) == 4, "std::uint32_t must be exactly 4 bytes!");
static_assert (sizeof (std::uint64_t) == 8, "std::uint64_t must be exactly 8 bytes!");
namespace beast
{
String SystemStats::getBeastVersion()
std::string
SystemStats::getBeastVersion()
{
// Some basic tests, to keep an eye on things and make sure these types work ok
// on all platforms. Let me know if any of these assertions fail on your system!
static_bassert (sizeof (std::intptr_t) == sizeof (void*));
static_bassert (sizeof (std::int8_t) == 1);
static_bassert (sizeof (std::uint8_t) == 1);
static_bassert (sizeof (std::int16_t) == 2);
static_bassert (sizeof (std::uint16_t) == 2);
static_bassert (sizeof (std::int32_t) == 4);
static_bassert (sizeof (std::uint32_t) == 4);
static_bassert (sizeof (std::int64_t) == 8);
static_bassert (sizeof (std::uint64_t) == 8);
return "Beast v" BEAST_STRINGIFY(BEAST_MAJOR_VERSION)
"." BEAST_STRINGIFY(BEAST_MINOR_VERSION)
"." BEAST_STRINGIFY(BEAST_BUILDNUMBER);
return "Beast v" + std::to_string (BEAST_MAJOR_VERSION) +
"." + std::to_string (BEAST_MINOR_VERSION) +
"." + std::to_string (BEAST_BUILDNUMBER);
}
//==============================================================================
struct CPUInformation
std::string
SystemStats::getStackBacktrace()
{
CPUInformation() noexcept
: hasMMX (false), hasSSE (false),
hasSSE2 (false), hasSSE3 (false), has3DNow (false)
{
initialise();
}
void initialise() noexcept;
bool hasMMX, hasSSE, hasSSE2, hasSSE3, has3DNow;
};
static const CPUInformation& getCPUInformation() noexcept
{
static CPUInformation info;
return info;
}
bool SystemStats::hasMMX() noexcept { return getCPUInformation().hasMMX; }
bool SystemStats::hasSSE() noexcept { return getCPUInformation().hasSSE; }
bool SystemStats::hasSSE2() noexcept { return getCPUInformation().hasSSE2; }
bool SystemStats::hasSSE3() noexcept { return getCPUInformation().hasSSE3; }
bool SystemStats::has3DNow() noexcept { return getCPUInformation().has3DNow; }
//==============================================================================
String SystemStats::getStackBacktrace()
{
String result;
std::string result;
#if BEAST_ANDROID || BEAST_MINGW || BEAST_BSD
bassertfalse; // sorry, not implemented yet!
@@ -96,16 +74,27 @@ String SystemStats::getStackBacktrace()
if (SymFromAddr (process, (DWORD64) stack[i], &displacement, symbol))
{
result << i << ": ";
result.append (std::to_string (i) + ": ");
IMAGEHLP_MODULE64 moduleInfo;
zerostruct (moduleInfo);
moduleInfo.SizeOfStruct = sizeof (moduleInfo);
if (::SymGetModuleInfo64 (process, symbol->ModBase, &moduleInfo))
result << moduleInfo.ModuleName << ": ";
{
result.append (moduleInfo.ModuleName);
result.append (": ");
}
result << symbol->Name << " + 0x" << String::toHexString ((std::int64_t) displacement) << newLine;
result.append (symbol->Name);
if (displacement)
{
result.append ("+");
result.append (std::to_string (displacement));
}
result.append ("\r\n");
}
}
@@ -115,7 +104,10 @@ String SystemStats::getStackBacktrace()
char** frameStrings = backtrace_symbols (stack, frames);
for (int i = 0; i < frames; ++i)
result << frameStrings[i] << newLine;
{
result.append (frameStrings[i]);
result.append ("\n");
}
::free (frameStrings);
#endif