Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - csstup

#1
newLISP and the O.S. /
April 24, 2007, 12:39:02 PM
Quote from: "Lutz"
'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.


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


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


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


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


QuoteLast 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):
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:
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.
#2
newLISP and the O.S. / Porting newLISP (AIX)
April 24, 2007, 11:09:33 AM
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 #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 (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!