~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/asm-i386/byteorder.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _I386_BYTEORDER_H
2
 
#define _I386_BYTEORDER_H
3
 
 
4
 
#include <asm/types.h>
5
 
 
6
 
#ifdef __GNUC__
7
 
 
8
 
/* For avoiding bswap on i386 */
9
 
#ifdef __KERNEL__
10
 
#include <linux/config.h>
11
 
#endif
12
 
 
13
 
static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
14
 
{
15
 
#ifdef CONFIG_X86_BSWAP
16
 
        __asm__("bswap %0" : "=r" (x) : "0" (x));
17
 
#else
18
 
        __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
19
 
                "rorl $16,%0\n\t"       /* swap words           */
20
 
                "xchgb %b0,%h0"         /* swap higher bytes    */
21
 
                :"=q" (x)
22
 
                : "0" (x));
23
 
#endif
24
 
        return x;
25
 
}
26
 
 
27
 
static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
28
 
{
29
 
        __asm__("xchgb %b0,%h0"         /* swap bytes           */ \
30
 
                : "=q" (x) \
31
 
                :  "0" (x)); \
32
 
                return x;
33
 
}
34
 
 
35
 
#define __arch__swab32(x) ___arch__swab32(x)
36
 
#define __arch__swab16(x) ___arch__swab16(x)
37
 
 
38
 
#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
39
 
#  define __BYTEORDER_HAS_U64__
40
 
#  define __SWAB_64_THRU_32__
41
 
#endif
42
 
 
43
 
#endif /* __GNUC__ */
44
 
 
45
 
#include <linux/byteorder/little_endian.h>
46
 
 
47
 
#endif /* _I386_BYTEORDER_H */