~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/fs/udf/udfend.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __UDF_ENDIAN_H
  2 #define __UDF_ENDIAN_H
  3 
  4 #ifndef __KERNEL__ 
  5 
  6 #include <sys/types.h>
  7 
  8 #if __BYTE_ORDER == 0
  9 
 10 #error "__BYTE_ORDER must be defined"
 11 
 12 #elif __BYTE_ORDER == __BIG_ENDIAN
 13 
 14 #define le16_to_cpu(x) \
 15         ((Uint16)((((Uint16)(x) & 0x00FFU) << 8) | \
 16                   (((Uint16)(x) & 0xFF00U) >> 8)))
 17  
 18 #define le32_to_cpu(x) \
 19         ((Uint32)((((Uint32)(x) & 0x000000FFU) << 24) | \
 20                   (((Uint32)(x) & 0x0000FF00U) <<  8) | \
 21                   (((Uint32)(x) & 0x00FF0000U) >>  8) | \
 22                   (((Uint32)(x) & 0xFF000000U) >> 24)))
 23 
 24 #define le64_to_cpu(x) \
 25         ((Uint64)((((Uint64)(x) & 0x00000000000000FFULL) << 56) | \
 26                   (((Uint64)(x) & 0x000000000000FF00ULL) << 40) | \
 27                   (((Uint64)(x) & 0x0000000000FF0000ULL) << 24) | \
 28                   (((Uint64)(x) & 0x00000000FF000000ULL) <<  8) | \
 29                   (((Uint64)(x) & 0x000000FF00000000ULL) >>  8) | \
 30                   (((Uint64)(x) & 0x0000FF0000000000ULL) >> 24) | \
 31                   (((Uint64)(x) & 0x00FF000000000000ULL) >> 40) | \
 32                   (((Uint64)(x) & 0xFF00000000000000ULL) >> 56)))               
 33 
 34 #define cpu_to_le16(x) (le16_to_cpu(x))
 35 #define cpu_to_le32(x) (le32_to_cpu(x))
 36 #define cpu_to_le64(x) (le64_to_cpu(x))
 37 
 38 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
 39 
 40 #define le16_to_cpu(x) (x)
 41 #define le32_to_cpu(x) (x)
 42 #define le64_to_cpu(x) (x)
 43 #define cpu_to_le16(x) (x)
 44 #define cpu_to_le32(x) (x)
 45 #define cpu_to_le64(x) (x)
 46 
 47 #endif /* __BYTE_ORDER == 0 */
 48 
 49 #include <string.h>
 50 
 51 #else /* __KERNEL__ */
 52 
 53 #include <asm/byteorder.h>
 54 #include <linux/string.h>
 55 
 56 #endif /* ! __KERNEL__ */
 57 
 58 static inline lb_addr lelb_to_cpu(lb_addr in)
 59 {
 60         lb_addr out;
 61         out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
 62         out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
 63         return out;
 64 }
 65 
 66 static inline lb_addr cpu_to_lelb(lb_addr in)
 67 {
 68         lb_addr out;
 69         out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
 70         out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
 71         return out;
 72 }
 73 
 74 static inline timestamp lets_to_cpu(timestamp in)
 75 {
 76         timestamp out;
 77         memcpy(&out, &in, sizeof(timestamp));
 78         out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
 79         out.year = le16_to_cpu(in.year);
 80         return out;
 81 }
 82 
 83 static inline long_ad lela_to_cpu(long_ad in)
 84 {
 85         long_ad out;
 86         out.extLength = le32_to_cpu(in.extLength);
 87         out.extLocation = lelb_to_cpu(in.extLocation);
 88         return out;
 89 }
 90 
 91 static inline long_ad cpu_to_lela(long_ad in)
 92 {
 93         long_ad out;
 94         out.extLength = cpu_to_le32(in.extLength);
 95         out.extLocation = cpu_to_lelb(in.extLocation);
 96         return out;
 97 }
 98 
 99 static inline extent_ad leea_to_cpu(extent_ad in)
100 {
101         extent_ad out;
102         out.extLength = le32_to_cpu(in.extLength);
103         out.extLocation = le32_to_cpu(in.extLocation);
104         return out;
105 }
106 
107 static inline timestamp cpu_to_lets(timestamp in)
108 {
109         timestamp out;
110         memcpy(&out, &in, sizeof(timestamp));
111         out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
112         out.year = cpu_to_le16(in.year);
113         return out;
114 }
115 
116 #endif /* __UDF_ENDIAN_H */
117 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.