[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jun 28 19:28:13 2003 
Subject:Re: 'errno' problem for poplog in redhat 9 
From:Waldek Hebisch 
Volume-ID:1030628.01 

Aaron Sloman (A.Sloman@cs.bham.ac.uk) wrote:

: Given the problems that have been reported I thought I should
: investigate poplog on redhat 9 myself.
 
: I think I've reached the point where I need help from an
: experienced C programmer.
 
: On Thursday night I took the plunge and upgraded my laptop
: from RH8 to RH 9. It was all very smooth except that (a) I
: can't get mplayer to work now and (b) although I can run a
: version of poplog that was linked on RH8 I cannot relink
: on RH 9, and whenever I run it I get this irritating warning
: message as others have reported:
 
:     Incorrectly built binary which accesses errno, h_errno or _res
:     directly.
:     Needs to be fixed
 
: It is clear that this has nothing to do with Ved, or X because the
: same warning message is produced by running the 'minimal' corepop,
: used for system building.
 
: Also it is not a problem in the external C bits of poplog because
: running
:     $usepop/pop/extern/lib/mklibpop
 
: produces no warnings or errors.


: Attempting to rebuild corepop using
:     pglink -safe
 
: fails with the usual warning followed by error messages about errno:
 
: Incorrectly built binary which accesses errno, h_errno or _res directly. Needs to be fixed.
 <snip>
: : undefined reference to `errno'
: /usr/local/poplog/v15.53/pop/obj/src.olb(devio.o)(.text+0xda9): more undefined references to `errno' follow
: collect2: ld returned 1 exit status
 
: So it looks as if the problem likes in $popsrc/devio.p

Not exactly, I see the following in unixdefs.ph :

lconstant macro _ERRNO = [_extern errno:data!(int)];

I think this macro references errno directly

<snip>

: So I have to find a place to declare errno (probably as an int)
: and make sure that that is included when poplog is linked.
 
: I wondered if it would suffice to put that in
:     $popexternlib/c_core.h
 
: I then looked at saw that it was already defined there:
:    #ifdef UNIX
:    /*
:     *  Save errno during signal handling (not done by default)
:     */
:    #include <errno.h>
:    extern int errno;   /* for systems which don't define it in <errno.h> */
:     ....
 
: So maybe we need to have another archive that can be linked in before
 
:     /usr/local/poplog/v15.53a/pop/obj/src.olb
 
: in the file
:     $popsys/poplink_cmnd
 
: If someone produces some C code that declares the global
: variable errno (and initialises it e.g. to 1 or 0) which I
: can use to create (with ar) a static library liberrno.a
: then I guess I can edit poplink_cmnd to link it before
: src.olb That may stop devio.p causing problems at link
: time.

Since errno is not an ordinary variable one really need 
a get and (possibly) update functions:

#include <errno.h>

int get_libc_errno(void)
{
	return errno;
}

void set_libc_errno(int x)
{
	errno = x;
}

The _ERRNO macro in unixdefs.ph have to be updated to call 
the C functions above.

--
                              Waldek Hebisch
hebisch@math.uni.wroc.pl    or hebisch@hera.math.uni.wroc.pl