Back to index

glibc  2.9
Defines | Functions
tst-align2.c File Reference
#include <sched.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#include <tst-stack-align.h>
#include <stackinfo.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define TEST_FUNCTION   do_test ()

Functions

static int f (void *arg)
static int do_test (void)

Define Documentation

#define TEST_FUNCTION   do_test ()

Definition at line 95 of file tst-align2.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 43 of file tst-align2.c.

{
  bool ok = true;

  puts ("in main");

  if (TEST_STACK_ALIGN ())
    ok = false;

#ifdef __ia64__
  extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
                     size_t __child_stack_size, int __flags,
                     void *__arg, ...);
  char st[256 * 1024];
  pid_t p = __clone2 (f, st, sizeof (st), 0, 0);
#else
  char st[128 * 1024] __attribute__ ((aligned));
# if _STACK_GROWS_DOWN
  pid_t p = clone (f, st + sizeof (st), 0, 0);
# elif _STACK_GROWS_UP
  pid_t p = clone (f, st, 0, 0);
# else
#  error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
# endif
#endif
  if (p == -1)
    {
      printf("clone failed: %m\n");
      return 1;
    }

  int e;
  if (waitpid (p, &e, __WCLONE) != p)
    {
      puts ("waitpid failed");
      kill (p, SIGKILL);
      return 1;
    }
  if (!WIFEXITED (e))
    {
      if (WIFSIGNALED (e))
       printf ("died from signal %s\n", strsignal (WTERMSIG (e)));
      else
       puts ("did not terminate correctly");
      return 1;
    }
  if (WEXITSTATUS (e) != 0)
    ok = false;

  return ok ? 0 : 1;
}

Here is the call graph for this function:

static int f ( void *  arg) [static]

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

{
  bool ok = true;

  puts ("in f");

  if (TEST_STACK_ALIGN ())
    ok = false;

  return ok ? 0 : 1;
}

Here is the call graph for this function: