OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [unaligned.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef __ARM_UNALIGNED_H
2
#define __ARM_UNALIGNED_H
3
 
4
#define get_unaligned(ptr) \
5
        ((__typeof__(*(ptr)))__get_unaligned((ptr), sizeof(*(ptr))))
6
 
7
#define put_unaligned(val, ptr) \
8
        __put_unaligned((unsigned long)(val), (ptr), sizeof(*(ptr)))
9
 
10
extern void bad_unaligned_access_length (void);
11
 
12
extern inline unsigned long __get_unaligned(const void *ptr, size_t size)
13
{
14
    unsigned long val;
15
    switch (size) {
16
        case 1:
17
            val = *(const unsigned char *)ptr;
18
            break;
19
 
20
        case 2:
21
            val = ((const unsigned char *)ptr)[0] | (((const unsigned char *)ptr)[1] << 8);
22
            break;
23
 
24
        case 4:
25
            val = ((const unsigned char *)ptr)[0]        | (((const unsigned char *)ptr)[1] << 8) |
26
                 (((const unsigned char *)ptr)[2]) << 16 | (((const unsigned char *)ptr)[3] << 24);
27
            break;
28
 
29
        default:
30
            bad_unaligned_access_length ();
31
    }
32
    return val;
33
}
34
 
35
extern inline void __put_unaligned(unsigned long val, void *ptr, size_t size)
36
{
37
    switch (size) {
38
        case 1:
39
            *(unsigned char *)ptr = val;
40
            break;
41
 
42
        case 2:
43
            ((unsigned char *)ptr)[0] = val;
44
            ((unsigned char *)ptr)[1] = val >> 8;
45
            break;
46
 
47
        case 4:
48
            ((unsigned char *)ptr)[0] = val;
49
            ((unsigned char *)ptr)[1] = val >> 8;
50
            ((unsigned char *)ptr)[2] = val >> 16;
51
            ((unsigned char *)ptr)[3] = val >> 24;
52
            break;
53
 
54
        default:
55
            bad_unaligned_access_length ();
56
    }
57
}
58
 
59
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.