vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / os / arch / arm / byteorder.S
blob5189c683f955f6fcaa36b3c37dfb74ed9f91ae7c
1 /*
2  * Copyright 2009, Johannes Wischert. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
6 #include <asm_defs.h>
8 .text
10 /* uint16 __swap_int16(uint16 value)
11  */
12 FUNCTION(__swap_int16):
13 #if __ARM_ARCH__ >= 6
14                 rev16 r0,r0;
15 #else
16 #warning IMPLEMENT_ME
17                 and r1,r0,#0x000000ff
18                 and r2,r0,#0x0000ff00
19                 mov r1,r1,LSL #8
20                 mov r2,r2,ROR #8
21                 orr r0,r1,r2
22 #endif
23                 mov pc,lr
24 FUNCTION_END(__swap_int16)
26 /* uint32 __swap_int32(uint32 value)
27  */
28 FUNCTION(__swap_int32):
29 #if __ARM_ARCH__ >= 6
30                 rev r0,r0;
31 #else
32 #warning IMPLEMENT_ME
33                 mov r3,#0xff000000
34                 orr r3,#0x0000ff00
35                 and r1,r0,r3
36                 mov r1,r1,ROR #24
37                 mov r3,r3,ROR #8
38                 and r2,r0,r3
39                 mov r2,r2,ROR #8
40                 orr r0,r1,r2
41 #endif
42                 mov pc,lr
43 FUNCTION_END(__swap_int32)
45 /* uint64 __swap_int64(uint64 value)
46  */
47 FUNCTION(__swap_int64):
48 #if __ARM_ARCH__ >= 6
49                 rev r0,r0;
50                 rev r1,r1;
51                 mov r12,r0;
52                 mov r0,r1;
53                 mov r1,r12;
54 #else
55 #warning IMPLEMENT_ME
56 #endif
57                 mov pc,lr
58 FUNCTION_END(__swap_int64)
60 /* TODO: The following functions can surely be optimized. A simple optimization
61  * would be to define macros with the contents of the __swap_int{32,64}
62  * functions and use those instead of calling the functions.
63  */
65 /* float __swap_float(float value)
66  */
67 FUNCTION(__swap_float):
68                 b               __swap_int32
69                 //rts
70 FUNCTION_END(__swap_float)
73 /* double __swap_double(double value)
74  */
75 FUNCTION(__swap_double):
76                 b               __swap_int32
77                 //rts
78 #warning M68K: XXX:check sizeof(double)
79 FUNCTION_END(__swap_double)