Porting newLISP (AIX)

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
csstup
Posts: 2
Joined: Mon Apr 23, 2007 10:26 pm

Porting newLISP (AIX)

Post by csstup »

Last couple days I went through a round of porting newLISP to AIX. Is anyone interested in the changes, perhaps folding them into the release?

I had a couple comments about the code base with regards to porting, incase the developers are interested:

1. The use of #ifdefs for platforms is a bit overused. While I'm not a big supporter of autoconf'ing everything, its general model of #ifdef'ing the capability/requirement, rather than the platform seems to work better for portable projects. #ifdef _READLINE is okay, but

Code: Select all

#ifdef SOLARIS #else #ifdef OS2...
is hard to manage when adding a new platform.

2. The usage of "opsys" in newlisp.c is restrictive. Since this ID is referenced all over the tests as stuff like

Code: Select all

(if opsys<5 || opsys==9)
, many many changes would have to be made to support a new opsys code for AIX. What ID do the developers recommend for AIX? This could be reworked in a couple different ways.

For the most part however, the code is portable ANSI C that, with a few minor changes, compiles under both gcc and the native IBM compilers under AIX4.3 .3. The qa-net test fails currently, I've not added debug code to see why as of yet. And I'll be building/testing under AIX5.X later this week.

I'd be happy to publish/discuss my changes if there is interest from the community. Thanks!

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hi csstup,

Yes the If then else is not my game either ;-) quite a puzzle when more
OSes join the club indeed...

The qa test you should first just leave as they are, if it compiles without big
errors qa tests can be done ;-)

But I think Mr. Guru himself will certainly give you a reply..

Norman.
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Hi csstup

'opsys' is referenced in the C source a few times, mainly to feed into the newLISP 'sys-info' call in nl-filesys.c. Later in the code it gets incremented by the bits for UTF-8 and mode and id the versin is a library.

In newLISP .lsp source a built-in variable exists, called: ostype to code platform specific newLISP (mostly necessary for Win32).

I suggest you add:

#ifdef AIX
int opsys = 10;
char ostype[]="AIX";
#endif

in newlisp.c and create a makefile_aix with -DAIX used in it. Then create a

#ifdef AIX
...
#endif

section in newlisp.h and use #ifdef AIX and #ifndef AIX throughout the C source code.

The current system is not perfect but has served well through the years. I agree that #ifdef <capability> is much better then #ifdef <platform> through out the code, but for the makefiles it is better to have -DAIX, -DSOLAIRS, -DLINUX etc. The best probably would be to have #ifdef <platform> only be used in newlisp.h to bracket a group of #define <cabalities> for each platform.

In part this has already happened (i.e. for vasprintf(), nanosleep() etc). If a specific other capability comes to your mind which could lead to take out more of #ifdef <platforms> throughout the C code let me know.

You will see that most platform dependent issues are in nl-filesys.c.

If you send me a package compiling on AIX based on the latest development release, I can modify/integrate your changes for the next development release. Just "#ifdef AIX" you stuff into it and I see how I can streamline things further if you haven't done already. I will then send you a package back to make sure things work on both side.

Over the years platforms have come and gone, it would be nice to have AIX among the standard makefiles as it probably will still be around for some time, and have it detected too in the 'build' and 'configure' scripts. These script use the UNIX utility uname to detect the platform.

Last not least very welcome to newLISP and thanks for participating in porting efforts ;-)

Lutz

csstup
Posts: 2
Joined: Mon Apr 23, 2007 10:26 pm

Post by csstup »

Lutz wrote: 'opsys' is referenced in the C source a few times, mainly to feed into the newLISP 'sys-info' call in nl-filesys.c. Later in the code it gets incremented by the bits for UTF-8 and mode and id the versin is a library.

In newLISP .lsp source a built-in variable exists, called: ostype to code platform specific newLISP (mostly necessary for Win32).

I suggest you add:

#ifdef AIX
int opsys = 10;
char ostype[]="AIX";
#endif
I thought 10 would be the logical choice, but a bunch of the tests all compare for the sys-info return value(ie, opsys), which makes them fail in wierd ways when set to 10. Perhaps using something like <15 for all Unix, 16-31 for Windows, etc, to not interfer with the flag usage of the variable as well.

For now I'm reusing 4, since its semi close to Solaris, and the tests will all run. The tests were *key* to verifying the various porting issues I came across.
in newlisp.c and create a makefile_aix with -DAIX used in it. Then create a

#ifdef AIX
...
#endif

section in newlisp.h and use #ifdef AIX and #ifndef AIX throughout the C source code.
Yep, already made a makefile_aix, changed makefile, build, etc. _AIX is defined by default when compiling under AIX (both GCC and native compilers) so I always use that.
The current system is not perfect but has served well through the years. I agree that #ifdef <capability> is much better then #ifdef <platform> through out the code, but for the makefiles it is better to have -DAIX, -DSOLAIRS, -DLINUX etc. The best probably would be to have #ifdef <platform> only be used in newlisp.h to bracket a group of #define <cabalities> for each platform.
Right, thats how I usually do it. One .h that list all the capabilities based on the -DSOLARIS define at compile time, which then all other source is based on those caps/requirements. Thats how autoconf's config.h works.
If you send me a package compiling on AIX based on the latest development release, I can modify/integrate your changes for the next development release. Just "#ifdef AIX" you stuff into it and I see how I can streamline things further if you haven't done already. I will then send you a package back to make sure things work on both side.
Will do. I'll get the prelim stuff packaged up shortly. Its built against 9.1.1, is that okay?
Over the years platforms have come and gone, it would be nice to have AIX among the standard makefiles as it probably will still be around for some time, and have it detected too in the 'build' and 'configure' scripts. These script use the UNIX utility uname to detect the platform.
Already changed build to detect uname and use makefile_aix as required.
Last not least very welcome to newLISP and thanks for participating in porting efforts ;-)
Looking forward to helping out where I can. Thanks for the reply!

