1 dnl Test getcontext() and makecontext() to ensure that we are able to
2 dnl copy the current user context, modify it with our own private stack
3 dnl and return to the original user context.
5 AC_DEFUN([OPENAFS_WORKING_UCONTEXT],[
6 AC_MSG_CHECKING([if user context manipulation is complete])
7 AC_RUN_IFELSE([AC_LANG_SOURCE([[
10 #ifdef HAVE_UCONTEXT_H
14 #define STACK_SIZE 16384
16 static ucontext_t main_context, thread_context;
17 static char *alt_stack;
22 unsigned long stack_ptr;
25 offset = (unsigned long) &stack_ptr - (unsigned long) alt_stack;
26 if (offset > STACK_SIZE)
28 swapcontext(&thread_context, &main_context);
29 /* should never get here */
34 main(int argc, char **argv)
36 if (getcontext(&thread_context) == -1)
38 alt_stack = malloc(STACK_SIZE);
41 thread_context.uc_stack.ss_sp = alt_stack;
42 thread_context.uc_stack.ss_size = STACK_SIZE;
43 makecontext(&thread_context, thread, 0);
45 if (swapcontext(&main_context, &thread_context) == -1)
50 }]])],[AC_MSG_RESULT(yes)
51 AC_DEFINE(HAVE_WORKING_SWAPCONTEXT,1,user context manipulation is complete)],[AC_MSG_RESULT(no)],[])])