summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/csu/h_initfini_common.cxx
blob: dd349833f00dba8aa270ccff72ea7f764ca021ad (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 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;
OpenPOWER on IntegriCloud