Just FYI, build from xlc (native compiler):

Code: Select all

bash-2.04# gmake
./build

Discovered AIX
        make -f makefile_aix
        xlc -c -g -O2 newlisp.c
     689  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
        xlc -c -g -O2 nl-symbol.c
        xlc -c -g -O2 nl-math.c
        xlc -c -g -O2 nl-list.c
        xlc -c -g -O2 nl-liststr.c
        xlc -c -g -O2 nl-string.c
        xlc -c -g -O2 nl-filesys.c
        xlc -c -g -O2 nl-sock.c
        xlc -c -g -O2 nl-import.c
        xlc -c -g -O2 nl-xml.c
        xlc -c -g -O2 nl-web.c
        xlc -c -g -O2 nl-matrix.c
        xlc -c -g -O2 nl-debug.c
        xlc -c -g -O2 pcre.c
        xlc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o  nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o -lm -ldl -o newlisp
And from gcc:

Code: Select all

bash-2.04# gmake
./build

Discovered AIX
        make -f makefile_aix
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 newlisp.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-symbol.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-math.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-list.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-liststr.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-string.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-filesys.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-sock.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-import.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-xml.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-web.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-matrix.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 nl-debug.c
        gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -fno-strict-aliasing -c -g -O2 pcre.c
        gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o  nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o pcre.o -lm -ldl -o newlisp
Both compile clean with no warnings after the changes.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks Csstup, the compiles look nice. Either send me the package to lutz at nuevatec dot com as attachment or let me know in a private message on this board where I can retrieve it.

Lutz

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

After modifying newlisp.c and ... as described in this thread I have tried it but got some errors?
Is there some sort of howto compile or installation guide for AIX?

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Can you dump the compile output here and the make file you used?
Gives a little more insight ;-)
-- (define? (Cornflakes))

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

makefile_aix_utf8
###########################################################################################
# makefile for newLISP v. 10.x.x on AIX woth UTF-8 support
#
#

OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o


# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX

CC = gcc

default: $(OBJS)
$(CC) $(OBJS) -lm -ldl -lrt -lnsl -o newlisp

.c.o:
$(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
###########################################################################################

I have added

#########################
#ifdef AIX
int opsys = 4;
char ostype[]="AIX";
#endif
#########################

to 'newlisp.c' and

########################
#ifdef AIX
#define OSTYPE "AIX"
#endif
########################

to 'newlisp.h' and

#######################
aix:
gmake -f makefile_aix_utf8

#######################

to 'Makefile' and

######################
AIX)
echo Discovered AIX:
gmake aix
exit
;;
######################

to 'build'.

I got the following link error message:

#############################################################################################
.............
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
nl-web.c: In function 'getPutPostDeleteUrl':
nl-web.c:338: warning: implicit declaration of function 'alloca'
nl-web.c:338: warning: incompatible implicit declaration of built-in function 'alloca'
nl-web.c: In function 'handleHTTPcgi':
nl-web.c:1250: warning: incompatible implicit declaration of built-in function 'alloca'
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lnsl -o newlisp
ld: 0711-317 ERROR: Undefined symbol: .vasprintf
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
gmake[2]: *** [default] Error 1
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
gmake: *** [default] Error 2
#############################################################################################

I have then tried it using AIX compiler xlc_r by changing 'makefile_aix_utf8' as follows:

#############################################################################################
# makefile for newLISP v. 10.x.x on AIX woth UTF-8 support
#
#

OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o


# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -c -g -O2 -DSUPPORT_UTF8 -DAIX

CC = xlc_r

default: $(OBJS)
$(CC) $(OBJS) -lm -ldl -lrt -lnsl -o newlisp

