]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/jemalloc/include/jemalloc/internal/quarantine.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / jemalloc / include / jemalloc / internal / quarantine.h
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
3
4 typedef struct quarantine_obj_s quarantine_obj_t;
5 typedef struct quarantine_s quarantine_t;
6
7 /* Default per thread quarantine size if valgrind is enabled. */
8 #define JEMALLOC_VALGRIND_QUARANTINE_DEFAULT    (ZU(1) << 24)
9
10 #endif /* JEMALLOC_H_TYPES */
11 /******************************************************************************/
12 #ifdef JEMALLOC_H_STRUCTS
13
14 struct quarantine_obj_s {
15         void    *ptr;
16         size_t  usize;
17 };
18
19 struct quarantine_s {
20         size_t                  curbytes;
21         size_t                  curobjs;
22         size_t                  first;
23 #define LG_MAXOBJS_INIT 10
24         size_t                  lg_maxobjs;
25         quarantine_obj_t        objs[1]; /* Dynamically sized ring buffer. */
26 };
27
28 #endif /* JEMALLOC_H_STRUCTS */
29 /******************************************************************************/
30 #ifdef JEMALLOC_H_EXTERNS
31
32 quarantine_t    *quarantine_init(size_t lg_maxobjs);
33 void    quarantine(void *ptr);
34 void    quarantine_cleanup(void *arg);
35 bool    quarantine_boot(void);
36
37 #endif /* JEMALLOC_H_EXTERNS */
38 /******************************************************************************/
39 #ifdef JEMALLOC_H_INLINES
40
41 #ifndef JEMALLOC_ENABLE_INLINE
42 malloc_tsd_protos(JEMALLOC_ATTR(unused), quarantine, quarantine_t *)
43
44 void    quarantine_alloc_hook(void);
45 #endif
46
47 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_QUARANTINE_C_))
48 malloc_tsd_externs(quarantine, quarantine_t *)
49 malloc_tsd_funcs(JEMALLOC_ALWAYS_INLINE, quarantine, quarantine_t *, NULL,
50     quarantine_cleanup)
51
52 JEMALLOC_ALWAYS_INLINE void
53 quarantine_alloc_hook(void)
54 {
55         quarantine_t *quarantine;
56
57         assert(config_fill && opt_quarantine);
58
59         quarantine = *quarantine_tsd_get();
60         if (quarantine == NULL)
61                 quarantine_init(LG_MAXOBJS_INIT);
62 }
63 #endif
64
65 #endif /* JEMALLOC_H_INLINES */
66 /******************************************************************************/
67