summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/builtins-55.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/builtins-55.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/builtins-55.c')
-rw-r--r--gcc/testsuite/gcc.dg/builtins-55.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/builtins-55.c b/gcc/testsuite/gcc.dg/builtins-55.c
new file mode 100644
index 000000000..0db7976a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-55.c
@@ -0,0 +1,86 @@
+/* { dg-do link } */
+/* { dg-options "-O2 -ffast-math" } */
+/* { dg-add-options c99_runtime } */
+
+#include "builtins-config.h"
+
+void link_error (void);
+
+extern long lround(double);
+extern long lrint(double);
+
+extern long long llround(double);
+extern long long llrint(double);
+
+extern long lroundf(float);
+extern long lrintf(float);
+
+extern long long llroundf(float);
+extern long long llrintf(float);
+
+extern long lroundl(long double);
+extern long lrintl(long double);
+
+extern long long llroundl(long double);
+extern long long llrintl(long double);
+
+
+void test(double x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (__builtin_lceil(x) != __builtin_llceil(x))
+ link_error();
+ if (__builtin_lfloor(x) != __builtin_llfloor(x))
+ link_error();
+ if (lround(x) != llround(x))
+ link_error();
+ if (lrint(x) != llrint(x))
+ link_error();
+#endif
+}
+
+void testf(float x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (__builtin_lceilf(x) != __builtin_llceilf(x))
+ link_error();
+ if (__builtin_lfloorf(x) != __builtin_llfloorf(x))
+ link_error();
+ if (lroundf(x) != llroundf(x))
+ link_error();
+ if (lrintf(x) != llrintf(x))
+ link_error();
+#endif
+}
+
+void testl(long double x)
+{
+#ifdef HAVE_C99_RUNTIME
+ if (sizeof(long) != sizeof(long long))
+ return;
+
+ if (__builtin_lceill(x) != __builtin_llceill(x))
+ link_error();
+ if (__builtin_lfloorl(x) != __builtin_llfloorl(x))
+ link_error();
+ if (lroundl(x) != llroundl(x))
+ link_error();
+ if (lrintl(x) != llrintl(x))
+ link_error();
+#endif
+}
+
+int main()
+{
+ test(0.0);
+ testf(0.0);
+ testl(0.0);
+ return 0;
+}
+