Back to index

glibc  2.9
Classes | Functions | Variables
tst-qsort.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <tst-stack-align.h>

Go to the source code of this file.

Classes

struct  big

Functions

int compare (void const *a1, void const *b1)
int main (int argc, char **argv)

Variables

struct bigarray
struct bigarray_end
static int align_check

Class Documentation

struct big

Definition at line 6 of file tst-qsort.c.

Class Members
char c

Function Documentation

int compare ( void const a1,
void const b1 
)

Definition at line 14 of file tst-qsort.c.

{
  struct big const *a = a1;
  struct big const *b = b1;

  if (!align_check)
    align_check = TEST_STACK_ALIGN () ? -1 : 1;

  if (! (array <= a && a < array_end
        && array <= b && b < array_end))
    {
      exit (EXIT_FAILURE);
    }
  return b->c[0] - a->c[0];
}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file tst-qsort.c.

{
  size_t i;
  size_t array_members = argv[1] ? atoi (argv[1]) : 50;
  array = (struct big *) malloc (array_members * sizeof *array);
  if (array == NULL)
    {
      puts ("no memory");
      exit (EXIT_FAILURE);
    }

  array_end = array + array_members;
  for (i = 0; i < array_members; i++)
    array[i].c[0] = i % 128;

  qsort (array, array_members, sizeof *array, compare);

  if (align_check == -1)
    {
      puts ("stack not sufficiently aligned");
      exit (EXIT_FAILURE);
    }

  return 0;
}

Here is the call graph for this function:


Variable Documentation

int align_check [static]

Definition at line 11 of file tst-qsort.c.

struct big* array

Definition at line 8 of file tst-qsort.c.

struct big* array_end

Definition at line 9 of file tst-qsort.c.