Porting newLISP (AIX)

Started by csstup, April 24, 2007, 11:09:33 AM

Previous topic - Next topic

nitralime

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

by
#if !defined  (TRU64) || (AIX)

Here is the output of "gmake"


# 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:


# ./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

#16
Compiling newlisp using xlc_r also works smoothly!
# 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
# ./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:
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:
# 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:
# ./newlisp qa-dot

Testing built-in functions ...
Segmentation fault (core dumped)

I have done the following naive check, whether the newlisp works at 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

#17
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:


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


change to


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


and in nl-sock.c:


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


change to:


#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

#18
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:


--------------------
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
#=====================================================================================


----------------------
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


#======================= 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:
 +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:
 +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
  +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
  +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
  +25  #ifdef SOLARIS
   +26  #include <stropts.h>
   +27  #ifndef TRU64
   +28  #define FIONREAD I_NREAD
   +29  #endif
   +30  #endif

with
  +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
  +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
  +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:
 +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
  +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):


----------------------------
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:
ld: 0711-736 ERROR: Input file newlisp.o:
        XCOFF64 object files are not allowed in 32-bit mode.


# ./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


--------------------
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!
# 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

Lutz

#19
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):


recvfrom(s, packet, PLEN, 0, (struct sockaddr *)&from, (socklen_t *)&fromlen)

Lutz

#20
... 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

