100fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#ifndef FIO_BSWAP_H
200fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#define FIO_BSWAP_H
300fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
400fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#include <inttypes.h>
500fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
60dcebdf4a70ef0d8144b8fcba763ae87e7fc74b5Jens Axboe#ifdef CONFIG_LITTLE_ENDIAN
700fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboestatic inline uint32_t __be32_to_cpu(uint32_t val)
800fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe{
900fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	uint32_t c1, c2, c3, c4;
1000fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
1100fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c1 = (val >> 24) & 0xff;
1200fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c2 = (val >> 16) & 0xff;
1300fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c3 = (val >> 8) & 0xff;
1400fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c4 = val & 0xff;
1500fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
1600fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	return c1 | c2 << 8 | c3 << 16 | c4 << 24;
1700fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe}
1800fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
1900fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboestatic inline uint64_t __be64_to_cpu(uint64_t val)
2000fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe{
2100fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	uint64_t c1, c2, c3, c4, c5, c6, c7, c8;
2200fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
2300fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c1 = (val >> 56) & 0xff;
2400fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c2 = (val >> 48) & 0xff;
2500fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c3 = (val >> 40) & 0xff;
2600fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c4 = (val >> 32) & 0xff;
2700fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c5 = (val >> 24) & 0xff;
2800fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c6 = (val >> 16) & 0xff;
2900fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c7 = (val >> 8) & 0xff;
3000fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	c8 = val & 0xff;
3100fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
3200fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	return c1 | c2 << 8 | c3 << 16 | c4 << 24 | c5 << 32 | c6 << 40 | c7 << 48 | c8 << 56;
3300fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe}
3400fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#else
3500fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboestatic inline uint64_t __be64_to_cpu(uint64_t val)
3600fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe{
3700fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	return val;
3800fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe}
3900fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
4000fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboestatic inline uint32_t __be32_to_cpu(uint32_t val)
4100fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe{
4200fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe	return val;
4300fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe}
4400fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#endif
4500fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe
4600fb3c8dcbb940338fea9f6cab689b4924266305Jens Axboe#endif
47