[Debian-med-packaging] Bug#776814: Patch: use more portable sysconf for memory sizing

Jeff Epler jepler at unpythonic.net
Wed Feb 4 16:26:21 UTC 2015


Package: vsearch
Followup-For: Bug #776814

This changes vsearch to use the more portable sysconf API for memory
sizing.  (sysconf is posix, while _SC_PHYS_PAGES is an extension)

While this does change the memory sizing method used on Linux,
I verified that the results are the same on my Jessie amd64 system:

    $ uname -a
    Linux babs 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt2-1 (2014-12-08) x86_64 GNU/Linux
    $ cat memsize.c
    #include <stdio.h>
    #include <sys/sysinfo.h>
    #include <unistd.h>

    static
    long long memsize_sysconf() {
        return (long long)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE);
    }

    long long memsize_sysinfo() {
        struct sysinfo si;
        if(sysinfo(&si) < 0) return 0;
        int mem_unit = si.mem_unit ?: 1;
        return (long long)si.totalram * mem_unit;
    }

    int main() {
        printf("memsize via sysconf: %16lld\n", memsize_sysconf());
        printf("memsize via sysinfo: %16lld\n", memsize_sysinfo());
        return memsize_sysconf() != memsize_sysinfo();
    }
    $ gcc memsize.c && ./a.out || echo fail
    memsize via sysconf:       8078680064
    memsize via sysinfo:       8078680064

-- System Information:
Debian Release: 8.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 10.1-0-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sysconf_memory_sizing.patch
Type: text/x-diff
Size: 1463 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debian-med-packaging/attachments/20150204/e0dd8876/attachment.patch>


More information about the Debian-med-packaging mailing list