~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/rtl/powerpc64/mathu.inc

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
    This file is part of the Free Pascal run time library.
 
3
    Copyright (c) 2005 by Thomas Schatzl
 
4
    member of the Free Pascal development team
 
5
 
 
6
    See the file COPYING.FPC, included in this distribution,
 
7
    for details about the copyright.
 
8
 
 
9
    This program is distributed in the hope that it will be useful,
 
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
12
 
 
13
 **********************************************************************}
 
14
 
 
15
const
 
16
  RoundModeMask        = %00000011;
 
17
  NonIEEEModeMask      = %00000100;
 
18
 
 
19
  InvalidOperationMask = %10000000;
 
20
  OverflowMask         = %01000000;
 
21
  UnderflowMask        = %00100000;
 
22
  ZeroDivideMask       = %00010000;
 
23
  InexactMask          = %00001000;
 
24
  ExceptionsPendingMask = %11111111111111100000011100000000;
 
25
 
 
26
  ExceptionMask        = InvalidOperationMask or OverflowMask or UnderflowMask or ZeroDivideMask or InexactMask;
 
27
 
 
28
  AllConfigBits        = ExceptionMask or NonIEEEModeMask or RoundModeMask;
 
29
 
 
30
function getFPSCR : DWord; assembler; nostackframe;
 
31
asm
 
32
  mffs f0
 
33
  stfd f0, -12(r1)
 
34
  lwz r3, -8(r1)
 
35
end;
 
36
 
 
37
procedure setFPSCR(newFPSCR : DWord); assembler; nostackframe;
 
38
asm
 
39
  stw r3, -8(r1)
 
40
  lfd f0, -12(r1)
 
41
  mtfsf 255, f0
 
42
end;
 
43
 
 
44
function GetRoundMode: TFPURoundingMode;
 
45
begin
 
46
  case (getFPSCR and RoundModeMask) of
 
47
    0 : result := rmNearest;
 
48
    1 : result := rmTruncate;
 
49
    2 : result := rmUp;
 
50
    3 : result := rmDown;
 
51
  end;
 
52
end;
 
53
 
 
54
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
 
55
var
 
56
  mode : DWord;
 
57
begin
 
58
  case (RoundMode) of
 
59
    rmNearest : mode := 0;
 
60
    rmTruncate : mode := 1;
 
61
    rmUp : mode := 2;
 
62
    rmDown : mode := 3;
 
63
  end;
 
64
  setFPSCR((getFPSCR and (not RoundModeMask)) or mode);
 
65
  result := RoundMode;
 
66
end;
 
67
 
 
68
 
 
69
function GetPrecisionMode: TFPUPrecisionMode;
 
70
begin
 
71
  result := pmDouble;
 
72
end;
 
73
 
 
74
function SetPrecisionMode(const Precision: TFPUPrecisionMode): TFPUPrecisionMode;
 
75
begin
 
76
  { nothing to do, not supported }
 
77
  result := pmDouble;
 
78
end;
 
79
 
 
80
 
 
81
function GetExceptionMask: TFPUExceptionMask;
 
82
begin
 
83
  result := [];
 
84
  if ((getFPSCR and InvalidOperationMask) = 0) then 
 
85
    result := result + [exInvalidOp];
 
86
  if ((getFPSCR and OverflowMask) = 0) then 
 
87
    result := result + [exOverflow];
 
88
  if ((getFPSCR and UnderflowMask) = 0) then 
 
89
    result := result + [exUnderflow];
 
90
  if ((getFPSCR and ZeroDivideMask) = 0) then 
 
91
    result := result + [exZeroDivide];
 
92
  if ((getFPSCR and InexactMask) = 0) then 
 
93
    result := result + [exPrecision];
 
94
end;
 
95
 
 
96
function SetExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
 
97
var
 
98
  mode : DWord;
 
99
begin
 
100
  mode := 0;
 
101
  if (exInvalidOp in Mask) then
 
102
    mode := mode or InvalidOperationMask;
 
103
  if (exOverflow in Mask) then
 
104
    mode := mode or OverflowMask;
 
105
  if (exUnderflow in Mask) then
 
106
    mode := mode or UnderflowMask;
 
107
  if (exZeroDivide in Mask) then
 
108
    mode := mode or ZeroDivideMask;
 
109
  if (exPrecision in Mask) then
 
110
    mode := mode or InexactMask;
 
111
  
 
112
  setFPSCR((getFPSCR or ExceptionMask) and not mode and not ExceptionsPendingMask);
 
113
  result := Mask - [exDenormalized];
 
114
end;
 
115
 
 
116
 
 
117
procedure ClearExceptions(RaisePending: Boolean = true);
 
118
begin
 
119
  { RaisePending has no effect on PPC, always raises them at the correct location }
 
120
  setFPSCR(getFPSCR and (not AllConfigBits));
 
121
end;
 
122