From 53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c Mon Sep 17 00:00:00 2001 From: Alex Light Date: Thu, 12 Jun 2014 11:26:29 -0700 Subject: Add patchoat tool to Art. Add a new executable called patchoat to art. This tool takes already compiled images and oat files and changes their base address, acting as a cheap form of relocation. Add a --include-patch-information flag to dex2oat and code to add required patch information to oat files created with the quick compiler. Bug: 15358152 Change-Id: Ie0c580db45bb14ec180deb84930def6c3628d97d --- runtime/utils.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'runtime/utils.h') diff --git a/runtime/utils.h b/runtime/utils.h index eb79968e21..448c591f2b 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -19,6 +19,7 @@ #include +#include #include #include @@ -50,6 +51,34 @@ enum TimeUnit { kTimeUnitSecond, }; +template +bool ParseUint(const char *in, T* out) { + char* end; + unsigned long long int result = strtoull(in, &end, 0); // NOLINT(runtime/int) + if (in == end || *end != '\0') { + return false; + } + if (std::numeric_limits::max() < result) { + return false; + } + *out = static_cast(result); + return true; +} + +template +bool ParseInt(const char* in, T* out) { + char* end; + long long int result = strtoll(in, &end, 0); // NOLINT(runtime/int) + if (in == end || *end != '\0') { + return false; + } + if (result < std::numeric_limits::min() || std::numeric_limits::max() < result) { + return false; + } + *out = static_cast(result); + return true; +} + template static constexpr bool IsPowerOfTwo(T x) { return (x & (x - 1)) == 0; -- cgit v1.2.3-59-g8ed1b