//stdlib.h Copyright (C) 1989-95 I.Pedley (CTPP) Fri 21-Mar-1997 at 15:13:54 //ChaOS variant of stdlib containing memory allocator #define NULL 0L VD* malloc (UL size); //ANSI C 7.10.3.1 VD* calloc (UL elements,UL size); //ANSI C 7.10.3.2 VD free (VD* ptr); //ANSI C 7.10.3.3 VD* realloc(VD* ptr,UL newsize); //ANSI C 7.10.3.4 //CTPP aligned memory allocators VD* alignedmalloc(UL size,UL align); VD* alignedcalloc(UL elements,UL size,UL align); //kernel memory allocators VD* tsrmalloc (UL size); VD* tsrcalloc (UL elements,UL size); VD* tsralignedmalloc(UL size,UL align); VD* tsralignedcalloc(UL elements,UL size,UL align); SL exit (SL retvalue); //ANSI C 7.10.4.3 //ANSI string conversion functions DB atof(CH* ptr); //ANSI C 7.10.1.1 SL atoi(CH* ptr); //ANSI C 7.10.1.2 SL atol(CH* ptr); //ANSI C 7.10.1.3 DB strtod (CH* p,CH** endp); //ANSI C 7.10.1.4 SL strtol (CH* p,CH** pend,SL base); //ANSI C 7.10.1.5 UL strtoul(CH* p,CH** pend,SL base); //ANSI C 7.10.1.6 //ANSI integer arithmetic functions SL abs(SL n); //ANSI C 7.10.6.1 //non-ANSI, but nevertheless widely used SL muldiv(SL a,SL b,SL c); CH* ecvt(DB val,SL ndig, SL* pdecpt,SL* psign); CH* fcvt(DB val,SL nfrac,SL* pdecpt,SL* psign); CH* itoa(SL i,CH* ptr,SL base); //CTPP useful function for concatenating numeric values when building strings CH* icat(SL i,CH* ptr,SL base); extern int atexit(void ( *func )( void ) ); #define RAND_MAX 32767u #define EXIT_SUCCESS 0 #define EXIT_FAILURE 0xff #define MB_CUR_MAX 1 typedef struct{ int quot; int rem; }div_t; typedef struct{ long quot; long rem; }ldiv_t; //graphics primitive structures, placed here so they don't get //duplicated all over the place struct IP2 {SL x,y;}; //integer 2d point struct IRECT{SL t,l,b,r;}; //integer 2d rectangle //oft needed file functions UC* uploadfile(CH* fname,UL* fsiz); SL downloadfile(CH* fname,UL fsiz,VD* buf);