PandA-2024.02
Data Structures | Macros | Functions
qsort.c File Reference
#include <limits.h>
#include <stdlib.h>
Include dependency graph for qsort.c:

Go to the source code of this file.

Data Structures

struct  stack_node
 

Macros

#define SWAP(a, b, size)
 
#define MAX_THRESH   4
 
#define STACK_SIZE   (CHAR_BIT * sizeof(size_t))
 
#define PUSH(low, high)   ((void) ((top->lo = (low)), (top->hi = (high)), ++top))
 
#define POP(low, high)   ((void) (--top, (low = top->lo), (high = top->hi)))
 
#define STACK_NOT_EMPTY   (stack < top)
 
#define min(x, y)   ((x) < (y) ? (x) : (y))
 

Functions

void _quicksort (void *const pbase, size_t total_elems, size_t size, int(*cmp)(const void *, const void *, void *), void *arg)
 

Macro Definition Documentation

◆ MAX_THRESH

#define MAX_THRESH   4

Definition at line 42 of file qsort.c.

Referenced by _quicksort().

◆ min

#define min (   x,
 
)    ((x) < (y) ? (x) : (y))

Referenced by _quicksort().

◆ POP

#define POP (   low,
  high 
)    ((void) (--top, (low = top->lo), (high = top->hi)))

Definition at line 58 of file qsort.c.

Referenced by _quicksort().

◆ PUSH

#define PUSH (   low,
  high 
)    ((void) ((top->lo = (low)), (top->hi = (high)), ++top))

Definition at line 57 of file qsort.c.

Referenced by _quicksort().

◆ STACK_NOT_EMPTY

#define STACK_NOT_EMPTY   (stack < top)

Definition at line 59 of file qsort.c.

Referenced by _quicksort().

◆ STACK_SIZE

#define STACK_SIZE   (CHAR_BIT * sizeof(size_t))

Definition at line 56 of file qsort.c.

Referenced by _quicksort().

◆ SWAP

#define SWAP (   a,
  b,
  size 
)
Value:
do \
{ \
size_t __size = (size); \
char *__a = (a), *__b = (b); \
do \
{ \
char __tmp = *__a; \
*__a++ = *__b; \
*__b++ = __tmp; \
} while (--__size > 0); \
} while (0)

Definition at line 27 of file qsort.c.

Referenced by _quicksort().

Function Documentation

◆ _quicksort()

void _quicksort ( void *const  pbase,
size_t  total_elems,
size_t  size,
int(*)(const void *, const void *, void *)  cmp,
void *  arg 
)

Definition at line 87 of file qsort.c.

References MAX_THRESH, min, NULL, POP, PUSH, STACK_NOT_EMPTY, STACK_SIZE, SWAP, and top().

Here is the call graph for this function:

Generated on Mon Feb 12 2024 13:02:58 for PandA-2024.02 by doxygen 1.8.13