#21
After implementing your suggested modification
recvfrom(s, packet, PLEN, 0, (struct sockaddr *)&from, (socklen_t *)&fromlen)
I get now the following outputs
------------------------
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
--------------------
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:
127.0.0.1               loopback localhost
One can check it directly:
#./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:
# 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:
# ./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)))
"ÎÎÎÎÎ©Î±Î²Î³Î´Ï ÐÐÐÐÐабвгдrn"
> (= (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

#22
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/library/au-gnu.html">http://www.ibm.com/developerworks/aix/l ... u-gnu.html">http://www.ibm.com/developerworks/aix/library/au-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

#23
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

#24
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.

nitralime

#25
Just for your info
# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.3'
gmake -f makefile_aix_utf8_xlc
gmake[2]: Entering directory `/tmp/newlisp-10.0.3'
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  newlisp.c
     729  1500-010: (W) WARNING in main: Infinite loop.  Program may not stop.
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  nl-symbol.c
"nl-symbol.c", line 131.7: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  nl-math.c
"nl-math.c", line 492.13: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-math.c", line 493.16: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-math.c", line 2156.10: 1506-068 (W) Operation between types "struct {...}**" and "int" is not allowed.
"nl-math.c", line 2157.7: 1506-068 (W) Operation between types "int*" and "int" is not allowed.
"nl-math.c", line 2158.7: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-math.c", line 2358.8: 1506-068 (W) Operation between types "double*" and "int" is not allowed.
"nl-math.c", line 2359.7: 1506-068 (W) Operation between types "double*" and "int" is not allowed.
"nl-math.c", line 2360.15: 1506-068 (W) Operation between types "double*" and "int" is not allowed.
"nl-math.c", line 2365.11: 1506-068 (W) Operation between types "double*" and "int" is not allowed.
"nl-math.c", line 2366.11: 1506-068 (W) Operation between types "double*" and "int" is not allowed.
"nl-math.c", line 2398.7: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  nl-list.c
"nl-list.c", line 1377.15: 1506-068 (W) Operation between types "unsigned long*" and "int" is not allowed.
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 2012.25: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  nl-sock.c
"nl-sock.c", line 1947.47: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
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 342.10: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 343.6: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 344.7: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 345.6: 1506-068 (W) Operation between types "char*" and "int" is not allowed.
"nl-web.c", line 1274.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 -lnsl -o newlisp
ld: 0711-317 ERROR: Undefined symbol: .alloca
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.3'
gmake[1]: *** [aix] Error 2
gmake[1]: Leaving directory `/tmp/newlisp-10.0.3'
gmake: *** [default] Error 2

Lutz

#26
It lost the include of alloca.h. I uploaded a new newlisp-10.0.3.tgz in your place with a changed newlisp.h.

nitralime

#27
I would change the following line
# makefile for newLISP v. 10.x.x on SOLARIS woth UTF-8 support on Sparc CPU
in both make files to
# makefile for newLISP v. 10.x.x on AIX with UTF-8 support on PowerPC CPU
and do the following renaming in order to be consistent with the entry in Makefile
mv makefile_aixLP64_utf8_xlc makefile_aix_utf8_xlcLP64
and then change  
$(OBJS): primes.h protos.h makefile_aixLP64_utf8_xlc
in makefile_aix_utf8_xlcLP64 to
$(OBJS): primes.h protos.h makefile_aix_utf8_xlcLP64
Here is the output of compilation runs that looks pretty good:-)
# gmake aixLP64
gmake -f makefile_aix_utf8_xlcLP64
gmake[1]: Entering directory `/tmp/newlisp-10.0.3'
xlc_r  -q64 -c -g -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX  newlisp.c
     729  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[1]: Leaving directory `/tmp/newlisp-10.0.3'
# ./newlisp qa-dot

Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 5700

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

UTF-8 upper-case: failed
UTF-8 lower-case: failed

# gmake
./build

Discovered AIX:
gmake[1]: Entering directory `/tmp/newlisp-10.0.3'
gmake -f makefile_aix_utf8_xlc
gmake[2]: Entering directory `/tmp/newlisp-10.0.3'
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  newlisp.c
     729  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
xlc_r  -c -g -O2 -DSUPPORT_UTF8 -DAIX  nl-sock.c
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 -lnsl -o newlisp
gmake[2]: Leaving directory `/tmp/newlisp-10.0.3'
gmake[1]: Leaving directory `/tmp/newlisp-10.0.3'
# ./newlisp qa-dot

Testing built-in functions ...

Testing contexts as objects and scoping rules ...

total time: 5522

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

>>>> 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: 7435

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

>>>> 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 the problem with "share" exists also for xlc_r in 32bit mode.

I would make 64bit the default choice for compilation on AIX for the time being!

Do you have any idea where  we should begin to fix this problem?

How critical is it?

Lutz

#28
I changed to this:


aix64:
    gmake -f makefile_aixLP64_utf8_xlc


in Makefile, as all makefile_xxx put the memory model-id: LP64 after the platform name. I also changed from Sparc to PowerPC in the aix makefiles.



Memory mapping is used in 'share' and in the Cilk multiprocessing API consisting of the functions 'spawn, 'sync' and 'abort'. The Cilk API is an extreme convenient standard for doing multiprocessing. I would love this to work.



To fix this one would have to study the docs/man pages for mmap() and munmap(). The mmap() call takes a load of different flags (modes) which may be platform sensitive and memory-model sensitive. I am pretty confident, that with a little bit of reading and experimentation this can be fixed for xlc_r 32-bit.



Another important parameter in mmap() is the pagesize. In newlisp.c the pagesize is aquired in line 585 with a getpagesize() call.



Here is a little test program to check memory mapping (used for sharing memory) on your machine:


~> cat test-mmap.c
#include <stdio>
#include <sys>

int main(int argc, char ** argv)
{
void * address;
int pagesize;

pagesize = getpagesize();

printf("pagesize: %dn", pagesize);

address = mmap( 0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);

printf("address:0x%Xn", address);
}


~> gcc -m32 test-mmap.c -o test-mmap
~> ./test-mmap
pagesize: 4096
address:0x8000
~>


You could try different flags and the xlc_r compiler with 32-bit memory model. I have this test program included in the distribution as util/test-mmap.c



Once mmap() works the Cilk API in newLISP is tested using qa-cilk, it launches 41 processes and gives memory mapping a good workout.



Another newlisp-10.0.3.tgz is in the usual place. The only changes I made are in the makefiles and the new test-mmap.c in util/. Thanks for the help! Looks like we are getting there :)

nitralime

#29
Thank you for implementing the modifications!

I have tested the new version and it works fine. I have also tried the 64bit version of gcc.

It also works fine. Last time I have forgotten to add the option -DNEWLISP64 to CFLAGS and

this was the reason why I got the segmentation fault! That means that gcc is on a par with xlc!

