| OLD | NEW |
| 1 // Copyright 2001,2007 Alan Donovan. All rights reserved. | 1 // Copyright 2015 The Bazel Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Author: Alan Donovan <adonovan@google.com> | |
| 4 // | |
| 5 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 7 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 8 // | 6 // |
| 9 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 // | 8 // |
| 11 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 12 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 p += 4; | 52 p += 4; |
| 55 return x; | 53 return x; |
| 56 } | 54 } |
| 57 | 55 |
| 58 inline u4 get_u4le(const u1 *&p) { | 56 inline u4 get_u4le(const u1 *&p) { |
| 59 u4 x = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; | 57 u4 x = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]; |
| 60 p += 4; | 58 p += 4; |
| 61 return x; | 59 return x; |
| 62 } | 60 } |
| 63 | 61 |
| 62 inline u8 get_u8le(const u1 *&p) { |
| 63 u4 lo = get_u4le(p); |
| 64 u4 hi = get_u4le(p); |
| 65 u8 x = ((u8)hi << 32) | lo; |
| 66 return x; |
| 67 } |
| 68 |
| 64 inline void put_u1(u1 *&p, u1 x) { | 69 inline void put_u1(u1 *&p, u1 x) { |
| 65 *p++ = x; | 70 *p++ = x; |
| 66 } | 71 } |
| 67 | 72 |
| 68 inline void put_u2be(u1 *&p, u2 x) { | 73 inline void put_u2be(u1 *&p, u2 x) { |
| 69 *p++ = x >> 8; | 74 *p++ = x >> 8; |
| 70 *p++ = x & 0xff; | 75 *p++ = x & 0xff; |
| 71 } | 76 } |
| 72 | 77 |
| 73 inline void put_u2le(u1 *&p, u2 x) { | 78 inline void put_u2le(u1 *&p, u2 x) { |
| 74 *p++ = x & 0xff; | 79 *p++ = x & 0xff; |
| 75 *p++ = x >> 8;; | 80 *p++ = x >> 8;; |
| 76 } | 81 } |
| 77 | 82 |
| 78 inline void put_u4be(u1 *&p, u4 x) { | 83 inline void put_u4be(u1 *&p, u4 x) { |
| 79 *p++ = x >> 24; | 84 *p++ = x >> 24; |
| 80 *p++ = (x >> 16) & 0xff; | 85 *p++ = (x >> 16) & 0xff; |
| 81 *p++ = (x >> 8) & 0xff; | 86 *p++ = (x >> 8) & 0xff; |
| 82 *p++ = x & 0xff; | 87 *p++ = x & 0xff; |
| 83 } | 88 } |
| 84 | 89 |
| 85 inline void put_u4le(u1 *&p, u4 x) { | 90 inline void put_u4le(u1 *&p, u4 x) { |
| 86 *p++ = x & 0xff; | 91 *p++ = x & 0xff; |
| 87 *p++ = (x >> 8) & 0xff; | 92 *p++ = (x >> 8) & 0xff; |
| 88 *p++ = (x >> 16) & 0xff; | 93 *p++ = (x >> 16) & 0xff; |
| 89 *p++ = x >> 24; | 94 *p++ = x >> 24; |
| 90 } | 95 } |
| 91 | 96 |
| 97 inline void put_u8le(u1 *&p, u8 x) { |
| 98 put_u4le(p, x & 0xffffffff); |
| 99 put_u4le(p, (x >> 32) & 0xffffffff); |
| 100 } |
| 101 |
| 92 // Copy n bytes from src to p, and advance p. | 102 // Copy n bytes from src to p, and advance p. |
| 93 inline void put_n(u1 *&p, const u1 *src, size_t n) { | 103 inline void put_n(u1 *&p, const u1 *src, size_t n) { |
| 94 memcpy(p, src, n); | 104 memcpy(p, src, n); |
| 95 p += n; | 105 p += n; |
| 96 } | 106 } |
| 97 | 107 |
| 98 extern bool verbose; | 108 extern bool verbose; |
| 99 | 109 |
| 100 } // namespace devtools_ijar | 110 } // namespace devtools_ijar |
| 101 | 111 |
| 102 #endif // INCLUDED_DEVTOOLS_IJAR_COMMON_H | 112 #endif // INCLUDED_DEVTOOLS_IJAR_COMMON_H |
| OLD | NEW |