mplisp

miniPicoLisp with FFI and modules for Buddy BDD library, OpenGL, Gtk and GMP
git clone https://logand.com/git/mplisp.git/
Log | Files | Refs

gmpx.c (489B)


      1 #include "../pico.h"
      2 #include "gmp.h"
      3 
      4 any cfun_mpz_new(any ex __attribute__((unused))) {
      5   mpz_ptr z = malloc(sizeof(__mpz_struct));
      6   return box(z);
      7 }
      8 
      9 any cfun_mpz_free(any ex) {
     10   any x = ex, y;
     11   x = cdr(x);
     12   y = EVAL(car(x));
     13   NeedNum(ex, y);
     14   mpz_ptr b1 = (mpz_ptr) unBox(y);
     15   free(b1);
     16   return Nil;
     17 }
     18 
     19 any cfun_mpz_print(any ex) {
     20   any x = ex, y;
     21   x = cdr(x);
     22   y = EVAL(car(x));
     23   NeedNum(ex, y);
     24   mpz_ptr b1 = (mpz_ptr) unBox(y);
     25   gmp_printf("%Zd", b1);
     26   return Nil;
     27 }