freebsd-skq/contrib/netbsd-tests/lib/csu/h_initfini_common.cxx
ngie 3f09b8d0af Import the NetBSD test suite from ^/vendor/NetBSD/tests/09.30.2014_20.45 ,
minus the vendor Makefiles

Provide directions for how to bootstrap the vendor sources in
FREEBSD-upgrade

MFC after 2 weeks
Discussed with: rpaulo
Sponsored by: EMC / Isilon Storage Division
2014-10-02 23:26:49 +00:00

38 lines
761 B
C++

#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;