gcl-devel
[Top][All Lists]
Advanced

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

Re: [Gcl-devel] Error compiling functions w/ (declare (integer x)) pres


From: Camm Maguire
Subject: Re: [Gcl-devel] Error compiling functions w/ (declare (integer x)) present
Date: 08 Jun 2002 01:18:58 -0400

Greetings!  Well, I can basically get it working with what I think is
the right answer:  add at the top of h/compbas2.h:
#ifdef GMP
#define save_avma 
#define restore_avma 
#endif


This seems to work for most argunemts to pi-inv, but using 10000 gives
me a segfault, and only when the module is compiled.  right now I
don't know if its a memory problem or my avma solution.  After several
gc's on t_contiguous, the linked list managed by insert_contblock gets
corrupted. 

When I can chase this down, I'll commit.  In the meantime, other
insights most welcome!

Take care,

John Jorgensen <address@hidden> writes:

> Well, CLX gets further in it's compile, but now with the example in the
> bignum docs, I get the error;
> =========================
> >(compile 'pi-inv)
> 
> Compiling gazonk0.lsp.
> End of Pass 1.  
> End of Pass 2.  
> gazonk0.c: In function `L1':
> gazonk0.c:4139: `save_avma' undeclared (first use in this function)
> gazonk0.c:4139: (Each undeclared identifier is reported only once
> gazonk0.c:4139: for each function it appears in.)
> gazonk0.c:4140: `restore_avma' undeclared (first use in this function)
> 
> Correctable error: (SYSTEM "(cd . ;gcc -pipe -fwritable-strings
> -DVOL=volatile -I/home/jjorgens/gcl/o -fsigned-char  -O -c -I. gazonk0.c
> -w)") returned a non-zero value 0.
> Signalled by UNLESS.
> If continued: Continues anyway.
> Broken at CERROR.  Type :H for Help.
> >>
> =========================
> Whatever the heck a avma is... CLX stops with the same type of error
> (save_avma undeclared).
> 
> J*
> 
> -------------------
> On 7 Jun 2002, Camm Maguire wrote:
> 
> > Greetings!  OK, I've committed a fix for this.  Please check it out.
> > And R.Toy, if you're listening, you should be able to uncomment
> > (declare (integer... too.
> > 
> > The solution I've implemented doesn't seem very optimal, but rather
> > uses the existing integer/bignum handling macros that were in place
> > for pari support and the original custom mp support.  The lisp
> > compiler spits out these C macros, and I'm far less comfortable
> > modifying the lisp compiler code.  
> > 
> > I thought declarations were supposed to help the compiler.  But all it
> > seems that they accomplish is the copying of integer data back and
> > forth needlessly.
> > 
> > Consider:
> > 
> > (defun max0 (x y &rest z)
> >   (declare (integer x y))
> >   (apply #'max x y z))
> > 
> > Here is the C code without the declaration :
> > 
> >     {object V1;
> >     object V2;
> >     object V3;
> >     V1=(base[0]);
> >     V2=(base[1]);
> >     vs_base=vs_base+2;
> >     vs_top[0]=Cnil;
> >     {object *p=vs_top;
> >      for(;p>vs_base;p--)p[-1]=MMcons(p[-1],p[0]);}
> >     V3=(base[2]);
> >     vs_top=sup;
> >     base[3]= (V1);
> >     base[4]= (V2);
> >     {object V4;
> >     V4= (V3);
> >      vs_top=base+5;
> >      while(V4!=Cnil)
> >      {vs_push((V4)->c.c_car);V4=(V4)->c.c_cdr;}
> >     vs_base=base+3;}
> >     Lmax();
> >     return;
> >     }
> > 
> > 
> > 
> > And here is the code with the declaration:
> > 
> > 
> > 
> >     {IDECL(GEN V1,V1space,V1alloc);
> >     IDECL(GEN V2,V2space,V2alloc);
> >     object V3;
> >     SETQ_IO(V1,V1alloc,(base[0]));
> >     SETQ_IO(V2,V2alloc,(base[1]));
> >     vs_base=vs_base+2;
> >     vs_top[0]=Cnil;
> >     {object *p=vs_top;
> >      for(;p>vs_base;p--)p[-1]=MMcons(p[-1],p[0]);}
> >     V3=(base[2]);
> >     vs_top=sup;
> >     base[3]= make_integer(V1);
> >     base[4]= make_integer(V2);
> >     {object V4;
> >     V4= (V3);
> >      vs_top=base+5;
> >      while(V4!=Cnil)
> >      {vs_push((V4)->c.c_car);V4=(V4)->c.c_cdr;}
> >     vs_base=base+3;}
> >     Lmax();
> >     return;
> >        }
> > 
> > 
> > What do we gain here, considering that we have to go back to objects
> > anyway when calling Lmax?
> > 
> > Take care,
> > 
> > 
> > John Jorgensen <address@hidden> writes:
> > 
> > > When I try to compile functions that declare integers, I get errors. They
> > > interpret just fine, but they don't compile. here is an example;
> > > ====================================
> > > (defun pi-inv (bits &aux (m 0))
> > >   (declare (integer bits m))
> > >   (let* ((n (+ bits (integer-length bits) 11))
> > >          (tt (truncate (ash 1 n) 882))
> > >          (d (* 4 882 882))
> > >          (s 0))
> > >     (declare (integer s d tt n))
> > >     (do ((i 2 (+ i 2))
> > >          (j 1123 (+ j 21460)))
> > >         ((zerop tt) (cons s (- (+ n 2))))
> > >       (declare (integer i j))
> > >         (setq s (+ s (* j tt))
> > >               m (- (* (- i 1) (- (* 2 i) 1) (- (* 2 i) 3)))
> > >               tt (truncate (* m tt) (* d (the integer (expt i 3))))))))
> > > ==========================
> > > 
> > > Right from the bugnum examples in the GCL documentation. running
> > > (compile 'pi-inv) produces the following errors;
> > > ==========================
> > > >(compile 'pi-inv)
> > > 
> > > Compiling gazonk1.lsp.
> > > End of Pass 1.  
> > > End of Pass 2.  
> > > gazonk1.c: In function `L1':
> > > gazonk1.c:3002: `GEN' undeclared (first use in this function)
> > > gazonk1.c:3002: (Each undeclared identifier is reported only once
> > > gazonk1.c:3002: for each function it appears in.)
> > > gazonk1.c:3002: parse error before `V1'
> > > gazonk1.c:3004: `V1' undeclared (first use in this function)
> > > gazonk1.c:3004: `V1alloc' undeclared (first use in this function)
> > > gazonk1.c:3007: parse error before `register'
> > > gazonk1.c:3008: `V2' undeclared (first use in this function)
> > > gazonk1.c:3008: `V2alloc' undeclared (first use in this function)
> > > gazonk1.c:3009: parse error before `register'
> > > gazonk1.c:3010: parse error before `register'
> > > gazonk1.c:3011: parse error before `V5'
> > > gazonk1.c:3012: parse error before `register'
> > > gazonk1.c:3023: `save_avma' undeclared (first use in this function)
> > > gazonk1.c:3024: `V3' undeclared (first use in this function)
> > > gazonk1.c:3024: `V3alloc' undeclared (first use in this function)
> > > gazonk1.c:3024: `restore_avma' undeclared (first use in this function)
> > > gazonk1.c:3036: `V4' undeclared (first use in this function)
> > > gazonk1.c:3036: `V4alloc' undeclared (first use in this function)
> > > gazonk1.c:3044: `V5' undeclared (first use in this function)
> > > gazonk1.c:3044: `V5alloc' undeclared (first use in this function)
> > > gazonk1.c:3045: `V6' undeclared (first use in this function)
> > > gazonk1.c:3045: `V6alloc' undeclared (first use in this function)
> > > gazonk1.c:3046: parse error before `register'
> > > gazonk1.c:3047: parse error before `register'
> > > gazonk1.c:3048: `V7' undeclared (first use in this function)
> > > gazonk1.c:3048: `V7alloc' undeclared (first use in this function)
> > > gazonk1.c:3049: `V8' undeclared (first use in this function)
> > > gazonk1.c:3049: `V8alloc' undeclared (first use in this function)
> > > 
> > > Correctable error: (SYSTEM "(cd . ;gcc -pipe -fwritable-strings
> > > -DVOL=volatile -I/opt/dl/gcl/o -fsigned-char  -O -c -I. gazonk1.c
> > > -w)") returned a non-zero value 0.
> > > Signalled by UNLESS.
> > > If continued: Continues anyway.
> > > Broken at CERROR.  Type :H for Help.
> > > >>
> > > ============================
> > > 
> > > If I remove the declares, it compiles just fine. It looks like this is
> > > what is keeping CLX from compiling. GEN looks like it's supposed to be a
> > > long, but I'm not sure.
> > > 
> > > J*
> > > 
> > > 
> > > _______________________________________________
> > > Gcl-devel mailing list
> > > address@hidden
> > > http://mail.gnu.org/mailman/listinfo/gcl-devel
> > > 
> > > 
> > 
> > 
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]