For the sake of completeness I append the make file that I used for gcc (64bit):
#================== makefile_aixLP64_utf8_gcc (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 = -maix64 -Wall -pedantic -fno-strict-aliasing -Wno-uninitialized -Wno-long-long -c -O2 -DNEWLISP64 -DSUPPORT_UTF8 -DAIX
CC = gcc

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

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

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

And here is the 32bit version for gcc (to facilitate Copy&Paste if necessary):
#==================== makefile_aix_utf8_gcc (32bit)============================
# 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_gcc
#
#==============================================================================

I would suggest that we modify the Makefile such that both compiler types can be used:
...
aix64:
        gmake -f makefile_aixLP64_utf8_xlc

aix:
        gmake -f makefile_aix_utf8_xlc

aix64_gcc:
        gmake -f makefile_aixLP64_utf8_gcc

aix_gcc:
        gmake -f makefile_aix_utf8_gcc
...

or something like this.

Here is the output of test-map for both gcc and xlc (64bit/32bit):
# gcc -maix64 test-mmap.c -o test-mmap
# ./test-mmap
pagesize: 4096
address:0x0
# xlc -q64 test-mmap.c -o test-mmap
# ./test-mmap
pagesize: 4096
address:0x0
# gcc test-mmap.c -o test-mmap
# ./test-mmap
pagesize: 4096
address:0x30000000
# xlc  test-mmap.c -o test-mmap
# ./test-mmap
pagesize: 4096
address:0x30000000

I agree with you on Cilk API. I find the language features regarding concurrency

and distribution very important from practical point of view (we live in the world

of multicore systems and cocurrency is omnipresent!!)

I have appended the AIX manpage for mmap. Maye it helps!  
             Technical Reference: Base Operating System and Extensions, Volume 1

mmap or mmap64 Subroutine

Purpose

       Maps a file-system object into virtual memory.

Library

       Standard C library (libc.a)

Syntax

       #include <sys/types.h>
       #include <sys/mman.h>

       void *mmap (addr, len, prot, flags, fildes, off)

       void * addr;

       size_t  len;

       int  prot,  flags,  fildes;

       off_t  off;

       void *mmap64 (addr, len, prot, flags, fildes, off)

       void * addr;

       size_t  len;

       int  prot,  flags,  fildes;

       off64_t  off;

Description
       Attention: A file-system object should not be simultaneously mapped using both the mmap
       and shmat subroutines. Unexpected results may occur when references are made beyond the
       end of the object.

       The mmap subroutine creates a new mapped file or anonymous memory region by establishing
       a mapping between a process-address space and a file-system object. Care needs to be
       taken when using the mmap subroutine if the program attempts to map itself. If the page
       containing executing instructions is currently referenced as data through an mmap
       mapping, the program will hang. Use the -H4096 binder option, and that will put the
       executable text on page boundaries. Then reset the file that contains the executable
       material, and view via an mmap mapping.

       A region created by the mmap subroutine cannot be used as the buffer for read or write
       operations that involve a device. Similarly, an mmap region cannot be used as the buffer
       for operations that require either a pin or xmattach operation on the buffer.

       Modifications to a file-system object are seen consistently, whether accessed from a
       mapped file region or from the read or write subroutine.

       Child processes inherit all mapped regions from the parent process when the fork
       subroutine is called. The child process also inherits the same sharing and protection

       attributes for these mapped regions. A successful call to any exec subroutine will unmap
       all mapped regions created with the mmap subroutine.

       The mmap64 subroutine is identical to the mmap subroutine except that the starting
       offset for the file mapping is specified as a 64-bit value. This permits file mappings
       which start beyond OFF_MAX.

       In the large file enabled programming environment, mmap is redefined to be mmap64.

       If the application has requested SPEC1170 compliant behavior then the st_atime field of
       the mapped file is marked for update upon successful completion of the mmap call.

       If the application has requested SPEC1170 compliant behavior then the st_ctime and
       st_mtime fields of a file that is mapped with MAP_SHARED and PROT_WRITE are marked for
       update at the next call to msync subroutine or munmap subroutine if the file has been
       modified.

