GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / include / c++ / 4.5.3 / profile / impl / profiler_hash_func.h
blob22c26bfa8485fc46c9e0fad1deca93136d59b776
1 // -*- C++ -*-
2 //
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 2, or (at your option) any later
9 // version.
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
29 // Public License.
31 /** @file profile/impl/profiler_trace.h
32 * @brief Data structures to represent profiling traces.
35 // Written by Lixia Liu and Silvius Rus.
37 #ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
38 #define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
40 #ifdef __GXX_EXPERIMENTAL_CXX0X__
41 #include <cstdlib>
42 #include <cstdio>
43 #include <cstring>
44 #else
45 #include <stdlib.h>
46 #include <stdio.h>
47 #include <string.h>
48 #endif
49 #include "profile/impl/profiler.h"
50 #include "profile/impl/profiler_node.h"
51 #include "profile/impl/profiler_trace.h"
53 namespace __gnu_profile
56 /** @brief A hash performance instrumentation line in the object table. */
57 class __hashfunc_info: public __object_info_base
59 public:
60 __hashfunc_info()
61 :_M_longest_chain(0), _M_accesses(0), _M_hops(0) {}
62 __hashfunc_info(const __hashfunc_info& o);
63 __hashfunc_info(__stack_t __stack)
64 : __object_info_base(__stack),
65 _M_longest_chain(0), _M_accesses(0), _M_hops(0){}
66 virtual ~__hashfunc_info() {}
68 void __merge(const __hashfunc_info& __o);
69 void __destruct(size_t __chain, size_t __accesses, size_t __hops);
70 void __write(FILE* __f) const;
71 float __magnitude() const { return static_cast<float>(_M_hops); }
72 const char* __advice() const { return strdup("change hash function"); }
74 private:
75 size_t _M_longest_chain;
76 size_t _M_accesses;
77 size_t _M_hops;
80 inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
81 : __object_info_base(__o)
83 _M_longest_chain = __o._M_longest_chain;
84 _M_accesses = __o._M_accesses;
85 _M_hops = __o._M_hops;
88 inline void __hashfunc_info::__merge(const __hashfunc_info& __o)
90 _M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
91 _M_accesses += __o._M_accesses;
92 _M_hops += __o._M_hops;
95 inline void __hashfunc_info::__destruct(size_t __chain, size_t __accesses,
96 size_t __hops)
98 _M_longest_chain = std::max(_M_longest_chain, __chain);
99 _M_accesses += __accesses;
100 _M_hops += __hops;
103 /** @brief A hash performance instrumentation line in the stack table. */
104 class __hashfunc_stack_info: public __hashfunc_info {
105 public:
106 __hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
109 /** @brief Hash performance instrumentation producer. */
110 class __trace_hash_func
111 : public __trace_base<__hashfunc_info, __hashfunc_stack_info>
113 public:
114 __trace_hash_func();
115 ~__trace_hash_func() {}
117 // Insert a new node at construct with object, callstack and initial size.
118 void __insert(__object_t __obj, __stack_t __stack);
119 // Call at destruction/clean to set container final size.
120 void __destruct(const void* __obj, size_t __chain,
121 size_t __accesses, size_t __hops);
124 inline __trace_hash_func::__trace_hash_func()
125 : __trace_base<__hashfunc_info, __hashfunc_stack_info>()
127 __id = "hash-distr";
130 inline void __trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
132 __add_object(__obj, __hashfunc_info(__stack));
135 inline void __hashfunc_info::__write(FILE* __f) const
137 fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain);
140 inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain,
141 size_t __accesses, size_t __hops)
143 if (!__is_on()) return;
145 // First find the item from the live objects and update the informations.
146 __hashfunc_info* __objs = __get_object_info(__obj);
147 if (!__objs)
148 return;
150 __objs->__destruct(__chain, __accesses, __hops);
151 __retire_object(__obj);
154 inline void __trace_hash_func_init()
156 _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func();
159 inline void __trace_hash_func_report(FILE* __f,
160 __warning_vector_t& __warnings)
162 if (_GLIBCXX_PROFILE_DATA(_S_hash_func)) {
163 _GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings);
164 _GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f);
168 inline void __trace_hash_func_construct(const void* __obj)
170 if (!__profcxx_init()) return;
172 _GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack());
175 inline void __trace_hash_func_destruct(const void* __obj, size_t __chain,
176 size_t __accesses, size_t __hops)
178 if (!__profcxx_init()) return;
180 _GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses,
181 __hops);
184 } // namespace __gnu_profile
185 #endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */