mirror of
https://github.com/encounter/osdev.git
synced 2026-03-30 11:33:54 -07:00
21 lines
658 B
C
21 lines
658 B
C
#pragma once
|
|
|
|
#include <common.h>
|
|
|
|
#define __bswap_16(x) \
|
|
((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
|
|
|
|
#define __bswap_32(x) \
|
|
((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) \
|
|
| (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
|
|
|
|
#define __bswap_64(x) \
|
|
((((x) & 0xff00000000000000ull) >> 56) \
|
|
| (((x) & 0x00ff000000000000ull) >> 40) \
|
|
| (((x) & 0x0000ff0000000000ull) >> 24) \
|
|
| (((x) & 0x000000ff00000000ull) >> 8) \
|
|
| (((x) & 0x00000000ff000000ull) << 8) \
|
|
| (((x) & 0x0000000000ff0000ull) << 24) \
|
|
| (((x) & 0x000000000000ff00ull) << 40) \
|
|
| (((x) & 0x00000000000000ffull) << 56))
|