Parameters

       addr
            Specifies the starting address of the memory region to be mapped. When the
            MAP_FIXED flag is specified, this address must be a multiple of the page size
            returned by the sysconf subroutine using the _SC_PAGE_SIZE value for the Name
            parameter. A region is never placed at address zero, or at an address where it
            would overlap an existing region.
       len
            Specifies the length, in bytes, of the memory region to be mapped. The system
            performs mapping operations over whole pages only. If the len parameter is not a
            multiple of the page size, the system will include in any mapping operation the
            address range between the end of the region and the end of the page containing the
            end of the region.
       prot
            Specifies the access permissions for the mapped region. The sys/mman.h file defines
            the following access options:
              PROT_READ
                   Region can be read.
              PROT_WRITE
                   Region can be written.
              PROT_EXEC
                   Region can be executed.
              PROT_NONE
                   Region cannot be accessed.
            The prot parameter can be the PROT_NONE flag, or any combination of the PROT_READ
            flag, PROT_WRITE flag, and PROT_EXEC flag logically ORed together. If the PROT_NONE
            flag is not specified, access permissions may be granted to the region in addition
            to those explicitly requested. However, write access will not be granted unless the
            PROT_WRITE flag is specified. Note: The operating system generates a SIGSEGV signal
            if a program attempts an access that exceeds the access permission given to a
            memory region. For example, if the PROT_WRITE flag is not specified and a program
            attempts a write access, a SIGSEGV signal results.

            If the region is a mapped file that was mapped with the MAP_SHARED flag, the mmap
            subroutine grants read or execute access permission only if the file descriptor
            used to map the file was opened for reading. It grants write access permission only
            if the file descriptor was opened for writing.

            If the region is a mapped file that was mapped with the MAP_PRIVATE flag, the mmap
            subroutine grants read, write, or execute access permission only if the file
            descriptor used to map the file was opened for reading. If the region is an

            anonymous memory region, the mmap subroutine grants all requested access
            permissions.
       fildes
            Specifies the file descriptor of the file-system object or of the shared memory
            object to be mapped. If the MAP_ANONYMOUS flag is set, the fildes parameter must be
            -1. After the successful completion of the mmap subroutine, the file or the shared
            memory object specified by the fildes parameter can be closed without affecting the
            mapped region or the contents of the mapped file. Each mapped region creates a file
            reference, similar to an open file descriptor, which prevents the file data from
            being deallocated. Note: The mmap subroutine supports the mapping of shared memory
            object and regular files only. An mmap call that specifies a file descriptor for a
            special file fails, returning the ENODEV error code. An example of a file
            descriptor for a special file is one that might be used for mapping either I/O or
            device memory.
       off
            Specifies the file byte offset at which the mapping starts. This offset must be a
            multiple of the page size returned by the sysconf subroutine using the
            _SC_PAGE_SIZE value for the Name parameter.
       flags
            Specifies attributes of the mapped region. Values for the flags parameter are
            constructed by a bitwise-inclusive ORing of values from the following list of
            symbolic names defined in the sys/mman.h file:
              MAP_FILE
                   Specifies the creation of a new mapped file region by mapping the file
                   associated with the fildes file descriptor. The mapped region can extend
                   beyond the end of the file, both at the time when the mmap subroutine is
                   called and while the mapping persists. This situation could occur if a file
                   with no contents was created just before the call to the mmap subroutine, or
                   if a file was later truncated. However, references to whole pages following
                   the end of the file result in the delivery of a SIGBUS signal. Only one of
                   the MAP_FILE and MAP_ANONYMOUS flags must be specified with the mmap
                   subroutine.
              MAP_ANONYMOUS
                   Specifies the creation of a new, anonymous memory region that is initialized
                   to all zeros. This memory region can be shared only with the descendants of
                   the current process. When using this flag, the fildes parameter must be -1.
                   Only one of the MAP_FILE and MAP_ANONYMOUS flags must be specified with the
                   mmap subroutine.
              MAP_ VARIABLE
                   Specifies that the system select an address for the new memory region if the
                   new memory region cannot be mapped at the address specified by the addr
                   parameter, or if the addr parameter is null. Only one of the MAP_VARIABLE
                   and MAP_FIXED flags must be specified with the mmap subroutine.
              MAP_FIXED
                   Specifies that the mapped region be placed exactly at the address specified
                   by the addr parameter. If the application has requested SPEC1170 complaint
                   behavior and the mmap request is successful, the mapping replaces any
                   previous mappings for the process' pages in the specified range. If the
                   application has not requested SPEC1170 compliant behavior and a previous
                   mapping exists in the range then the request fails. Only one of the
                   MAP_VARIABLE and MAP_FIXED flags must be specified with the mmap subroutine.
              MAP_SHARED
                   When the MAP_SHARED flag is set, modifications to the mapped memory region
                   will be visible to other processes that have mapped the same region using
                   this flag. If the region is a mapped file region, modifications to the
                   region will be written to the file.

                   You can specify only one of the MAP_SHARED or MAP_PRIVATE flags with the
                   mmap subroutine. MAP_PRIVATE is the default setting when neither flag is

                   specified unless you request SPEC1170 compliant behavior. In this case, you
                   must choose either MAP_SHARED or MAP_PRIVATE.
              MAP_PRIVATE
                   When the MAP_PRIVATE flag is specified, modifications to the mapped region
                   by the calling process are not visible to other processes that have mapped
                   the same region. If the region is a mapped file region, modifications to the
                   region are not written to the file.

                   If this flag is specified, the initial write reference to an object page
                   creates a private copy of that page and redirects the mapping to the copy.
                   Until then, modifications to the page by processes that have mapped the same
                   region with the MAP_SHARED flag are visible.

                   You can specify only one of the MAP_SHARED or MAP_PRIVATE flags with the
                   mmap subroutine. MAP_PRIVATE is the default setting when neither flag is
                   specified unless you request SPEC1170 compliant behavior. In this case, you
                   must choose either MAP_SHARED or MAP_PRIVATE.
