summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/stackalign/check.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/stackalign/check.h')
-rw-r--r--gcc/testsuite/gcc.dg/torture/stackalign/check.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/check.h b/gcc/testsuite/gcc.dg/torture/stackalign/check.h
new file mode 100644
index 000000000..af1988512
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/check.h
@@ -0,0 +1,36 @@
+#include <stddef.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" void abort (void);
+#else
+extern void abort (void);
+#endif
+
+int
+check_int (int *i, int align)
+{
+ *i = 20;
+ if ((((ptrdiff_t) i) & (align - 1)) != 0)
+ {
+#ifdef DEBUG
+ printf ("\nUnalign address (%d): %p!\n", align, i);
+#endif
+ abort ();
+ }
+ return *i;
+}
+
+void
+check (void *p, int align)
+{
+ if ((((ptrdiff_t) p) & (align - 1)) != 0)
+ {
+#ifdef DEBUG
+ printf ("\nUnalign address (%d): %p!\n", align, p);
+#endif
+ abort ();
+ }
+}