RAM/Swap Memory Code Errors [Archive] - C Board

PDA

View Full Version : RAM/Swap Memory Code Errors


ghe1
03-28-2002, 12:49 PM
I use the following code to determine memory values on a 32bit machine and succeed with no errors and correct data. However, when I try to use this code for a 64bit machine it chokes. The error output is: In function 'sysinfo' undefined reference to '__ia64_syscall'. ANY SUGGESTIONS!!!!!!!!!!!
*********************CODE************************* **
#include <stdio.h>
#include <linux/unistd.h> /* for _syscallX macros/related stuff */
#include <linux/kernel.h> /* for struct sysinfo */
#include <linux/sys.h>

_syscall1(int, sysinfo, struct sysinfo *, info);

int main(void)
{
struct sysinfo s_info;
int error;

error = sysinfo(&s_info);
printf("code error = %d\n", error);
printf("RAM: total %d KB/ free %d KB\n"
"Swap: total %d KB/ free %d KB\n",
(s_info.totalram/1024), (s_info.freeram/1024),
(s_info.totalswap/1024), (s_info.freeswap/1024));

return(0);
}

***********************CODE*********************** **

starX
03-29-2002, 01:01 AM
Nothing directly useful, but you might want to look at the header files on the 32 bit machine, and compare them to the header files on the 64 bit machine, or at least the function calls for the different architectures.

Even if the hedares are the same, if the actual function varies between different architectures, you're going to have to account for that in your code.

starX
www.axisoftime.com

ghe1
04-01-2002, 07:37 AM
I solved the problem. I just needed to remove a line and the code worked fine. I guess I was trying to do more than I needed and it put me in a jam. Thanks for your help!