MSI-X: Minor changes
[akaros.git] / kern / arch / riscv / endian.h
1 /* Copyright (c) 2010 The Regents of the University of California
2  * Barret Rhoden <brho@cs.berkeley.edu>
3  * See LICENSE for details.
4  *
5  * Endian #def and byte_swapping functions */
6
7 #ifndef ROS_KERN_ARCH_ENDIAN_H
8 #define ROS_KERN_ARCH_ENDIAN_H
9
10 #include <ros/common.h>
11 #include <arch/types.h>
12
13 static inline uint16_t byte_swap16(uint16_t x)
14 {
15         return (uint16_t)(x << 8 | x >> 8);
16 }
17
18 static inline uint32_t byte_swap32(uint32_t x)
19 {
20         return (uint32_t)(((uint32_t)byte_swap16(x & 0xffff) << 16) |
21                           (byte_swap16(x >> 16)));
22 }
23
24 static inline uint64_t byte_swap64(uint64_t x)
25 {
26         return (uint64_t)(((uint64_t)byte_swap32(x & 0xffffffff) << 32) |
27                           (byte_swap32(x >> 32)));
28 }
29
30 #endif /* ROS_KERN_ARCH_ENDIAN_H */