Skip to content

Commit ff7a9f5

Browse files
committed
Fix test p047 loopholes for various types on 32 bit architectures
1 parent 3ace800 commit ff7a9f5

File tree

3 files changed

+103
-15
lines changed

3 files changed

+103
-15
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
(* Copyright (C) 1994, Digital Equipment Corporation. *)
2+
(* All rights reserved. *)
3+
(* See the file COPYRIGHT for a full description. *)
4+
5+
(* LOOPHOLE tests between integer types and real types *)
6+
7+
UNSAFE MODULE Main32 EXPORTS Main;
8+
9+
FROM Test IMPORT checkI,checkR,checkL,checkX,checkN,done;
10+
11+
TYPE
12+
Int32 = [0..16_7FFFFFFF];
13+
Rec32 = RECORD
14+
xx : BITS 32 FOR Int32;
15+
END;
16+
17+
PROCEDURE Test() =
18+
VAR
19+
i : INTEGER;
20+
l : LONGINT;
21+
a : ADDRESS;
22+
r1 : REAL;
23+
l1 : LONGREAL;
24+
e1 : EXTENDED;
25+
int32 : Int32;
26+
rec32 : Rec32;
27+
BEGIN
28+
29+
checkI (BITSIZE(INTEGER), 32);
30+
checkI (BITSIZE(LONGINT), 64);
31+
checkI (BITSIZE(ADDRESS), 32);
32+
checkI (BITSIZE(int32), 32);
33+
checkI (BITSIZE(LONGREAL), BITSIZE(EXTENDED));
34+
35+
(* REAL *)
36+
37+
i := LOOPHOLE(r1,INTEGER);
38+
39+
r1 := 1.234E0;
40+
int32 := LOOPHOLE(r1,Int32);
41+
checkI(1067316150,int32);
42+
43+
r1 := LOOPHOLE(int32,REAL);
44+
checkR(1.234E0,r1);
45+
46+
rec32 := LOOPHOLE(r1,Rec32);
47+
checkI(1067316150,rec32.xx);
48+
49+
(* LONGREAL *)
50+
51+
l1 := 1.234D0;
52+
l := LOOPHOLE(l1,LONGINT);
53+
checkN(4608236261112822104L,l);
54+
55+
l1 := LOOPHOLE(l,LONGREAL);
56+
checkL(1.234D0,l1);
57+
58+
(* EXTENDED *)
59+
60+
l1 := 1.234D0;
61+
e1 := LOOPHOLE(l1,EXTENDED);
62+
checkX(1.234X0,e1);
63+
64+
l1 := LOOPHOLE(e1,LONGREAL);
65+
checkL(1.234D0,l1);
66+
67+
(* ADDRESS *)
68+
69+
a := LOOPHOLE(i,ADDRESS);
70+
a := LOOPHOLE(r1,ADDRESS);
71+
72+
END Test;
73+
74+
BEGIN
75+
Test();
76+
done ();
77+
END Main32.
78+
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
(* LOOPHOLE tests between integer types and real types *)
66

7-
UNSAFE MODULE Main;
7+
UNSAFE MODULE Main64 EXPORTS Main;
88

9-
FROM Test IMPORT checkI,checkR,checkL,checkX,done;
9+
FROM Test IMPORT checkI,checkR,checkL,checkX,checkN,done;
1010

1111
TYPE
12-
Int32 = [0..16_FFFFFFFF];
12+
Int32 = [0..16_7FFFFFFF];
1313
Rec32 = RECORD
1414
xx : BITS 32 FOR Int32;
1515
END;
@@ -25,19 +25,16 @@ PROCEDURE Test() =
2525
int32 : Int32;
2626
rec32 : Rec32;
2727
BEGIN
28-
(*
28+
2929
checkI (BITSIZE(INTEGER), 64);
30+
checkI (BITSIZE(LONGINT), 64);
3031
checkI (BITSIZE(ADDRESS), 64);
3132
checkI (BITSIZE(int32), 32);
3233
checkI (BITSIZE(LONGREAL), BITSIZE(EXTENDED));
3334
checkI (BITSIZE(LONGINT), BITSIZE(INTEGER));
34-
*)
35+
3536
(* REAL *)
3637

37-
(* REAL to INTEGER will not compile on 64 bit - size mismatch
38-
i := LOOPHOLE(r1,INTEGER);
39-
*)
40-
4138
r1 := 1.234E0;
4239
int32 := LOOPHOLE(r1,Int32);
4340
checkI(1067316150,int32);
@@ -54,22 +51,30 @@ PROCEDURE Test() =
5451
i := LOOPHOLE(l1,INTEGER);
5552
checkI(4608236261112822104,i);
5653

57-
l1 := LOOPHOLE(i,LONGREAL);
58-
checkL(1.234D0,l1);
59-
6054
l := LOOPHOLE(l1,LONGINT);
55+
checkN(4608236261112822104L,l);
6156

62-
a := LOOPHOLE(l1,ADDRESS);
57+
l1 := LOOPHOLE(i,LONGREAL);
58+
checkL(1.234D0,l1);
6359

6460
(* EXTENDED *)
6561

6662
l1 := 1.234D0;
6763
e1 := LOOPHOLE(l1,EXTENDED);
6864
checkX(1.234X0,e1);
6965

66+
l1 := LOOPHOLE(e1,LONGREAL);
67+
checkL(1.234D0,l1);
68+
69+
(* ADDRESS *)
70+
71+
a := LOOPHOLE(i,ADDRESS);
72+
a := LOOPHOLE(l,ADDRESS);
73+
a := LOOPHOLE(l1,ADDRESS);
74+
7075
END Test;
7176

7277
BEGIN
7378
Test();
7479
done ();
75-
END Main.
80+
END Main64.

m3-sys/m3tests/src/p0/p047/m3makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
% All rights reserved.
33
% See the file COPYRIGHT for a full description.
44

5-
implementation ("Main")
5+
if equal(WORD_SIZE, "64BITS")
6+
implementation("Main64")
7+
else
8+
implementation("Main32")
9+
end
10+
611
include ("../../Test.common")

0 commit comments

Comments
 (0)