Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
tests
support
18.csetjmp.cpp
Go to the documentation of this file.
1
29
#include <csetjmp>
30
31
#include <
rw_driver.h
>
32
33
35
std::jmp_buf
env
;
36
37
void
test_longjmp
(
int
arg
)
38
{
39
std::longjmp (
env
,
arg
);
40
41
rw_assert
(0, 0, __LINE__,
42
"call to std::longjmp(..., %d) returned"
,
arg
);
43
}
44
45
47
static
int
48
run_test
(
int
,
char
**)
49
{
50
#ifdef longjmp
51
52
// longjmp must not be #defined as a macro
53
rw_assert
(0, 0, __LINE__,
"longjmp #defined as a macro"
);
54
55
#endif
// longjmp
56
57
#ifdef jmp_buf
58
59
//jmp_buf must not be #defined as a macro
60
rw_assert
(0, 0, __LINE__,
"jmp_buf #defined as a macro"
);
61
62
#endif
// jmp_buf
63
64
#ifndef setjmp
65
66
//setjmp must be #defined as a macro
67
rw_assert
(0, 0, __LINE__,
"macro setjmp not #defined"
);
68
69
#endif
// setjmp
70
71
// verify that setjmp works
72
// using volatile to work around a gcc optimizer bug:
73
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34024
74
volatile
int
arg
= 1;
75
int
result
;
76
77
result
=
setjmp
(
env
);
78
79
if
(0 ==
result
) {
80
81
test_longjmp
(
arg
);
82
83
rw_assert
(0, 0, __LINE__,
84
"call to std::longjmp(..., %d) returned"
,
arg
);
85
}
86
else
{
87
rw_assert
(
arg
==
result
, 0, __LINE__,
88
"std::longjmp(..., %d) returned %d from setjmp()"
,
89
arg
,
result
);
90
91
// repeat a couple more times
92
if
(
arg
< 3)
93
test_longjmp
(++
arg
);
94
}
95
96
return
0;
97
}
98
99
101
int
main
(
int
argc,
char
*argv[])
102
{
103
return
rw_test
(argc, argv, __FILE__,
104
"support.runtime"
,
105
"header <csetjmp>"
,
106
run_test
,
107
""
,
108
(
void
*)0);
109
}
test_longjmp
void test_longjmp(int arg)
Definition
18.csetjmp.cpp:37
env
std::jmp_buf env
Definition
18.csetjmp.cpp:35
result
volatile int result
Definition
18.limits.traps.stdcxx-624.cpp:35
run_test
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
Definition
25.find.first.cpp:275
main
#define main
Definition
BAD_ALLOC_COPY_CTOR.cpp:32
setjmp
#define setjmp
Definition
_csetjmp.h:52
rw_driver.h
rw_test
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
rw_assert
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
Definition
driver.cpp:1630
arg
int arg
Definition
locale.cpp:2806
Generated by
1.9.8