RAM/Swap Memory Code Errors

This is a discussion on RAM/Swap Memory Code Errors within the Linux Programming forums, part of the Platform Specific Boards category; I use the following code to determine memory values on a 32bit machine and succeed with no errors and correct ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    26

    RAM/Swap Memory Code Errors

    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*********************** **

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    26
    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!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. Visual Studio 2005 - Debug code with compile errors?
    By Swerve in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-17-2008, 08:12 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. linked list source code errors
    By C++_Learner in forum C++ Programming
    Replies: 1
    Last Post: 04-18-2002, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21