Subversion Repositories HelenOS

Rev

Rev 1702 | Rev 1787 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1702 Rev 1780
Line 33... Line 33...
33
 */
33
 */
34
 
34
 
35
#ifndef __BYTEORDER_H__
35
#ifndef __BYTEORDER_H__
36
#define __BYTEORDER_H__
36
#define __BYTEORDER_H__
37
 
37
 
38
static inline __u64 __u64_byteorder_swap(__u64 n)
38
static inline uint64_t uint64_t_byteorder_swap(uint64_t n)
39
{
39
{
40
    return ((n & 0xff) << 56) |
40
    return ((n & 0xff) << 56) |
41
        ((n & 0xff00) << 40) |
41
        ((n & 0xff00) << 40) |
42
        ((n & 0xff0000) << 24) |
42
        ((n & 0xff0000) << 24) |
43
        ((n & 0xff000000LL) << 8) |
43
        ((n & 0xff000000LL) << 8) |
Line 45... Line 45...
45
        ((n & 0xff0000000000LL) >> 24) |
45
        ((n & 0xff0000000000LL) >> 24) |
46
        ((n & 0xff000000000000LL) >> 40) |
46
        ((n & 0xff000000000000LL) >> 40) |
47
        ((n & 0xff00000000000000LL) >> 56);
47
        ((n & 0xff00000000000000LL) >> 56);
48
}
48
}
49
 
49
 
50
static inline __u32 __u32_byteorder_swap(__u32 n)
50
static inline uint32_t uint32_t_byteorder_swap(uint32_t n)
51
{
51
{
52
    return ((n & 0xff) << 24) |
52
    return ((n & 0xff) << 24) |
53
        ((n & 0xff00) << 8) |
53
        ((n & 0xff00) << 8) |
54
        ((n & 0xff0000) >> 8) |
54
        ((n & 0xff0000) >> 8) |
55
        ((n & 0xff000000) >> 24);
55
        ((n & 0xff000000) >> 24);