Home | History | Annotate | Download | only in base

Lines Matching refs:memory

43 // Reading and writing of little and big-endian numbers from memory
49 inline void Set8(void* memory, size_t offset, uint8 v) {
50 static_cast<uint8*>(memory)[offset] = v;
52 inline uint8 Get8(const void* memory, size_t offset) {
53 return static_cast<const uint8*>(memory)[offset];
56 inline void SetBE16(void* memory, uint16 v) {
57 Set8(memory, 0, static_cast<uint8>(v >> 8));
58 Set8(memory, 1, static_cast<uint8>(v >> 0));
60 inline void SetBE32(void* memory, uint32 v) {
61 Set8(memory, 0, static_cast<uint8>(v >> 24));
62 Set8(memory, 1, static_cast<uint8>(v >> 16));
63 Set8(memory, 2, static_cast<uint8>(v >> 8));
64 Set8(memory, 3, static_cast<uint8>(v >> 0));
66 inline void SetBE64(void* memory, uint64 v) {
67 Set8(memory, 0, static_cast<uint8>(v >> 56));
68 Set8(memory, 1, static_cast<uint8>(v >> 48));
69 Set8(memory, 2, static_cast<uint8>(v >> 40));
70 Set8(memory, 3, static_cast<uint8>(v >> 32));
71 Set8(memory, 4, static_cast<uint8>(v >> 24));
72 Set8(memory, 5, static_cast<uint8>(v >> 16));
73 Set8(memory, 6, static_cast<uint8>(v >> 8));
74 Set8(memory, 7, static_cast<uint8>(v >> 0));
76 inline uint16 GetBE16(const void* memory) {
77 return (static_cast<uint16>(Get8(memory, 0)) << 8)
78 | (static_cast<uint16>(Get8(memory, 1)) << 0);
80 inline uint32 GetBE32(const void* memory) {
81 return (static_cast<uint32>(Get8(memory, 0)) << 24)
82 | (static_cast<uint32>(Get8(memory, 1)) << 16)
83 | (static_cast<uint32>(Get8(memory, 2)) << 8)
84 | (static_cast<uint32>(Get8(memory, 3)) << 0);
86 inline uint64 GetBE64(const void* memory) {
87 return (static_cast<uint64>(Get8(memory, 0)) << 56)
88 | (static_cast<uint64>(Get8(memory, 1)) << 48)
89 | (static_cast<uint64>(Get8(memory, 2)) << 40)
90 | (static_cast<uint64>(Get8(memory, 3)) << 32)
91 | (static_cast<uint64>(Get8(memory, 4)) << 24)
92 | (static_cast<uint64>(Get8(memory, 5)) << 16)
93 | (static_cast<uint64>(Get8(memory, 6)) << 8)
94 | (static_cast<uint64>(Get8(memory, 7)) << 0);
97 inline void SetLE16(void* memory, uint16 v) {
98 Set8(memory, 1, static_cast<uint8>(v >> 8));
99 Set8(memory, 0, static_cast<uint8>(v >> 0));
101 inline void SetLE32(void* memory, uint32 v) {
102 Set8(memory, 3, static_cast<uint8>(v >> 24));
103 Set8(memory, 2, static_cast<uint8>(v >> 16));
104 Set8(memory, 1, static_cast<uint8>(v >> 8));
105 Set8(memory, 0, static_cast<uint8>(v >> 0));
107 inline void SetLE64(void* memory, uint64 v) {
108 Set8(memory, 7, static_cast<uint8>(v >> 56));
109 Set8(memory, 6, static_cast<uint8>(v >> 48));
110 Set8(memory, 5, static_cast<uint8>(v >> 40));
111 Set8(memory, 4, static_cast<uint8>(v >> 32));
112 Set8(memory, 3, static_cast<uint8>(v >> 24));
113 Set8(memory, 2, static_cast<uint8>(v >> 16));
114 Set8(memory, 1, static_cast<uint8>(v >> 8));
115 Set8(memory, 0, static_cast<uint8>(v >> 0));
117 inline uint16 GetLE16(const void* memory) {
118 return (static_cast<uint16>(Get8(memory, 1)) << 8)
119 | (static_cast<uint16>(Get8(memory, 0)) << 0);
121 inline uint32 GetLE32(const void* memory) {
122 return (static_cast<uint32>(Get8(memory, 3)) << 24)
123 | (static_cast<uint32>(Get8(memory, 2)) << 16)
124 | (static_cast<uint32>(Get8(memory, 1)) << 8)
125 | (static_cast<uint32>(Get8(memory, 0)) << 0);
127 inline uint64 GetLE64(const void* memory) {
128 return (static_cast<uint64>(Get8(memory, 7)) << 56)
129 | (static_cast<uint64>(Get8(memory, 6)) << 48)
130 | (static_cast<uint64>(Get8(memory, 5)) << 40)
131 | (static_cast<uint64>(Get8(memory, 4)) << 32)
132 | (static_cast<uint64>(Get8(memory, 3)) << 24)
133 | (static_cast<uint64>(Get8(memory, 2)) << 16)
134 | (static_cast<uint64>(Get8(memory, 1)) << 8)
135 | (static_cast<uint64>(Get8(memory, 0)) << 0);