diff options
author | Alex Light <allight@google.com> | 2014-06-12 11:26:29 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2014-07-07 15:19:58 -0700 |
commit | 53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c (patch) | |
tree | c0129ef3de7148dc6a114449b4f751a560283eb0 /runtime/utils.h | |
parent | ae2efea4582df773f80be274bdc754f732b07df3 (diff) | |
download | art-53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c.tar.gz art-53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c.tar.bz2 art-53cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3c.zip |
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
Diffstat (limited to 'runtime/utils.h')
-rw-r--r-- | runtime/utils.h | 29 |
1 files changed, 29 insertions, 0 deletions
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 <pthread.h> +#include <limits> #include <string> #include <vector> @@ -50,6 +51,34 @@ enum TimeUnit { kTimeUnitSecond, }; +template <typename T> +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<T>::max() < result) { + return false; + } + *out = static_cast<T>(result); + return true; +} + +template <typename T> +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<T>::min() || std::numeric_limits<T>::max() < result) { + return false; + } + *out = static_cast<T>(result); + return true; +} + template<typename T> static constexpr bool IsPowerOfTwo(T x) { return (x & (x - 1)) == 0; |