mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-13 07:47:39 +02:00
Rewriting ash to use inline C instead
This commit is contained in:
parent
eed4ca7e61
commit
c13f37e3b5
1 changed files with 16 additions and 2 deletions
18
srfi/60.scm
18
srfi/60.scm
|
@ -135,8 +135,22 @@
|
||||||
(ash from start)
|
(ash from start)
|
||||||
to))
|
to))
|
||||||
|
|
||||||
(define (ash x y)
|
(define-c ash
|
||||||
(exact (floor (* x (expt 2 y)))))
|
"(void* data, int argc, closure _, object k, object x, object y)"
|
||||||
|
"Cyc_check_int(data, x);
|
||||||
|
Cyc_check_int(data,y);
|
||||||
|
int bf = (int)unbox_number(x);
|
||||||
|
int shift = (int)unbox_number(y);
|
||||||
|
if (shift > 0) {
|
||||||
|
for (int i = 0; i < shift; i++) {
|
||||||
|
bf *= 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < abs(shift); i++) {
|
||||||
|
bf /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return_closcall1(data, k, obj_int2obj(bf))")
|
||||||
|
|
||||||
(define arithmetic-shift ash)
|
(define arithmetic-shift ash)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue