From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,cda77c61b7cc7099,start X-Google-Attributes: gidf7344,public X-Google-Thread: f73f6,cda77c61b7cc7099,start X-Google-Attributes: gidf73f6,public X-Google-Thread: fc7fa,cda77c61b7cc7099,start X-Google-Attributes: gidfc7fa,public From: Ertugrul Akmese Subject: Problems using IEEE and Vax Floats on same executable Date: 1999/04/15 Message-ID: <371653C2.F2A00F03@io.com> X-Deja-AN: 466866007 Content-Transfer-Encoding: 7bit Sender: ertugrul@mci173.aspentec.com Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@io.com X-Trace: hiram.io.com 924210407 9391 206.24.77.173 (15 Apr 1999 21:06:47 GMT) Organization: Illuminati Online Mime-Version: 1.0 NNTP-Posting-Date: 15 Apr 1999 21:06:47 GMT Newsgroups: comp.os.vms,vmsnet.internals,comp.sys.vms I am using IEEE floating points on this executable, but one of the Third party libraries that I use requires me to send VAX floats. So I convert the IEEE floats to VAX floats before I pass floats to this library. This scheme is being used in many different applications I implemented and it works. However this particular API caused some problems. I spoke to the vendor, they confirmed the problem, and we're trying to find out what is wrong. I use two libraries. First one is also compiled with /IEEE option just like my files. I wrote a simple test program to duplicate this problem. I have tested this on OVMS/AXP v6.2 and v7.1 they all produce same results. The problem is: high and low order words are swapped when entered to the function compiled without IEEE. If I don't use any conversion (assuming that RTL is trying to handle the conversion itself) Then the value I get inside the function is 1/4 of the original value I passed. I cannot pass pointers since I cannot modify this third party API. There must be some kind of option to use to prevent this from happening (some other APIs that requires vax floats works in the same setting that I'm trying to do here, of course I don't know how they do it...) I'm sending the test program that duplicates the problem below. Sorry about long listings and ravings here, I just need some help to be able to understand the problem. Thanks a lot, any help would be greatly appreciated. Ertugrul Akmese ---- start test5.c ---- This is the main routine which uses IEEE floats #include #include #include #include int testsub(float); main() { int st,err; float fval=50.0; float ieeefval=50.0; printf("main: Initial (%e:%#x)\n\n", fval, *((int*)&fval)); err = testsub((float)fval); /*try it without conversion */ st=CVT$CONVERT_FLOAT(&ieeefval, CVT$K_IEEE_S, &fval, CVT$K_VAX_F, CVT$M_VAX_ROUNDING); printf("main: ieeefval:%e:%#x fval:%e:%#x\n\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*)&fval)); /* printout result of conversion */ err = testsub((float)fval); /* try it with converted values */ } ----- end test5.c ----- ----- start testsub.c ---- #include #include #include #include #include int testsub(float value) { float ieeefval=0.0; float fval=0.0; int st=0; printf(" Initial: testsub(%e:%#x)\n", value, *((int*)&value)); /* show passed float at the start */ fval=value; st=CVT$CONVERT_FLOAT(&fval, CVT$K_VAX_F, &ieeefval, CVT$K_IEEE_S, CVT$M_ROUND_TO_NEAREST); printf(" = : ieeefval:%e:%#x fval:%e:%#x\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*)&fval)); memcpy((void*)&fval, (void*)&value, sizeof(float)); st=CVT$CONVERT_FLOAT(&fval, CVT$K_VAX_F, &ieeefval, CVT$K_IEEE_S, CVT$M_ROUND_TO_NEAREST); printf(" memcpy : ieeefval:%e:%#x fval:%e:%#x\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*)&fval)); printf(" Exiting: testsub(%e:%#x)\n\n", value, *((int*)&value)); /* show it again */ return 0; } ---- end testsub.c ---- *************** outputs ************* heres the compile and link options I used. I also experinmented with /ansi vs /standard=VAXC etc /prefix=all vs /noprefix /float=g_float vs /nog_float I used debugger and exa/hex to check the values to make sure the problem are not related to displaying them on screen ALPHA1$ cc testsub.c /debug=all/noopt/list/float=g_float/ansi/extern=strict ALPHA1$ CC TEST5.C/list/noopt/debug=(all)/float=ieee/ieee_mode=DENORM_RES/ansi/exter=strict ALPHA1$ LINK /ALPHA /debug TEST5.OBJ, testsub.obj ALPHA1$ r test5 main: Initial (5.000000e+01:0x42480000) {{{ this is the part to see how it behaves without floating point conversion }}} Initial: testsub(1.250000e+01:0x4248) {{{ as you can see 0x42480000 becomes 0x00004248 as soon as I enter function}}} = : ieeefval:0.000000e+00:0x41480000 fval:1.250000e+01:0x4248 memcpy : ieeefval:0.000000e+00:0x41480000 fval:1.250000e+01:0x4248 {{{ using assignment and memcpy produces same results }}} Exiting: testsub(1.250000e+01:0x4248) main: ieeefval:5.000000e+01:0x42480000 fval:0.000000e+00:0x4348 {{{ after conversion , still in main }}} Initial: testsub(0.000000e+00:0x43480000) {{{ as soon as we enter function, it is swapped again }}} = : ieeefval:0.000000e+00:000 fval:0.000000e+00:0x43480000 memcpy : ieeefval:0.000000e+00:000 fval:0.000000e+00:0x43480000 Exiting: testsub(0.000000e+00:0x43480000) ------------------ If /noprefix used ------------------ ALPHA1$ CC TEST5.C/list/noopt/debug=(all)/float=ieee/ieee_mode=DENORM_RES/ansi/exter=strict/noprefix ALPHA1$ cc testsub.c /debug=all/noopt/list/machine/float=g_float/extern=strict/noprefix ALPHA1$ LINK /ALPHA /debug TEST5.OBJ, testsub.obj, sys$library:vaxcrtlt.olb/lib, sys$library:vaxcrtl.olb/lib ALPHA1$ r test5 main: Initial (5.000000e+01:0x42480000) Initial: testsub(8.130838e-320:0x4248) = : ieeefval:6.763991e-316:0x41480000 fval:8.130838e-320:0x4248 memcpy : ieeefval:6.763991e-316:0x41480000 fval:8.130838e-320:0x4248 Exiting: testsub(8.130838e-320:0x4248) main: ieeefval:5.000000e+01:0x42480000 fval:0.000000e+00:0x4348 Initial: testsub(6.971217e-316:0x43480000) = : ieeefval:0.000000e+00:000 fval:6.971217e-316:0x43480000 memcpy : ieeefval:0.000000e+00:000 fval:6.971217e-316:0x43480000 Exiting: testsub(6.971217e-316:0x43480000) --------------- Listing file --------------- Source Listing 13-APR-1999 17:08:31 DEC C V5.5-002 Page 1 13-APR-1999 16:21:08 [000000.APITEST]TEST5.C;7 1 #include 673 #include 1581 #include 1646 #include 1712 1713 int testsub(float); 1714 1715 main() 1716 { 1717 int st,err; 1718 float fval=50.0; 1719 float ieeefval=50.0; 1720 1721 1722 printf("main: Initial (%e:%#x)\n\n", fval, *((int*)&fval)); 1723 1724 err = testsub((float)fval); 1725 1726 1727 st=CVT$CONVERT_FLOAT(&ieeefval, CVT$K_IEEE_S, &fval, CVT$K_VAX_F, CVT$M_VAX_ROUNDING); 1728 printf("main: ieeefval:%e:%#x fval:%e:%#x\n\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*)&fval)) 1728 ; 1729 1730 err = testsub((float)fval); 1731 1732 } Command Line ------- ---- CC TEST5.C/LIST/NOOPT/DEBUG=(ALL)/FLOAT=IEEE/IEEE_MODE=DENORM_RES/ANSI/EXTER=ST RICT These macros are in effect at the start of the compilation. ----- ------ --- -- ------ -- --- ----- -- --- ------------ __VMS_VERSION="V6.2 " __DECC_MODE_RELAXED=1 __vms_version="V6.2 " VMS_VERSION="V6.2 " __ALPHA=1 _IEEE_FP=1 __Alpha_AXP=1 vms=1 __D_FLOAT=0 __DECC=1 __alpha=1 __32BITS=1 __X_FLOAT=1 VMS=1 vms_version="V6.2 " __IEEE_FLOAT=1 __vms=1 __G_FLOAT=0 CC$gfloat=0 __BIASED_FLT_ROUNDS=2 __DECC_VER=50590002 __INITIAL_POINTER_SIZE=0 __VMS=1 __VMS_VER=60200022 __PRAGMA_ENVIRONMENT=1 Source Listing 13-APR-1999 17:08:17 DEC C V5.5-002 Page 1 13-APR-1999 16:19:40 [000000.APITEST]TESTSUB.C;7 1 #include 673 #include 1581 #include 1982 #include 2047 #include 2113 2114 int testsub(float value) 2115 { 2116 float ieeefval=0.0; 2117 float fval=0.0; 2118 int st=0; 2119 2120 printf(" Initial: testsub(%e:%#x)\n", value, *((int*)&value)); 2121 2122 fval=value; 2123 st=CVT$CONVERT_FLOAT(&fval, CVT$K_VAX_F, &ieeefval, CVT$K_IEEE_S, CVT$M_ROUND_TO_NEAREST); 2124 printf(" = : ieeefval:%e:%#x fval:%e:%#x\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*) 2124 &fval)); 2125 2126 memcpy((void*)&fval, (void*)&value, sizeof(float)); 2127 st=CVT$CONVERT_FLOAT(&fval, CVT$K_VAX_F, &ieeefval, CVT$K_IEEE_S, CVT$M_ROUND_TO_NEAREST); 2128 printf(" memcpy : ieeefval:%e:%#x fval:%e:%#x\n", (double)ieeefval, *((int*)&ieeefval), (double)fval, *((int*) 2128 &fval)); 2129 2130 printf(" Exiting: testsub(%e:%#x)\n\n", value, *((int*)&value)); 2131 2132 return 0; 2133 } Command Line ------- ---- CC TESTSUB.C/DEBUG=ALL/NOOPT/LIST/FLOAT=G_FLOAT/ANSI/EXTERN=STRICT These macros are in effect at the start of the compilation. ----- ------ --- -- ------ -- --- ----- -- --- ------------ __VMS_VERSION="V6.2 " __DECC_MODE_RELAXED=1 __vms_version="V6.2 " VMS_VERSION="V6.2 " __ALPHA=1 __Alpha_AXP=1 vms=1 __D_FLOAT=0 __DECC=1 __alpha=1 __32BITS=1 __X_FLOAT=1 VMS=1 vms_version="V6.2 " __IEEE_FLOAT=0 __vms=1 __G_FLOAT=1 CC$gfloat=1 __BIASED_FLT_ROUNDS=2 __DECC_VER=50590002 __INITIAL_POINTER_SIZE=0 __VMS=1 __VMS_VER=60200022 __PRAGMA_ENVIRONMENT=1 *********************** END OUTPUTS AND LISTING ******************** Maybe I'm wasting bandwidth here but I wanted to be complete, I'm submitting the linker map file 13-APR-1999 17:59 Linker A11-20 Page 1 +------------------------+ ! Object Module Synopsis ! +------------------------+ Module Name Ident Bytes File Creation Date Creator ----------- ----- ----- ----- ------------- ------- TEST5 V1.0 750 TEST5.OBJ;12 13-APR-1999 17:08 DEC C V5.5-002 TESTSUB V1.0 617 TESTSUB.OBJ;12 13-APR-1999 17:08 DEC C V5.5-002 LIBRTL X01-001 0 SYS$COMMON:[SYSLIB]LIBRTL.EXE;1 4-MAY-1995 22:30 Linker A11-12 DECC$SHR T06.2-05 0 SYS$COMMON:[SYSLIB]DECC$SHR.EXE;1 4-MAY-1995 22:33 Linker A11-12 SYS$PUBLIC_VECTORS X-33 0 [SYSLIB]SYS$PUBLIC_VECTORS.EXE;1 4-MAY-1995 22:29 Linker A11-12 USERDISK2:[000000.APITEST]TEST5.EXE;9 13-APR-1999 17:59 Linker A11-20 Page 2 +------------------------+ ! Image Section Synopsis ! +------------------------+ Cluster Type Pglts Base Addr Disk VBN PFC Protection and Paging Global Sec. Name Match Majorid Minorid ------- ---- ----- --------- -------- --- --------------------- ---------------- ----- ------- ------- DEFAULT_CLUSTER 0 1 00010000 3 0 READ WRITE NON-SHAREABLE ADDRESS DATA 0 2 00020000 4 0 READ ONLY EXECUTABLE 0 1 00030000 6 0 READ WRITE FIXUP VECTORS 253 20 7FFF0000 0 0 READ WRITE DEMAND ZERO LIBRTL 3 1136 00000000-R 0 0 READ ONLY EXECUTABLE LIBRTL_001 LESS/EQUAL 1 1 2 100 00090000-R 0 0 READ WRITE COPY ON REF LIBRTL_002 LESS/EQUAL 1 1 2 8 000A0000-R 0 0 READ WRITE COPY ON REF LIBRTL_003 LESS/EQUAL 1 1 3 94 000B0000-R 0 0 READ ONLY LIBRTL_004 LESS/EQUAL 1 1 4 1 P-000C0000-R 0 0 READ WRITE COPY ON REF LIBRTL_005 LESS/EQUAL 1 1 2 8 000D0000-R 0 0 READ WRITE DEMAND ZERO LIBRTL_006 LESS/EQUAL 1 1 2 11 000E0000-R 0 0 READ WRITE FIXUP VECTORS LIBRTL_007 LESS/EQUAL 1 1 DECC$SHR 3 2281 00000000-R 0 0 READ ONLY EXECUTABLE DECC$SHR_001 LESS/EQUAL 1 1 2 216 00120000-R 0 0 READ WRITE COPY ON REF DECC$SHR_002 LESS/EQUAL 1 1 2 77 00140000-R 0 0 READ WRITE COPY ON REF DECC$SHR_003 LESS/EQUAL 1 1 3 39 00150000-R 0 0 READ ONLY DECC$SHR_004 LESS/EQUAL 1 1 4 1 P-00160000-R 0 0 READ WRITE COPY ON REF DECC$SHR_005 LESS/EQUAL 1 1 2 35 00170000-R 0 0 READ WRITE DEMAND ZERO DECC$SHR_006 LESS/EQUAL 1 1 2 14 00180000-R 0 0 READ WRITE FIXUP VECTORS DECC$SHR_007 LESS/EQUAL 1 1 SYS$PUBLIC_VECTORS 2 11 00000000-R 0 0 READ ONLY EXECUTABLE SYS$PUBLIC_VECTO EQUAL 125 16186164 1 33 00004000-R 0 0 READ WRITE COPY ON REF SYS$PUBLIC_VECTO EQUAL 125 16186164 2 1 0000C000-R 0 0 READ WRITE FIXUP VECTORS SYS$PUBLIC_VECTO EQUAL 125 16186164 Key for special characters above: +--------------------+ ! R - Relocatable ! ! P - Protected ! +--------------------+ USERDISK2:[000000.APITEST]TEST5.EXE;9 13-APR-1999 17:59 Linker A11-20 Page 3 +--------------------------+ ! Program Section Synopsis ! +--------------------------+ Psect Name Module Name Base End Length Align Attributes ---------- ----------- ---- --- ------ ----- ---------- $LINK$ 00010000 0001010F 00000110 ( 272.) OCTA 4 NOPIC,CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC, MOD TEST5 00010000 000100BF 000000C0 ( 192.) OCTA 4 TESTSUB 000100C0 0001010F 00000050 ( 80.) OCTA 4 $LITERAL$ 00010110 000101FC 000000ED ( 237.) OCTA 4 PIC,CON,REL,LCL, SHR,NOEXE,NOWRT,NOVEC, MOD TEST5 00010110 00010151 00000042 ( 66.) OCTA 4 TESTSUB 00010160 000101FC 0000009D ( 157.) OCTA 4 $CODE$ 00020000 0002036B 0000036C ( 876.) OCTA 4 PIC,CON,REL,LCL, SHR, EXE,NOWRT,NOVEC, MOD TEST5 00020000 000201EB 000001EC ( 492.) OCTA 4 TESTSUB 000201F0 0002036B 0000017C ( 380.) OCTA 4 $BSS$ 00030000 00030000 00000000 ( 0.) OCTA 4 NOPIC,CON,REL,LCL,NOSHR,NOEXE, WRT,NOVEC,NOMOD TEST5 00030000 00030000 00000000 ( 0.) OCTA 4 TESTSUB 00030000 00030000 00000000 ( 0.) OCTA 4 $DATA$ 00030000 00030000 00000000 ( 0.) OCTA 4 NOPIC,CON,REL,LCL,NOSHR,NOEXE, WRT,NOVEC,NOMOD TEST5 00030000 00030000 00000000 ( 0.) OCTA 4 TESTSUB 00030000 00030000 00000000 ( 0.) OCTA 4 $READONLY$ 00030000 00030000 00000000 ( 0.) OCTA 4 PIC,CON,REL,LCL, SHR,NOEXE,NOWRT,NOVEC,NOMOD TEST5 00030000 00030000 00000000 ( 0.) OCTA 4 TESTSUB 00030000 00030000 00000000 ( 0.) OCTA 4 $READONLY_ADDR$ 00030000 00030000 00000000 ( 0.) OCTA 4 PIC,CON,REL,LCL,NOSHR,NOEXE,NOWRT,NOVEC,NOMOD TEST5 00030000 00030000 00000000 ( 0.) OCTA 4 TESTSUB 00030000 00030000 00000000 ( 0.) OCTA 4 USERDISK2:[000000.APITEST]TEST5.EXE;9 13-APR-1999 17:59 Linker A11-20 Page 4 +------------------------+ ! Symbol Cross Reference ! +------------------------+ Symbol Value Defined By Referenced By ... ------ ----- ---------- ----------------- CVT$CONVERT_FLOAT 00001380-RX LIBRTL TEST5 TESTSUB DECC$$SHELL_HANDLER 00003A20-RX DECC$SHR TEST5 DECC$EXIT 00002000-RX DECC$SHR TEST5 DECC$GXPRINTF 000046E0-RX DECC$SHR TESTSUB DECC$MAIN 000007B0-RX DECC$SHR TEST5 DECC$TXPRINTF 00004960-RX DECC$SHR TEST5 MAIN 00010000-R TEST5 SYS$IMGSTA 00000340-RX SYS$PUBLIC_VECTORS TESTSUB 000100C0-R TESTSUB TEST5 __MAIN 00010070-R TEST5 USERDISK2:[000000.APITEST]TEST5.EXE;9 13-APR-1999 17:59 Linker A11-20 Page 5 +------------------+ ! Symbols By Value ! +------------------+ Value Symbols... ----- ---------- 00000340 RX-SYS$IMGSTA 000007B0 RX-DECC$MAIN 00001380 RX-CVT$CONVERT_FLOAT 00002000 RX-DECC$EXIT 00003A20 RX-DECC$$SHELL_HANDLER 000046E0 RX-DECC$GXPRINTF 00004960 RX-DECC$TXPRINTF 00010000 R-MAIN 00010070 R-__MAIN 000100C0 R-TESTSUB Key for special characters above: +--------------------+ ! * - Undefined ! ! A - Alias Name ! ! I - Internal Name ! ! U - Universal ! ! R - Relocatable ! ! X - External ! ! WK - Weak ! +--------------------+ USERDISK2:[000000.APITEST]TEST5.EXE;9 13-APR-1999 17:59 Linker A11-20 Page 6 +----------------+ ! Image Synopsis ! +----------------+ Virtual memory allocated: 00010000 0003FFFF 00030000 (196608. bytes, 384. pages) Stack size: 20. pages Image header virtual block limits: 1. 2. ( 2. blocks) Image binary virtual block limits: 3. 6. ( 4. blocks) Image name and identification: TEST5 V1.0 Number of files: 7. Number of modules: 5. Number of program sections: 11. Number of global symbols: 1767. Number of cross references: 18. Number of image sections: 21. User transfer address: 00010070 Debugger transfer address: 00000340 Number of code references to shareable images: 7. Image type: EXECUTABLE. Map format: FULL WITH CROSS REFERENCE in file USERDISK2:[000000.APITEST]TEST5. Estimated map length: 250. blocks +---------------------+ ! Link Run Statistics ! +---------------------+ Performance Indicators Page Faults CPU Time Elapsed Time ---------------------- ----------- -------- ------------ Command processing: 23 00:00:00.00 00:00:00.09 Pass 1: 115 00:00:00.17 00:00:00.28 Allocation/Relocation: 8 00:00:00.02 00:00:00.08 Pass 2: 10 00:00:00.05 00:00:00.16 Map data after object module synopsis: 3 00:00:00.01 00:00:00.01 Symbol table output: 0 00:00:00.00 00:00:00.04 Total run values: 159 00:00:00.25 00:00:00.69 Using a working set limited to 6496 pages and 2703 pages of data storage (excluding image) Total number object records read (both passes): 341 of which 0 were in libraries and 31 were DEBUG data records containing 2685 bytes 1977 bytes of DEBUG data were written,starting at VBN 7 with 4 blocks allocated Number of modules extracted explicitly = 0 with 0 extracted to resolve undefined symbols 1 library searches were for symbols not in the library searched A total of 5 global symbol table records was written LINK/ALPHA/DEBUG/MAP/CROSS/FULL TEST5.OBJ,TESTSUB.OBJ