X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=blobdiff_plain;f=platform%2Fposix%2Ffunctions%2F_PDCLIB%2Fallocpages.c;fp=platform%2Fexample_cygwin%2Ffunctions%2F_PDCLIB%2Fallocpages.c;h=435e8c64b8840fa7c429f2faadaf9d81caca3d8a;hp=5998c405abe880a789b08de4c25599f10a7f7b8a;hb=a38d56a6a13dbb89022b5448d2d5247f3f99ea41;hpb=81f4c957d2f820d9340d90d5b650cbbed054caa0 diff --git a/platform/example_cygwin/functions/_PDCLIB/allocpages.c b/platform/posix/functions/_PDCLIB/allocpages.c similarity index 94% rename from platform/example_cygwin/functions/_PDCLIB/allocpages.c rename to platform/posix/functions/_PDCLIB/allocpages.c index 5998c40..435e8c6 100644 --- a/platform/example_cygwin/functions/_PDCLIB/allocpages.c +++ b/platform/posix/functions/_PDCLIB/allocpages.c @@ -13,6 +13,7 @@ #include #include +int brk( void * ); void * sbrk( intptr_t ); #ifndef _PDCLIB_GLUE_H @@ -44,7 +45,7 @@ void * _PDCLIB_allocpages( int const n ) /* increasing or decreasing heap - standard operation */ void * oldbreak = membreak; membreak = (void *)( (char *)membreak + ( n * _PDCLIB_PAGESIZE ) ); - if ( sbrk( (char*)membreak - (char*)oldbreak ) == membreak ) + if ( brk( membreak ) == 0 ) { /* successful */ return oldbreak; @@ -62,6 +63,8 @@ void * _PDCLIB_allocpages( int const n ) int main( void ) { +#ifndef REGTEST + { char * startbreak = sbrk( 0 ); TESTCASE( _PDCLIB_allocpages( 0 ) ); TESTCASE( ( (char *)sbrk( 0 ) - startbreak ) <= _PDCLIB_PAGESIZE ); @@ -72,6 +75,9 @@ int main( void ) TESTCASE( sbrk( 0 ) == startbreak + ( 6 * _PDCLIB_PAGESIZE ) ); TESTCASE( _PDCLIB_allocpages( -3 ) ); TESTCASE( sbrk( 0 ) == startbreak + ( 3 * _PDCLIB_PAGESIZE ) ); + } +#endif + return TEST_RESULTS; } #endif