| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 NET_BASE_BIG_ENDIAN_H_ | 5 #ifndef NET_BASE_BIG_ENDIAN_H_ |
| 6 #define NET_BASE_BIG_ENDIAN_H_ | 6 #define NET_BASE_BIG_ENDIAN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string_piece.h" |
| 10 #include "net/base/net_export.h" | 11 #include "net/base/net_export.h" |
| 11 | 12 |
| 12 namespace base { | |
| 13 class StringPiece; | |
| 14 } | |
| 15 | |
| 16 namespace net { | 13 namespace net { |
| 17 | 14 |
| 18 // Read an integer (signed or unsigned) from |buf| in Big Endian order. | 15 // Read an integer (signed or unsigned) from |buf| in Big Endian order. |
| 19 // Note: this loop is unrolled with -O1 and above. | 16 // Note: this loop is unrolled with -O1 and above. |
| 20 // NOTE(szym): glibc dns-canon.c and SpdyFrameBuilder use | 17 // NOTE(szym): glibc dns-canon.c and SpdyFrameBuilder use |
| 21 // ntohs(*(uint16_t*)ptr) which is potentially unaligned. | 18 // ntohs(*(uint16_t*)ptr) which is potentially unaligned. |
| 22 // This would cause SIGBUS on ARMv5 or earlier and ARMv6-M. | 19 // This would cause SIGBUS on ARMv5 or earlier and ARMv6-M. |
| 23 template<typename T> | 20 template<typename T> |
| 24 inline void ReadBigEndian(const char buf[], T* out) { | 21 inline void ReadBigEndian(const char buf[], T* out) { |
| 25 *out = buf[0]; | 22 *out = buf[0]; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 bool Write(T v); | 95 bool Write(T v); |
| 99 | 96 |
| 100 char* ptr_; | 97 char* ptr_; |
| 101 char* end_; | 98 char* end_; |
| 102 }; | 99 }; |
| 103 | 100 |
| 104 } // namespace net | 101 } // namespace net |
| 105 | 102 |
| 106 #endif // NET_BASE_BIG_ENDIAN_H_ | 103 #endif // NET_BASE_BIG_ENDIAN_H_ |
| 107 | 104 |
| OLD | NEW |