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.setjmp.cpp
Go to the documentation of this file.
1
29
#include <
setjmp.h
>
30
31
#include <
rw_driver.h
>
32
33
35
jmp_buf
env
;
36
37
void
test_longjmp
(
int
arg
)
38
{
39
longjmp (
env
,
arg
);
40
41
rw_assert
(0, 0, __LINE__,
42
"call to 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
73
// using volatile to work around a gcc optimizer bug:
74
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34024
75
volatile
int
arg
= 1;
76
77
int
result
;
78
79
result
=
setjmp
(
env
);
80
81
if
(0 ==
result
) {
82
83
test_longjmp
(
arg
);
84
85
rw_assert
(0, 0, __LINE__,
86
"call to longjmp(..., %d) returned"
,
arg
);
87
}
88
else
{
89
rw_assert
(
arg
==
result
, 0, __LINE__,
90
"longjmp(..., %d) returned %d from setjmp()"
,
91
arg
,
result
);
92
93
// repeat a couple more times
94
if
(
arg
< 3)
95
test_longjmp
(++
arg
);
96
}
97
98
return
0;
99
}
100
101
103
int
main
(
int
argc,
char
*argv[])
104
{
105
return
rw_test
(argc, argv, __FILE__,
106
"support.runtime"
,
107
"header <setjmp.h>"
,
108
run_test
,
109
""
,
110
(
void
*)0);
111
}
result
volatile int result
Definition
18.limits.traps.stdcxx-624.cpp:35
test_longjmp
void test_longjmp(int arg)
Definition
18.setjmp.cpp:37
env
jmp_buf env
Definition
18.setjmp.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
setjmp.h
arg
int arg
Definition
locale.cpp:2806
Generated by
1.9.8