delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/28/05:34:18

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
Date: Sun, 28 Sep 2003 10:42:21 +0100
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.3.50 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
Subject: K. B. Williams's comparison macros [PATCH]
Message-Id: <E1A3Xuc-0001Q1-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Below is a diff for K. B. Williams's work on the new C99 maths
comparison macros. K. B. Williams: Thanks!

Changes I made to his work:

* add @findex entries;
* change the portability information - specify they're in C99;
  remove POSIX information for later review.

I wonder if this works with gcc < 3? Do they have builtin versions
of these functions? I think we should support gcc < 3. So I think
we need our own implementation of these macros.

Thanks, bye, Rich =]

Index: include/math.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/math.h,v
retrieving revision 1.9
diff -p -u -3 -r1.9 math.h
--- include/math.h	3 Sep 2003 17:05:22 -0000	1.9
+++ include/math.h	28 Sep 2003 09:28:11 -0000
@@ -79,6 +79,13 @@ int __fpclassifyf(float) __attribute__((
 int __fpclassifyd(double) __attribute__((const));
 int __fpclassifyld(long double) __attribute__((const));
 
+#define	isgreater(x,y)		__builtin_isgreater(x,y)
+#define	isgreaterequal(x,y)	__builtin_isgreaterequal(x,y)
+#define	isless(x,y)		__builtin_isless(x,y)
+#define	islessequal(x,y)	__builtin_islessequal(x,y)
+#define	islessgreater(x,y)	__builtin_islessgreater(x,y)
+#define	isunordered(x,y)	__builtin_isunordered(x,y)
+
 #endif /* (__STDC_VERSION__ >= 199901L) || !__STRICT_ANSI__ */
   
 #ifndef __STRICT_ANSI__
Index: src/docs/kb/wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.160
diff -p -u -3 -r1.160 wc204.txi
--- src/docs/kb/wc204.txi	3 Sep 2003 17:05:22 -0000	1.160
+++ src/docs/kb/wc204.txi	28 Sep 2003 09:28:17 -0000
@@ -1008,3 +1014,12 @@ into itself, when the current directory 
 The C99 macro @code{fpclassify} and the supporting functions
 @code{__fpclassifyf}, @code{__fpclassifyd} and @code{__fpclassifyld}
 were added.
+
+@findex isgreater AT r{ added}
+@findex isgreaterequal AT r{ added}
+@findex isless AT r{ added}
+@findex islessequal AT r{ added}
+@findex islessgreater AT r{ added}
+@findex isunordered AT r{ added}
+The C99 macros @code{isgreater}, @code{isgreaterequal}, @code{isless},
+@code{islessequal}, @code{islessgreater} and @code{isunordered} were added.
--- /dev/null	2003-09-28 10:38:27.000000000 +0000
+++ src/libc/c99/math/isgrt.txh	2003-09-28 10:30:18.000000000 +0000
@@ -0,0 +1,48 @@
+@c ----------------------------------------------------------------------
+@node isgreater, math
+@findex isgreater
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int isgreater(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{isgreater()} macro determines whether its first argument
+is greater than its second argument.
+
+The value of @code{isgreater(@var{x},@var{y})}
+is equal to @math{(@var{x}) > (@var{y})}; unlike 
+@math{(@var{x}) > (@var{y})}, @code{isgreater(@var{x},@var{y})}
+does not raise the floating-point invalid exception when
+@var{x} and @var{y} are unordered.
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the floating-point invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{isgreater()} macro returns the value of @math{(@var{x}) > (@var{y})}.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99
--- /dev/null	2003-09-28 10:38:27.000000000 +0000
+++ src/libc/c99/math/isgrteq.txh	2003-09-28 10:30:26.000000000 +0000
@@ -0,0 +1,48 @@
+@c ----------------------------------------------------------------------
+@node isgreaterequal, math
+@findex isgreaterequal
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int isgreaterequal(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{isgreaterequal()} macro determines whether its first argument
+is greater than or equal to its second argument.
+
+The value of @code{isgreaterequal(@var{x},@var{y})}
+is equal to @math{(@var{x}) >= (@var{y})}; unlike 
+@math{(@var{x}) >= (@var{y})}, @code{isgreaterequal(@var{x},@var{y})}
+does not raise the floating-point invalid exception when
+@var{x} and @var{y} are unordered.
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the floating-point invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{isgreaterequal()} macro returns the value of @math{(@var{x}) >= (@var{y})}.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99
--- /dev/null	2003-09-28 10:38:27.000000000 +0000
+++ src/libc/c99/math/islss.txh	2003-09-28 10:30:32.000000000 +0000
@@ -0,0 +1,48 @@
+@c ----------------------------------------------------------------------
+@node isless, math
+@findex isless
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int isless(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{isless()} macro determines whether its first argument
+is less than its second argument.
+
+The value of @code{isless(@var{x},@var{y})}
+is equal to @math{(@var{x}) < (@var{y})}; unlike 
+@math{(@var{x}) < (@var{y})}, @code{isless(@var{x},@var{y})}
+does not raise the floating-point invalid exception when
+@var{x} and @var{y} are unordered.
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the floating-point invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{isless()} macro returns the value of @math{(@var{x}) < (@var{y})}.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99
--- /dev/null	2003-09-28 10:38:27.000000000 +0000
+++ src/libc/c99/math/islsseq.txh	2003-09-28 10:30:38.000000000 +0000
@@ -0,0 +1,48 @@
+@c ----------------------------------------------------------------------
+@node islessequal, math
+@findex islessequal
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int islessequal(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{islessequal()} macro determines whether its first argument
+is less than or equal to its second argument.
+
+The value of @code{islessequal(@var{x},@var{y})}
+is equal to @math{(@var{x}) <= (@var{y})}; however, unlike 
+@math{(@var{x}) <= (@var{y})}, @code{islessequal(@var{x},@var{y})}
+does not raise the floating-point invalid exception when
+@var{x} and @var{y} are unordered.
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the floating-point invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{islessequal()} macro returns the value of @math{(@var{x}) <= (@var{y})}.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99
--- /dev/null	2003-09-28 10:38:27.000000000 +0000
+++ src/libc/c99/math/islssgrt.txh	2003-09-28 10:30:44.000000000 +0000
@@ -0,0 +1,52 @@
+@c ----------------------------------------------------------------------
+@node islessgreater, math
+@findex islessgreater
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int islessgreater(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{islessgreater()} macro determines whether its first argument
+is less than or greater than its second argument.
+
+The value of @code{islessgreater(@var{x},@var{y})}
+is equal to @math{(@var{x}) <> (@var{y})}.
+The @code{islessgreater(@var{x},@var{y})} macro is similar to 
+@math{(@var{x}) < (@var{y})} || @math{(@var{x}) > (@var{y})}; 
+however, @code{islessgreater(@var{x},@var{y})}
+does not raise the floating-point invalid exception when
+@var{x} and @var{y} are unordered (nor does it evaluate @var{x} and @var{y}
+twice).
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the floating-point invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{islessgreater()} macro returns the value of @math{(@var{x}) < (@var{y})}
+or @math{(@var{x}) > (@var{y})}.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99
--- /dev/null	2003-09-28 10:38:28.000000000 +0000
+++ src/libc/c99/math/isunord.txh	2003-09-28 10:30:48.000000000 +0000
@@ -0,0 +1,43 @@
+@c ----------------------------------------------------------------------
+@node isunordered, math
+@findex isunordered
+@subheading Syntax
+
+@example
+#include <math.h>
+
+int isunordered(real-floating x, real-floating y);
+@end example
+
+@subheading Description
+
+The @code{isunordered()} macro determines whether its arguments
+are unordered.
+
+The type @code{real-floating} indicates that the argument is an expression
+of real floating type whether float, double or long double.
+
+Application Note:
+
+The relational and equality operators support the usual
+mathematical relationships between numeric values.
+For any ordered pair of numeric values exactly one of the
+relationships (less, greater, and equal) is true.
+Relational operators may raise the invalid
+exception when argument values are NaNs.
+For a NaN and a numeric value, or for two NaNs, just the unordered
+relationship is true.  This macro is a quiet (non exception raising)
+version of a relational operator.  It facilitates writing efficient
+code that accounts for NaNs without suffering the invalid exception.
+
+@subheading Return Value
+
+The @code{isunordered()} macro returns 1 if its arguments are unorderd; 
+otherwise, 0 is returned.
+
+If either @var{x} or @var{y} is NaN, 0 is returned.
+
+
+@subheading Portability
+
+@portability !ansi-c89, ansi-c99

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019