mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
Revert to standard linux macros (for correct behaviour on rare architectures).
This commit is contained in:
parent
d327698491
commit
1f835295d8
@ -1,53 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||||
*
|
*
|
||||||
* This file is released under the GPL.
|
* This file is released under the LGPL.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LVM_XLATE_H
|
#ifndef _LVM_XLATE_H
|
||||||
#define _LVM_XLATE_H
|
#define _LVM_XLATE_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <asm/byteorder.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
#define xlate16(x) __cpu_to_le16((x));
|
||||||
|
#define xlate32(x) __cpu_to_le32((x));
|
||||||
static inline uint16_t swab16(uint16_t x)
|
#define xlate64(x) __cpu_to_le64((x));
|
||||||
{
|
|
||||||
return (x & 0x00ffU) << 8 |
|
|
||||||
(x & 0xff00U) >> 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t swab32(uint32_t x)
|
|
||||||
{
|
|
||||||
return (x & 0x000000ffU) << 24 |
|
|
||||||
(x & 0x0000ff00U) << 8 |
|
|
||||||
(x & 0x00ff0000U) >> 8 |
|
|
||||||
(x & 0xff000000U) >> 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t swab64(uint64_t x)
|
|
||||||
{
|
|
||||||
return (x & 0x00000000000000ffULL) << 56 |
|
|
||||||
(x & 0x000000000000ff00ULL) << 40 |
|
|
||||||
(x & 0x0000000000ff0000ULL) << 24 |
|
|
||||||
(x & 0x00000000ff000000ULL) << 8 |
|
|
||||||
(x & 0x000000ff00000000ULL) >> 8 |
|
|
||||||
(x & 0x0000ff0000000000ULL) >> 24 |
|
|
||||||
(x & 0x00ff000000000000ULL) >> 40 |
|
|
||||||
(x & 0xff00000000000000ULL) >> 56;
|
|
||||||
}
|
|
||||||
|
|
||||||
# define xlate16(x) swab16((x))
|
|
||||||
# define xlate32(x) swab32((x))
|
|
||||||
# define xlate64(x) swab64((x))
|
|
||||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
|
||||||
# define xlate16(x) (x)
|
|
||||||
# define xlate32(x) (x)
|
|
||||||
# define xlate64(x) (x)
|
|
||||||
#else
|
|
||||||
# error "__BYTE_ORDER must be defined as __LITTLE_ENDIAN or __BIG_ENDIAN"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user