The above source files are definitely Linux, was able to compile the code, but when it runs it tries to make some Linux specific calls like reading the file "/proc/kcore", but of course exists as it does not exist in Irix 5.3.
So was hoping that someone might be able to help with the source code for gmemusage from one of those Developer Tooklkit CDs and let me know the changes to be made...
Thanks...
Code:
/*
* Cheap way to get amount of installed mem in the computer -- get size of
* /proc/kcore.
*/
if ( stat ( "/proc/kcore" , &s ) < 0 )
{
fprintf ( stderr , "%s: cannot stat /proc/kcore" , progname ) ;
perror ( "" ) ;
exit ( 1 ) ;
}
sysmem = s . st_size ; /* in Kilobytes */
/*
* Read /proc/meminfo to get usable memory and buffers. Presumably buffers
* should be considered a part of the kernel memory.
*/
if ( ( meminfo = fopen ( "/proc/meminfo" , "r" ) ) == NULL )
{
fprintf ( stderr , "%s: cannot open /proc/meminfo" , progname ) ;
perror ( "" ) ;
exit ( 1 ) ;
}
while ( fgets ( buf , sizeof ( buf ) , meminfo ) )
{
if ( !strncmp ( buf , MemLine , MemLineLen ) )
{
/* Mem: total used free shared buffers cached */
sscanf ( buf , "%*s %d %*d %d %*d %d" , &totalmem , &freemem ,
&buffermem ) ;
break ;
}
}
sysmem /= 1024 ;
totalmem /= 1024 ;
freemem /= 1024 ;
buffermem /= 1024 ;
kernelmem = sysmem - totalmem ;
fclose ( meminfo ) ;
return ;
}