The problem we are trying to deal with here is that some systems use a
function named stat and others, _stat.  At the same time, the second arg
may be either (struct stat *) or (struct _stat *), and there's no apparent
correlation between the choice of the function and structure name.   So we
have to figure out a combination that works.  This was done by separately
choosing a valid function name and a valid structure name.

Confusing the issue is that we need the right answer in C++.  The standard
configure macro that looks to see if a function foois available tries to
compile and link a little program:

char *foo();
main() { foo(); }

On our SGI (and your's, I expect), when this is done in C, both foo=stat
and foo=_stat work.  Unfortunately, only one works in C++, so we have to
test for it in C++.  Unfortunately, this test doesn't compile and link in
C++ with either stat or _stat, because the args aren't given.  And we don't
know the right args.  So the recent fix uses a double loop to figure out a
working combination: essentially

for f in stat     _stat ; do
    for s in stat    _stat ; do

cat > tt.c << EOF
#include <sys/stat.h>
main() { int i = $f("foo", (struct $s *)0); }
EOF

if (eval "CC tt.c") > /dev/null 2>&1 ; then
    fcn=$f
    str=$s
fi

    done
done

echo the function is $fcn
echo the structure name is $str

On our SGI this tells us the correct choice is stat in both cases -
function and structure name.

The fix we put in to acinclude.m4 works on several machines around here,
including our SGE (though the original code worked there, so I don't know
how much this tells us).  If this script fails on your machine, then we
need to know why so we can fix it the new DX_CHECK_STAT autoconf macro.  If
this script works on your system, then I guess we need to figure out why,
too - the actual macro includes additional logic to support other possible
include files etc.

Greg



Richard Gillilan <[EMAIL PROTECTED]>@opendx.watson.ibm.com on
06/21/2000 08:46:24 AM

Please respond to [email protected]

Sent by:  [EMAIL PROTECTED]


To:   [email protected]
cc:
Subject:  Re: [opendx-dev] dx acinclude.m4



This patch may have just broken my configure (even more).
Configure now dies with a "could not find working combination of stat
function and
strcuture"
Perhaps it's a clue to what's wrong on my system.

[EMAIL PROTECTED] wrote:

> Update of /src/master/dx
> In directory opendx.watson.ibm.com:/tmp/cvs-serv12278
>
> Modified Files:
>         acinclude.m4
> Log Message:
> AC_CHECK_FUNCS pathologically calls funcs with default "int func(void)"
> which doesn't work if the testing compiler is c++  and the function
prototype
> doesn't fortuitously match the default.  Change to use AC_TRY_LINK
instead,
> to determine the working combination of stat function and structure
definitions.





Reply via email to