Vasili Burdo on Fri, 18 Dec 2009 11:14:14 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: A patch for native PARI/GP build on Windows (Mingw+Msys)


Bill Allombert wrote:

6) Is gp2c support possible ?
Bill, I tried to compile gp2c from the latest tarball.
"configure --with-pari-cfg" and "make" work well, but "make check" fails at first test with message which I believe is not a problem of gp2c configuration.
See details attached.


/usr/src/pari-gp2c$> ./configure --with-pari-cfg=../pari-svn/Omingw-i686/pari.cfg
loading cache ./config.cache
checking for a BSD compatible install... (cached) /bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... (cached) yes
checking for working aclocal-1.4... missing
checking for working autoconf... missing
checking for working automake-1.4... missing
checking for working autoheader... missing
checking for working makeinfo... found
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... (cached) gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking how to run the C preprocessor... (cached) gcc -E
checking for flex... (cached) flex
checking for flex... (cached) flex
checking for yywrap in -lfl... (cached) no
checking lex output file root... (cached) lex.yy
checking whether yytext is a pointer... (cached) no
checking for bison... (cached) bison -y
checking for perl... (cached) /bin/perl
checking for PARI configuration... /usr/local/lib/pari/pari.cfg
checking for PARI configuration (debugging)... not found
checking for PARI version... 2.4.3 (DEVELOPMENT VERSION)
checking for PARI module build... /mingw/bin/gcc -c -o %s.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -I\"/usr/local/include\" %s.c && /mingw/bin/gcc -o %s.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl, %s.o
checking for GP path... /usr/local/bin/gp
checking for PARI data directory... /usr/local/share/pari
checking for PARI description database... pari21.desc
checking for ANSI C header files... (cached) yes
checking for malloc.h... (cached) yes
checking for unistd.h... (cached) yes
checking for working const... (cached) yes
checking for inline... (cached) inline
checking for size_t... (cached) yes
checking whether struct tm is in sys/time.h or time.h... (cached) time.h
checking for vprintf... (cached) yes
checking for strdup... (cached) yes
checking for strtol... (cached) yes
checking for getopt... (cached) yes
checking for strcmp... (cached) yes
checking for memccpy... (cached) yes
checking for strrchr... (cached) yes
creating ./config.status
creating Makefile
creating src/Makefile
creating desc/Makefile
creating doc/Makefile
creating test/Makefile
creating scripts/Makefile
creating scripts/822_desc.pl
creating scripts/dotest
creating scripts/gp2c-run
creating scripts/gp2c-dbg
creating doc/gp2c-run.1
creating doc/gp2c-dbg.1
creating src/config.h
/usr/src/pari-gp2c$> make
Making all in src
make[1]: Entering directory `/usr/src/pari-gp2c/src'
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c gp2c.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c context.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c funcdesc.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c funcspec.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c genblock.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c gencast.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c gencode.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c genfunc.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c gentype.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c gerepile.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c parse.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c lang.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c moveblock.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c node.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c printnode.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c toplevel.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c util.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c varlist.c
gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\" -c stack.c
gcc  -g -O2 -DFUNCDSC_PATH=\"/usr/local/share/gp2c/func.dsc\"  -o gp2c  gp2c.o context.o funcdesc.o funcspec.o genblock.
o gencast.o gencode.o genfunc.o gentype.o gerepile.o lang.o moveblock.o node.o parse.o printnode.o toplevel.o util.o var
list.o stack.o
make[1]: Leaving directory `/usr/src/pari-gp2c/src'
Making all in desc
make[1]: Entering directory `/usr/src/pari-gp2c/desc'
Using PARI 2.3 description
make[1]: Leaving directory `/usr/src/pari-gp2c/desc'
Making all in test
make[1]: Entering directory `/usr/src/pari-gp2c/test'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/src/pari-gp2c/test'
Making all in scripts
make[1]: Entering directory `/usr/src/pari-gp2c/scripts'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/src/pari-gp2c/scripts'
Making all in doc
make[1]: Entering directory `/usr/src/pari-gp2c/doc'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/src/pari-gp2c/doc'
make[1]: Entering directory `/usr/src/pari-gp2c'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/usr/src/pari-gp2c'
/usr/src/pari-gp2c$> make check
Making check in src
make[1]: Entering directory `/usr/src/pari-gp2c/src'
make[1]: Leaving directory `/usr/src/pari-gp2c/src'
Making check in desc
make[1]: Entering directory `/usr/src/pari-gp2c/desc'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/pari-gp2c/desc'
Making check in test
make[1]: Entering directory `/usr/src/pari-gp2c/test'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/pari-gp2c/test'
Making check in scripts
make[1]: Entering directory `/usr/src/pari-gp2c/scripts'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/pari-gp2c/scripts'
Making check in doc
make[1]: Entering directory `/usr/src/pari-gp2c/doc'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/usr/src/pari-gp2c/doc'
make[1]: Entering directory `/usr/src/pari-gp2c'
make  check-TESTS
make[2]: Entering directory `/usr/src/pari-gp2c'
Testing script affect...affect.gp.c: In function 'gp2c_f':
affect.gp.c:48: error: subscripted value is neither array nor pointer
FAIL: scripts/dotest
===================
1 of 1 tests failed
===================
make[2]: *** [check-TESTS] Error 1
make[2]: Leaving directory `/usr/src/pari-gp2c'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/usr/src/pari-gp2c'
make: *** [check-recursive] Error 1
/*-*- compile-command: "/mingw/bin/gcc -c -o affect.gp.o -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -I"/usr/local/include" affect.gp.c && /mingw/bin/gcc -o affect.gp.so -shared -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer -Wl, affect.gp.o "; -*-*/
#include <pari/pari.h>
/*
GP;install("gp2c_f","D0,G,","f","./affect.gp.so");
GP;install("gp2c_g","D0,G,D0,G,","g","./affect.gp.so");
GP;install("gp2c_h","D0,G,D0,G,","h","./affect.gp.so");
GP;install("gp2c_th","","th","./affect.gp.so");
GP;install("gp2c_col","D0,G,D0,G,D0,G,","col","./affect.gp.so");
GP;install("gp2c_lin","D0,G,D0,G,D0,G,","lin","./affect.gp.so");
GP;install("gp2c_tr","D0,G,p","tr","./affect.gp.so");
GP;install("gp2c_gp2crand31","l","gp2crand31","./affect.gp.so");
GP;install("gp2c_gp2crand","D0,G,","gp2crand","./affect.gp.so");
GP;install("gp2c_randomprime","D0,G,p","randomprime","./affect.gp.so");
GP;install("gp2c_init_affect","v","init_affect","./affect.gp.so");
*/
GEN gp2c_f(GEN gp2c_x);
GEN gp2c_g(GEN gp2c_x, GEN gp2c_y);
GEN gp2c_h(GEN gp2c_x, GEN gp2c_y);
GEN gp2c_th(void);
GEN gp2c_col(GEN gp2c_x, GEN gp2c_a, GEN gp2c_v);
GEN gp2c_lin(GEN gp2c_x, GEN gp2c_a, GEN gp2c_v);
GEN gp2c_tr(GEN gp2c_v, long prec);
long gp2c_gp2crand31(void);
GEN gp2c_gp2crand(GEN gp2c_N);
GEN gp2c_randomprime(GEN gp2c_N, long prec);
void gp2c_init_affect(void);
/*End of prototype*/

static long gp2c_seed;
/*End of global vars*/

void
gp2c_init_affect(void)	  /* void */
{
  pari_sp gp2c_ltop = avma;
  gp2c_seed = 0;
  avma = gp2c_ltop;
  return;
}

GEN
gp2c_f(GEN gp2c_x)	  /* vec */
{
  pari_sp gp2c_ltop = avma;
  GEN gp2c_v = gen_0, gp2c_i = gen_0;
  long gp2c_j = 0;
  GEN p1 = gen_0;	  /* vec */
  GEN gp2c_m = pol_x[fetch_user_var("m")];
  GEN p2 = gen_0;	  /* vec */
  {
    long l3;
    p1 = cgetg(itos(gp2c_x)+1, t_VEC);
    for (l3 = 1; gcmpsg(l3, gp2c_x) <= 0; ++l3)
      gel(p1, l3) = gen_0;
  }
  gp2c_v = p1;
  gp2c_m = matqpascal(itos(gp2c_x), NULL);
  {
    pari_sp gp2c_btop = avma, gp2c_st_lim = stack_lim(gp2c_btop, 1);
    long l4, l5;
    while (gcmp(gp2c_i, gp2c_x) < 0)
    {
      l4 = itos(gp2c_i = gaddgs(gp2c_i, 1));
      gel(gp2c_v, l4) = gaddgs(gel(gp2c_v, l4), 1);
      l5 = ++gp2c_j;
      gcoeff(gp2c_m, l5, gp2c_j) = gadd(gcoeff(gp2c_m, l5, gp2c_j), gp2c_i);
      if (low_stack(gp2c_st_lim, stack_lim(gp2c_btop, 1)))
        gerepileall(gp2c_btop, 3, &gp2c_i, &gp2c_v, &gp2c_m);
    }
  }
  p2 = cgetg(3, t_VEC);
  gel(p2, 1) = gcopy(gp2c_v);
  gel(p2, 2) = gcopy(gp2c_m);
  p2 = gerepileupto(gp2c_ltop, p2);
  return p2;
}

GEN
gp2c_g(GEN gp2c_x, GEN gp2c_y)	  /* vec */
{
  pari_sp gp2c_ltop = avma;
  GEN p1 = gen_0;	  /* vec */
  gp2c_x = gcopy(gp2c_x);
  gp2c_y = gcopy(gp2c_y);
  gel(gp2c_x, 2) = stoi(3);
  gcoeff(gp2c_y, 1, 1) = gaddgs(gcoeff(gp2c_y, 1, 1), 1);
  p1 = cgetg(3, t_VEC);
  gel(p1, 1) = gcopy(gp2c_x);
  gel(p1, 2) = gcopy(gp2c_y);
  p1 = gerepileupto(gp2c_ltop, p1);
  return p1;
}

GEN
gp2c_h(GEN gp2c_x, GEN gp2c_y)
{
  pari_sp gp2c_ltop = avma;
  GEN p1 = gen_0;
  if (gcmpgs(gp2c_y, 0) > 0)
    p1 = gcopy(gp2c_x);
  else
    p1 = gcopy(gp2c_y);
  p1 = gerepileupto(gp2c_ltop, p1);
  return p1;
}

GEN
gp2c_th(void)	  /* vec */
{
  pari_sp gp2c_ltop = avma;
  GEN gp2c_V = gen_0;
  GEN p1 = gen_0, p2 = gen_0;	  /* vec */
  {
    long gp2c_i;
    p1 = cgetg(6, t_VEC);
    for (gp2c_i = 1; gp2c_i <= 5; ++gp2c_i)
      gel(p1, gp2c_i) = stoi(gp2c_i);
  }
  gp2c_V = p1;
  {
    long gp2c_i;
    p2 = cgetg(6, t_VEC);
    for (gp2c_i = 1; gp2c_i <= 5; ++gp2c_i)
      gel(p2, gp2c_i) = gp2c_h(gel(gp2c_V, gp2c_i), stoi(gp2c_i - 1));
  }
  p2 = gerepileupto(gp2c_ltop, p2);
  return p2;
}

GEN
gp2c_col(GEN gp2c_x, GEN gp2c_a, GEN gp2c_v)
{
  pari_sp gp2c_ltop = avma;
  GEN p1 = gen_0;
  gp2c_x = gcopy(gp2c_x);
  if (gcmpgs(gp2c_a, 0) <= 0)
  {
    pariprintf("a is too small\n");
    avma = gp2c_ltop;
    return gen_0;
    p1 = gen_0;
  }
  else
    p1 = gcopy(gp2c_a);
  gel(gp2c_x, itos(p1)) = gcopy(gp2c_v);
  gp2c_x = gerepilecopy(gp2c_ltop, gp2c_x);
  return gp2c_x;
}

GEN
gp2c_lin(GEN gp2c_x, GEN gp2c_a, GEN gp2c_v)
{
  pari_sp gp2c_ltop = avma;
  long l1;	  /* lg */
  long l2;
  GEN p3 = gen_0;
  gp2c_x = gcopy(gp2c_x);
  if (gcmpgs(gp2c_a, 0) <= 0)
  {
    pari_err(talker, "a is too small");
    p3 = gen_0;
  }
  else
    p3 = gcopy(gp2c_a);
  l1 = lg(gp2c_x);
  for (l2 = 1; l2 < l1; ++l2)
    gcoeff(gp2c_x, itos(p3), l2) = gcopy(gel(gp2c_v, l2));
  gp2c_x = gerepilecopy(gp2c_ltop, gp2c_x);
  return gp2c_x;
}

GEN
gp2c_tr(GEN gp2c_v, long prec)
{
  pari_sp gp2c_ltop = avma;
  gp2c_v = gcopy(gp2c_v);
  trunc0(mppi(prec), &gel(gp2c_v, 1));
  gp2c_v = gerepilecopy(gp2c_ltop, gp2c_v);
  return gp2c_v;
}

long
gp2c_gp2crand31(void)
{
  pari_sp gp2c_ltop = avma;
  long l1;
  l1 = gp2c_seed = itos(gbitand(addis(mulsi(1000276549, stoi(gp2c_seed)), 12347), subis(shifti(gen_1, 31), 1)));
  avma = gp2c_ltop;
  return l1;
}

GEN
gp2c_gp2crand(GEN gp2c_N)
{
  pari_sp gp2c_ltop = avma;
  GEN gp2c_p = gen_0, p1 = gen_0;
  {
    pari_sp gp2c_btop = avma;
    while (gcmp(gp2c_p, gp2c_N) < 0)
    {
      gp2c_p = mpadd(gshift(gp2c_p, 31), stoi(gp2c_gp2crand31()));
      gp2c_p = gerepileupto(gp2c_btop, gp2c_p);
    }
  }
  p1 = gmod(gp2c_p, gp2c_N);
  p1 = gerepileupto(gp2c_ltop, p1);
  return p1;
}

GEN
gp2c_randomprime(GEN gp2c_N, long prec)
{
  pari_sp gp2c_ltop = avma;
  GEN p1 = gen_0;
  p1 = gnextprime(gp2c_gp2crand(gpow(gen_2, gp2c_N, prec)));
  p1 = gerepileupto(gp2c_ltop, p1);
  return p1;
}