110093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI/*	$OpenBSD: endian.h,v 1.1.1.1 2006/10/06 21:02:55 miod Exp $	*/
210093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI/*	$NetBSD: endian.h,v 1.4 2000/03/17 00:09:25 mycroft Exp $	*/
310093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
410093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI/* Written by Manuel Bouyer. Public domain */
510093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
610093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#ifndef _SH_ENDIAN_H_
710093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define	_SH_ENDIAN_H_
810093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
910093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#ifdef  __GNUC__
1010093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
1110093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define	__swap64md	__swap64gen
1210093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
1310093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define __swap16md(x) ({						\
1410093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	uint16_t rval;							\
1510093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI									\
1610093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	__asm volatile ("swap.b %1,%0" : "=r"(rval) : "r"(x));		\
1710093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI									\
1810093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	rval;								\
1910093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI})
2010093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
2110093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define __swap32md(x) ({						\
2210093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	uint32_t rval;							\
2310093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI									\
2410093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	__asm volatile ("swap.b %1,%0; swap.w %0,%0; swap.b %0,%0"	\
2510093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI			  : "=r"(rval) : "r"(x));			\
2610093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI									\
2710093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI	rval;								\
2810093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI})
2910093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
3010093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define MD_SWAP
3110093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
3210093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#endif /* __GNUC_ */
3310093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
3410093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define	_BYTE_ORDER _LITTLE_ENDIAN
3510093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#include <sys/endian.h>
3610093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
3710093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#define	__STRICT_ALIGNMENT
3810093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI
3910093276e98d26428875480c502a278dffe550c7Shin-ichiro KAWASAKI#endif /* !_SH_ENDIAN_H_ */
40