Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 393
b: refs/heads/master
c: 3106dbc
h: refs/heads/master
i:
  391: 9adfb3a
v: v3
  • Loading branch information
Al Viro authored and Linus Torvalds committed Apr 24, 2005
1 parent b9d00e6 commit d4cb8c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b5a48daddc88fa0467a6ba371fcff0710781bf11
refs/heads/master: 3106dbcd914d8dac4b89f52d8d51ec93526cbb95
83 changes: 42 additions & 41 deletions trunk/include/asm-generic/unaligned.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,47 @@ static inline void __ustw(__u16 val, __u16 *addr)
ptr->x = val;
}

static inline unsigned long __get_unaligned(const void *ptr, size_t size)
{
unsigned long val;
switch (size) {
case 1:
val = *(const __u8 *)ptr;
break;
case 2:
val = __uldw((const __u16 *)ptr);
break;
case 4:
val = __uldl((const __u32 *)ptr);
break;
case 8:
val = __uldq((const __u64 *)ptr);
break;
default:
bad_unaligned_access_length();
};
return val;
}

static inline void __put_unaligned(unsigned long val, void *ptr, size_t size)
{
switch (size) {
case 1:
*(__u8 *)ptr = val;
break;
case 2:
__ustw(val, (__u16 *)ptr);
break;
case 4:
__ustl(val, (__u32 *)ptr);
break;
case 8:
__ustq(val, (__u64 *)ptr);
break;
default:
bad_unaligned_access_length();
};
}
#define __get_unaligned(ptr, size) ({ \
const void *__gu_p = ptr; \
unsigned long val; \
switch (size) { \
case 1: \
val = *(const __u8 *)__gu_p; \
break; \
case 2: \
val = __uldw(__gu_p); \
break; \
case 4: \
val = __uldl(__gu_p); \
break; \
case 8: \
val = __uldq(__gu_p); \
break; \
default: \
bad_unaligned_access_length(); \
}; \
val; \
})

#define __put_unaligned(val, ptr, size) \
do { \
void *__gu_p = ptr; \
switch (size) { \
case 1: \
*(__u8 *)__gu_p = val; \
break; \
case 2: \
__ustw(val, __gu_p); \
break; \
case 4: \
__ustl(val, __gu_p); \
break; \
case 8: \
__ustq(val, __gu_p); \
break; \
default: \
bad_unaligned_access_length(); \
}; \
} while(0)

#endif /* _ASM_GENERIC_UNALIGNED_H */

0 comments on commit d4cb8c2

Please sign in to comment.