.c.o:
$(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
#############################################################################################

I get now

#############################################################################################
...............
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
"nl-web.c", line 338.10: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 339.6: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 340.7: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 341.6: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 1250.9: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lnsl -o newlisp
ld: 0711-317 ERROR: Undefined symbol: .alloca
ld: 0711-317 ERROR: Undefined symbol: .vasprintf
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
gmake[2]: *** [default] Error 8
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
gmake: *** [default] Error 2
#############################################################################################

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Lets take it step by step:

(1) you should definitely stay with gcc not xlc_r

(2) in newlisp.h where you define AIX change to:

Code: Select all

#ifdef AIX
#define OSTYPE "AIX"
#define SOLARIS         /* <-- this line added */
#endif
put this around line 39 after the #ifdef SOLARIS definition. This makes AIX a sub flavor of SOLARIS (System V, BSD derived)

(3) in newlisp.h after all the includes around line 115 before the #ifndef SOLARIS put:

Code: Select all

#ifdef AIX
#define vasprintf my_vasprintf
#endif
After the compiling and linking well do a:

Code: Select all

./newlisp qa-dot
inside the newlisp-10.0.1 directory. This is a basic test suite trying out most built-in functions. Most likely we will have problems with system level functions located in nl-filesys.c. If that goes well do a:

Code: Select all

make test
in the same location. This runs a more comprehensive test suite.

ps: thanks to nodep for helping out here too.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

... also please compile util/types.c and post the output:

Code: Select all

> cd newlisp-10.0.1/util
 
> gcc types.c -o types

> ./types
It will probably give something like this:

Code: Select all

type      bytes
---------------
char        1
char *      4
void *      4
short int   2
int         4
long        4
long int    4
long long   8
size_t      4
float       4
double      8
long double 16
wchar_t     4

format input              output
------------------------------------------------
%d     0xffffffff           -1
%u     0xffffffff           4294967295
%d     0x7fffffff           2147483647
%u     0x7fffffff           2147483647
%d     0x80000000           -2147483648
%u     0x80000000           2147483648
%d     0x7fffffffffffffffLL -1
%u     0x7fffffffffffffffLL 4294967295
%x     0xffffffffffffffffLL ffffffff
%X     0x7fffffffffffffffLL ffffffff
%X     0x8000000000000000LL 0
%llX   0xFFFFFFFFFFFFFFFFLL ffffffff
%llX   0x7FFFFFFFFFFFFFFFLL ffffffff
%llX   0x8000000000000000LL 0
%lld   0xffffffffffffffffLL -1
%llu   0xffffffffffffffffLL 18446744073709551615
%lld   0x7fffffffffffffffLL 9223372036854775807
%llu   0x7fffffffffffffffLL 9223372036854775807
%lld   0x8000000000000000LL -9223372036854775808
%llu   0x8000000000000000LL 9223372036854775808

CPU is little endian
The constant __LITTLE_ENDIAN__ is defined by the compiler
The only difference is probably, that your machine may be big endian.

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

Here is the relevant part pf my "newlisp.h" file:
####################################################################################
+1 /* newlisp.h - header file for newLISP
+2
+3 Copyright (C) 2009 Lutz Mueller
+4
+5 This program is free software: you can redistribute it and/or modify
+6 it under the terms of the GNU General Public License as published by
+7 the Free Software Foundation, either version 3 of the License, or
+8 (at your option) any later version.
+9
+10 This program is distributed in the hope that it will be useful,
+11 but WITHOUT ANY WARRANTY; without even the implied warranty of
+12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+13 GNU General Public License for more details.
+14
+15 You should have received a copy of the GNU General Public License
+16 along with this program. If not, see <http>.
+17
+18 */
+19
+20 #ifdef LINUX
+21 #define OSTYPE "Linux"
+22 #endif
+23
+24 #ifdef _BSD
+25 #define OSTYPE "BSD"
+26 #endif
+27
+28 #ifdef MAC_OSX
+29 #define OSTYPE "OSX"
+30 #endif
+31
+32 #ifdef SOLARIS
+33 #ifdef TRU64
+34 #define OSTYPE "Tru64Unix"
+35 #else
+36 #define OSTYPE "Solaris"
+37 #endif
+38 #endif
+39
+40 #ifdef AIX
+41 #define OSTYPE "AIX"
+42 #define SOLARIS
+43 #endif
+44
+45 #ifdef WIN_32
+46 #define OSTYPE "Win32"
+47 #endif
+48
+49 #ifdef OS2
+50 #define OSTYPE "OS/2"
+51 #endif

..........

+107 #include <unistd>
+108 #include <sys>
+109 #include <math>
+110 #include <float>
+111 #include <string>
+112 #include <ctype>
+113 #include <fcntl>
+114 #include <stdarg>
+115 #include <time>
+116 #include <sys>
+117 #include <sys>
+118 #include <sys>
+119
+120 #ifdef AIX
+121 #define vasprintf my_vasprintf
+122 #endif
+123
+124 #ifndef SOLARIS
+125 #ifndef _BSD
+126 #ifndef MAC_OSX
+127 #include <malloc>
+128 #endif
+129 #endif
+130 #else
+131 #include <alloca>
+132 #endif
+133
#######################################################################################

I get now the error message:

#gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.1'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.1'
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
newlisp.c:78: error: redefinition of 'opsys'
newlisp.c:73: error: previous definition of 'opsys' was here
gmake[2]: *** [newlisp.o] Error 1
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
gmake: *** [default] Error 2

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

probably opsys is defined twice in newlisp.c. As of now AIX is a sub-flavor of SOLARIS, similar to TRU64. Change newlisp.c around line 68


#ifdef SOLARIS
int opsys 4
#endif

#ifdef TRU64
int opsys += 5;
#endif

#ifdef AIX
int opsys += 6;
#endif

As both, TRU64 and AIX are sub-flavors of SOLARIS, they will end up with numbers 9 and 10. Then test using the qa-files from 10.0.2, released later today, which elminate all references to opsys numbers from 'sys-info'. It would also help if you can give the output of types.c (see my last post).

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

After modifying "newlisp.c" as follows

Code: Select all

################################
#ifdef SOLARIS
  #ifdef TRU64
    int opsys = 9;
  #endif
  #ifdef AIX
    int opsys = 10;
  #else
    int opsys = 4;
  #endif
#endif
#################################
I have managed to compile newlisp:-)
Here is the output of gmake:

