Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/android_crazy_linker/src/src/crazy_linker_leb128.h

Issue 1557733002: Prepare for -Wall for third-party code, -Wextra for chromium_code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CRAZY_LINKER_LEB128_H 5 #ifndef CRAZY_LINKER_LEB128_H
6 #define CRAZY_LINKER_LEB128_H 6 #define CRAZY_LINKER_LEB128_H
7 7
8 #include <assert.h> 8 #include <assert.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 // Helper classes for decoding LEB128, used in packed relocation data. 11 // Helper classes for decoding LEB128, used in packed relocation data.
12 // http://en.wikipedia.org/wiki/LEB128 12 // http://en.wikipedia.org/wiki/LEB128
13 13
14 namespace crazy { 14 namespace crazy {
15 15
16 class Sleb128Decoder { 16 class Sleb128Decoder {
17 public: 17 public:
18 Sleb128Decoder(const uint8_t* buffer, size_t count) 18 Sleb128Decoder(const uint8_t* buffer, size_t count) : current_(buffer)
19 : current_(buffer), end_(buffer + count) { } 19 #ifndef NDEBUG
20 , end_(buffer + count)
21 #endif
22 {}
20 23
21 size_t pop_front() { 24 size_t pop_front() {
22 size_t value = 0; 25 size_t value = 0;
23 static const size_t size = CHAR_BIT * sizeof(value); 26 static const size_t size = CHAR_BIT * sizeof(value);
24 27
25 size_t shift = 0; 28 size_t shift = 0;
26 uint8_t byte; 29 uint8_t byte;
27 30
28 do { 31 do {
29 assert(current_ < end_); 32 assert(current_ < end_);
30 33
31 byte = *current_++; 34 byte = *current_++;
32 value |= (static_cast<size_t>(byte & 127) << shift); 35 value |= (static_cast<size_t>(byte & 127) << shift);
33 shift += 7; 36 shift += 7;
34 } while (byte & 128); 37 } while (byte & 128);
35 38
36 if (shift < size && (byte & 64)) { 39 if (shift < size && (byte & 64)) {
37 value |= -(static_cast<size_t>(1) << shift); 40 value |= -(static_cast<size_t>(1) << shift);
38 } 41 }
39 42
40 return value; 43 return value;
41 } 44 }
42 45
43 private: 46 private:
44 const uint8_t* current_; 47 const uint8_t* current_;
48 #ifndef NDEBUG
45 const uint8_t* const end_; 49 const uint8_t* const end_;
50 #endif
46 }; 51 };
47 52
48 } // namespace crazy 53 } // namespace crazy
49 54
50 #endif // CRAZY_LINKER_LEB128_H 55 #endif // CRAZY_LINKER_LEB128_H
OLDNEW
« no previous file with comments | « ppapi/native_client/src/untrusted/irt_stub/thread_creator.c ('k') | third_party/android_protobuf/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698