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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-m68knommu/] [unaligned.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef __M68K_UNALIGNED_H
2
#define __M68K_UNALIGNED_H
3
 
4
/*
5
 * The m68k can do unaligned accesses itself.
6
 *
7
 * The strange macros are there to make sure these can't
8
 * be misused in a way that makes them not work on other
9
 * architectures where unaligned accesses aren't as simple.
10
 */
11
 
12
#ifdef BLASTED_MOTOROLA
13
 
14
#define get_unaligned(ptr) (*(ptr))
15
 
16
#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
17
 
18
#else
19
 
20
/* However, the simpler architecture m68k devices, including '328 and '332,
21
   cannot perform unaligned access. - kja */
22
 
23
#define get_unaligned(ptr) ({                   \
24
        typeof((*(ptr))) x;                     \
25
        memcpy(&x, (void*)ptr, sizeof(*(ptr))); \
26
        x;                                      \
27
})
28
 
29
#define put_unaligned(val, ptr) ({              \
30
        typeof((*(ptr))) x = val;               \
31
        memcpy((void*)ptr, &x, sizeof(*(ptr))); \
32
})
33
 
34
#endif
35
 
36
#endif

powered by: WebSVN 2.1.0

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