1/*
2 * endian.h - Defines for endianness handling in NTFS Linux kernel driver.
3 *	      Part of the Linux-NTFS project.
4 *
5 * Copyright (c) 2001-2004 Anton Altaparmakov
6 *
7 * This program/include file is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program/include file is distributed in the hope that it will be
13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program (in the main directory of the Linux-NTFS
19 * distribution in the file COPYING); if not, write to the Free Software
20 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 */
22
23#ifndef _LINUX_NTFS_ENDIAN_H
24#define _LINUX_NTFS_ENDIAN_H
25
26#include <asm/byteorder.h>
27#include "types.h"
28
29/*
30 * Signed endianness conversion functions.
31 */
32
33static inline s16 sle16_to_cpu(sle16 x)
34{
35	return le16_to_cpu((__force le16)x);
36}
37
38static inline s32 sle32_to_cpu(sle32 x)
39{
40	return le32_to_cpu((__force le32)x);
41}
42
43static inline s64 sle64_to_cpu(sle64 x)
44{
45	return le64_to_cpu((__force le64)x);
46}
47
48static inline s16 sle16_to_cpup(sle16 *x)
49{
50	return le16_to_cpu(*(__force le16*)x);
51}
52
53static inline s32 sle32_to_cpup(sle32 *x)
54{
55	return le32_to_cpu(*(__force le32*)x);
56}
57
58static inline s64 sle64_to_cpup(sle64 *x)
59{
60	return le64_to_cpu(*(__force le64*)x);
61}
62
63static inline sle16 cpu_to_sle16(s16 x)
64{
65	return (__force sle16)cpu_to_le16(x);
66}
67
68static inline sle32 cpu_to_sle32(s32 x)
69{
70	return (__force sle32)cpu_to_le32(x);
71}
72
73static inline sle64 cpu_to_sle64(s64 x)
74{
75	return (__force sle64)cpu_to_le64(x);
76}
77
78static inline sle16 cpu_to_sle16p(s16 *x)
79{
80	return (__force sle16)cpu_to_le16(*x);
81}
82
83static inline sle32 cpu_to_sle32p(s32 *x)
84{
85	return (__force sle32)cpu_to_le32(*x);
86}
87
88static inline sle64 cpu_to_sle64p(s64 *x)
89{
90	return (__force sle64)cpu_to_le64(*x);
91}
92
93#endif /* _LINUX_NTFS_ENDIAN_H */
94