Code: Select all

#########################################################################################
$ gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.1'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.1'
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
nl-string.c: In function 'p_search':
nl-string.c:135: warning: dereferencing type-punned pointer will break strict-aliasing rules
nl-string.c: In function 'p_pack':
nl-string.c:1619: warning: dereferencing type-punned pointer will break strict-aliasing rules
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
nl-filesys.c:28:1: warning: "FIONREAD" redefined
In file included from /usr/include/sys/stropts.h:33,
                 from /usr/include/stropts.h:30,
                 from nl-filesys.c:26:
/usr/include/sys/ioctl.h:356:1: warning: this is the location of the previous definition
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
nl-sock.c:64:1: warning: "FIONREAD" redefined
In file included from nl-sock.c:47:
/usr/include/sys/ioctl.h:356:1: warning: this is the location of the previous definition
nl-sock.c: In function 'ping':
nl-sock.c:2053: warning: passing argument 6 of 'nrecvfrom' from incompatible pointer type
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
#########################################################################################
And here is the output of "types":

Code: Select all

#######################################################
$ cd util
$ gcc types.c -o types
$./types

type      bytes
---------------
char        1
char *      4
void *      4
short int   2
int         4
long        4
long int    4
long long   8
size_t      4
float       4
double      8
long double 8
wchar_t     2

format input              output
------------------------------------------------
%d     0xffffffff           -1
%u     0xffffffff           4294967295
%d     0x7fffffff           2147483647
%u     0x7fffffff           2147483647
%d     0x80000000           -2147483648
%u     0x80000000           2147483648
%d     0x7fffffffffffffffLL 2147483647
%u     0x7fffffffffffffffLL 2147483647
%x     0xffffffffffffffffLL ffffffff
%X     0x7fffffffffffffffLL 7fffffff
%X     0x8000000000000000LL 80000000
%llX   0xFFFFFFFFFFFFFFFFLL ffffffff
%llX   0x7FFFFFFFFFFFFFFFLL 7fffffff
%llX   0x8000000000000000LL 80000000
%lld   0xffffffffffffffffLL -1
%llu   0xffffffffffffffffLL 18446744073709551615
%lld   0x7fffffffffffffffLL 9223372036854775807
%llu   0x7fffffffffffffffLL 9223372036854775807
%lld   0x8000000000000000LL -9223372036854775808
%llu   0x8000000000000000LL 9223372036854775808

CPU is big endian
The constant __BIG_ENDIAN__ is defined by the compiler
#######################################################
What should the following command do on AIX?

Code: Select all

#######################################################
./newlisp qa-dot

Testing built-in functions ...
---------- testing UDP Win32 and OS/2 -------------
waiting ...
sending ...
receiving ...
msg:("HELLO" "127.0.0.1" 42935)
deleting semaphore:true
------------------------------------------
  -> share
#######################################################
It is hanging here!!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

The types output looks fine, as we don't care about the 'long double' type.

(1) add -fno-strict-aliasing to the make file as done in makefile_solaris

(2) in nl-filesys.c change:

Code: Select all

#ifdef SOLARIS
#include <stropts>
#ifndef TRU64
#define FIONREAD I_NREAD
#endif
#endif
to

Code: Select all

#ifdef SOLARIS
#include <stropts>
#if !defined  (TRU64) || (AIX)
#define FIONREAD I_NREAD
#endif
#endif
For the other warnings I would have to see the header files on your machine in /usr/include/. Some of the functions may have different call-type patterns. If we are lucky it can just be re-mended with a type-cast. The fact that these are only warnings means that we are probably Ok.

In qa-dot replace the definition of test-share with:

Code: Select all

(define (test-share) true)
And you make have to do the same with (test-semaphore). One or both of newLISP 'share' and 'semaphore' functions do not work.

This effectively skips the test. We would have to consult the manpages for mmap() and munmap() to find out how memory sharing is done on your system and the same is true for the semaphore() call.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

I just see on the snippet, where its hanging on 'share' qa-dot seems to think its in Win32 or OS2. Make sure you are using qa-dot from 10.0.2. After doing the changes in my last post and using 10.0.2-qa-dot, perhaps it will pass 'share' and 'semaphore'.

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

As you suggested, in files "nl-filesys.c" and "nl-sock.c" I replaced

Code: Select all

#ifndef TRU64

by

Code: Select all

#if !defined  (TRU64) || (AIX) 
Here is the output of "gmake"

Code: Select all

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.1'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.1'
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
nl-filesys.c:28:1: warning: "FIONREAD" redefined
In file included from /usr/include/sys/stropts.h:33,
                 from /usr/include/stropts.h:30,
                 from nl-filesys.c:26:
/usr/include/sys/ioctl.h:356:1: warning: this is the location of the previous definition
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
nl-sock.c:64:1: warning: "FIONREAD" redefined
In file included from nl-sock.c:47:
/usr/include/sys/ioctl.h:356:1: warning: this is the location of the previous definition
nl-sock.c: In function 'ping':
nl-sock.c:2053: warning: passing argument 6 of 'nrecvfrom' from incompatible pointer type
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
# OBJECT_MODE=64 gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
Using "qa-dot" of the version 10.0.2 I get now the result:

