hugs98-Dec2001 on AIX

James B. White III (Trey) whitejbiii@ornl.gov
Fri, 21 Dec 2001 17:13:02 -0500


Hugs debuggers,

I built the December 2001 distribution of Hugs on AIX using IBM's C
compiler, and it required a few changes to the distribution to work.

System:
AIX 4.3.3
XL C 5.0.2

To build without error, I had to change the value of "CFLAGS". I could
not do this with "configure" because it was hardwired to set "CFLAGS =
-g". I modified "configure" as follows, commenting out the hardwired values.

% diff configure.orig configure
4611,4612c4611,4612
< CFLAGS="-g"
< OPTFLAGS="-O2"
---
> #CFLAGS="-g"
> #OPTFLAGS="-O2"

Then I configured with the following command. The "-qalloca" is required.

CC=cc CFLAGS="-g -qalloca" OPTFLAGS="-O -qmaxmem=-1"
LDFLAGS="-bmaxdata:0x70000000" configure --prefix=$MYPREFIX

The resulting Hugs executable hung while parsing the Prelude. (The
distribution from February 2001 did not have this problem.) I eventually
discovered the root of the problem in "input.c". I made the following
change to fix it.

% diff input.c.orig input.c
516c516
<         if (lineBuffer[lineLength] == EOF)
---
>         if (lineBuffer[lineLength] == (char)EOF)

With AIX, "EOF" is a signed integer of value -1, but characters are
unsigned. When the character variable "lineBuffer[lineLength]" is set to
"EOF", its value becomes 255. Since 255 doesn't equal -1, the "if"
statement is never true. Casting "EOF" to a character give it the needed
value of 255.

Section 2.7 of K&R's C book, 2nd edition, describes the machine
dependence of the automatic conversion of characters "up" to signed
integers. The explicit "downward" cast avoids this machine dependence. I
humbly suggest incorporating this change to "input.c" in future Hugs distributions.

-- 
James B. White III (Trey)
Center for Computational Sciences
Oak Ridge National Laboratory
whitejbiii@ornl.gov