From: Vincent Pit Date: Sun, 29 Jun 2008 16:41:22 +0000 (+0200) Subject: Importing Linux-SysInfo-0.02.tar.gz X-Git-Tag: v0.02 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=f58f6a33b8ac6d0a353a2e57947294276ead61cf;p=perl%2Fmodules%2FLinux-SysInfo.git Importing Linux-SysInfo-0.02.tar.gz --- diff --git a/Changes b/Changes index 8c5dd92..d2abddc 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Linux-SysInfo +0.02 2007-04-18 10:18 UTC + + Fix : Load average raw values have to be shifted on a platform + dependant way. They are now correctly reported. + + Fix : Missing META.yml + + Doc : Information about binary compatibility. + 0.01 2007-04-11 12:45 UTC - First version, released on an unsuspecting world. + * First version, released on an unsuspecting world. diff --git a/MANIFEST b/MANIFEST index 359ca9e..03999d1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,6 +1,6 @@ Changes MANIFEST -META.yml # Will be created by "make dist" +META.yml Makefile.PL README SysInfo.xs diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..99ca604 --- /dev/null +++ b/META.yml @@ -0,0 +1,14 @@ +--- #YAML:1.0 +name: Linux-SysInfo +version: 0.02 +abstract: Perl interface to the sysinfo(2) Linux system call. +license: ~ +generated_by: ExtUtils::MakeMaker version 6.32 +distribution_type: module +requires: + Test::More: 0 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.2.html + version: 1.2 +author: + - Vincent Pit diff --git a/README b/README index 47fe5f4..185d16c 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call. VERSION - Version 0.01 + Version 0.02 SYNOPSIS use Linux::SysInfo qw/sysinfo/; @@ -72,6 +72,15 @@ CONSTANTS This constant is set to 1 if your kernel supports the three extended fields "totalhigh", "freehigh" and "mem_unit" ; and to 0 otherwise. +BINARY COMPATIBILITY + If you upgrade your kernel to a greater version than 2.3.23 on i386 or + 2.3.48 on any other platform, you will need to rebuild the module to + access the extended fields. + + Moreover, since the perl hash function has changed after the 5.6 + version, you will also need to recompile the module if you upgrade your + perl from a version earlier than 5.6. + SEE ALSO The sysinfo(2) man page. diff --git a/SysInfo.xs b/SysInfo.xs index 9874185..7017009 100644 --- a/SysInfo.xs +++ b/SysInfo.xs @@ -2,8 +2,8 @@ #include "perl.h" #include "XSUB.h" -#include -#include +#include /* LINUX_VERSION_CODE, KERNEL_VERSION() */ +#include /* , sysinfo(), SI_LOAD_SHIFT */ #if ((defined(__i386__) || defined(__x86_64__)) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 23))) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 48)) # define SYSINFO_EXTENDED 1 @@ -65,19 +65,24 @@ SV * sysinfo() PREINIT: struct sysinfo si; + NV l; HV* h; CODE: if (sysinfo(&si) == -1) { XSRETURN_UNDEF; } - h = newHV(); -/* sv_2mortal((SV *) h); */ + h = newHV(); /* mortalized in RETVAL */ SYSINFO_KEY_STORE(h, key_uptime, newSViv(si.uptime)); - SYSINFO_KEY_STORE(h, key_load1, newSVuv(si.loads[0])); - SYSINFO_KEY_STORE(h, key_load5, newSVuv(si.loads[1])); - SYSINFO_KEY_STORE(h, key_load15, newSVuv(si.loads[2])); + + l = ((NV) si.loads[0]) / ((NV) (((U32) 1) << ((U32) SI_LOAD_SHIFT))); + SYSINFO_KEY_STORE(h, key_load1, newSVnv(l)); + l = ((NV) si.loads[1]) / ((NV) (((U32) 1) << ((U32) SI_LOAD_SHIFT))); + SYSINFO_KEY_STORE(h, key_load5, newSVnv(l)); + l = ((NV) si.loads[2]) / ((NV) (((U32) 1) << ((U32) SI_LOAD_SHIFT))); + SYSINFO_KEY_STORE(h, key_load15, newSVnv(l)); + SYSINFO_KEY_STORE(h, key_totalram, newSVuv(si.totalram)); SYSINFO_KEY_STORE(h, key_freeram, newSVuv(si.freeram)); SYSINFO_KEY_STORE(h, key_sharedram, newSVuv(si.sharedram)); @@ -98,6 +103,6 @@ OUTPUT: SV * LS_HAS_EXTENDED() CODE: - RETVAL = newSViv(SYSINFO_EXTENDED); + RETVAL = newSViv(SYSINFO_EXTENDED); /* mortalized in RETVAL */ OUTPUT: RETVAL diff --git a/lib/Linux/SysInfo.pm b/lib/Linux/SysInfo.pm index 8b7eb0e..0e49377 100644 --- a/lib/Linux/SysInfo.pm +++ b/lib/Linux/SysInfo.pm @@ -9,11 +9,11 @@ Linux::SysInfo - Perl interface to the sysinfo(2) Linux system call. =head1 VERSION -Version 0.01 +Version 0.02 =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 SYNOPSIS @@ -112,6 +112,12 @@ Memory unit size in bytes. This constant is set to 1 if your kernel supports the three extended fields C, C and C ; and to 0 otherwise. +=head1 BINARY COMPATIBILITY + +If you upgrade your kernel to a greater version than 2.3.23 on i386 or 2.3.48 on any other platform, you will need to rebuild the module to access the extended fields. + +Moreover, since the perl hash function has changed after the 5.6 version, you will also need to recompile the module if you upgrade your perl from a version earlier than 5.6. + =head1 SEE ALSO The C man page.