[m-dev.] Update library pragma C code

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Tue Aug 4 14:27:50 AEST 1998


Fergus Henderson, you write:
> On 03-Aug-1998, Thomas Charles CONWAY <conway at cs.mu.OZ.AU> wrote:
> > Here's the final diff. I've committed this.
> ...
> > Index: math.m
> >  	% Pythagoras' number
> > -:- pragma(c_code, math__pi(Pi::out), "Pi = MERCURY_FLOAT__PI;").
> > +:- pragma c_code(math__pi(Pi::out), "Pi = MERCURY_FLOAT__PI;").
> >  
> >  	% Base of natural logarithms
> > -:- pragma(c_code, math__e(E::out), "E = MERCURY_FLOAT__E;").
> > +:- pragma c_code(math__e(E::out), "E = MERCURY_FLOAT__E;").
> 
> These and all the others in math.m are missing `will_not_call_mercury'.
> 

Here's a diff which fixes them which I'll commit.

-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+


library/math.m:
	Introduce will_not_call_mercury in places where it is implicit and
	that I missed on my last change.

cvs diff: Diffing .
Index: math.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/math.m,v
retrieving revision 1.13
diff -u -r1.13 math.m
--- math.m	1998/08/03 00:19:46	1.13
+++ math.m	1998/08/04 01:53:46
@@ -209,12 +209,12 @@
 % Mathematical constants from math.m
 %
 	% Pythagoras' number
-:- pragma c_code(math__pi = (Pi::out),will_not_call_mercury,"
+:- pragma c_code(math__pi = (Pi::out), will_not_call_mercury,"
 	Pi = MERCURY_FLOAT__PI;
 ").
 
 	% Base of natural logarithms
-:- pragma c_code(math__e = (E::out),will_not_call_mercury,"
+:- pragma c_code(math__e = (E::out), will_not_call_mercury,"
 	E = MERCURY_FLOAT__E;
 ").
 
@@ -639,29 +639,33 @@
 % Mathematical constants from math.m
 %
 	% Pythagoras' number
-:- pragma c_code(math__pi(Pi::out), "Pi = MERCURY_FLOAT__PI;").
+:- pragma c_code(math__pi(Pi::out), will_not_call_mercury,
+		"Pi = MERCURY_FLOAT__PI;").
 
 	% Base of natural logarithms
-:- pragma c_code(math__e(E::out), "E = MERCURY_FLOAT__E;").
+:- pragma c_code(math__e(E::out), will_not_call_mercury,
+		"E = MERCURY_FLOAT__E;").
 
 %
 % math__ceiling(X, Ceil) is true if Ceil is the smallest integer
 % not less than X.
 %
-:- pragma c_code(math__ceiling(Num::in, Ceil::out), "Ceil = ceil(Num);").
+:- pragma c_code(math__ceiling(Num::in, Ceil::out), will_not_call_mercury,
+		"Ceil = ceil(Num);").
 
 %
 % math__floor(X, Floor) is true if Floor is the largest integer
 % not greater than X.
 %
-:- pragma c_code(math__floor(Num::in, Floor::out), "Floor = floor(Num);").
+:- pragma c_code(math__floor(Num::in, Floor::out), will_not_call_mercury,
+		"Floor = floor(Num);").
 
 %
 % math__round(X, Round) is true if Round is the integer
 % closest to X.  If X has a fractional component of 0.5,
 % it is rounded up.
 %
-:- pragma c_code(math__round(Num::in, Rounded::out), "
+:- pragma c_code(math__round(Num::in, Rounded::out), will_not_call_mercury, "
 	Rounded = floor(Num+0.5);
 ").
 
@@ -669,7 +673,7 @@
 % math__truncate(X, Trunc) is true if Trunc is the integer
 % closest to X such that |Trunc| =< |X|.
 %
-:- pragma c_code(math__truncate(X::in, Trunc::out), "
+:- pragma c_code(math__truncate(X::in, Trunc::out), will_not_call_mercury, "
 	if (X < 0.0) {
 	    Trunc = ceil(X);
 	} else {
@@ -684,7 +688,7 @@
 % Domain restrictions:
 %		X >= 0
 %
-:- pragma c_code(math__sqrt(X::in, SquareRoot::out), "
+:- pragma c_code(math__sqrt(X::in, SquareRoot::out), will_not_call_mercury, "
 	if (X < 0.0) {
 	    mercury_domain_error(""math__sqrt"");
 	}
@@ -699,7 +703,7 @@
 %		X >= 0
 %		X = 0 implies Y > 0
 %
-:- pragma c_code(math__pow(X::in, Y::in, Res::out), "
+:- pragma c_code(math__pow(X::in, Y::in, Res::out), will_not_call_mercury, "
 	if (X < 0.0) {
 	    mercury_domain_error(""math__pow"");
 	}
@@ -717,7 +721,9 @@
 % math__exp(X, Exp) is true if Exp is X raised to the
 % power of e.
 %
-:- pragma c_code(math__exp(X::in, Exp::out), "Exp = exp(X);").
+:- pragma c_code(math__exp(X::in, Exp::out), will_not_call_mercury, "
+	Exp = exp(X);
+").
 
 %
 % math__ln(X, Log) is true if Log is the natural logarithm
@@ -726,7 +732,7 @@
 % Domain restrictions:
 %		X > 0
 %
-:- pragma c_code(math__ln(X::in, Log::out), "
+:- pragma c_code(math__ln(X::in, Log::out), will_not_call_mercury, "
 	if (X <= 0.0) {
 	    mercury_domain_error(""math__ln"");
 	}
@@ -740,7 +746,7 @@
 % Domain restrictions:
 %		X > 0
 %
-:- pragma c_code(math__log10(X::in, Log10::out), "
+:- pragma c_code(math__log10(X::in, Log10::out), will_not_call_mercury, "
 	if (X <= 0.0)
 	    mercury_domain_error(""math__log10"");
 	Log10 = log10(X);
@@ -753,7 +759,7 @@
 % Domain restrictions:
 %		X > 0
 %
-:- pragma c_code(math__log2(X::in, Log2::out), "
+:- pragma c_code(math__log2(X::in, Log2::out), will_not_call_mercury, "
 	if (X <= 0.0) {
 	    mercury_domain_error(""math__log2"");
 	}
@@ -769,7 +775,7 @@
 %		B > 0
 %		B \= 1
 %
-:- pragma c_code(math__log(B::in, X::in, Log::out), "
+:- pragma c_code(math__log(B::in, X::in, Log::out), will_not_call_mercury, "
 	if (X <= 0.0 || B <= 0.0) {
 	    mercury_domain_error(""math__log"");
 	}
@@ -782,17 +788,23 @@
 %
 % math__sin(X, Sin) is true if Sin is the sine of X.
 %
-:- pragma c_code(math__sin(X::in, Sin::out), "Sin = sin(X);").
+:- pragma c_code(math__sin(X::in, Sin::out), will_not_call_mercury, "
+	Sin = sin(X);
+").
 
 %
 % math__cos(X, Sin) is true if Cos is the cosine of X.
 %
-:- pragma c_code(math__cos(X::in, Cos::out), "Cos = cos(X);").
+:- pragma c_code(math__cos(X::in, Cos::out), will_not_call_mercury, "
+	Cos = cos(X);
+").
 
 %
 % math__tan(X, Tan) is true if Tan is the tangent of X.
 %
-:- pragma c_code(math__tan(X::in, Tan::out), "Tan = tan(X);").
+:- pragma c_code(math__tan(X::in, Tan::out), will_not_call_mercury, "
+	Tan = tan(X);
+").
 
 %
 % math__asin(X, ASin) is true if ASin is the inverse
@@ -801,7 +813,7 @@
 % Domain restrictions:
 %		X must be in the range [-1,1]
 %
-:- pragma c_code(math__asin(X::in, ASin::out), "
+:- pragma c_code(math__asin(X::in, ASin::out), will_not_call_mercury, "
 	if (X < -1.0 || X > 1.0) {
 	    mercury_domain_error(""math__asin"");
 	}
@@ -815,7 +827,7 @@
 % Domain restrictions:
 %		X must be in the range [-1,1]
 %
-:- pragma c_code(math__acos(X::in, ACos::out), "
+:- pragma c_code(math__acos(X::in, ACos::out), will_not_call_mercury, "
 	if (X < -1.0 || X > 1.0) {
 	    mercury_domain_error(""math__acos"");
 	}
@@ -826,13 +838,15 @@
 % math__atan(X, ATan) is true if ATan is the inverse
 % tangent of X, where ATan is in the range [-pi/2,pi/2].
 %
-:- pragma c_code(math__atan(X::in, ATan::out), "ATan = atan(X);").
+:- pragma c_code(math__atan(X::in, ATan::out), will_not_call_mercury, "
+	ATan = atan(X);
+").
 
 %
 % math__atan2(Y, X, ATan) is true if ATan is the inverse
 % tangent of Y/X, where ATan is in the range [-pi,pi].
 %
-:- pragma c_code(math__atan2(Y::in, X::in, ATan2::out), "
+:- pragma c_code(math__atan2(Y::in, X::in, ATan2::out), will_not_call_mercury, "
 	ATan2 = atan2(Y, X);
 ").
 
@@ -840,19 +854,25 @@
 % math__sinh(X, Sinh) is true if Sinh is the hyperbolic
 % sine of X.
 %
-:- pragma c_code(math__sinh(X::in, Sinh::out), "Sinh = sinh(X);").
+:- pragma c_code(math__sinh(X::in, Sinh::out), will_not_call_mercury, "
+	Sinh = sinh(X);
+").
 
 %
 % math__cosh(X, Cosh) is true if Cosh is the hyperbolic
 % cosine of X.
 %
-:- pragma c_code(math__cosh(X::in, Cosh::out), "Cosh = cosh(X);").
+:- pragma c_code(math__cosh(X::in, Cosh::out), will_not_call_mercury, "
+	Cosh = cosh(X);
+").
 
 %
 % math__tanh(X, Tanh) is true if Tanh is the hyperbolic
 % tangent of X.
 %
-:- pragma c_code(math__tanh(X::in, Tanh::out), "Tanh = tanh(X);").
+:- pragma c_code(math__tanh(X::in, Tanh::out), will_not_call_mercury, "
+	Tanh = tanh(X);
+").
 
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list