Code: Select all

# ./newlisp qa-dot

Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 5564

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-accept failed nil
>>>> net-close failed nil
>>>> net-local failed nil
>>>> net-lookup failed nil
>>>> net-peek failed nil
>>>> net-peer failed nil
>>>> net-receive failed nil
>>>> net-sessions failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed

Testing contexts as objects and scoping rules ...

total time: 7462

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-accept failed nil
>>>> net-close failed nil
>>>> net-local failed nil
>>>> net-lookup failed nil
>>>> net-peek failed nil
>>>> net-peer failed nil
>>>> net-receive failed nil
>>>> net-sessions failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed
If it helps you to fix the warnings, I can upload the archive file containing "/usr/include" of my machine.

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

Compiling newlisp using xlc_r also works smoothly!

Code: Select all

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.1'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.1'
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
     724  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
"nl-filesys.c", line 28.9: 1506-236 (W) Macro name FIONREAD has been redefined.
"nl-filesys.c", line 28.9: 1506-358 (I) "FIONREAD" is defined on line 356 of /usr/include/sys/ioctl.h.
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
"nl-sock.c", line 64.9: 1506-236 (W) Macro name FIONREAD has been redefined.
"nl-sock.c", line 64.9: 1506-358 (I) "FIONREAD" is defined on line 356 of /usr/include/sys/ioctl.h.
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -c -g -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
# OBJECT_MODE=64 xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
"newlisp qa-dot" returns the expected result as before

Code: Select all

# ./newlisp qa-dot
Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 8559

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-accept failed nil
>>>> net-close failed nil
>>>> net-local failed nil
>>>> net-lookup failed nil
>>>> net-peek failed nil
>>>> net-peer failed nil
>>>> net-receive failed nil
>>>> net-sessions failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed

Testing contexts as objects and scoping rules ...

total time: 11004

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-accept failed nil
>>>> net-close failed nil
>>>> net-local failed nil
>>>> net-lookup failed nil
>>>> net-peek failed nil
>>>> net-peer failed nil
>>>> net-receive failed nil
>>>> net-sessions failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed
I have also tried to compile a 64-BIT version of newlisp using the following makefile:

Code: Select all

OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
        nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o


# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX

CC = xlc_r

default: $(OBJS)
         OBJECT_MODE=64 $(CC) $(OBJS) -lm  -ldl -lrt -lnsl -o newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
Here is the output of gmake:

Code: Select all

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.1'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.1'
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
     724  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
"nl-filesys.c", line 28.9: 1506-236 (W) Macro name FIONREAD has been redefined.
"nl-filesys.c", line 28.9: 1506-358 (I) "FIONREAD" is defined on line 356 of /usr/include/sys/ioctl.h.
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
"nl-sock.c", line 64.9: 1506-236 (W) Macro name FIONREAD has been redefined.
"nl-sock.c", line 64.9: 1506-358 (I) "FIONREAD" is defined on line 356 of /usr/include/sys/ioctl.h.
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -q64 -c -g -O2 -DSUPPORT_UTF8 -DAIX pcre.c
#xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm -ldl -lrt -lsocket -lnsl -o newlisp
OBJECT_MODE=64 xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
#xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.1'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.1'
But this time the test results in a segmentation fault:

Code: Select all

# ./newlisp qa-dot

Testing built-in functions ...
Segmentation fault (core dumped)
I have done the following naive check, whether the newlisp works at all:

Code: Select all

# ./newlisp
newLISP v.10.0.1 on AIX IPv4 UTF-8, execute 'newlisp -h' for more info.

> (define fac (lambda (n) (if (< n 1) 1 (* n (fac (- n 1))))))
(lambda (n)
 (if (< n 1)
  1
  (* n (fac (- n 1)))))
> (fac 10)
3628800
>
It does!

How can I compile a 64-BIT version of newlisp using gcc?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Looks like FIONREAD is already defined in ioctl.h and perhaps we don't have to include stropts.h either.

In the original nl-filesys.c:

Code: Select all

#ifdef SOLARIS
#include <stropts>
#ifndef TRU64
#define FIONREAD I_NREAD
#endif
#endif
change to

Code: Select all

#ifndef AIX
#ifdef SOLARIS
#include <stropts>
#ifndef TRU64
#define FIONREAD I_NREAD
#endif
#endif
#endif
and in nl-sock.c:

Code: Select all

#ifdef SOLARIS
#include <stropts>
#include <sys>
#include <netinet>
#define gethostbyname2(A, B) gethostbyname(A)
#ifndef TRU64
#define FIONREAD I_NREAD
#endif
#endif
change to:

Code: Select all

#ifdef SOLARIS
#ifndef AIX
#include <stropts>
#endif
#include <sys>
#include <netinet>
#define gethostbyname2(A, B) gethostbyname(A)
#ifndef TRU64
#ifndef AIX
#define FIONREAD I_NREAD
#endif
#endif
#endif

This is getting all very messy. Once we have it working I will detangle all the SOLARIS dependencies and make TRU64 and AIX independent flavors. But for now lets get it working first.

The above would only fix the peek and net-peek functiona, which are the only once using that special FIONREAD or I_NREAD flag.

The fact that all of the net-xxx functions fail, tells me that something more fundamental is failing, because most of the network code is completely portable, even between Unix and Win32.

