]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/LongMath.mod
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / LongMath.mod
1 (* LongMath.mod implement the ISO LongMath specification.
2
3 Copyright (C) 2003-2021 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 IMPLEMENTATION MODULE LongMath ;
28
29 IMPORT libm ;
30 IMPORT cbuiltin ;
31
32 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_sqrtl)) sqrt (x: LONGREAL): LONGREAL;
33 (* Returns the positive square root of x *)
34 BEGIN
35 RETURN cbuiltin.sqrtl(x)
36 END sqrt ;
37
38 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_expl)) exp (x: LONGREAL): LONGREAL;
39 (* Returns the exponential of x *)
40 BEGIN
41 RETURN cbuiltin.expl(x)
42 END exp ;
43
44 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_logl)) ln (x: LONGREAL): LONGREAL;
45 (* Returns the natural logarithm of x *)
46 BEGIN
47 RETURN cbuiltin.logl(x)
48 END ln ;
49
50 (* The angle in all trigonometric functions is measured in radians *)
51
52 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_sinl)) sin (x: LONGREAL): LONGREAL;
53 (* Returns the sine of x *)
54 BEGIN
55 RETURN cbuiltin.sinl(x)
56 END sin ;
57
58 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cosl)) cos (x: LONGREAL): LONGREAL;
59 (* Returns the cosine of x *)
60 BEGIN
61 RETURN cbuiltin.cosl(x)
62 END cos ;
63
64 PROCEDURE tan (x: LONGREAL): LONGREAL;
65 (* Returns the tangent of x *)
66 BEGIN
67 RETURN libm.tanl(x)
68 END tan ;
69
70 PROCEDURE arcsin (x: LONGREAL): LONGREAL;
71 (* Returns the arcsine of x *)
72 BEGIN
73 RETURN libm.asinl(x)
74 END arcsin ;
75
76 PROCEDURE arccos (x: LONGREAL): LONGREAL;
77 (* Returns the arccosine of x *)
78 BEGIN
79 RETURN libm.acosl(x)
80 END arccos ;
81
82 PROCEDURE arctan (x: LONGREAL): LONGREAL;
83 (* Returns the arctangent of x *)
84 BEGIN
85 RETURN libm.atanl(x)
86 END arctan ;
87
88 PROCEDURE power (base, exponent: LONGREAL): LONGREAL;
89 (* Returns the value of the number base raised to the power exponent *)
90 BEGIN
91 RETURN libm.powl(base, exponent)
92 END power ;
93
94 PROCEDURE round (x: LONGREAL) : INTEGER;
95 (* Returns the value of x rounded to the nearest integer *)
96 BEGIN
97 RETURN TRUNC(x)
98 END round ;
99
100 PROCEDURE IsRMathException (): BOOLEAN;
101 (* Returns TRUE if the current coroutine is in the
102 exceptional execution state because of the raising
103 of an exception in a routine from this module; otherwise
104 returns FALSE.
105 *)
106 BEGIN
107 RETURN FALSE
108 END IsRMathException ;
109
110 END LongMath.