Web Wispers 1.2.2 C++ Unit Test Coverage
Current view: top level - ssrc/wispers/utility - memusage.h (source / functions) Hit Total Coverage
Test: Web Wispers 1.2.2 C++ Unit Tests Lines: 1 1 100.0 %
Date: 2012-04-09 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright 2009 Savarese Software Research Corporation
       3                 :            :  *
       4                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       5                 :            :  * you may not use this file except in compliance with the License.
       6                 :            :  * You may obtain a copy of the License at
       7                 :            :  *
       8                 :            :  *     https://www.savarese.com/software/ApacheLicense-2.0
       9                 :            :  *
      10                 :            :  * Unless required by applicable law or agreed to in writing, software
      11                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      12                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      13                 :            :  * See the License for the specific language governing permissions and
      14                 :            :  * limitations under the License.
      15                 :            :  */
      16                 :            : 
      17                 :            : /**
      18                 :            :  * @file
      19                 :            :  * This header defines platform-specific functions for retrieving process
      20                 :            :  * memory usage.
      21                 :            :  */
      22                 :            : 
      23                 :            : #ifndef __SSRC_WSPR_UTILITY_MEMUSAGE_H
      24                 :            : #define __SSRC_WSPR_UTILITY_MEMUSAGE_H
      25                 :            : 
      26                 :            : #include <ssrc/wispers-packages.h>
      27                 :            : #include <ssrc/wisp/utility/wisp_struct.h>
      28                 :            : 
      29                 :            : __BEGIN_NS_SSRC_WSPR_UTILITY
      30                 :            : 
      31                 :            : // TODO: Implement for FreeBSD.
      32                 :            : #if defined(linux) || defined(__linux) || defined(__linux__)
      33                 :            : 
      34                 :            : #define WISPERS_HAVE_GET_MEMUSAGE 1
      35                 :            : 
      36                 :            : WISP_STRUCT(memusage,
      37                 :            :             ((unsigned int, size))      // total program size
      38                 :            :             ((unsigned int, resident))  // resident set size
      39                 :            :             ((unsigned int, share))     // shared pages
      40                 :            :             ((unsigned int, text))      // text (code)
      41                 :            :             ((unsigned int, lib))       // library
      42                 :            :             ((unsigned int, data))      // data/stack
      43                 :            :             ((unsigned int, dt))        // dirty pages (unused in Linux 2.6)
      44                 :            :             ((unsigned int, page_size)));
      45                 :            : 
      46                 :            : #elif defined(sun) || defined(__sun) || defined(__sun__)
      47                 :            : 
      48                 :            : #define WISPERS_HAVE_GET_MEMUSAGE 1
      49                 :            : 
      50                 :            : WISP_STRUCT(memusage,
      51                 :            :             ((unsigned int, size))
      52                 :            :             ((unsigned int, resident))
      53                 :            :             ((unsigned int, heap))
      54                 :          2 :             ((unsigned int, stack)));
      55                 :            : 
      56                 :            : #endif
      57                 :            : 
      58                 :            : #if defined(WISPERS_HAVE_GET_MEMUSAGE)
      59                 :            : 
      60                 :            : bool get_memusage(const unsigned int pid, memusage & usage);
      61                 :            : 
      62                 :            : #endif
      63                 :            : 
      64                 :            : __END_NS_SSRC_WSPR_UTILITY
      65                 :            : 
      66                 :            : #endif