LCOV - code coverage report
Current view: top level - src/ftimings - virtual_memory.c (source / functions) Hit Total Coverage
Test: coverage_50ab7a7628bba174fc62cee3ab72b26e81f87fe5.info Lines: 0 10 0.0 %
Date: 2018-01-10 09:29:53 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* Copyright 2014 Andreas Marek, Lorenz Hüdepohl
       2             :  *
       3             :  * This file is part of ftimings.
       4             :  *
       5             :  * ftimings is free software: you can redistribute it and/or modify
       6             :  * it under the terms of the GNU Lesser General Public License as published by
       7             :  * the Free Software Foundation, either version 3 of the License, or
       8             :  * (at your option) any later version.
       9             :  *
      10             :  * ftimings is distributed in the hope that it will be useful,
      11             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :  * GNU Lesser General Public License for more details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with ftimings.  If not, see <http://www.gnu.org/licenses/>.
      17             :  */
      18             : 
      19             : #include <stdio.h>
      20             : #include <unistd.h>
      21             : 
      22           0 : long ftimings_virtual_memory() {
      23             : 
      24           0 :         long rss = 0L;
      25           0 :         FILE* fp = NULL;
      26           0 :         if ((fp = fopen( "/proc/self/statm", "r" )) == NULL ) {
      27           0 :                 return 0L;
      28             :         }
      29           0 :         if (fscanf(fp, "%ld", &rss) != 1) {
      30           0 :                 fclose(fp);
      31           0 :                 return (size_t)0L;        /* Can't read? */
      32             :         }
      33           0 :         fclose(fp);
      34           0 :         return rss * sysconf( _SC_PAGESIZE);
      35             : }

Generated by: LCOV version 1.12