Compiling on Tru64Unix 4.0f

Started by pjot, May 11, 2005, 09:37:47 AM

Previous topic - Next topic

pjot

#15
The Tru64Unix port is ready.



Peter

newdep

#16
newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> (setq a 1)

1

> (inc 'a -15)

4294967282

> (setq b -16)

-16

> (inc 'b)

-15

> (inc 'b -17)

8589934560

> (inc 'b -255)

1.28849016e+10

>
-- (define? (Cornflakes))

pjot

#17
Strange, there is an issue with negative numbers:


Quote
newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> (set 'a 10)

10

> (inc 'a)

11

> (inc 'a 3)

14

> (inc 'a -1)

4294967309

>

-----------------------



But normal expressions work:
Quote
> (- -1 -5)

4

> (+ 1 -10)

-9

>

-----------------------



I'll look into 'nl-match.c' to see what is going on. Obviously, negative numbers are rounded wrong, though the format works:
Quote
> (format "%x %X" -1 -1)

"ffffffff FFFFFFFF"


As a workaround you can use a float:


Quote
> (set 'b 5)

5

> (inc 'b 0.1)

5.1

> (inc 'b -0.1)

5

> (inc 'b -6.5)

-1.5


Peter

Lutz

#18
I wonder if true64 formats numbers as IEE 754 double, 8 bytes long. The function doing the 'inc' and 'dec' is called incDec() and is in nl-math.c.



But I would check first if things like:



(sub 10 -1) or (add 10 1)



work. It may be that the function getFloat() in newlisp.c is not working right on true64-unix. Did you run qa_dot, testing all integer and float arithemetik?



Lutz

pjot

#19
Hi Lutz,



Well we are in the process of testing, and indeed I was wondering if there was such a thing as a testsuite.



Here the results of the 'div' and 'add':
Quote
newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> (sub 10 -1)

-4294967285

> (add 10 1)

11

>


So it seems to be something with negative numbers. A '-1' should be 0xFFFFFFFF right? Probably on Tru64 this is bigger.



If I run the 'qa_dot' program, there is a crash after the 'append':
Quote
pamela_vaspadm> newlisp qa_dot



Testing built-in functions ...



!              !=             $              %              &

*              +              -              /              <

<<             <=             =              >              >=

>>             NaN?           ^              abs            acos

add            address        amb            and            append

Segmentation fault (core dumped)


To avoid this, I have commented out the following functions:

-(test-array-list) which causes this crash.

-(test-dotimes , aList) which blocked newLisp

-(test-pmt) which gave a FLOAT error





If I run again, this is the result:
Quote
pamela_vaspadm> newlisp qa_dot



Testing built-in functions ...



!              !=             $              %              &

*              +              -              /              <

<<             <=             =              >              >=

>>             NaN?           ^              abs            acos

add            address        amb            and            append

apply          args           array          array-list     array?

asin           assoc          atan           atan2          atom?

base64-dec     base64-enc     begin          beta           betai

binomial       case           catch          ceil           change-dir

char           chop           close          command-line   cond

cons           constant       context        context?       copy-file

cos            count          cpymem         crit-chi2      crit-z

current-line   date           date-value     debug          dec

def-new        define         define-macro   delete         delete-file

device         difference     directory      directory?     div

do-until       do-while       dolist         dotimes        dotree

dump           dup            empty?         encrypt        ends-with

env            error-event    error-number   error-text     eval

eval-string    exec           exit           exp            expand

explode        factor         fft            file-info      file?

filter         find           first          flat           float

float?         floor          flt            for            fork

format         fv             gammai         gammaln        get-char

get-float      get-int        get-integer    get-string     get-url

global         if             ifft           import         inc

index          int            integer        integer?       intersect

invert         irr            join           lambda?        last

legal?         length         let            letn           list

list?          load           log            lookup         lower-case

macro?         main-args      make-dir       map            match

max            member         min            mod            mul

multiply       name           net-accept     net-close      net-connect

net-error      net-listen     net-local      net-lookup     net-peek

net-peer       net-receive    net-receive-from net-receive-udp net-select

net-send       net-send-to    net-send-udp   net-service    net-sessions

new            normal         not            now            nper

npv            nth            nth-set        open           or

pack           parse          pipe           pack           parse          pipe           pmt            pop

post-url       pow            pretty-print   primitive?     print

println        prob-chi2      prob-z         process        println        prob-chi2      prob-z         process        push  

put-url        pv             quote          quote?         rand

random         read-buffer    read-char      read-file      read-key

read-line      ref            regex          remove-dir     rename-file

replace        replace-assoc  reset          rest           reverse

rotate         save           search         seed           seek

select         semaphore      sequence       series         set

set!           set-locale     set-nth        setq           share

signal         silent         sin            sleep          --- sleep duration: 1000 ---

slice

sort           source         sqrt           starts-with    string

string?        sub            swap           sym            symbol

symbol?        symbols        sys-error      sys-info       tan

throw          throw-error    time           time-of-day    timer

trace          trace-highlight transpose      trim           unique

unless         unpack         until          upper-case     wait-pid

while          write-buffer   write-char     write-file     write-line

xml-error      xml-parse      xml-type-tags  |              ~





Testing contexts as objects and scoping rules ...





TESTING FINISHED WITH ERRORS:



>>>> / failed nil

>>>> < failed nil

>>>> <= failed nil

>>>> > failed nil

>>>> NaN? failed nil

>>>> abs failed nil

>>>> array-list failed nil

>>>> array? failed nil

>>>> binomial failed nil

>>>> dotimes failed nil

>>>> exec failed nil

>>>> fv failed nil

>>>> int failed nil

>>>> integer failed nil

>>>> net-receive-udp failed nil

>>>> net-send-udp failed nil

>>>> npv failed nil

>>>> pmt failed nil

>>>> semaphore failed nil

>>>> share failed nil



newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> ring...


Most of these failed tests use negative numbers or floats.

pjot

#20
In this situation:



newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.

> (set 'a 5)
5
> (inc 'a 1)
6
> (inc 'a -1)
4294967301


The function 'CELL * getFloat(CELL * params, double * floatNumber)' determines the '-1' wrongly.



This is caused by the fact that "cell = evaluateExpression(params);" determines the cell->type as a CELL_FLOAT for the number '-1'.



So the cause seems to be in the routine 'evaluateExpression'. Or is the cell->type previously determined by a parser? Continuing...

Lutz

#21
Looks like for doing this true64 port we need to look in the Compaq 'C' compiler documentation to find out about floating point formats etc. Can you compile types.c again and show the output? Perhaps we missed something there.



Lutz

pjot

#22
I found a compiler switch '-ieee' to ensure the IEEE754 compatibility, but the resulting newLisp binary delivers the same results with 'qa_dot'.



Compiled the 'types.c' again:


Quote
pamela_vaspadm> cc -o types -ieee -taso types.c

pamela_vaspadm> ./types

type      bytes

---------------

char      1

char *    8

short int 2

int       4

long      8

long long 8

float     4

double    8

wchar_t   4

jmp_buf   672


I have the strong feeling it is an issue with the negative sign '-' on a number...



Hacked the routine 'CELL * incDec(CELL * params, int type)' to print info about variables:


Quote
newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> (set 'a 5)

5

> (inc 'a 1)

adjust: 1.000000

type: 1

6

> (inc 'a -1.0)

adjust: -1.000000

type: 1

5

> (inc 'a -1)

adjust: 4294967295.000000

type: 1

4294967300

pjot

#23
Are you using INT's or LONG's for normal numbers? Since on the alpha the LONG is twice as big as an INT.



While on X86 both the INT and also the LONG contain 4 bytes.



So a '-1' as a long will be 0xFFFFFFFFFFFFFFFF instead of 0xFFFFFFFF.



If Alpha sees 0xFFFFFFFF it will treat this as a regular number which is 4294967295.



Jep that's it. Any idea what I need to change in the source?

Lutz

#24
There are no 'long's in newlisp.c but in several other files, all these could be replaced with 'int', because int and long are the same for 32bit GCC. Its mostly in older code from Win16 times, I haven't touched for a longer time. You would have to go through all the files for this. I could do this, but not before the weekend.



But there is a bigger problem with pcre.c there are tons of 'long int' in it and I have no idea if that code was written with 'long int' == 8byte in mind.  But you might just try and see ;)



Lutz

pjot

#25
Well, you are wrong... :-)



At line 2872 in 'newlisp.c'  you cast to long:
Quote
*floatNumber = (long)cell->contents;}


I have changed the (long) to (int), and guess what? The (inc 'a -1) works now.


Quote
*floatNumber = (int)cell->contents;}


Tonight I will test more. Probably all LONGs should be switched to INTs.



Could you also add the '-ieee' compiler switch to 'makefile_tru64'?

Lutz

#26
That's the one in getFloat() doing the conversion. There are lots of (long) casts in nl-math.c too, you will see. Lets hope that all this streightens out the port to tru64.



Lutz

pjot

#27
Well, I can try again to compile with



-protect_headers default -xtaso_short


compile flags, which will force a 32-bit compilation. That denifitively should solve the 8byte/4byte stuff.



But it would ne nice to run in 64-bit mode!

pjot

#28
Just ran the 'qa_dot' again, the result is much better:


Quote
Testing contexts as objects and scoping rules ...





TESTING FINISHED WITH ERRORS:



>>>> array-list failed nil

>>>> array? failed nil

>>>> binomial failed nil

>>>> exec failed nil

>>>> fv failed nil

>>>> int failed nil

>>>> integer failed nil

>>>> net-receive-udp failed nil

>>>> net-send-udp failed nil

>>>> npv failed nil

>>>> semaphore failed nil

>>>> share failed nil



newLISP v.8.5.8 on Tru64Unix, execute 'newlisp -h' for more info.



> ring...


So 12 functions left, instead of the 23 yesterday, which means that 11 functions have been solved by changing that cast to (int).



I will run through the other sourcefiles of newLisp tonight to see what is going on.



Peter

Lutz

#29
Looking through some of the array functions I cannot see anything obvious. The good news is the "ring ..." at the end, which is from testing the timer functions, so signals seem to work.



I want to do a development release on the weekend. If there is anything you want me to merge in just tell me, where I can get it like you did before.



Lutz