summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/csu/dso/h_initfini3_dso.cxx
blob: ff90ce66b94b005c5704dec1f5a175e36b3dc358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <unistd.h>

#ifdef CHECK_STACK_ALIGNMENT
#include <stdlib.h>

extern "C" int check_stack_alignment(void);
#endif

class Test2 {
public:
	Test2()
	{
		static const char msg[] = "constructor2 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
	}
	~Test2()
	{
		static const char msg[] = "destructor2 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
	}
};

Test2 test2;
OpenPOWER on IntegriCloud