View Single Post
Old 2012-10-28, 03:30   #4
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

410710 Posts
Default

I tried again with a version that's about as simple as I can get. I used the following gp routine:
Code:
pTest(a,b)=
{
  for(e=a,b,
    print("e is ",e)
  )
}
Terminal result:
Code:
[user@comp pari]$ gp2c-run -g pariTest.gp
                  GP/PARI CALCULATOR Version 2.3.5 (released)

...

Type ? for help, \q to quit.
Type ?12 for how to get moral (and possibly technical) support.

parisize = 8000000, primelimit = 500000
? pTest(15,32)
e is 15
e is 16
...
e is 31
e is 32
?
The PariTest.gp.c file:
Code:
/*-*- compile-command: "/usr/bin/gcc -c -o pariTest.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -I/usr/include pariTest.gp.c && /usr/bin/gcc -o pariTest.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -fPIC -Wl,-shared pariTest.gp.o -lc -ldl -lm -L/usr/lib64 -lgmp -L/usr/lib64 -lpari"; -*-*/
#include <pari/pari.h>
/*
GP;install("init_pariTest","v","init_pariTest","./pariTest.gp.so");
GP;install("pTest","vD0,G,D0,G,","pTest","./pariTest.gp.so");
*/
void init_pariTest(void);
void pTest(GEN a, GEN b);
/*End of prototype*/

void
init_pariTest(void)      /* void */
{
  pari_sp ltop = avma;
  avma = ltop;
  return;
}

void
pTest(GEN a, GEN b)      /* void */
{
  pari_sp ltop = avma;
  {
    pari_sp btop = avma, st_lim = stack_lim(btop, 1);
    GEN e = gen_0;
    for (e = gcopy(a); gcmp(e, b) <= 0; e = gaddgs(e, 1))
    {
      pariprintf("e is %Z\n", e);
      if (low_stack(st_lim, stack_lim(btop, 1)))
        e = gerepilecopy(btop, e);
    }
  }
  avma = ltop;
  return;
}
Debugger message:
Code:
Program received signal SIGSEGV, Segmentation fault.
In gcopy () (usr/lib64/libpari-gmp.so.2)
Thanks for any assistance...
EdH is offline   Reply With Quote