[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Sun Apr 2 12:23:48 2006 
Subject:pop-forum C programming help for mklibpop 
From:Aaron Sloman 
Volume-ID: 

In linux poplog in $popexternlib there is a command mklibpop
which currently produces the following:

    c_core.c:1450: error: conflicting types for 'malloc'
    c_core.c:1644: error: conflicting types for 'calloc'
    In file included from c_core.c:1996:
    /usr/lib/gcc/i386-redhat-linux/4.0.2/include/varargs.h:4:2: error:
    #error "GCC no longer implements <varargs.h>."
    /usr/lib/gcc/i386-redhat-linux/4.0.2/include/varargs.h:5:2: error:
    #error "Revise your code to use <stdarg.h>."
    c_core.c:2002: error: syntax error before 'va_dcl'
    c_core.c:2003: error: syntax error before '{' token
    c_core.c:2005: error: initializer element is not constant
    c_core.c:2007: error: syntax error before 'argp'
    c_core.c:2007: warning: data definition has no type or storage class
    c_core.c:2009: warning: parameter names (without types) in function declaration
    c_core.c:2009: warning: data definition has no type or storage class
    c_core.c:2010: error: syntax error before '|=' token
    c_core.c:2042: error: syntax error before '&' token
    c_core.c:2042: warning: data definition has no type or storage class
    c_core.c:2045: warning: parameter names (without types) in function declaration
    c_core.c:2045: warning: data definition has no type or storage class
    c_core.c:2046: error: syntax error before '}' token

In an attempt to fix this I tried copying and editing the c_core.c code
that Waldek produced when he ported poplog to AMD64

I am not a C programmer so I did not find it easy to tell which bits
of his code were due to the conversion to 64 bit poplog and which bits
were there to fix the varargs problem (or other C problems) in the 32
bit code.

Anyhow I managed to produce something that compiled without that error.
It is now in

    http://www.cs.bham.ac.uk/research/poplog/c_core/new/c_core.c

the original, for comparison is in
    http://www.cs.bham.ac.uk/research/poplog/c_core/old/c_core.c

and all the AMD64 C code for poplog is in
    http://www.cs.bham.ac.uk/research/poplog/c_core/amd64/

The whole lot is in a tar file (85KB)
    http://www.cs.bham.ac.uk/research/poplog/c_core.tar.gz
        c_core/old
        c_core/amd64
        c_core/new

Using v15.6 on linux fedora 4, if I install my new c_core.c in
$popexternlib, and run mklibpop then none of the errors occur, and I get
a libpop.a file.

Moreover I can then run pglink and create a newpop11 using that
libpop.a, which seems to work.

So I tried using it to rebuild the whole system.

    cd $popsys
    pglink -safe
        to create compact newpop11

    cp -p newpop11 popcore

    $popsrc/mksyscomp popc poplibr poplink
    $popsrc/mknewpop

So far so good.

    cd $popsrc

    pgcomp *.s
        works fine

    pgcomp *.p
        fails - stuck in a loop compiling bigint_float.p

I am about to go away and don't have time to investigate. But it looks
as if the change to c_core.c is nearly right but not quite right.

Maybe some constant is wrong that only causes problems in compiling that
file. I have not had time to check whether it fails in other places too.
(Must catch a train).

Maybe an expert C programmer will be able to tell what's wrong
with new/c_core.c

Waldek also altered pop_timer.c chanking 'int' to 'long' in one place,
which I assume had to do with the conversion to 64 bit poplog.

Aaron