Message ID | 1402441994-16780-4-git-send-email-hpa@zytor.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jun 10, 2014 at 4:13 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> For architectures which handle unaligned references transparently.
Shouldn't these depend on host endianness?
--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On 06/10/2014 04:25 PM, Andy Lutomirski wrote: > On Tue, Jun 10, 2014 at 4:13 PM, H. Peter Anvin <hpa@zytor.com> wrote: >> For architectures which handle unaligned references transparently. > > Shouldn't these depend on host endianness? > See further down the series for how these end up being invoked. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Jun 10, 2014 at 4:30 PM, H. Peter Anvin <hpa@zytor.com> wrote: > On 06/10/2014 04:25 PM, Andy Lutomirski wrote: >> On Tue, Jun 10, 2014 at 4:13 PM, H. Peter Anvin <hpa@zytor.com> wrote: >>> For architectures which handle unaligned references transparently. >> >> Shouldn't these depend on host endianness? >> > > See further down the series for how these end up being invoked. > Ah, sneaky. Would it make sense to put a comment in this file (and similar files) indicating that they must only be included on architectures of the appropriate endianness? --Andy > -hpa > >
On 06/10/2014 04:33 PM, Andy Lutomirski wrote: > > Ah, sneaky. > > Would it make sense to put a comment in this file (and similar files) > indicating that they must only be included on architectures of the > appropriate endianness? > That might make sense, yes, although I don't think we do that for the kernel variants. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/tools/include/tools/unaligned/be_direct.h b/tools/include/tools/unaligned/be_direct.h new file mode 100644 index 000000000000..10a9b8229003 --- /dev/null +++ b/tools/include/tools/unaligned/be_direct.h @@ -0,0 +1,48 @@ +#ifndef _TOOLS_BE_DIRECT_H +#define _TOOLS_BE_DIRECT_H + +#include <stdint.h> + +static inline uint16_t get_unaligned_be16(const void *_p) +{ + const uint16_t *p = _p; + + return *p; +} + +static inline uint32_t get_unaligned_be32(const void *_p) +{ + const uint32_t *p = _p; + + return *p; +} + +static inline uint64_t get_unaligned_be64(const void *_p) +{ + const uint64_t *p = _p; + + return *p; +} + +static inline void put_unaligned_be16(uint16_t val, void *_p) +{ + uint16_t *p = _p; + + *p = val; +} + +static inline void put_unaligned_be32(uint32_t val, void *_p) +{ + uint32_t *p = _p; + + *p = val; +} + +static inline void put_unaligned_be64(uint64_t val, void *_p) +{ + uint64_t *p = _p; + + *p = val; +} + +#endif /* _TOOLS_BE_DIRECT_H */ diff --git a/tools/include/tools/unaligned/le_direct.h b/tools/include/tools/unaligned/le_direct.h new file mode 100644 index 000000000000..6353dfd04fd7 --- /dev/null +++ b/tools/include/tools/unaligned/le_direct.h @@ -0,0 +1,48 @@ +#ifndef _TOOLS_LE_DIRECT_H +#define _TOOLS_LE_DIRECT_H + +#include <stdint.h> + +static inline uint16_t get_unaligned_le16(const void *_p) +{ + const uint16_t *p = _p; + + return *p; +} + +static inline uint32_t get_unaligned_le32(const void *_p) +{ + const uint32_t *p = _p; + + return *p; +} + +static inline uint64_t get_unaligned_le64(const void *_p) +{ + const uint64_t *p = _p; + + return *p; +} + +static inline void put_unaligned_le16(uint16_t val, void *_p) +{ + uint16_t *p = _p; + + *p = val; +} + +static inline void put_unaligned_le32(uint32_t val, void *_p) +{ + uint32_t *p = _p; + + *p = val; +} + +static inline void put_unaligned_le64(uint64_t val, void *_p) +{ + uint64_t *p = _p; + + *p = val; +} + +#endif /* _TOOLS_LE_DIRECT_H */
For architectures which handle unaligned references transparently. Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- tools/include/tools/unaligned/be_direct.h | 48 +++++++++++++++++++++++++++++++ tools/include/tools/unaligned/le_direct.h | 48 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tools/include/tools/unaligned/be_direct.h create mode 100644 tools/include/tools/unaligned/le_direct.h