

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
8 messages in net.java.dev.jna.usersRe: [jna-users] call to sysinfo() cau...| From | Sent On | Attachments |
|---|---|---|
| Joel Uckelman | Apr 7, 2009 8:37 am | |
| Timothy Wall | Apr 7, 2009 8:47 am | |
| Joel Uckelman | Apr 7, 2009 9:05 am | |
| Kevin Burton | Apr 7, 2009 9:56 am | |
| Timothy Wall | Apr 7, 2009 9:58 am | |
| Joel Uckelman | Apr 7, 2009 12:19 pm | |
| Joel Uckelman | Apr 7, 2009 12:22 pm | |
| Kevin Burton | Apr 7, 2009 1:33 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] call to sysinfo() causes crash | Actions... |
|---|---|---|
| From: | Kevin Burton (bur...@spinn3r.com) | |
| Date: | Apr 7, 2009 1:33:43 pm | |
| List: | net.java.dev.jna.users | |
Interesting... Yeah. I didn't test it out on 32bit machines. We don't have any more 32bit machines :) Though, I do think there should be shared code for these functions. We have some posix stuff done and I might throw it into google code if there's interest in collaboration.
On Tue, Apr 7, 2009 at 12:20 PM, Joel Uckelman <ucke...@nomic.net> wrote:
Thus spake Kevin Burton:
I just wrote an implementation of this recently... this works:
public class sysinfo {
private static SysinfoInterface delegate = (SysinfoInterface)Native.loadLibrary( "c", SysinfoInterface.class);
public static class SysinfoStructure extends Structure { public long uptime; /* Seconds since boot */ public long[] loads = new long[3]; /* 1, 5, and 15 minute load averages */ public long totalram; /* Total usable main memory size */ public long freeram; /* Available memory size */ public long sharedram; /* Amount of shared memory */ public long bufferram; /* Memory used by buffers */ public long totalswap; /* Total swap space size */ public long freeswap; /* swap space still available */ public short procs; /* Number of current processes */ public long totalhigh; /* Total high memory size */ public long freehigh; /* Available high memory size */ public int mem_unit; /* Memory unit size in bytes */ //char _f[ 20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */ };
public static SysinfoStructure sysinfo() { SysinfoStructure result = new SysinfoStructure(); delegate.sysinfo( result ); return result; }
}
interface SysinfoInterface extends Library {
void sysinfo(sysinfo.SysinfoStructure sysinfo);
}
Have you tested this on both 32- and 64-bit systems? This is exactly what I had originally, and it caused the JVM to crash on 32-bit systems. Based on the JNA docs, you should be using NativeLong instead of long.
-- J.
-- Founder/CEO Spinn3r.com Location: San Francisco, CA AIM/YIM: sfburtonator Skype: burtonator Work: http://spinn3r.com







