aboutsummaryrefslogtreecommitdiff
path: root/lib/csu/h_initfini_common.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csu/h_initfini_common.cxx')
-rw-r--r--lib/csu/h_initfini_common.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/csu/h_initfini_common.cxx b/lib/csu/h_initfini_common.cxx
new file mode 100644
index 000000000000..dd349833f00d
--- /dev/null
+++ b/lib/csu/h_initfini_common.cxx
@@ -0,0 +1,37 @@
+#include <unistd.h>
+
+#ifdef CHECK_STACK_ALIGNMENT
+#include <stdlib.h>
+
+extern "C" int check_stack_alignment(void);
+#endif
+
+class Test {
+public:
+ Test()
+ {
+ static const char msg[] = "constructor executed\n";
+ write(STDOUT_FILENO, msg, sizeof(msg) - 1);
+#ifdef CHECK_STACK_ALIGNMENT
+ if (!check_stack_alignment()) {
+ static const char msg2[] = "stack unaligned \n";
+ write(STDOUT_FILENO, msg2, sizeof(msg2) - 1);
+ exit(1);
+ }
+#endif
+ }
+ ~Test()
+ {
+ static const char msg[] = "destructor executed\n";
+ write(STDOUT_FILENO, msg, sizeof(msg) - 1);
+#ifdef CHECK_STACK_ALIGNMENT
+ if (!check_stack_alignment()) {
+ static const char msg2[] = "stack unaligned \n";
+ write(STDOUT_FILENO, msg2, sizeof(msg2) - 1);
+ exit(1);
+ }
+#endif
+ }
+};
+
+Test test;