source: release/1.7/source/lisp-kernel/arm-asmutils.s @ 15267

Last change on this file since 15267 was 14549, checked in by gb, 8 years ago

Android wants to pretend that Linux only supports 32 traditional
signals (and doesn't support RT signals.) Use traditional (non-RT)
signal numbers for CCL (so no #$SIGUSR2 for user code.)

That's bad enough, but they define #_pthread_sigmask in terms
of #_rt_sigprocmask, and get it wrong: #_pthread_sigmask always
fails. It's possible to waste lots of time tracking this down,
but it's been known for a long time:

<http://markmail.org/message/s657k4ogn7qtqghp#query:+page:1+mid:s657k4ogn7qtqghp+state:results>

Sadly, poor little Google can't afford to hire people who know
what they're doing.

File size: 4.7 KB
Line 
1/*   Copyright (C) 2009 Clozure Associates */
2/*   Copyright (C) 1994-2001 Digitool, Inc */
3/*   This file is part of Clozure CL. */
4
5/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public */
6/*   License , known as the LLGPL and distributed with Clozure CL as the */
7/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL, */
8/*   which is distributed with Clozure CL as the file "LGPL".  Where these */
9/*   conflict, the preamble takes precedence. */
10
11/*   Clozure CL is referenced in the preamble as the "LIBRARY." */
12
13/*   The LLGPL is also available online at */
14/*   http://opensource.franz.com/preamble.html */
15
16
17        .syntax unified
18        .arm   
19
20        include(lisp.s)
21
22        _beginfile
23
24/* Force data from r0, size r1 into the icache */       
25_exportfn(C(flush_cache_lines))
26        __ifdef(`LINUX')
27        __(add r1,r1,r0)
28        __(mov r2,#0)           /* options.  Pass as 0 until we know better */
29        __(mov r12,r7)          /* preserve r7 ;  r12 saved by syscall */
30        __(mov r7,#0x0f0000)     /* __ARM_NR_cacheflush */
31        __(add r7,r7,#2)
32        __(svc #0)
33        __(mov r7,r12)
34        __endif
35        __ifdef(`DARWIN')
36        __(mov r3,#0)
37        __(mov r12,#0x80000000)
38        __(svc #0)
39        __endif               
40        __(bx lr)
41
42_exportfn(C(touch_page))
43        __(str r0,[r0,#0])
44        __(mov r1,#0)
45        __(str r1,[r0,#0])
46        __(mov r0,#1)
47        .globl C(touch_page_end)
48C(touch_page_end):     
49        __(bx lr)
50_endfn       
51                               
52_exportfn(C(current_stack_pointer))
53        __(mov r0,sp)
54        __(bx lr)
55_endfn
56       
57_exportfn(C(count_leading_zeros))
58        __(clz r0,r0)
59        __(bx lr)
60_endfn
61
62_exportfn(C(noop))
63        __(bx lr)
64_endfn
65
66
67
68
69
70/* Atomically store new value (r2) in *r0, if old value == expected (r1). */
71/* Return actual old value. */
72
73_exportfn(C(store_conditional))
740:      __(ldrex r3,[r0])
75        __(cmp r3,r1)
76        __(bne 1f)
77        __(strex ip,r2,[r0])
78        __(cmp ip,#0)
79        __(bne 0b)
80        __(b 2f)
811:      __(clrex)
822:      __(mov r0,r3)
83        __(bx lr)               
84_endfn
85
86/* Atomically store new_value(r1) in *r0 ;  return previous contents */
87/* of *r0. */
88
89_exportfn(C(atomic_swap))
90        __(mov r2,r0)
91        __(swp r0,r1,[r2])
92        __(bx lr)
93_endfn
94
95/* Logior the value in *r0 with the value in r1 (presumably a bitmask with exactly 1 */
96/* bit set.)  Return non-zero if any of the bits in that bitmask were already set. */
97       
98_exportfn(C(atomic_ior))
99        __(stmdb sp!,{r4,lr})
1000:      __(ldrex r2,[r0])
101        __(orr r3,r2,r1)
102        __(strex r4,r3,[r0])
103        __(cmp r4,#0)
104        __(bne 0b)
105        __(mov r0,r2)
106        __(ldmia sp!,{r4,pc})
107_endfn
108
109
110/* Logand the value in *r0 with the value in r1 (presumably a bitmask with exactly 1 */
111/* bit set.)  Return the value now in *r0 (for some value of "now" */
112
113_exportfn(C(atomic_and))
1140:      __(ldrex r2,[r0])
115        __(and r2,r2,r1)
116        __(strex r3,r2,[r0])
117        __(cmp r3,#0)
118        __(bne 0b)
119        __(mov r0,r2)
120        __(bx lr)
121_endfn
122               
123       
124        __ifdef(`DARWIN')
125_exportfn(C(enable_fp_exceptions))
126        __(.long 0)
127        __(bx lr)
128_endfn
129       
130_exportfn(C(disable_fp_exceptions))
131        __(.long 0)
132        __(bx lr)
133_endfn
134
135_exportfn(C(pseudo_sigreturn))
136        __(uuo_pseudo_sigreturn())
137        __(b C(pseudo_sigreturn))
138_endfn
139        __endif
140       
141_exportfn(C(save_fp_context))
142        __(uuo_debug_trap(al))
143_endfn         
144_exportfn(C(restore_fp_context))
145        __(uuo_debug_trap(al))
146_endfn         
147_exportfn(C(put_vector_registers))
148        __(uuo_debug_trap(al))
149_endfn         
150_exportfn(C(get_vector_registers))
151        __(uuo_debug_trap(al))
152_endfn
153       
154        __ifdef(`ANDROID')
155_exportfn(rt_sigprocmask)
156        __(stmdb sp!,{r7,lr})
157        __(mov r7,#175)
158        __(svc #0)
159        __(ldmia sp!,{r7,pc})
160_endfn
161        __endif
162       
163
164        __ifdef(`DARWIN')
165/* divide the 64-bit unsigned integer in r0/r1 by the 64-bit unsigned
166   integer in r2/r3; return the 64-bit quotient in r0/r1 and the 64-bit
167   remainder in r2/r3.  Implement this in terms of the libgcc function: 
168
169   unsigned long long __udivti3 (unsigned long long a, 
170                                 unsigned long long b, 
171                                 unsigned long long *c)
172*/       
173_exportfn(C(__aeabi_uldivmod))
174        __(stmdb sp!,{r7,lr})
175        __(mov r7,sp)
176        __(sub sp,sp,#8)
177        __(mov ip,sp)
178        __(push1(ip,sp))
179        __(push1(ip,sp))
180        __(bl C(__udivmoddi4))
181        __(add sp,sp,#8)
182        __(ldmia sp!,{r2,r3})
183        __(ldmia sp!,{r7,pc})
184_endfn               
185        __endif
186
187_exportfn(call_handler_on_main_stack)
188        __(ldr ip,[sp])
189        __(mov lr,r3)
190        __(mov sp,r1)
191        __(bx ip)
192_endfn               
193
194                               
195        _endfile
196
Note: See TracBrowser for help on using the repository browser.