summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20020226-1.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.c-torture/execute/20020226-1.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.c-torture/execute/20020226-1.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20020226-1.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020226-1.c b/gcc/testsuite/gcc.c-torture/execute/20020226-1.c
new file mode 100644
index 000000000..6372ffc27
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20020226-1.c
@@ -0,0 +1,104 @@
+/* This tests the rotate patterns that some machines support. */
+
+#include <limits.h>
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
+#define ROR(a,b) (((a) >> (b)) | ((a) << ((sizeof (a) * CHAR_BIT) - (b))))
+#define ROL(a,b) (((a) << (b)) | ((a) >> ((sizeof (a) * CHAR_BIT) - (b))))
+
+#define CHAR_VALUE ((unsigned char)0x1234U)
+#define SHORT_VALUE ((unsigned short)0x1234U)
+#define INT_VALUE 0x1234U
+#define LONG_VALUE 0x12345678LU
+#define LL_VALUE 0x12345678abcdef0LLU
+
+#define SHIFT1 4
+#define SHIFT2 ((sizeof (long long) * CHAR_BIT) - SHIFT1)
+
+unsigned char uc = CHAR_VALUE;
+unsigned short us = SHORT_VALUE;
+unsigned int ui = INT_VALUE;
+unsigned long ul = LONG_VALUE;
+unsigned long long ull = LL_VALUE;
+int shift1 = SHIFT1;
+int shift2 = SHIFT2;
+
+main ()
+{
+ if (ROR (uc, shift1) != ROR (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (uc, SHIFT1) != ROR (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (us, shift1) != ROR (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (us, SHIFT1) != ROR (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ui, shift1) != ROR (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ui, SHIFT1) != ROR (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ul, shift1) != ROR (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ul, SHIFT1) != ROR (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ull, shift1) != ROR (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ull, SHIFT1) != ROR (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROR (ull, shift2) != ROR (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROR (ull, SHIFT2) != ROR (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROL (uc, shift1) != ROL (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (uc, SHIFT1) != ROL (CHAR_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (us, shift1) != ROL (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (us, SHIFT1) != ROL (SHORT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ui, shift1) != ROL (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ui, SHIFT1) != ROL (INT_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ul, shift1) != ROL (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ul, SHIFT1) != ROL (LONG_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ull, shift1) != ROL (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ull, SHIFT1) != ROL (LL_VALUE, SHIFT1))
+ abort ();
+
+ if (ROL (ull, shift2) != ROL (LL_VALUE, SHIFT2))
+ abort ();
+
+ if (ROL (ull, SHIFT2) != ROL (LL_VALUE, SHIFT2))
+ abort ();
+
+ exit (0);
+}