As if some special initialization for the socket-, network- function stack is necessary on AIX?

Perhaps the man pages for the socket() call gives us som info about this. Is this AIX installation very old? From what year is it?

In the makefile put -m32 at the beginning of the CFLAGS line and the beginning of the $(CC) line for gcc. Although you make have a 64-bit machine I want to compile a 32-bit API first. If this is not possible on your machine (It should) then you have have to add the flag -DNEWLISP64 in the CFLAGS line, and you can add -m64 to the gcc CFLAGS and $(CC) lines. -DNEWLISP64 should go in for any compiler when compiling for LP64 model.

ps: note that in all #include's the forum software has stripped the dot-h after the filenames.

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

Although there are still some open issues on AIX platform, I would like
to summarize the necessary steps for compiling newLISP on AIX.

1) Depending on your C compiler you should use one of the following make files:

Code: Select all

--------------------
GNU C Compiler (gcc)
--------------------
#============================ makefile_aix_utf8 (gcc) ==================================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
        nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o


# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX
CC = gcc

default: $(OBJS)
        $(CC) $(OBJS) -lm  -ldl -lrt -lnsl -o newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================

Code: Select all

----------------------
IBM C Compiler (xlc_r)
----------------------
#========================= makefile_aix_utf8 (xlc_r) =================================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
# 
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
        nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o


# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -c -g -O2 -DSUPPORT_UTF8 -DAIX
CC = xlc_r

default: $(OBJS)
        $(CC) $(OBJS) -lm  -ldl -lrt -lnsl -o newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================
and for 64bit version of newLISP

Code: Select all

#======================= makefile_aix_utf8 (xlc_r 64bit) =============================
#
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
# 
#
OBJS = newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o \
        nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o

# use following for UTF-8 support and add nl-utf8.o to the OBJS line
CFLAGS = -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX
CC = xlc_r


default: $(OBJS)
        OBJECT_MODE=64 $(CC) $(OBJS) -lm  -ldl -lrt -lnsl -o newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h makefile_aix_utf8
#=====================================================================================
2) In "newlisp.h" insert the following lines after the line 122.
befor insert:

Code: Select all

  +121  #include <sys/timeb.h>
  +122  #include <sys/types.h>
  +123
  +124  #ifndef SOLARIS
  +125  #ifndef _BSD
  +126  #ifndef MAC_OSX
  +127  #include <malloc.h>
  +128  #endif
  +129  #endif
  +130  #else
  +131  #include <alloca.h>
  +132  #endif
after insert:

Code: Select all

  +121  #include <sys/timeb.h>
  +122  #include <sys/types.h>
  +123
  +124  #ifdef AIX
  +125  #define vasprintf my_vasprintf
  +126  #endif
  +127
  +128  #ifndef SOLARIS
  +129  #ifndef _BSD
  +130  #ifndef MAC_OSX
  +131  #include <malloc.h>
  +132  #endif
  +133  #endif
  +134  #else
  +135  #include <alloca.h>
  +136  #endif 
3) In "newlisp.c" replace

Code: Select all

   +69  #ifdef SOLARIS
   +70  int opsys 4
   +71  #endif
   +72
   +73  #ifdef TRU64
   +74  int opsys += 5;
   +75  #endif
   +76
   +77  #ifdef AIX
   +78  int opsys += 6;
   +79  #endif
with

Code: Select all

   +69  #ifdef SOLARIS
   +70  #ifdef TRU64
   +71  int opsys = 9;
   +72  #endif
   +73  #ifdef AIX
   +74  int opsys = 10;
   +75  #else
   +76  int opsys = 4;
   +77  #endif
   +78  #endif
4) In "nl-filesystem.c" replace

Code: Select all

   +25  #ifdef SOLARIS
   +26  #include <stropts.h>
   +27  #ifndef TRU64
   +28  #define FIONREAD I_NREAD
   +29  #endif
   +30  #endif
with

Code: Select all

   +25  #ifdef SOLARIS
   +26  #include <stropts.h>
   +27  #ifndef TRU64
   +28  #ifndef AIX
   +29  #define FIONREAD I_NREAD
   +30  #endif
   +31  #endif
   +32  #endif
5) In "nl-sock.c" replace

Code: Select all

   +60  #ifdef SOLARIS
   +61  #include <stropts.h>
   +62  #include <sys/conf.h>
   +63  #include <netinet/in_systm.h>
   +64  #define gethostbyname2(A, B) gethostbyname(A)
   +65  #ifndef TRU64
   +66  #define FIONREAD I_NREAD
   +67  #endif
   +68  #endif
with

Code: Select all

   +60  #ifdef SOLARIS
   +61  #include <stropts.h>
   +62  #include <sys/conf.h>
   +63  #include <netinet/in_systm.h>
   +64  #define gethostbyname2(A, B) gethostbyname(A)
   +65  #ifndef TRU64
   +66  #ifndef AIX
   +67  #define FIONREAD I_NREAD
   +68  #endif
   +69  #endif
   +70  #endif 
6) In "Makefile" change all occurrences of make to gmake and insert an entry for AIX make file
after e.g. opensolaris entry:

