Problem
The following program, when compiled on SCO UNIX System V/386
Release 3.2 Version 4.2 (3.2v4.2), runs correctly on SCO UNIX
Version 4.2 and SCO OpenServer 5.0.0 and 5.0.2. However, when
run on SCO OpenServer 5.0.4, the floating point value comparison
in this program fails.If the code is *compiled* and executed on OpenServer 5.0.4, then it will work correctly.
Using SCO XENIX/DOS Cross Development compiler 'xcc' on OpenServer 5.0.0, 5.0.2, 5.0.4 will also generate a failing binary.
<---------------------------CUT HERE---------------------------------------->/*
cc scotest.c -lm -o scotestThis program will fail if:(a) compiled on 3.2v4.2 and run on v5.0.4 (b) compiled with the XENIX/DOS Cross compiler 'xcc' on v5.0.[024] and run on v5.0.4
This program will succeed if:(a) compiled on 3.2v4.2 and run on v5.0.[02] (b) re-compiled on any release of SCO OpenServer 5.0.[024]
*/#include <stdio.h>
#include <math.h>double mspower(x,y)
double x,y;
{
double d,ip;double floor(),ceil();d=(pow(x,y)+0.00000001)*1000000.0;#if defined (DEBUG)
printf(" pt1: (%lf)\n",d);
#endif
ip=(d>0.0)?floor(d):ceil(d);#if defined (DEBUG)
printf(" pt2: (%lf)\n",ip);
#endifreturn(ip/1000000.0);
}main()
{
double test_val;test_val=10.0; if ( test_val != mspower((double) 10, (double) 1)) printf(" Values are not equal!\n"); else printf(" Values are equal!\n");
#if defined (DEBUG)
printf(" Value returned by POW is (%.15f)\n",
mspower((double) 10, (double) 1));
#endif
}<---------------------------CUT HERE---------------------------------------->NOTES: This problem is fixed in SCO OpenServer Release 5.0.6. Solution
This behavior was introduced by the changes made to the floating-point driver in SCO OpenServer 5.0.4. Replacing the /etc/conf/pack.d/fp/Driver.o on 5.0.4 with the previous driver from 5.0.2 will result in both the version 4.2 and 5.0.4 binaries working successfully.
Another possible workaround is to patch the floating-point driver in SCO OpenServer 5.0.4 so that it's initialized in the same way that it was in previous releases of SCO OpenServer 5. In order to patch the driver in this way, do the following:
1. First, make a backup of the /etc/conf/pack.d/fp/Driver.o file.
2. Then patch the fp/Driver.o as follows:
# /etc/_fst -w /etc/conf/pack.d/fp/Driver.o
* finitstate/X
finitstate: 0x137f
* finitstate/W 0x1272
finitstate: 0x137f= 0x1272 (this confirms that the current
value of 0x137f has now been
changed to 0x1272)
* $qNOTE: On certain pre-release versions of OpenServer 5.0.4, finitstate/X may return the value 0x1372 instead of 0x137f, but this technical article will still work correctly.
3. Relink the UNIX kernel and reboot the system.