OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 V8_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 | 1517 |
1518 template <typename V> | 1518 template <typename V> |
1519 static inline void WriteUnalignedValue(void* p, V value) { | 1519 static inline void WriteUnalignedValue(void* p, V value) { |
1520 #if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64) | 1520 #if !(V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64) |
1521 *(reinterpret_cast<V*>(p)) = value; | 1521 *(reinterpret_cast<V*>(p)) = value; |
1522 #else // V8_TARGET_ARCH_MIPS | 1522 #else // V8_TARGET_ARCH_MIPS |
1523 memmove(p, &value, sizeof(V)); | 1523 memmove(p, &value, sizeof(V)); |
1524 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 1524 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1525 } | 1525 } |
1526 | 1526 |
| 1527 static inline double ReadFloatValue(const void* p) { |
| 1528 return ReadUnalignedValue<float>(p); |
| 1529 } |
| 1530 |
1527 static inline double ReadDoubleValue(const void* p) { | 1531 static inline double ReadDoubleValue(const void* p) { |
1528 return ReadUnalignedValue<double>(p); | 1532 return ReadUnalignedValue<double>(p); |
1529 } | 1533 } |
1530 | 1534 |
1531 static inline void WriteDoubleValue(void* p, double value) { | 1535 static inline void WriteDoubleValue(void* p, double value) { |
1532 WriteUnalignedValue(p, value); | 1536 WriteUnalignedValue(p, value); |
1533 } | 1537 } |
1534 | 1538 |
1535 static inline uint16_t ReadUnalignedUInt16(const void* p) { | 1539 static inline uint16_t ReadUnalignedUInt16(const void* p) { |
1536 return ReadUnalignedValue<uint16_t>(p); | 1540 return ReadUnalignedValue<uint16_t>(p); |
1537 } | 1541 } |
1538 | 1542 |
1539 static inline void WriteUnalignedUInt16(void* p, uint16_t value) { | 1543 static inline void WriteUnalignedUInt16(void* p, uint16_t value) { |
1540 WriteUnalignedValue(p, value); | 1544 WriteUnalignedValue(p, value); |
1541 } | 1545 } |
1542 | 1546 |
1543 static inline uint32_t ReadUnalignedUInt32(const void* p) { | 1547 static inline uint32_t ReadUnalignedUInt32(const void* p) { |
1544 return ReadUnalignedValue<uint32_t>(p); | 1548 return ReadUnalignedValue<uint32_t>(p); |
1545 } | 1549 } |
1546 | 1550 |
1547 static inline void WriteUnalignedUInt32(void* p, uint32_t value) { | 1551 static inline void WriteUnalignedUInt32(void* p, uint32_t value) { |
1548 WriteUnalignedValue(p, value); | 1552 WriteUnalignedValue(p, value); |
1549 } | 1553 } |
1550 | 1554 |
1551 } // namespace internal | 1555 } // namespace internal |
1552 } // namespace v8 | 1556 } // namespace v8 |
1553 | 1557 |
1554 #endif // V8_UTILS_H_ | 1558 #endif // V8_UTILS_H_ |
OLD | NEW |