Skip to contentSkip to conversation

call to sysinfo in ia32 mode trashes the stack

Linux-ia64 Jose Luu 2 participants 2 messages May 11, 2001

lore
Share & tools
lore

Jose Luu

author
#0 lore raw

I noticed the above problem using kernel 2.4.1. Is it solved in 2.4.4 ?

Thanks
Jose

------------------------------ test
program ------------------------------------

#include <stdio.h>
#include <sys/sysinfo.h>

typedef struct {

    unsigned int dwTotalPhys ;
    unsigned int dwAvailPhys ;
    unsigned int dwTotalPageFile ;
    unsigned int dwAvailPageFile ;
}  MEMORYSTATUS;

int Memory(MEMORYSTATUS *lpmstMemStat)
{

#if defined(AIR_BAG)
    char szBuffer[1000];

#endif

      struct sysinfo info;

       if(sysinfo(&info))
               return 1;
       lpmstMemStat->dwTotalPhys = info.totalram;
       lpmstMemStat->dwAvailPhys = info.freeram;
       lpmstMemStat->dwTotalPageFile = info.totalswap;
       lpmstMemStat->dwAvailPageFile = info.freeswap;
       return 0;
}

main ()

{
    MEMORYSTATUS mem;
    if (Memory(&mem) != 0) {
fprintf(stderr,"error\n");
    }
    fprintf(stderr,"Total Phys %u\n",mem.dwTotalPhys);
    fprintf(stderr,"Avail Phys %u\n",mem.dwAvailPhys);
    fprintf(stderr,"Total PageFile  %u\n",mem.dwTotalPageFile);
    fprintf(stderr,"Avail PageFile  %u\n",mem.dwAvailPageFile);
}
#1 lore raw

Jose-

Not yet, it's on my todo list.

Quoted 56 lines · Jose Luu

I noticed the above problem using kernel 2.4.1. Is it solved in 2.4.4 ?

Thanks
Jose

------------------------------ test
program ------------------------------------

#include <stdio.h>
#include <sys/sysinfo.h>

typedef struct {

    unsigned int dwTotalPhys ;
    unsigned int dwAvailPhys ;
    unsigned int dwTotalPageFile ;
    unsigned int dwAvailPageFile ;
}  MEMORYSTATUS;

int Memory(MEMORYSTATUS *lpmstMemStat)
{

#if defined(AIR_BAG)
    char szBuffer[1000];

#endif

      struct sysinfo info;

       if(sysinfo(&info))
               return 1;
       lpmstMemStat->dwTotalPhys = info.totalram;
       lpmstMemStat->dwAvailPhys = info.freeram;
       lpmstMemStat->dwTotalPageFile = info.totalswap;
       lpmstMemStat->dwAvailPageFile = info.freeswap;
       return 0;
}

main ()

{
    MEMORYSTATUS mem;
    if (Memory(&mem) != 0) {
fprintf(stderr,"error\n");
    }
    fprintf(stderr,"Total Phys %u\n",mem.dwTotalPhys);
    fprintf(stderr,"Avail Phys %u\n",mem.dwAvailPhys);
    fprintf(stderr,"Total PageFile  %u\n",mem.dwTotalPageFile);
    fprintf(stderr,"Avail PageFile  %u\n",mem.dwAvailPageFile);
}

_______________________________________________
Linux-IA64 mailing list
[email protected]
http://lists.linuxia64.org/lists/listinfo/linux-ia64

Signature · 4 lines
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
[email protected]
Ph: 303/938-9838