FreeBSD kernel libkern code
qsort.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/libkern.h>
Include dependency graph for qsort.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define min(a, b)   (a) < (b) ? (a) : (b)
 
#define swapcode(TYPE, parmi, parmj, n)
 
#define SWAPINIT(a, es)
 
#define swap(a, b)
 
#define vecswap(a, b, n)   if ((n) > 0) swapfunc(a, b, n, swaptype)
 
#define CMP(t, x, y)   (cmp((x), (y)))
 
#define thunk   NULL
 

Typedefs

typedef int cmp_t(const void *, const void *)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static __inline char * med3 (char *, char *, char *, cmp_t *, void *)
 
static __inline void swapfunc (char *, char *, int, int)
 
static __inline char * med3 (char *a, char *b, char *c, cmp_t *cmp, void *thunk __unused)
 
void qsort (void *a, size_t n, size_t es, cmp_t *cmp)
 

Macro Definition Documentation

#define CMP (   t,
  x,
 
)    (cmp((x), (y)))

Definition at line 85 of file qsort.c.

Referenced by med3(), and qsort().

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

Definition at line 44 of file qsort.c.

Referenced by iconv_xlat_conv(), and qsort().

#define swap (   a,
 
)
Value:
if (swaptype == 0) { \
long t = *(long *)(a); \
*(long *)(a) = *(long *)(b); \
*(long *)(b) = t; \
swapfunc(a, b, es, swaptype)
static __inline void swapfunc(char *, char *, int, int)
Definition: qsort.c:64

Definition at line 72 of file qsort.c.

Referenced by qsort().

#define swapcode (   TYPE,
  parmi,
  parmj,
 
)
Value:
{ \
long i = (n) / sizeof (TYPE); \
register TYPE *pi = (TYPE *) (parmi); \
register TYPE *pj = (TYPE *) (parmj); \
do { \
register TYPE t = *pi; \
*pi++ = *pj; \
*pj++ = t; \
} while (--i > 0); \
}

Definition at line 49 of file qsort.c.

Referenced by swapfunc().

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

Definition at line 60 of file qsort.c.

Referenced by qsort().

#define thunk   NULL

Definition at line 104 of file qsort.c.

Referenced by med3().

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

Definition at line 80 of file qsort.c.

Referenced by qsort().

Typedef Documentation

typedef int cmp_t(const void *, const void *)

Definition at line 39 of file qsort.c.

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static __inline char* med3 ( char *  ,
char *  ,
char *  ,
cmp_t ,
void *   
)
static

Referenced by qsort().

Here is the caller graph for this function:

static __inline char* med3 ( char *  a,
char *  b,
char *  c,
cmp_t cmp,
void *thunk  __unused 
)
static

Definition at line 89 of file qsort.c.

References c, CMP, and thunk.

void qsort ( void *  a,
size_t  n,
size_t  es,
cmp_t cmp 
)

Definition at line 106 of file qsort.c.

References CMP, med3(), min, swap, SWAPINIT, and vecswap.

Here is the call graph for this function:

static __inline void swapfunc ( char *  a,
char *  b,
int  n,
int  swaptype 
)
static

Definition at line 64 of file qsort.c.

References swapcode.