X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fqsort.c;h=51edf4b2aa407b8b5995ef9e6daa42e55c308821;hb=cd6cfe0f578c4f744ddc9a342243aff6b42f8027;hp=c37760f546fa47a089b913cff22d47e084f7d13f;hpb=0d54a75af25ca44411e7c4190cc2a93a390e61a2;p=pdclib.old diff --git a/functions/stdlib/qsort.c b/functions/stdlib/qsort.c index c37760f..51edf4b 100644 --- a/functions/stdlib/qsort.c +++ b/functions/stdlib/qsort.c @@ -34,8 +34,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 * ) ) { @@ -151,7 +154,7 @@ int main( void ) strcpy( s, presort ); qsort( s, 1, 1, compare ); TESTCASE( strcmp( s, presort ) == 0 ); -#if __BSD_VISIBLE +#if defined(REGTEST) && (__BSD_VISIBLE || __APPLE__) puts( "qsort.c: Skipping test #4 for BSD as it goes into endless loop here." ); #else qsort( s, 100, 0, compare );