Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / sh3 / include / byte_swap.h
blob3d08af4cb243817ab5dbdf3bfe067b3962e9f5a7
1 /* $NetBSD: byte_swap.h,v 1.3 2006/02/16 20:17:15 perry Exp $ */
3 /* Written by Manuel Bouyer. Public domain */
5 #ifndef _SH3_BYTE_SWAP_H_
6 #define _SH3_BYTE_SWAP_H_
8 #include <sys/cdefs.h>
10 #ifdef __GNUC__
11 #include <sys/types.h>
12 __BEGIN_DECLS
14 #define __BYTE_SWAP_U16_VARIABLE __byte_swap_u16_variable
15 static __inline uint16_t
16 __byte_swap_u16_variable(uint16_t x)
18 uint16_t rval;
20 __asm volatile ("swap.b %1,%0" : "=r"(rval) : "r"(x));
22 return (rval);
25 #define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
26 static __inline uint32_t
27 __byte_swap_u32_variable(uint32_t x)
29 uint32_t rval;
31 __asm volatile ("swap.b %1,%0; swap.w %0,%0; swap.b %0,%0"
32 : "=r"(rval) : "r"(x));
34 return (rval);
37 __END_DECLS
38 #endif /* __GNUC_ */
40 #endif /* !_SH3_BYPE_SWAP_H_ */