Back to index

glibc  2.9
Defines | Functions | Variables
tst-makecontext2.c File Reference
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ucontext.h>
#include <tst-stack-align.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

char st1[262144] __attribute__ ((aligned(16)))
void cf (int i, int j)
int do_test (void)

Variables

ucontext_t ucp
ucontext_t ucp2

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 79 of file tst-makecontext2.c.


Function Documentation

char st1 [262144] __attribute__ ( (aligned(16))  )
void cf ( int  i,
int  j 
)

Definition at line 30 of file tst-makecontext2.c.

{
  if (i != 78 || j != 274)
    {
      printf ("i %d j %d\n", i, j);
      exit (1);
    }
  else if (TEST_STACK_ALIGN ())
    {
      puts ("insufficiently aligned stack");
      exit (2);
    }
}

Here is the call graph for this function:

int do_test ( void  )

Definition at line 45 of file tst-makecontext2.c.

{
  for (size_t j = 32; j < 64; j += sizeof (long))
    {
      if (getcontext (&ucp) != 0)
       {
         if (errno == ENOSYS)
           {
             puts ("context handling not supported");
             return 0;
           }

         puts ("getcontext failed");
         return 1;
       }
      ucp.uc_link = &ucp2;
      ucp.uc_stack.ss_sp = st1;
      ucp.uc_stack.ss_size = sizeof (st1) - j;
      memset (&st1[sizeof (st1) - j], 0x55, j);
      makecontext (&ucp, (void (*) (void)) cf, 2, 78, 274);
      if (swapcontext (&ucp2, &ucp) != 0)
       {
         puts ("setcontext failed");
         return 1;
       }

      for (size_t i = j; i > 0; i--)
       if (st1[sizeof (st1) - j + i - 1] != 0x55)
         { printf ("fail %zd %zd\n", i, j); break; }
    }

  return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 26 of file tst-makecontext2.c.

Definition at line 26 of file tst-makecontext2.c.