X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fqsort.c;h=e26ea863cfa9e9f702236538921281ea7c7ab688;hb=d865c4403fc91d1f1ac95ba76febcee9f429bb97;hp=c37760f546fa47a089b913cff22d47e084f7d13f;hpb=393020b6e48719d27699dea6b29e53025bbd5123;p=pdclib diff --git a/functions/stdlib/qsort.c b/functions/stdlib/qsort.c index c37760f..e26ea86 100644 --- a/functions/stdlib/qsort.c +++ b/functions/stdlib/qsort.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* qsort( void *, size_t, size_t, int(*)( const void *, const void * ) ) This file is part of the Public Domain C Library (PDCLib). @@ -34,8 +32,11 @@ static inline void memswp( char * i, char * j, size_t size ) #define PREPARE_STACK char * stack[STACKSIZE]; char * * stackptr = stack #define PUSH( base, limit ) stackptr[0] = base; stackptr[1] = limit; stackptr += 2 #define POP( base, limit ) stackptr -= 2; base = stackptr[0]; limit = stackptr[1] -/* TODO: This is platform-dependent */ -#define STACKSIZE 40 +/* TODO: Stack usage is log2( nmemb ) (minus what T shaves off the worst case). + Worst-case nmemb is platform dependent and should probably be + configured through _PDCLIB_config.h. +*/ +#define STACKSIZE 64 void qsort( void * base, size_t nmemb, size_t size, int (*compar)( const void *, const void * ) ) { @@ -127,7 +128,9 @@ void qsort( void * base, size_t nmemb, size_t size, int (*compar)( const void *, #endif #ifdef TEST -#include <_PDCLIB_test.h> + +#include "_PDCLIB_test.h" + #include #include