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])
12 #ifdef HAVE_UCONTEXT_H
16 #define STACK_SIZE 16384
18 static ucontext_t main_context, thread_context;
19 static char *alt_stack;
24 unsigned long stack_ptr;
27 offset = (unsigned long) &stack_ptr - (unsigned long) alt_stack;
28 if (offset > STACK_SIZE)
30 swapcontext(&thread_context, &main_context);
31 /* should never get here */
36 main(int argc, char **argv)
38 if (getcontext(&thread_context) == -1)
40 alt_stack = malloc(STACK_SIZE);
43 thread_context.uc_stack.ss_sp = alt_stack;
44 thread_context.uc_stack.ss_size = STACK_SIZE;
45 makecontext(&thread_context, thread, 0);
47 if (swapcontext(&main_context, &thread_context) == -1)
55 AC_DEFINE(HAVE_WORKING_SWAPCONTEXT, 1,
56 user context manipulation is complete)],