Embedded Artistry Framework
Embedded Systems C++ Framework
Macros | Typedefs | Functions
qsort.c File Reference
#include <stdlib.h>
#include <string.h>
#include <strings.h>
Include dependency graph for qsort.c:
This graph shows which files directly or indirectly include this file:

Macros

#define min(a, b)   (a) < (b) ? a : b
 
#define swapcode(TYPE, parmi, parmj, n)
 
#define SWAPINIT(a, es)   swaptype = (uintptr_t)a % sizeof(long) || es % sizeof(long) ? 2 : es == sizeof(long) ? 0 : 1;
 
#define swap(a, b)   swapfunc(a, b, (size_t)es, (size_t)swaptype)
 
#define vecswap(a, b, n)
 
#define CMP(t, x, y)   (cmp((x), (y)))
 
#define DEPTH(x)   (2 * (fls((int)(x)) - 1))
 
#define thunk   NULL
 

Typedefs

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

Functions

static char * med3 (char *a, char *b, char *c, cmp_t *cmd, void *thunk) __attribute__((always_inline))
 
static void swapfunc (char *a, char *b, size_t n, size_t swaptype) __attribute__((always_inline))
 
static char * med3 (char *a, char *b, char *c, cmp_t *cmp, void *thunk __attribute__((unused)))
 
static void _qsort (void *a, size_t n, size_t es, #define thunk cmp_t *cmp, int depth_limit)
 
void qsort (void *a, size_t n, size_t es, cmp_t *cmp)
 

Macro Definition Documentation

◆ CMP

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

◆ DEPTH

#define DEPTH (   x)    (2 * (fls((int)(x)) - 1))

◆ min

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

◆ swap

#define swap (   a,
  b 
)    swapfunc(a, b, (size_t)es, (size_t)swaptype)

◆ swapcode

#define swapcode (   TYPE,
  parmi,
  parmj,
  n 
)
Value:
{ \
size_t i = (n) / sizeof(TYPE); \
TYPE* pi = (TYPE*)(parmi); \
TYPE* pj = (TYPE*)(parmj); \
do \
{ \
TYPE t = *pi; \
*pi++ = *pj; \
*pj++ = t; \
} while(--i > 0); \
}
static const long double pi
Definition: e_lgammal_r.c:96
static int n[]
Definition: qsort.c:32
static struct @36 t[]

◆ SWAPINIT

#define SWAPINIT (   a,
  es 
)    swaptype = (uintptr_t)a % sizeof(long) || es % sizeof(long) ? 2 : es == sizeof(long) ? 0 : 1;

◆ thunk

#define thunk   NULL

◆ vecswap

#define vecswap (   a,
  b,
  n 
)
Value:
if((n) > 0) \
swapfunc(a, b, n, swaptype ? (size_t)swaptype : 1)
double b[ARR_LEN]
Definition: libm-bench.cpp:75
double a[ARR_LEN]
Definition: libm-bench.cpp:74
static int n[]
Definition: qsort.c:32

Typedef Documentation

◆ cmp_t

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

Function Documentation

◆ _qsort()

static void _qsort ( void *  a,
size_t  n,
size_t  es,
#define thunk cmp_t cmp,
int  depth_limit 
)
static

References a, CMP, cmp(), heapsort(), heapsort_r(), med3(), min, n, pa, r, swap, SWAPINIT, thunk, and vecswap.

Referenced by qsort().

◆ med3() [1/2]

static char* med3 ( char *  a,
char *  b,
char *  c,
cmp_t cmd,
void *  thunk 
)
inlinestatic

Referenced by _qsort().

◆ med3() [2/2]

static char* med3 ( char *  a,
char *  b,
char *  c,
cmp_t cmp,
void *thunk   __attribute__(unused) 
)
inlinestatic

References a, b, CMP, and thunk.

◆ qsort()

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

◆ swapfunc()

static void swapfunc ( char *  a,
char *  b,
size_t  n,
size_t  swaptype 
)
inlinestatic

References a, b, n, swapcode, and t.