doc: Add screenshot to spiv page.
[gfxprim/pasky.git] / tests / framework / tst_preload.h
blobb4922c40a4f57de618ecc1a161248f172c9d934b
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
23 #ifndef TST_PRELOAD_H
24 #define TST_PRELOAD_H
27 * Starts malloc check.
29 void tst_malloc_check_start(void);
32 * Stops malloc check.
34 void tst_malloc_check_stop(void);
36 enum tst_malloc_canary {
37 MALLOC_CANARY_OFF,
38 /* canary before the chunk */
39 MALLOC_CANARY_BEGIN,
40 /* canary after the chunk */
41 MALLOC_CANARY_END,
45 * Turns on malloc canaries.
47 * If turned on each malloc gets a canary (a page with both read and write
48 * turned off) allocated at the end or at the start of the allocated chunk.
50 * Canaries cannot be turned on when malloc checking is off, and malloc checking
51 * cannot be turned off when canaries are turned on.
53 void tst_malloc_canaries_set(enum tst_malloc_canary canary);
55 struct malloc_stats {
57 * Sum of all alocated chunks.
59 size_t total_size;
60 unsigned int total_chunks;
63 * Maximal allocated size and number of chunks at any time.
65 size_t max_size;
66 unsigned int max_chunks;
69 * Memory that was allocated but not freed
71 size_t lost_size;
72 unsigned int lost_chunks;
76 * Reports current malloc status.
78 * Size and chunks are filled with sum and number of currently allocated
79 * chunks, i.e, chunks that were allocated but not freed. The allocs is
80 * filled with number of allocations done.
82 void tst_malloc_check_report(struct malloc_stats *stats);
85 * Prints malloc statistics.
87 void tst_malloc_print(const struct malloc_stats *stats);
89 #endif /* TST_PRELOAD_H */