summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/bfin/bits/byteswap.h
blob: a72700254c3896ebad9710ff83d226485d1d3a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* File: libc/sysdeps/linux/bfin/bits/byteswap.h
 *
 * Copyright 2004-2006 Analog Devices Inc.
 *
 * Enter bugs at http://blackfin.uclinux.org/
 *
 * Licensed under the GPL-2 or later.
 */

#ifndef _ASM_BITS_BYTESWAP_H
#define _ASM_BITS_BYTESWAP_H 1

#define __bswap_non_constant_16(x) \
     (__extension__							      \
      ({ register unsigned short int __v;				      \
	 __asm__ ("%0 = PACK (%1.L, %1.L);"				      \
		  "%0 >>= 8;"						      \
		  : "=d" (__v)						      \
		  : "d" (x));						      \
	 __v; }))

#define __bswap_non_constant_32(x) \
     (__extension__							      \
      ({ register unsigned int __v;					      \
	 __asm__ ("%1 = %0 >> 8 (V);"					      \
		  "%0 = %0 << 8 (V);"					      \
		  "%0 = %0 | %1;"					      \
		  "%1 = PACK(%0.L, %0.H);"				      \
		  : "+d"(x), "=&d"(__v));				      \
	 __v; }))

#endif

#include <bits/byteswap-common.h>