1 #ifndef FAST_H
2 #define FAST_H
3 
4 #include <stdio.h>
5 #include <setjmp.h>
6 #include <stdbool.h>
7 #include <stdint.h>
8 #include "ffi.h"
9 const int       INT_PSQRT = 1073773446;	// INT_FLAG+sqrt(999999999)
10 const int       INT_MSQRT = -31622;	// - sqrt(999999999)
11 #define FASTSTRLONG_SIZE 17
12 static tfunc    deftfunc;
13 static fn0      f0[NUM_FN0S];
14 static fn1      f1[NUM_FN1S];
15 static fn2      f2[NUM_FN2S];
16 static fn3      f3[NUM_FN3S];
17 static fn4      f4[NUM_FN4S];
18 static fn5      f5[NUM_FN5S];
19 static fn6      f6[NUM_FN6S];
20 static fn7      f7[NUM_FN7S];
21 static fn8      f8[NUM_FN8S];
22 void
init0(int n,fn0 x)23 init0(int n, fn0 x)
24 {
25     f0[n] = x;
26 }
27 void
init1(int n,fn1 x)28 init1(int n, fn1 x)
29 {
30     f1[n] = x;
31 }
32 void
init2(int n,fn2 x)33 init2(int n, fn2 x)
34 {
35     f2[n] = x;
36 }
37 void
init3(int n,fn3 x)38 init3(int n, fn3 x)
39 {
40     f3[n] = x;
41 }
42 void
init4(int n,fn4 x)43 init4(int n, fn4 x)
44 {
45     f4[n] = x;
46 }
47 void
init5(int n,fn5 x)48 init5(int n, fn5 x)
49 {
50     f5[n] = x;
51 }
52 void
init6(int n,fn6 x)53 init6(int n, fn6 x)
54 {
55     f6[n] = x;
56 }
57 void
init7(int n,fn7 x)58 init7(int n, fn7 x)
59 {
60     f7[n] = x;
61 }
62 void
init8(int n,fn8 x)63 init8(int n, fn8 x)
64 {
65     f8[n] = x;
66 }
67 void
init_deftfunc(tfunc x)68 init_deftfunc(tfunc x)
69 {
70     deftfunc = (tfunc) x;
71 }
72 static int      catch_arg;	// recieve argument of catch
73 
74 static int      block_arg;	// recieve argument of block
75 static inline int
Fcheckgbc(void)76 Fcheckgbc(void)
77 {
78     return f0[CHECKGBC_IDX] ();
79 }
80 
81 static inline int
Fgbc(void)82 Fgbc(void)
83 {
84     return f0[GBC_IDX] ();
85 }
86 
87 static inline int
Ffreshcell(void)88 Ffreshcell(void)
89 {
90     return f0[FRESHCELL_IDX] ();
91 }
92 
93 static inline int
Ffreecell(void)94 Ffreecell(void)
95 {
96     return f0[FREECELL_IDX] ();
97 }
98 
99 static inline int
Fgbcsw(void)100 Fgbcsw(void)
101 {
102     return f0[GBCSW_IDX] ();
103 }
104 
105 static inline int
Fgetwp(void)106 Fgetwp(void)
107 {
108     return f0[GETWP_IDX] ();
109 }
110 
111 static inline int
Fargpop(void)112 Fargpop(void)
113 {
114     return f0[ARGPOP_IDX] ();
115 }
116 
117 static inline int
Fshelterpop(void)118 Fshelterpop(void)
119 {
120     return f0[SHELTERPOP_IDX] ();
121 }
122 
123 static inline int
Fpop(void)124 Fpop(void)
125 {
126     return f0[POP_IDX] ();
127 }
128 
129 static inline int
Fgetdynpt(void)130 Fgetdynpt(void)
131 {
132     return f0[GETDYNPT_IDX] ();
133 }
134 
135 static inline int
Fcar(int x)136 Fcar(int x)
137 {
138     return f1[CAR_IDX] (x);
139 }
140 
141 static inline int
Fcdr(int x)142 Fcdr(int x)
143 {
144     return f1[CDR_IDX] (x);
145 }
146 
147 static inline int
Fcadr(int x)148 Fcadr(int x)
149 {
150     return f1[CADR_IDX] (x);
151 }
152 
153 static inline int
Fcaddr(int x)154 Fcaddr(int x)
155 {
156     return f1[CADDR_IDX] (x);
157 }
158 
159 static inline int
Fcaar(int x)160 Fcaar(int x)
161 {
162     return f1[CAAR_IDX] (x);
163 }
164 
165 static inline int
Fcadar(int x)166 Fcadar(int x)
167 {
168     return f1[CADAR_IDX] (x);
169 }
170 
171 static inline int
Flist1(int x)172 Flist1(int x)
173 {
174     return f1[LIST1_IDX] (x);
175 }
176 
177 static inline int
Feval(int x)178 Feval(int x)
179 {
180     return f1[EVAL_IDX] (x);
181 }
182 
183 static inline int
Faux(int x)184 Faux(int x)
185 {
186     return f1[AUX_IDX] (x);
187 }
188 
189 static inline int
Flength(int x)190 Flength(int x)
191 {
192     return f1[LENGTH_IDX] (x);
193 }
194 
195 static inline int
Fsubrp(int x)196 Fsubrp(int x)
197 {
198     return f1[SUBRP_IDX] (x);
199 }
200 
201 static inline int
Ffsubrp(int x)202 Ffsubrp(int x)
203 {
204     return f1[FSUBRP_IDX] (x);
205 }
206 
207 static inline int
Ffunctionp(int x)208 Ffunctionp(int x)
209 {
210     return f1[FUNCTIONP_IDX] (x);
211 }
212 
213 static inline int
Fmacrop(int x)214 Fmacrop(int x)
215 {
216     return f1[MACROP_IDX] (x);
217 }
218 
219 static inline int
Fintegerp(int x)220 Fintegerp(int x)
221 {
222     return f1[INTEGERP_IDX] (x);
223 }
224 
225 static inline int
Flongnump(int x)226 Flongnump(int x)
227 {
228     return f1[LONGNUMP_IDX] (x);
229 }
230 
231 static inline int
Fbignump(int x)232 Fbignump(int x)
233 {
234     return f1[BIGNUMP_IDX] (x);
235 }
236 
237 static inline int
Fgetint(int x)238 Fgetint(int x)
239 {
240     return f1[GETINT_IDX] (x);
241 }
242 
243 static inline int
Fmakeint(int x)244 Fmakeint(int x)
245 {
246     return f1[MAKEINT_IDX] (x);
247 }
248 
249 static inline int
Fmakeintlong(int x)250 Fmakeintlong(int x)
251 {
252     return f1[MAKEINTLONG_IDX] (x);
253 }
254 
255 static inline int
Fvector(int x)256 Fvector(int x)
257 {
258     return f1[VECTOR_IDX] (x);
259 }
260 
261 static inline int
fast_car(int x)262 fast_car(int x)
263 {
264     return f1[FASTCAR_IDX] (x);
265 }
266 
267 static inline int
fast_cdr(int x)268 fast_cdr(int x)
269 {
270     return f1[FASTCDR_IDX] (x);
271 }
272 
273 static inline int
Ffindenv(int x)274 Ffindenv(int x)
275 {
276     return f1[FINDENV_IDX] (x);
277 }
278 
279 static inline int
Ffinddyn(int x)280 Ffinddyn(int x)
281 {
282     return f1[FINDDYN_IDX] (x);
283 }
284 
285 static inline int
Fargpush(int x)286 Fargpush(int x)
287 {
288     return f1[ARGPUSH_IDX] (x);
289 }
290 
291 static inline int
Fshelterpush(int x)292 Fshelterpush(int x)
293 {
294     return f1[SHELTERPUSH_IDX] (x);
295 }
296 
297 static inline int
Fpush(int x)298 Fpush(int x)
299 {
300     return f1[PUSH_IDX] (x);
301 }
302 
303 static inline int
Fgetopt(int x)304 Fgetopt(int x)
305 {
306     return f1[GETOPT_IDX] (x);
307 }
308 
309 static inline int
Fgetprop(int x)310 Fgetprop(int x)
311 {
312     return f1[GETPROP_IDX] (x);
313 }
314 
315 static inline int
Fsetdynpt(int x)316 Fsetdynpt(int x)
317 {
318     return f1[SETDYNPT_IDX] (x);
319 }
320 
321 static inline int
Fsetcatchsymbols(int x)322 Fsetcatchsymbols(int x)
323 {
324     return f1[SETCATCHSYMBOLS_IDX] (x);
325 }
326 
327 
328 static inline int
Fcons(int x,int y)329 Fcons(int x, int y)
330 {
331     return f2[CONS_IDX] (x, y);
332 }
333 
334 static inline int
Fnth(int x,int y)335 Fnth(int x, int y)
336 {
337     return f2[NTH_IDX] (x, y);
338 }
339 
340 static inline int
Fset_car(int x,int y)341 Fset_car(int x, int y)
342 {
343     return f2[SETCAR_IDX] (x, y);
344 }
345 
346 static inline int
Fset_cdr(int x,int y)347 Fset_cdr(int x, int y)
348 {
349     return f2[SETCDR_IDX] (x, y);
350 }
351 
352 static inline int
Fset_aux(int x,int y)353 Fset_aux(int x, int y)
354 {
355     return f2[SETAUX_IDX] (x, y);
356 }
357 
358 static inline int
Fset_opt(int x,int y)359 Fset_opt(int x, int y)
360 {
361     return f2[SETOPT_IDX] (x, y);
362 }
363 
364 static inline int
Fcallsubr(int x,int y)365 Fcallsubr(int x, int y)
366 {
367     return f2[CALLSUBR_IDX] (x, y);
368 }
369 
370 static inline int
Flist2(int x,int y)371 Flist2(int x, int y)
372 {
373     return f2[LIST2_IDX] (x, y);
374 }
375 
376 static inline int
Fnthcdr(int x,int y)377 Fnthcdr(int x, int y)
378 {
379     return f2[NTHCDR_IDX] (x, y);
380 }
381 
382 static inline int
Fapply(int x,int y)383 Fapply(int x, int y)
384 {
385     return f2[APPLY_IDX] (x, y);
386 }
387 
388 static inline int
Fplus(int x,int y)389 Fplus(int x, int y)
390 {
391     return f2[PLUS_IDX] (x, y);
392 }
393 
394 static inline int
Fminus(int x,int y)395 Fminus(int x, int y)
396 {
397     return f2[MINUS_IDX] (x, y);
398 }
399 
400 static inline int
Fmult(int x,int y)401 Fmult(int x, int y)
402 {
403     return f2[MULT_IDX] (x, y);
404 }
405 
406 static inline int
Fquotient(int x,int y)407 Fquotient(int x, int y)
408 {
409     return f2[QUOTIENT_IDX] (x, y);
410 }
411 
412 static inline int
Fremainder(int x,int y)413 Fremainder(int x, int y)
414 {
415     return f2[REMAINDER_IDX] (x, y);
416 }
417 
418 static inline int
Fdivide(int x,int y)419 Fdivide(int x, int y)
420 {
421     return f2[DIVIDE_IDX] (x, y);
422 }
423 
424 static inline int
Feqp(int x,int y)425 Feqp(int x, int y)
426 {
427     return f2[EQP_IDX] (x, y);
428 }
429 
430 static inline int
Feqlp(int x,int y)431 Feqlp(int x, int y)
432 {
433     return f2[EQLP_IDX] (x, y);
434 }
435 
436 static inline int
Fnumeqp(int x,int y)437 Fnumeqp(int x, int y)
438 {
439     return f2[NUMEQP_IDX] (x, y);
440 }
441 
442 static inline int
Fsmallerp(int x,int y)443 Fsmallerp(int x, int y)
444 {
445     return f2[SMALLERP_IDX] (x, y);
446 }
447 
448 static inline int
Feqsmallerp(int x,int y)449 Feqsmallerp(int x, int y)
450 {
451     return f2[EQSMALLERP_IDX] (x, y);
452 }
453 
454 static inline int
Fgreaterp(int x,int y)455 Fgreaterp(int x, int y)
456 {
457     return f2[GREATERP_IDX] (x, y);
458 }
459 
460 static inline int
Feqgreaterp(int x,int y)461 Feqgreaterp(int x, int y)
462 {
463     return f2[EQGREATERP_IDX] (x, y);
464 }
465 
466 static inline int
Fmember(int x,int y)467 Fmember(int x, int y)
468 {
469     return f2[MEMBER_IDX] (x, y);
470 }
471 
472 static inline int
Fconvert(int x,int y)473 Fconvert(int x, int y)
474 {
475     return f2[CONVERT_IDX] (x, y);
476 }
477 
478 static inline int
Farray(int x,int y)479 Farray(int x, int y)
480 {
481     return f2[ARRAY_IDX] (x, y);
482 }
483 
484 static inline int
Fsetdynenv(int x,int y)485 Fsetdynenv(int x, int y)
486 {
487     return f2[SETDYNENV_IDX] (x, y);
488 }
489 
490 static inline int
Fadddynenv(int x,int y)491 Fadddynenv(int x, int y)
492 {
493     return f2[ADDDYNENV_IDX] (x, y);
494 }
495 
496 static inline int
Fsetdynamic(int x,int y)497 Fsetdynamic(int x, int y)
498 {
499     return f2[SETDYNAMIC_IDX] (x, y);
500 }
501 
502 static inline int
Fsetprop(int x,int y)503 Fsetprop(int x, int y)
504 {
505     return f2[SETPROP_IDX] (x, y);
506 }
507 
508 static inline int
Fadaptp(int x,int y)509 Fadaptp(int x, int y)
510 {
511     return f2[ADAPTP_IDX] (x, y);
512 }
513 
514 static inline int
Fmatchp(int x,int y)515 Fmatchp(int x, int y)
516 {
517     return f2[MATCHP_IDX] (x, y);
518 }
519 
520 
521 static inline int
FILOSerror(int x,int y)522 FILOSerror(int x, int y)
523 {
524     return f2[ILOSERR_IDX] (x, y);
525 }
526 
527 
528 static inline int
Fmakestr(const char * x)529 Fmakestr(const char *x)
530 {
531     return f3[MAKESTR_IDX] ((char *) x);
532 }
533 static inline int
Fmakesym(const char * x)534 Fmakesym(const char *x)
535 {
536     return f3[MAKESYM_IDX] ((char *) x);
537 }
538 static inline int
Fmakechar(const char * x)539 Fmakechar(const char *x)
540 {
541     return f3[MAKECHAR_IDX] ((char *) x);
542 }
543 static inline int
Fmakestrflt(const char * x)544 Fmakestrflt(const char *x)
545 {
546     return f3[MAKESTRFLT_IDX] ((char *) x);
547 }
548 static inline int
Fmakebig(char * x)549 Fmakebig(char *x)
550 {
551     return f3[MAKEBIG_IDX] (x);
552 }
553 
554 static inline int
Fmakestrlong(const char * x)555 Fmakestrlong(const char *x)
556 {
557     return f3[MAKESTRLONG_IDX] ((char *) x);
558 }
559 static inline int
Fmakefaststrlong(const char * x)560 Fmakefaststrlong(const char *x)
561 {
562     return f3[MAKEFASTSTRLONG_IDX] ((char *) x);
563 }
564 static inline long long int
Fgetlong(int x)565 Fgetlong(int x)
566 {
567     return f4[GETLONG_IDX] (x);
568 }
569 
570 static inline int
Fstringset(int x,int y,int z)571 Fstringset(int x, int y, int z)
572 {
573     return f5[STRINGSET_IDX] (x, y, z);
574 }
575 
576 static inline int
Farrayset(int x,int y,int z)577 Farrayset(int x, int y, int z)
578 {
579     return f5[ARRAYSET_IDX] (x, y, z);
580 }
581 
582 static inline int
Fmember1(int x,int y,int z)583 Fmember1(int x, int y, int z)
584 {
585     return f5[MEMBER1_IDX] (x, y, z);
586 }
587 
588 static inline char *
Fgetname(int x)589 Fgetname(int x)
590 {
591     return f6[GETNAME_IDX] (x);
592 }
593 
594 static inline double
Fgetflt(int x)595 Fgetflt(int x)
596 {
597     return f7[GETFLT_IDX] (x);
598 }
599 
600 static inline int
Fmakedoubleflt(double x)601 Fmakedoubleflt(double x)
602 {
603     return f8[MAKEDOUBLEFLT_IDX] (x);
604 }
605 
606 static inline int
fast_immediate(int x)607 fast_immediate(int x)
608 {
609     if (x >= 0)
610 	return (x | INT_FLAG);
611     else
612 	return (x);
613 }
614 
615 static int
fast_numeqp()616 fast_numeqp()
617 {
618     int             x,
619                     y;
620     y = Fargpop();
621     x = Fargpop();
622     if (x >= INT_FLAG && y >= INT_FLAG)
623 	if (x == y)
624 	    return (T);
625 	else
626 	    return (0);
627     else if (x < 0 && y < 0)
628 	if (x == y)
629 	    return (T);
630 	else
631 	    return (0);
632     else if (x >= INT_FLAG && y < 0)
633 	return (0);
634     else if (x < 0 && y >= INT_FLAG)
635 	return (0);
636     else
637 	return (Fnumeqp(x, y));
638 }
639 
640 static int
fast_smallerp()641 fast_smallerp()
642 {
643     int             x,
644                     y;
645     y = Fargpop();
646     x = Fargpop();
647     if (x >= INT_FLAG && y >= INT_FLAG)
648 	if (x < y)
649 	    return (T);
650 	else
651 	    return (0);
652     else if (x < 0 && y < 0)
653 	if (x < y)
654 	    return (T);
655 	else
656 	    return (0);
657     else if (x >= INT_FLAG && y < 0)
658 	return (0);
659     else if (x < 0 && y >= INT_FLAG)
660 	return (T);
661     else
662 	return (Fsmallerp(x, y));
663 }
664 
665 static int
fast_eqsmallerp()666 fast_eqsmallerp()
667 {
668     int             x,
669                     y;
670     y = Fargpop();
671     x = Fargpop();
672     if (x >= INT_FLAG && y >= INT_FLAG)
673 	if (x <= y)
674 	    return (T);
675 	else
676 	    return (0);
677     else if (x < 0 && y < 0)
678 	if (x <= y)
679 	    return (T);
680 	else
681 	    return (0);
682     else if (x >= INT_FLAG && y < 0)
683 	return (0);
684     else if (x < 0 && y >= INT_FLAG)
685 	return (T);
686     else
687 	return (Feqsmallerp(x, y));
688 }
689 
690 static inline int
fast_greaterp()691 fast_greaterp()
692 {
693     int             x,
694                     y;
695     y = Fargpop();
696     x = Fargpop();
697     Fargpush(y);
698     Fargpush(x);
699     return (fast_smallerp());
700 }
701 
702 static inline int
fast_eqgreaterp()703 fast_eqgreaterp()
704 {
705     int             x,
706                     y;
707     y = Fargpop();
708     x = Fargpop();
709     Fargpush(y);
710     Fargpush(x);
711     return (fast_eqsmallerp());
712 }
713 
714 static int
fast_plus()715 fast_plus()
716 {
717     int             x,
718                     y,
719                     intx,
720                     inty,
721                     res;
722     y = Fargpop();
723     x = Fargpop();
724     if (x >= INT_FLAG && y >= INT_FLAG) {
725 	intx = (x & INT_MASK);
726 	inty = (y & INT_MASK);
727 	res = intx + inty;
728 	if (res >= SMALL_INT_MAX)
729 	    return (Fmakeintlong(res));
730 	else
731 	    return (res | INT_FLAG);
732     } else if (x >= INT_FLAG && y < 0) {
733 	intx = (x & INT_MASK);
734 	inty = y;
735 	res = intx + inty;
736 	if (res >= 0)
737 	    res = res | INT_FLAG;
738 	return (res);
739     } else if (x < 0 && y >= INT_FLAG) {
740 	intx = x;
741 	inty = (y & INT_MASK);
742 	res = intx + inty;
743 	if (res >= 0)
744 	    res = res | INT_FLAG;
745 	return (res);
746     } else
747 	return (Fplus(x, y));
748 }
749 
750 static int
fast_minus()751 fast_minus()
752 {
753     int             x,
754                     y,
755                     intx,
756                     inty,
757                     res;
758     y = Fargpop();
759     x = Fargpop();
760     if (x >= INT_FLAG && y >= INT_FLAG) {
761 	intx = (x & INT_MASK);
762 	inty = (y & INT_MASK);
763 	res = intx - inty;
764 	if (res >= 0)
765 	    res = res | INT_FLAG;
766 	return (res);
767     } else if (x >= INT_FLAG && y < 0) {
768 	intx = (x & INT_MASK);
769 	inty = y;
770 	res = intx - inty;
771 	if (res >= 0)
772 	    res = res | INT_FLAG;
773 	return (res);
774     } else if (x < 0 && y >= INT_FLAG) {
775 	intx = x;
776 	inty = (y & INT_MASK);
777 	res = intx - inty;
778 	if (res >= 0)
779 	    return (res | INT_FLAG);
780 	else if (res <= SMALL_INT_MAX)
781 	    return (Fmakeintlong(res));
782 	else
783 	    return (res);
784     } else
785 	return (Fminus(x, y));
786 }
787 
788 static int
fast_mult()789 fast_mult()
790 {
791     int             x,
792                     y,
793                     intx,
794                     inty,
795                     res;
796     y = Fargpop();
797     x = Fargpop();
798     if (x >= INT_FLAG && x <= INT_PSQRT && y >= INT_FLAG && y <= INT_PSQRT) {
799 	intx = (x & INT_MASK);
800 	inty = (y & INT_MASK);
801 	res = intx * inty;
802 	return (res | INT_FLAG);
803     } else if (x >= INT_FLAG && x <= INT_PSQRT && y < 0 && y >= INT_MSQRT) {
804 	intx = (x & INT_MASK);
805 	inty = y;
806 	res = intx * inty;
807 	return (res);
808     } else if (x < 0 && x >= INT_MSQRT && y >= INT_FLAG && y <= INT_PSQRT) {
809 	intx = x;
810 	inty = (y & INT_MASK);
811 	res = intx * inty;
812 	return (res);
813     } else
814 	return (Fmult(x, y));
815 }
816 
817 static int
fast_mod()818 fast_mod()
819 {
820     int             x,
821                     y,
822                     intx,
823                     inty,
824                     res;
825     long long int   longx,
826                     longy;
827     y = Fargpop();
828     x = Fargpop();
829     if (x >= INT_FLAG && y >= INT_FLAG) {
830 	intx = (x & INT_MASK);
831 	inty = (y & INT_MASK);
832 	res = intx % inty;
833 	res = res | INT_FLAG;
834 	return (res);
835     } else if (x >= INT_FLAG && y < 0) {
836 	intx = (x & INT_MASK);
837 	inty = y;
838 	res = -1 * (intx % inty);
839 	if (res >= 0)
840 	    res = res | INT_FLAG;
841 	return (res);
842     } else if (x < 0 && y >= INT_FLAG) {
843 	intx = x;
844 	inty = (y & INT_MASK);
845 	res = -1 * (intx % inty);
846 	if (res >= 0)
847 	    res = res | INT_FLAG;
848 	return (res);
849     } else if (x < 0 && y < 0) {
850 	res = -1 * ((-1 * x) % (-1 * y));
851 	return (res);
852     } else if ((CELLRANGE(x) && Flongnump(x)) && !CELLRANGE(y)) {
853 	longx = Fgetlong(x);
854 	if (y >= INT_FLAG)
855 	    inty = (y & INT_MASK);
856 	longy = (long long int) inty;
857 	res = (int) (longx % longy);
858 	if (res >= 0)
859 	    res = res | INT_FLAG;
860 	return (res);
861     } else
862 	return (Fcallsubr(Fcar(Fmakesym("MOD")), Flist2(x, y)));
863 }
864 
865 static inline int
fast_not(int x)866 fast_not(int x)
867 {
868     if (x == NIL)
869 	return (T);
870     else
871 	return (NIL);
872 }
873 
874 static inline int
fast_eq()875 fast_eq()
876 {
877     int             x,
878                     y;
879     y = Fargpop();
880     x = Fargpop();
881     if (x == y)
882 	return (T);
883     else
884 	return (NIL);
885 }
886 
887 static int
fast_setnth(int x,int n,int y)888 fast_setnth(int x, int n, int y)
889 {
890     while (n > 0) {
891 	x = Fcdr(x);
892 	n--;
893     }
894     Fset_car(x, y);
895     return (y);
896 }
897 
898 static char    *
fast_sprint_hex_long(long int n)899 fast_sprint_hex_long(long int n)
900 {
901     static char     res[FASTSTRLONG_SIZE];
902     static const char *hex_digits = "0123456789ABCDEF";
903     uint64_t        u = n;
904     for (int i = 0; i < 8; i++) {
905 	uint8_t         byte = (u >> (i << 3)) & 0xFF;
906 	uint8_t         hi_nybble = (byte >> 4) & 0x0F,
907 	    lo_nybble = byte & 0x0F;
908 	res[14 - (i << 1)] = hex_digits[hi_nybble];
909 	res[15 - (i << 1)] = hex_digits[lo_nybble];
910     } return res;
911 }
912 
913 
914     // ---------------OPenGL-----------------
915 static int      displayfunc;
916 static inline void
display_callback(void)917 display_callback(void)
918 {
919     Feval(displayfunc);
920 }
921 static int      keyboardfunc;
922 
923 static void
keyboard_callback(unsigned char key,int x,int y)924 keyboard_callback(unsigned char key, int x, int y)
925 {
926     Fset_cdr(Fmakesym("gl::key"), Fmakeint((int) key));
927     Fset_cdr(Fmakesym("gl::x"), Fmakeint(x));
928     Fset_cdr(Fmakesym("gl::y"), Fmakeint(y));
929     Feval(keyboardfunc);
930 }
931 static int      mousefunc;
932 
933 static void
mouse_callback(int button,int state,int x,int y)934 mouse_callback(int button, int state, int x, int y)
935 {
936     Fset_cdr(Fmakesym("gl::button"), Fmakeint(button));
937     Fset_cdr(Fmakesym("gl::state"), Fmakeint(state));
938     Fset_cdr(Fmakesym("gl::x"), Fmakeint(x));
939     Fset_cdr(Fmakesym("gl::y"), Fmakeint(y));
940     Feval(mousefunc);
941 }
942 #endif				/* */
943