~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to src/bft/bft_mem_usage.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __BFT_MEM_USAGE_H__
 
2
#define __BFT_MEM_USAGE_H__
 
3
 
 
4
/*============================================================================
 
5
 * Base memory usage information (System and Library dependent)
 
6
 *============================================================================*/
 
7
 
 
8
/*
 
9
  This file is part of Code_Saturne, a general-purpose CFD tool.
 
10
 
 
11
  Copyright (C) 1998-2011 EDF S.A.
 
12
 
 
13
  This program is free software; you can redistribute it and/or modify it under
 
14
  the terms of the GNU General Public License as published by the Free Software
 
15
  Foundation; either version 2 of the License, or (at your option) any later
 
16
  version.
 
17
 
 
18
  This program is distributed in the hope that it will be useful, but WITHOUT
 
19
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
20
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
21
  details.
 
22
 
 
23
  You should have received a copy of the GNU General Public License along with
 
24
  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
25
  Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
26
*/
 
27
 
 
28
/*----------------------------------------------------------------------------*/
 
29
 
 
30
/*
 
31
 * Obtain definitions such as that of size_t through stddef.h (C99 standard)
 
32
 * if available (preferred method), or through stdlib.h (which defines
 
33
 * malloc() and family and so must define size_t some way) otherwise.
 
34
 */
 
35
 
 
36
#if defined(__STDC_VERSION__)
 
37
#  if (__STDC_VERSION__ == 199901L)
 
38
#    include <stddef.h>
 
39
#  else
 
40
#    include <stdlib.h>
 
41
#  endif
 
42
#else
 
43
#  include <stdlib.h>
 
44
#endif
 
45
 
 
46
/* BFT library headers */
 
47
 
 
48
/*-----------------------------------------------------------------------------*/
 
49
 
 
50
#ifdef __cplusplus
 
51
extern "C" {
 
52
#if 0
 
53
} /* Fake brace to force Emacs auto-indentation back to column 0 */
 
54
#endif
 
55
#endif /* __cplusplus */
 
56
 
 
57
/*============================================================================
 
58
 * Public types
 
59
 *============================================================================*/
 
60
 
 
61
/*============================================================================
 
62
 * Public function prototypes
 
63
 *============================================================================*/
 
64
 
 
65
/*
 
66
 * Initialize memory usage count depending on system.
 
67
 *
 
68
 * This functions checks if it has already been called, so
 
69
 * it is safe to call more than once (though it is not
 
70
 * thread-safe). Only the first call is effective.
 
71
 */
 
72
 
 
73
void
 
74
bft_mem_usage_init(void);
 
75
 
 
76
/*
 
77
 * End memory usage count depending on system.
 
78
 */
 
79
 
 
80
void
 
81
bft_mem_usage_end(void);
 
82
 
 
83
/*
 
84
 * Indicates if bft_mem_usage_...() functions are initialized.
 
85
 *
 
86
 * returns:
 
87
 *   1 if bft_mem_usage_init has been called, 0 otherwise.
 
88
 */
 
89
 
 
90
int
 
91
bft_mem_usage_initialized(void);
 
92
 
 
93
/*
 
94
 * Return current process memory use (in kB) depending on OS.
 
95
 */
 
96
 
 
97
size_t
 
98
bft_mem_usage_pr_size(void);
 
99
 
 
100
/*
 
101
 * Return maximum process memory use (in kB) depending on OS.
 
102
 *
 
103
 * The returned value is the maximum returned by bft_mem_usage_pr_size()
 
104
 * during the program's lifetime. With memory allocations which return
 
105
 * memory to the system, this value could be incorrect in certain cases.
 
106
 */
 
107
 
 
108
size_t
 
109
bft_mem_usage_max_pr_size(void);
 
110
 
 
111
/*
 
112
 * Return counter to number of calls to malloc, realloc, and free.
 
113
 *
 
114
 * This function returns zeroes when the appropriate instrumentation
 
115
 * is not available.
 
116
 */
 
117
 
 
118
void
 
119
bft_mem_usage_n_calls(size_t count[3]);
 
120
 
 
121
/*----------------------------------------------------------------------------*/
 
122
 
 
123
#ifdef __cplusplus
 
124
}
 
125
#endif /* __cplusplus */
 
126
 
 
127
#endif /* __BFT_MEM_USAGE_H__ */