check_function_exists(fprintf HAVE_FPRINTF)
check_function_exists(free HAVE_FREE)
check_function_exists(longjmp HAVE_LONGJMP)
+check_function_exists(siglongjmp HAVE_SIGLONGJMP)
check_function_exists(malloc HAVE_MALLOC)
check_function_exists(memcpy HAVE_MEMCPY)
check_function_exists(memset HAVE_MEMSET)
/* Define to 1 if you have the `longjmp' function. */
#cmakedefine HAVE_LONGJMP 1
+/* Define to 1 if you have the `siglongjmp' function. */
+#cmakedefine HAVE_SIGLONGJMP 1
+
/* Define to 1 if you have the `malloc' function. */
#cmakedefine HAVE_MALLOC 1
#define CMOCKA_CLOCK_GETTIME(clock_id, ts)
#endif
+/**
+ * POSIX has sigsetjmp/siglongjmp, while Windows only has setjmp/longjmp.
+ */
+#ifdef HAVE_SIGLONGJMP
+# define cm_jmp_buf sigjmp_buf
+# define cm_setjmp(env) sigsetjmp(env, 1)
+# define cm_longjmp(env, val) siglongjmp(env, val)
+#else
+# define cm_jmp_buf jmp_buf
+# define cm_setjmp(env) setjmp(env)
+# define cm_longjmp(env, val) longjmp(env, val)
+#endif
+
+
/*
* Declare and initialize the pointer member of ValuePointer variable name
* with ptr.
* Keeps track of the calling context returned by setenv() so that the fail()
* method can jump out of a test.
*/
-static CMOCKA_THREAD jmp_buf global_run_test_env;
+static CMOCKA_THREAD cm_jmp_buf global_run_test_env;
static CMOCKA_THREAD int global_running_test = 0;
/* Keeps track of the calling context returned by setenv() so that */
print_error("%s", cm_error_message);
abort();
} else if (global_running_test) {
- longjmp(global_run_test_env, 1);
+ cm_longjmp(global_run_test_env, 1);
} else if (quit_application) {
exit(-1);
}
global_running_test = 1;
- if (setjmp(global_run_test_env) == 0) {
+ if (cm_setjmp(global_run_test_env) == 0) {
if (test_func != NULL) {
test_func(state != NULL ? state : ¤t_state);
}
initialize_testing(function_name);
global_running_test = 1;
- if (setjmp(global_run_test_env) == 0) {
+ if (cm_setjmp(global_run_test_env) == 0) {
Function(state ? state : ¤t_state);
fail_if_leftover_values(function_name);