~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/ipxe/src/arch/arm32/include/bits/byteswap.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _BITS_BYTESWAP_H
 
2
#define _BITS_BYTESWAP_H
 
3
 
 
4
/** @file
 
5
 *
 
6
 * Byte-order swapping functions
 
7
 *
 
8
 */
 
9
 
 
10
#include <stdint.h>
 
11
 
 
12
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 
13
 
 
14
static inline __attribute__ (( always_inline, const )) uint16_t
 
15
__bswap_variable_16 ( uint16_t x ) {
 
16
        __asm__ ( "rev16 %0, %1" : "=l" ( x ) : "l" ( x ) );
 
17
        return x;
 
18
}
 
19
 
 
20
static inline __attribute__ (( always_inline )) void
 
21
__bswap_16s ( uint16_t *x ) {
 
22
        *x = __bswap_variable_16 ( *x );
 
23
}
 
24
 
 
25
static inline __attribute__ (( always_inline, const )) uint32_t
 
26
__bswap_variable_32 ( uint32_t x ) {
 
27
        __asm__ ( "rev %0, %1" : "=l" ( x ) : "l" ( x ) );
 
28
        return x;
 
29
}
 
30
 
 
31
static inline __attribute__ (( always_inline )) void
 
32
__bswap_32s ( uint32_t *x ) {
 
33
        *x = __bswap_variable_32 ( *x );
 
34
}
 
35
 
 
36
static inline __attribute__ (( always_inline, const )) uint64_t
 
37
__bswap_variable_64 ( uint64_t x ) {
 
38
        uint32_t in_high = ( x >> 32 );
 
39
        uint32_t in_low = ( x & 0xffffffffUL );
 
40
        uint32_t out_high = __bswap_variable_32 ( in_low );
 
41
        uint32_t out_low = __bswap_variable_32 ( in_high );
 
42
 
 
43
        return ( ( ( ( uint64_t ) out_high ) << 32 ) |
 
44
                 ( ( uint64_t ) out_low ) );
 
45
}
 
46
 
 
47
static inline __attribute__ (( always_inline )) void
 
48
__bswap_64s ( uint64_t *x ) {
 
49
        *x = __bswap_variable_64 ( *x );
 
50
}
 
51
 
 
52
#endif