]> pd.if.org Git - pdclib/blobdiff - platform/example/functions/_PDCLIB/allocpages.c
No exceptions to regtestdrivers anymore.
[pdclib] / platform / example / functions / _PDCLIB / allocpages.c
index 48b8dc9cad8ea4ddaa8015501b02a6276db4b42e..f3414bbb0bc8058925f0d67a8c107e0a894adbef 100644 (file)
@@ -1,7 +1,3 @@
-/* $Id$ */
-
-/* Release $Name$ */
-
 /* _PDCLIB_allocpages( int const )
 
    This file is part of the Public Domain C Library (PDCLib).
 */
 
 #include <stdint.h>
+#include <stddef.h>
 
-#include <unistd.h>
+#ifndef REGTEST
 
-#ifndef _PDCLIB_CONFIG_H
-#define _PDCLIB_CONFIG_H _PDCLIB_CONFIG_H
-#include <_PDCLIB_config.h>
-#endif
+int brk( void * );
+void * sbrk( intptr_t );
+
+#include "_PDCLIB_glue.h"
 
 static void * membreak = NULL;
 
@@ -39,7 +36,7 @@ void * _PDCLIB_allocpages( int const n )
                 /* error */
                 return NULL;
             }
-            membreak += unaligned;
+            membreak = (char *)membreak + unaligned;
         }
     }
     /* increasing or decreasing heap - standard operation */
@@ -58,19 +55,17 @@ void * _PDCLIB_allocpages( int const n )
     }
 }
 
-#ifdef TEST
-#include <_PDCLIB_test.h>
+#endif
 
-int puts( const char * );
+#ifdef TEST
+#include "_PDCLIB_test.h"
 
-int main()
+int main( void )
 {
-    BEGIN_TESTS;
 #ifndef REGTEST
-    {
-    void * startbreak = sbrk( 0 );
+    char * startbreak = sbrk( 0 );
     TESTCASE( _PDCLIB_allocpages( 0 ) );
-    TESTCASE( ( sbrk( 0 ) - startbreak ) <= _PDCLIB_PAGESIZE );
+    TESTCASE( ( (char *)sbrk( 0 ) - startbreak ) <= _PDCLIB_PAGESIZE );
     startbreak = sbrk( 0 );
     TESTCASE( _PDCLIB_allocpages( 1 ) );
     TESTCASE( sbrk( 0 ) == startbreak + ( 1 * _PDCLIB_PAGESIZE ) );
@@ -78,7 +73,6 @@ int main()
     TESTCASE( sbrk( 0 ) == startbreak + ( 6 * _PDCLIB_PAGESIZE ) );
     TESTCASE( _PDCLIB_allocpages( -3 ) );
     TESTCASE( sbrk( 0 ) == startbreak + ( 3 * _PDCLIB_PAGESIZE ) );
-    }
 #endif
     return TEST_RESULTS;
 }