Code: Select all

  +142  opensolaris:
  +143          gmake -f makefile_opensolaris
  +144
  +145  aix:
  +146          gmake -f makefile_aix_utf8
  +147
  +148  mingw:
  +149          gmake -f makefile_mingw
7) in "build" change all occurrences of make to gmake and insert an entry for AIX

Code: Select all

   +42          SunOS)
   +43                  echo  Discovered SunOS, making for Sparc CPU:
   +44                  gmake solaris
   +45                  exit
   +46                  ;;
   +47          AIX)
   +48                  echo  Discovered AIX:
   +49                  gmake aix
   +50                  exit
   +51                  ;;
   +52          OSF1)
   +53                  echo Discovered Tru64 Unix, please read doc/TRU64BUILD
   +54                  gmake -f gmakefile_tru64
   +55                  exit
   +56                  ;;
And you see here the output of compilation runs on my machine
(AIX 5.3 CPU type:PowerPC_POWER5 1.9 GHz):

Code: Select all

----------------------------
IBM C Compiler (xlc_r 64bit) 
----------------------------
# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX newlisp.c
     728  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-symbol.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-math.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-list.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-liststr.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-string.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-filesys.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-sock.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-web.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX pcre.c
OBJECT_MODE=64 xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
The environment variable OBJECT_MODE=64 is necessary for 64bit version, otherwise you get the following linking error:

Code: Select all

ld: 0711-736 ERROR: Input file newlisp.o:
        XCOFF64 object files are not allowed in 32-bit mode.

Code: Select all

# ./newlisp qa-dot

Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 8458

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-lookup failed nil
UTF-8 upper-case: failed
UTF-8 lower-case: failed

Code: Select all

--------------------
GNU C Compiler (gcc)
--------------------

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
nl-sock.c: In function 'ping':
nl-sock.c:2060: warning: passing argument 6 of 'nrecvfrom' from incompatible pointer type
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'

# ./newlisp qa-dot

Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 5477

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-lookup failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed

Testing contexts as objects and scoping rules ...

total time: 7364

>>>>> TESTING: ./newlisp FINISHED WITH ERRORS:

>>>> net-lookup failed nil
>>>> share failed ERR: not enough memory in function share
called from user defined function QA:unix-test-share
called from user defined function QA:qa
UTF-8 upper-case: failed
UTF-8 lower-case: failed
As you see there are still some failing tests and a compilation warning.
By the way just for your information gcc doesn't accept -m64 on AIX!

Code: Select all

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
gcc -m64 -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX newlisp.c
cc1: error: invalid option '64'
gmake[2]: *** [newlisp.o] Error 1
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
gmake: *** [default] Error 2
Last edited by nitralime on Wed Mar 11, 2009 8:22 pm, edited 1 time in total.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Thanks for summarizing all the steps necessary. I will try to integrate this into the next maintenance or development release and with both makefiles. Separating the AIX and TRU64 flavors from SOLARIS, will make the #ifdef's simpler and less confusing.

The 'net-lookup' function relies on "localhost" beeing defined as 127.0.0.1. May be there is a different setting on your machine?

The UTF-8 upper-case/lower-case failures are probably due to wrong or missing locale settings on your machine. The 'recvfrom' warning using gcc can probably be fixed by casting the last parameter (in or close to line 2059):

Code: Select all

recvfrom(s, packet, PLEN, 0, (struct sockaddr *)&from, (socklen_t *)&fromlen)
Last edited by Lutz on Wed Mar 11, 2009 2:16 pm, edited 1 time in total.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

... may be for now we include only the makefile for the IBM xlc_r compiler, because of the 'share' error. Unless you are able to find out what's going on there. The fact that the same code works fine using the xlc_r compiler, means perhaps that there is a problem with gcc on AIX? Except for Win32 there are no special platform dependencies in this function. Perhaps it is a flags issue with the mmap() function.

Is the xlc_r compiler included on this machine by default? Does everybody using this system have it?

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

After implementing your suggested modification

Code: Select all

recvfrom(s, packet, PLEN, 0, (struct sockaddr *)&from, (socklen_t *)&fromlen)
I get now the following outputs

Code: Select all

------------------------
IBM Compiler xlc_r 64bit
------------------------
# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX newlisp.c
     728  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-symbol.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-math.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-list.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-liststr.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-string.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-filesys.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-sock.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-import.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-xml.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-web.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-matrix.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-debug.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX nl-utf8.c
xlc_r -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX pcre.c
OBJECT_MODE=64 xlc_r newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
and

Code: Select all

