endian.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef _LINUX_NTFS_ENDIAN_H
  23. #define _LINUX_NTFS_ENDIAN_H
  24. #include <asm/byteorder.h>
  25. #include "types.h"
  26. /*
  27. * Signed endianness conversion functions.
  28. */
  29. static inline s16 sle16_to_cpu(sle16 x)
  30. {
  31. return le16_to_cpu((__force le16)x);
  32. }
  33. static inline s32 sle32_to_cpu(sle32 x)
  34. {
  35. return le32_to_cpu((__force le32)x);
  36. }
  37. static inline s64 sle64_to_cpu(sle64 x)
  38. {
  39. return le64_to_cpu((__force le64)x);
  40. }
  41. static inline s16 sle16_to_cpup(sle16 *x)
  42. {
  43. return le16_to_cpu(*(__force le16*)x);
  44. }
  45. static inline s32 sle32_to_cpup(sle32 *x)
  46. {
  47. return le32_to_cpu(*(__force le32*)x);
  48. }
  49. static inline s64 sle64_to_cpup(sle64 *x)
  50. {
  51. return le64_to_cpu(*(__force le64*)x);
  52. }
  53. static inline sle16 cpu_to_sle16(s16 x)
  54. {
  55. return (__force sle16)cpu_to_le16(x);
  56. }
  57. static inline sle32 cpu_to_sle32(s32 x)
  58. {
  59. return (__force sle32)cpu_to_le32(x);
  60. }
  61. static inline sle64 cpu_to_sle64(s64 x)
  62. {
  63. return (__force sle64)cpu_to_le64(x);
  64. }
  65. static inline sle16 cpu_to_sle16p(s16 *x)
  66. {
  67. return (__force sle16)cpu_to_le16(*x);
  68. }
  69. static inline sle32 cpu_to_sle32p(s32 *x)
  70. {
  71. return (__force sle32)cpu_to_le32(*x);
  72. }
  73. static inline sle64 cpu_to_sle64p(s64 *x)
  74. {
  75. return (__force sle64)cpu_to_le64(*x);
  76. }
  77. #endif /* _LINUX_NTFS_ENDIAN_H */