xref: /freebsd/contrib/netbsd-tests/lib/csu/dso/h_initfini3_dso.cxx (revision 9268022b74279434ed6300244e3f977e56a8ceb5)
1*57718be8SEnji Cooper #include <unistd.h>
2*57718be8SEnji Cooper 
3*57718be8SEnji Cooper #ifdef CHECK_STACK_ALIGNMENT
4*57718be8SEnji Cooper #include <stdlib.h>
5*57718be8SEnji Cooper 
6*57718be8SEnji Cooper extern "C" int check_stack_alignment(void);
7*57718be8SEnji Cooper #endif
8*57718be8SEnji Cooper 
9*57718be8SEnji Cooper class Test2 {
10*57718be8SEnji Cooper public:
Test2()11*57718be8SEnji Cooper 	Test2()
12*57718be8SEnji Cooper 	{
13*57718be8SEnji Cooper 		static const char msg[] = "constructor2 executed\n";
14*57718be8SEnji Cooper 		write(STDOUT_FILENO, msg, sizeof(msg) - 1);
15*57718be8SEnji Cooper #ifdef CHECK_STACK_ALIGNMENT
16*57718be8SEnji Cooper 		if (!check_stack_alignment()) {
17*57718be8SEnji Cooper 			static const char msg2[] = "stack unaligned \n";
18*57718be8SEnji Cooper 			write(STDOUT_FILENO, msg2, sizeof(msg2) - 1);
19*57718be8SEnji Cooper 			exit(1);
20*57718be8SEnji Cooper 		}
21*57718be8SEnji Cooper #endif
22*57718be8SEnji Cooper 	}
~Test2()23*57718be8SEnji Cooper 	~Test2()
24*57718be8SEnji Cooper 	{
25*57718be8SEnji Cooper 		static const char msg[] = "destructor2 executed\n";
26*57718be8SEnji Cooper 		write(STDOUT_FILENO, msg, sizeof(msg) - 1);
27*57718be8SEnji Cooper #ifdef CHECK_STACK_ALIGNMENT
28*57718be8SEnji Cooper 		if (!check_stack_alignment()) {
29*57718be8SEnji Cooper 			static const char msg2[] = "stack unaligned \n";
30*57718be8SEnji Cooper 			write(STDOUT_FILENO, msg2, sizeof(msg2) - 1);
31*57718be8SEnji Cooper 			exit(1);
32*57718be8SEnji Cooper 		}
33*57718be8SEnji Cooper #endif
34*57718be8SEnji Cooper 	}
35*57718be8SEnji Cooper };
36*57718be8SEnji Cooper 
37*57718be8SEnji Cooper Test2 test2;
38