--------------------
GNU C Compiler (gcc)
--------------------
# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.2'
gmake -f makefile_aix_utf8
gmake[2]: Entering directory `/tmp/newlisp-10.0.2'
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX newlisp.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-symbol.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-math.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-list.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-liststr.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-string.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-filesys.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-sock.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-import.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-xml.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-web.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-matrix.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-debug.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX nl-utf8.c
gcc -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DSUPPORT_UTF8 -DAIX pcre.c
gcc newlisp.o nl-symbol.o nl-math.o nl-list.o nl-liststr.o nl-string.o nl-filesys.o nl-sock.o nl-import.o nl-xml.o nl-web.o nl-matrix.o nl-debug.o nl-utf8.o pcre.o -lm  -ldl -lrt -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.2'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.2'
It looks pretty good:-)
The failure of "net-lookup" test was because of an additional name for "127.0.0.1" in my /etc/hosts file:

Code: Select all

127.0.0.1               loopback localhost
One can check it directly:

Code: Select all

#./newlisp
newLISP v.10.0.2 64-bit on AIX IPv4 UTF-8, execute 'newlisp -h' for more info.

> (net-lookup "localhost")
"127.0.0.1"
> (net-lookup "127.0.0.1")
"loopback"
>
Regarding "UTF-8 upper-case" and "UTF-8 lower-case" tests it seems
that something is wrong with "upper-case" and "lower-case" functions.
Because I'm just a (new)LISP newbie my findings maybe totally wrong!
It seems that these functions act as identity on characters beyond
ASCII range! (I know it doesn't help you. It is just my observation.)
My locale setting:

Code: Select all

# locale
LANG=en_US
LC_COLLATE="en_US"
LC_CTYPE="en_US"
LC_MONETARY="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_MESSAGES="en_US"
LC_ALL=
And here is the result of my simple experiment using code fragments from qa-dot file:

Code: Select all

# ./newlisp
newLISP v.10.0.2 64-bit on AIX IPv4 UTF-8, execute 'newlisp -h' for more info.

> (= (length (char 937)) 2)
true
> (set-locale "en_US")
("en_US en_US en_US en_US en_US en_US" ".")
> (set 'unicodelist '(913 914 915 916 937 945 946 947 948 969 32 1040 1041 1042 1043 1044 1072 1073 1074 1075 1076 13 10))
(913 914 915 916 937 945 946 947 948 969 32 1040 1041 1042 1043 1044 1072 1073 1074 1075 1076 13 10)
> (set 'utf8str (join (map char unicodelist)))
"ÎÎÎÎÎ©Î±Î²Î³Î´Ï ÐÐÐÐÐабвгд\r\n"
> (= (map char (explode (upper-case utf8str))) '(913 914 915 916 937 913 914 915 916 937 32 1040 1041 1042 1043 1044 1040 1041 1042 1043 1044 13 10))
nil
> (map char (explode (upper-case utf8str)))
(913 914 915 916 937 945 946 947 948 969 32 1040 1041 1042 1043 1044 1072 1073 1074 1075 1076 13 10)
>
Do you have any idea?

Regarding your question about IBM Compiler: It is unfortunately neither free nor included by default!

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Many systems do not contain upper-, lower- case mappings for wide characters which are not from their own locale, even if their compiler offers the necessary towuppper() and towlower() C-functions, that is normal. Your compile will work well for UTF-8 characters otherwise. Only on Mac OS X, UBUNTU Linux and Win32, localized for most of the world, upper- and lower- casing UTF-8 characters beyond the ASCII part works well consistently.

Regarding running 64-bit newLISP, be aware that this doubles memory requirements for many data and operations in newLISP, as all pointers are now 64-bit. On the upside your program runs about 30% faster on average and potentially can use all memory available on your machine. Also, it seems the 64-bit option for gcc on AIX is: -maix64. See here:
http://www.ibm.com/developerworks/aix/l ... u-gnu.html

Although IBM xlc_r is not free and installed by default, I assume that most AIX installations have it. At least from googling around on AIX, I have that impression. I will include both makefiles, but move the gcc one in the util directory with a comment about 'share'.

The next version 10.0.3 will have all your changes integrated and with AIX and TRU64 as flavors independent from SOLARIS. AIX will stay with 10 for the 'sys-info' number. If you want, I can make it available for you earlier to test building on AIX.

nitralime
Posts: 21
Joined: Wed Mar 04, 2009 4:04 pm

Post by nitralime »

I have upgraded my gcc installation to version 4.2.4.
Compiling with option -maix64 works but by calling ./newlisp qa-dot
I get segmentation fault. The 32bit version compiled by gcc suffers
from the same problem as before. I would say that you should
integrate just the xlc_r version into the upcoming maintenance
release. The gcc version can be provided as an alternative to xlc_r
version supplied by a remark about issues that are still open.

Thank you very much for pointing out URL. I came to this guide
as I have struggled with compiling Python on AIX:-)
Nearly the same problems (and a few more) as here.

It would give me great pleasure to support you in your effort to
improve newLISP (at least with regard to its portability).

I will do it (I mean testing newLISP 10.0.3 on AIX).
I can also test it on Solaris (SPARC) if you don't have access to it.
Where can I get it?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Regarding gcc, version 4.3.2 seems to be fine on Linux, on Mac OS X I am using now 4.2.1 previously 4.0.1 and they all seem to be fine. It would be good though to get gcc with newLISP going on AIX too.

I left you a private message, how to pickup a 10.0.3 preview. After it tests well on AIX using "make test", I will do either a development release or wait for the maintenance release until May.

Note, that I only changed to "gmake" in the few places where necessary for AIX. As Mac OS X, Win32 and Linux typically refer to it as "make". I hope I covered all necessary places.

For SOLARIS I am using:
"SunOS carbon 5.8 Generic_117350-25 sun4u sparc SUNW,Ultra-2"

Another user on this board made it available for me accessible via the SSH. All releases get fully tested on that machine.

The user pjotl is porting to TRU64 on a Compaq system, which is very non-standard how it implements certain data types. The AIX port so far has been a pretty standard Unix port, thanks to the ANSI compatible IBM xlc_r compiler.

Locked