udfend.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef __UDF_ENDIAN_H
  2. #define __UDF_ENDIAN_H
  3. #include <asm/byteorder.h>
  4. #include <linux/string.h>
  5. static inline lb_addr lelb_to_cpu(lb_addr in)
  6. {
  7. lb_addr out;
  8. out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
  9. out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
  10. return out;
  11. }
  12. static inline lb_addr cpu_to_lelb(lb_addr in)
  13. {
  14. lb_addr out;
  15. out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
  16. out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
  17. return out;
  18. }
  19. static inline timestamp lets_to_cpu(timestamp in)
  20. {
  21. timestamp out;
  22. memcpy(&out, &in, sizeof(timestamp));
  23. out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
  24. out.year = le16_to_cpu(in.year);
  25. return out;
  26. }
  27. static inline short_ad lesa_to_cpu(short_ad in)
  28. {
  29. short_ad out;
  30. out.extLength = le32_to_cpu(in.extLength);
  31. out.extPosition = le32_to_cpu(in.extPosition);
  32. return out;
  33. }
  34. static inline short_ad cpu_to_lesa(short_ad in)
  35. {
  36. short_ad out;
  37. out.extLength = cpu_to_le32(in.extLength);
  38. out.extPosition = cpu_to_le32(in.extPosition);
  39. return out;
  40. }
  41. static inline long_ad lela_to_cpu(long_ad in)
  42. {
  43. long_ad out;
  44. out.extLength = le32_to_cpu(in.extLength);
  45. out.extLocation = lelb_to_cpu(in.extLocation);
  46. return out;
  47. }
  48. static inline long_ad cpu_to_lela(long_ad in)
  49. {
  50. long_ad out;
  51. out.extLength = cpu_to_le32(in.extLength);
  52. out.extLocation = cpu_to_lelb(in.extLocation);
  53. return out;
  54. }
  55. static inline extent_ad leea_to_cpu(extent_ad in)
  56. {
  57. extent_ad out;
  58. out.extLength = le32_to_cpu(in.extLength);
  59. out.extLocation = le32_to_cpu(in.extLocation);
  60. return out;
  61. }
  62. static inline timestamp cpu_to_lets(timestamp in)
  63. {
  64. timestamp out;
  65. memcpy(&out, &in, sizeof(timestamp));
  66. out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
  67. out.year = cpu_to_le16(in.year);
  68. return out;
  69. }
  70. #endif /* __UDF_ENDIAN_H */