qsort_r.c File Reference

#include <sys/cdefs.h>
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>

Defines

#define min(a, b)   (a) < (b) ? a : b
#define swap(a, b)
#define swapcode(TYPE, parmi, parmj, n)
#define SWAPINIT(a, es)
#define vecswap(a, b, n)   if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)

Functions

void qsort_r (void *a, size_t n, size_t es, void *context, int *cmp)


Define Documentation

#define min a,
 )     (a) < (b) ? a : b
 

#define swap a,
 ) 
 

Value:

if (swaptype == 0) {                    \
        long t = *(long *)(void *)(a);          \
        *(long *)(void *)(a) = *(long *)(void *)(b);    \
        *(long *)(void *)(b) = t;           \
    } else                          \
        swapfunc(a, b, es, swaptype)

#define swapcode TYPE,
parmi,
parmj,
 ) 
 

Value:

{       \
    size_t i = (n) / sizeof (TYPE);         \
    TYPE *pi = (TYPE *)(void *)(parmi);         \
    TYPE *pj = (TYPE *)(void *)(parmj);         \
    do {                        \
        TYPE    t = *pi;            \
        *pi++ = *pj;                \
        *pj++ = t;              \
        } while (--i > 0);              \
}

#define SWAPINIT a,
es   ) 
 

Value:

swaptype = ((char *)a - (char *)0) % sizeof(long) || \
    es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;

#define vecswap a,
b,
 )     if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
 


Function Documentation

void qsort_r void *  a,
size_t  n,
size_t  es,
void *  context,
int *  cmp