Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H
00038 #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1
00039
00040 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00041 #include <cstdlib>
00042 #include <cstdio>
00043 #include <cstring>
00044 #else
00045 #include <stdlib.h>
00046 #include <stdio.h>
00047 #include <string.h>
00048 #endif
00049 #include "profile/impl/profiler.h"
00050 #include "profile/impl/profiler_node.h"
00051 #include "profile/impl/profiler_trace.h"
00052
00053 namespace __gnu_profile
00054 {
00055
00056 class __list2slist_info: public __object_info_base
00057 {
00058 public:
00059 __list2slist_info() : _M_rewind(false), _M_operations(0) {}
00060 __list2slist_info(__stack_t __stack)
00061 : _M_rewind(false), _M_operations(0),__object_info_base(__stack) {}
00062 virtual ~__list2slist_info() {}
00063 __list2slist_info(const __list2slist_info& __o) : __object_info_base(__o)
00064 { _M_rewind = __o._M_rewind; _M_operations = __o._M_operations; }
00065
00066
00067
00068
00069
00070
00071
00072 float __magnitude() const
00073 { if (!_M_rewind) return _M_operations; else return 0; }
00074 void __merge(const __list2slist_info& __o) {};
00075 void __write(FILE* __f) const;
00076 const char* __advice() const
00077 { return strdup("change std::list to std::forward_list"); }
00078 void __opr_rewind() { _M_rewind = true; _M_valid = false;}
00079 void __record_operation() { _M_operations++; }
00080 bool __has_rewind() { return _M_rewind; }
00081
00082 private:
00083 bool _M_rewind;
00084 size_t _M_operations;
00085 };
00086
00087 class __list2slist_stack_info: public __list2slist_info {
00088 public:
00089 __list2slist_stack_info(const __list2slist_info& __o)
00090 : __list2slist_info(__o) {}
00091 };
00092
00093 class __trace_list_to_slist
00094 : public __trace_base<__list2slist_info, __list2slist_stack_info>
00095 {
00096 public:
00097 ~__trace_list_to_slist() {}
00098 __trace_list_to_slist()
00099 : __trace_base<__list2slist_info, __list2slist_stack_info>()
00100 { __id = "list-to-slist"; }
00101 void __opr_rewind(const void* __obj);
00102 void __record_operation(const void* __obj);
00103 void __insert(const __object_t __obj, __stack_t __stack)
00104 { __add_object(__obj, __list2slist_info(__stack)); }
00105 void __destruct(const void* __obj);
00106 };
00107
00108 inline void __list2slist_info::__write(FILE* __f) const
00109 {
00110 fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid");
00111 }
00112
00113 inline void __trace_list_to_slist::__destruct(const void* __obj)
00114 {
00115 if (!__is_on())
00116 return;
00117
00118 __list2slist_info* __res = __get_object_info(__obj);
00119 if (!__res)
00120 return;
00121
00122 __retire_object(__obj);
00123 }
00124
00125 inline void __trace_list_to_slist_init()
00126 {
00127 _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist();
00128 }
00129
00130 inline void __trace_list_to_slist_report(FILE* __f,
00131 __warning_vector_t& __warnings)
00132 {
00133 if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist)) {
00134 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__collect_warnings(__warnings);
00135 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f);
00136 }
00137 }
00138
00139 inline void __trace_list_to_slist::__opr_rewind(const void* __obj)
00140 {
00141 __list2slist_info* __res = __get_object_info(__obj);
00142 if (__res)
00143 __res->__opr_rewind();
00144 }
00145
00146 inline void __trace_list_to_slist::__record_operation(const void* __obj)
00147 {
00148 __list2slist_info* __res = __get_object_info(__obj);
00149 if (__res)
00150 __res->__record_operation();
00151 }
00152
00153 inline void __trace_list_to_slist_rewind(const void* __obj)
00154 {
00155 if (!__profcxx_init()) return;
00156
00157 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
00158 }
00159
00160 inline void __trace_list_to_slist_operation(const void* __obj)
00161 {
00162 if (!__profcxx_init()) return;
00163
00164 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj);
00165 }
00166
00167 inline void __trace_list_to_slist_construct(const void* __obj)
00168 {
00169 if (!__profcxx_init()) return;
00170
00171 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack());
00172 }
00173
00174 inline void __trace_list_to_slist_destruct(const void* __obj)
00175 {
00176 if (!__profcxx_init()) return;
00177
00178 _GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj);
00179 }
00180
00181 }
00182 #endif