Return Values

       If successful, the mmap subroutine returns the address at which the mapping was placed.
       Otherwise, it returns -1 and sets the errno global variable to indicate the error.

Error Codes

       Under the following conditions, the mmap subroutine fails and sets the errno global
       variable to:
       EACCES
            The file referred to by the fildes parameter is not open for read access, or the
            file is not open for write access and the PROT_WRITE flag was specified for a
            MAP_SHARED mapping operation. Or, the file to be mapped has enforced locking
            enabled and the file is currently locked.
       EAGAIN
            The fildes parameter refers to a device that has already been mapped.
       EBADF
            The fildes parameter is not a valid file descriptor, or the MAP_ANONYMOUS flag was
            set and the fildes parameter is not -1.
       EFBIG
            The mapping requested extends beyond the maximum file size associated with fildes.
       EINVAL
            The flags or prot parameter is invalid, or the addr parameter or off parameter is
            not a multiple of the page size returned by the sysconf subroutine using the
            _SC_PAGE_SIZE value for the Name parameter.
       EINVAL
            The application has requested SPEC1170 compliant behavior and the value of flags is
            invalid (neither MAP_PRIVATE nor MAP_SHARED is set).
       EMFILE
            The application has requested SPEC1170 compliant behavior and the number of mapped
            regions would excedd and implementation-dependent limit (per process or per
            system).
       ENODEV
            The fildes parameter refers to an object that cannot be mapped, such as a terminal.
       ENOMEM
            There is not enough address space to map len bytes, or the application has not
            requested Single UNIX Specification, Version 2 compliant behavior and the MAP_FIXED
            flag was set and part of the address-space range (addr, addr+len) is already
            allocated.
       ENXIO
            The addresses specified by the range (off, off+len) are invalid for the fildes
            parameter.

       EOVERFLOW
            The mapping requested extends beyond the offset maximum for the file description
            associated with fildes.

Related Information

       The exec (exec: execl, execle, execlp, execv, execve, execvp, or exect Subroutine)
       subroutine, fork (fork, f_fork, or vfork Subroutine) subroutine, munmap (munmap
       Subroutine) subroutine, read subroutine, shm_open subroutine, shm_unlink subroutine,
       shmat subroutine, sysconf subroutine, write subroutine.

       The pin kernel service, xmattach kernel service.

       List of Memory Manipulation Services, List of Memory Mapping Services, Understanding
       Memory Mapping in AIX 5L Version 5.3 General Programming Concepts: Writing and Debugging
       Programs.