A fallback implementation of uintptr_t for systems that lack it.
| 256 | |
| 257 | // A fallback implementation of uintptr_t for systems that lack it. |
| 258 | struct fallback_uintptr { |
| 259 | unsigned char value[sizeof(void*)]; |
| 260 | |
| 261 | fallback_uintptr() = default; |
| 262 | explicit fallback_uintptr(const void* p) { |
| 263 | *this = bit_cast<fallback_uintptr>(p); |
| 264 | if (is_big_endian()) { |
| 265 | for (size_t i = 0, j = sizeof(void*) - 1; i < j; ++i, --j) |
| 266 | std::swap(value[i], value[j]); |
| 267 | } |
| 268 | } |
| 269 | }; |
| 270 | #ifdef UINTPTR_MAX |
| 271 | using uintptr_t = ::uintptr_t; |
| 272 | inline uintptr_t to_uintptr(const void* p) { return bit_cast<uintptr_t>(p); } |