Commit c7d42abb by Paolo Carlini Committed by Paolo Carlini

profiler_trace.h (__warning_data:: __warning_message): Change to std::string...

2010-06-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/profile/impl/profiler_trace.h (__warning_data::
	__warning_message): Change to std::string; clean-up includes,
	qualify size_t, fprintf, etc, with std everywhere.
	(struct __warn::operator()): Adjust.
	* include/profile/impl/profiler_list_to_slist.h
	(__list2slist_info::__advice): Change to return a std::string;
	clean-up includes, qualify size_t, fprintf, etc, with std.
	* include/profile/impl/profiler_container_size.h
	(__container_size_info::__advice): Likewise.
	* include/profile/impl/profiler_hash_func.h (__hashfunc_info::
	__advice): Likewise.
	* include/profile/impl/profiler_list_to_vector.h
	(__list2vector_info::__advice): Likewise.
	* include/profile/impl/profiler_vector_to_list.h
	(__vector2list_info::__advice): Likewise.
	* include/profile/impl/profiler_map_to_unordered_map.h
	(__map2umap_info::__advice): Likewise.
	* include/profile/impl/profiler.h: Likewise.
	* include/profile/impl/profiler_hashtable_size.h: Likewise.
	* include/profile/impl/profiler_node.h: Likewise.
	* include/profile/impl/profiler_vector_size.h: Likewise.

	* include/profile/iterator_tracker.h: Formatting and stylistic
	tweaks.
	* include/profile/base.h: Likewise.
	* include/profile/map.h: Likewise.

From-SVN: r161325
parent 4f8f9b8f
2010-06-24 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_trace.h (__warning_data::
__warning_message): Change to std::string; clean-up includes,
qualify size_t, fprintf, etc, with std everywhere.
(struct __warn::operator()): Adjust.
* include/profile/impl/profiler_list_to_slist.h
(__list2slist_info::__advice): Change to return a std::string;
clean-up includes, qualify size_t, fprintf, etc, with std.
* include/profile/impl/profiler_container_size.h
(__container_size_info::__advice): Likewise.
* include/profile/impl/profiler_hash_func.h (__hashfunc_info::
__advice): Likewise.
* include/profile/impl/profiler_list_to_vector.h
(__list2vector_info::__advice): Likewise.
* include/profile/impl/profiler_vector_to_list.h
(__vector2list_info::__advice): Likewise.
* include/profile/impl/profiler_map_to_unordered_map.h
(__map2umap_info::__advice): Likewise.
* include/profile/impl/profiler.h: Likewise.
* include/profile/impl/profiler_hashtable_size.h: Likewise.
* include/profile/impl/profiler_node.h: Likewise.
* include/profile/impl/profiler_vector_size.h: Likewise.
* include/profile/iterator_tracker.h: Formatting and stylistic
tweaks.
* include/profile/base.h: Likewise.
* include/profile/map.h: Likewise.
2010-06-23 Paolo Carlini <paolo.carlini@oracle.com> 2010-06-23 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_tree.h (erase(iterator), erase(const_iterator)): * include/bits/stl_tree.h (erase(iterator), erase(const_iterator)):
......
...@@ -38,9 +38,7 @@ ...@@ -38,9 +38,7 @@
#ifndef _GLIBCXX_PROFILE_BASE_H #ifndef _GLIBCXX_PROFILE_BASE_H
#define _GLIBCXX_PROFILE_BASE_H 1 #define _GLIBCXX_PROFILE_BASE_H 1
#include <cstdio>
#include <functional> #include <functional>
#include <bits/c++config.h>
#include <profile/impl/profiler.h> #include <profile/impl/profiler.h>
// Profiling mode namespaces. // Profiling mode namespaces.
......
...@@ -37,11 +37,7 @@ ...@@ -37,11 +37,7 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_H #ifndef _GLIBCXX_PROFILE_PROFILER_H
#define _GLIBCXX_PROFILE_PROFILER_H 1 #define _GLIBCXX_PROFILE_PROFILER_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #include <bits/c++config.h>
#include <cstddef>
#else
#include <stddef.h>
#endif
// Mechanism to define data with inline linkage. // Mechanism to define data with inline linkage.
#define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \ #define _GLIBCXX_PROFILE_DEFINE_UNINIT_DATA(__type, __name) \
...@@ -109,21 +105,22 @@ namespace __gnu_profile ...@@ -109,21 +105,22 @@ namespace __gnu_profile
bool __is_on(); bool __is_on();
bool __is_off(); bool __is_off();
void __report(void); void __report(void);
void __trace_hashtable_size_resize(const void*, size_t, size_t); void __trace_hashtable_size_resize(const void*, std::size_t, std::size_t);
void __trace_hashtable_size_destruct(const void*, size_t, size_t); void __trace_hashtable_size_destruct(const void*, std::size_t, std::size_t);
void __trace_hashtable_size_construct(const void*, size_t); void __trace_hashtable_size_construct(const void*, std::size_t);
void __trace_vector_size_resize(const void*, size_t, size_t); void __trace_vector_size_resize(const void*, std::size_t, std::size_t);
void __trace_vector_size_destruct(const void*, size_t, size_t); void __trace_vector_size_destruct(const void*, std::size_t, std::size_t);
void __trace_vector_size_construct(const void*, size_t); void __trace_vector_size_construct(const void*, std::size_t);
void __trace_hash_func_destruct(const void*, size_t, size_t, size_t); void __trace_hash_func_destruct(const void*, std::size_t, std::size_t,
std::size_t);
void __trace_hash_func_construct(const void*); void __trace_hash_func_construct(const void*);
void __trace_vector_to_list_destruct(const void*); void __trace_vector_to_list_destruct(const void*);
void __trace_vector_to_list_construct(const void*); void __trace_vector_to_list_construct(const void*);
void __trace_vector_to_list_insert(const void*, size_t, size_t); void __trace_vector_to_list_insert(const void*, std::size_t, std::size_t);
void __trace_vector_to_list_iterate(const void*, size_t); void __trace_vector_to_list_iterate(const void*, std::size_t);
void __trace_vector_to_list_invalid_operator(const void*); void __trace_vector_to_list_invalid_operator(const void*);
void __trace_vector_to_list_resize(const void*, size_t, size_t); void __trace_vector_to_list_resize(const void*, std::size_t, std::size_t);
void __trace_vector_to_list_find(const void*, size_t); void __trace_vector_to_list_find(const void*, std::size_t);
void __trace_list_to_slist_destruct(const void*); void __trace_list_to_slist_destruct(const void*);
void __trace_list_to_slist_construct(const void*); void __trace_list_to_slist_construct(const void*);
...@@ -132,24 +129,26 @@ namespace __gnu_profile ...@@ -132,24 +129,26 @@ namespace __gnu_profile
void __trace_list_to_vector_destruct(const void*); void __trace_list_to_vector_destruct(const void*);
void __trace_list_to_vector_construct(const void*); void __trace_list_to_vector_construct(const void*);
void __trace_list_to_vector_insert(const void*, size_t, size_t); void __trace_list_to_vector_insert(const void*, std::size_t, std::size_t);
void __trace_list_to_vector_iterate(const void*, size_t); void __trace_list_to_vector_iterate(const void*, std::size_t);
void __trace_list_to_vector_invalid_operator(const void*); void __trace_list_to_vector_invalid_operator(const void*);
void __trace_list_to_vector_resize(const void*, size_t, size_t); void __trace_list_to_vector_resize(const void*, std::size_t, std::size_t);
void __trace_list_to_set_destruct(const void*); void __trace_list_to_set_destruct(const void*);
void __trace_list_to_set_construct(const void*); void __trace_list_to_set_construct(const void*);
void __trace_list_to_set_insert(const void*, size_t, size_t); void __trace_list_to_set_insert(const void*, std::size_t, std::size_t);
void __trace_list_to_set_iterate(const void*, size_t); void __trace_list_to_set_iterate(const void*, std::size_t);
void __trace_list_to_set_invalid_operator(const void*); void __trace_list_to_set_invalid_operator(const void*);
void __trace_list_to_set_find(const void*, size_t); void __trace_list_to_set_find(const void*, std::size_t);
void __trace_map_to_unordered_map_construct(const void*); void __trace_map_to_unordered_map_construct(const void*);
void __trace_map_to_unordered_map_invalidate(const void*); void __trace_map_to_unordered_map_invalidate(const void*);
void __trace_map_to_unordered_map_insert(const void*, size_t, size_t); void __trace_map_to_unordered_map_insert(const void*, std::size_t,
void __trace_map_to_unordered_map_erase(const void*, size_t, size_t); std::size_t);
void __trace_map_to_unordered_map_iterate(const void*, size_t); void __trace_map_to_unordered_map_erase(const void*, std::size_t,
void __trace_map_to_unordered_map_find(const void*, size_t); std::size_t);
void __trace_map_to_unordered_map_iterate(const void*, std::size_t);
void __trace_map_to_unordered_map_find(const void*, std::size_t);
void __trace_map_to_unordered_map_destruct(const void*); void __trace_map_to_unordered_map_destruct(const void*);
} // namespace __gnu_profile } // namespace __gnu_profile
......
...@@ -37,16 +37,6 @@ ...@@ -37,16 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H #ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1 #define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include <sstream> #include <sstream>
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
...@@ -73,7 +63,7 @@ namespace __gnu_profile ...@@ -73,7 +63,7 @@ namespace __gnu_profile
_M_resize(__o._M_resize), _M_cost(__o._M_cost) _M_resize(__o._M_resize), _M_cost(__o._M_cost)
{ } { }
__container_size_info(__stack_t __stack, size_t __num) __container_size_info(__stack_t __stack, std::size_t __num)
: __object_info_base(__stack), _M_init(__num), _M_max(__num), : __object_info_base(__stack), _M_init(__num), _M_max(__num),
_M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0), _M_min(0), _M_total(0), _M_item_min(0), _M_item_max(0),
_M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0) _M_item_total(0), _M_count(0), _M_resize(0), _M_cost(0)
...@@ -84,23 +74,23 @@ namespace __gnu_profile ...@@ -84,23 +74,23 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ {
fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n", std::fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max, _M_total, _M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max,
_M_item_min, _M_item_max, _M_item_total); _M_total, _M_item_min, _M_item_max, _M_item_total);
} }
float float
__magnitude() const __magnitude() const
{ return static_cast<float>(_M_cost); } { return static_cast<float>(_M_cost); }
const char* std::string
__advice() const __advice() const
{ {
std::stringstream __message; std::stringstream __message;
if (_M_init < _M_item_max) if (_M_init < _M_item_max)
__message << "change initial container size from " << _M_init __message << "change initial container size from " << _M_init
<< " to " << _M_item_max; << " to " << _M_item_max;
return strdup(__message.str().c_str()); return __message.str();
} }
void void
...@@ -120,7 +110,7 @@ namespace __gnu_profile ...@@ -120,7 +110,7 @@ namespace __gnu_profile
// Call if a container is destructed or cleaned. // Call if a container is destructed or cleaned.
void void
__destruct(size_t __num, size_t __inum) __destruct(std::size_t __num, std::size_t __inum)
{ {
_M_max = std::max(_M_max, __num); _M_max = std::max(_M_max, __num);
_M_item_max = std::max(_M_item_max, __inum); _M_item_max = std::max(_M_item_max, __inum);
...@@ -141,12 +131,12 @@ namespace __gnu_profile ...@@ -141,12 +131,12 @@ namespace __gnu_profile
// Estimate the cost of resize/rehash. // Estimate the cost of resize/rehash.
float float
__resize_cost(size_t __from, size_t) __resize_cost(std::size_t __from, std::size_t)
{ return __from; } { return __from; }
// Call if container is resized. // Call if container is resized.
void void
__resize(size_t __from, size_t __to) __resize(std::size_t __from, std::size_t __to)
{ {
_M_cost += this->__resize_cost(__from, __to); _M_cost += this->__resize_cost(__from, __to);
_M_resize += 1; _M_resize += 1;
...@@ -154,16 +144,16 @@ namespace __gnu_profile ...@@ -154,16 +144,16 @@ namespace __gnu_profile
} }
private: private:
size_t _M_init; std::size_t _M_init;
size_t _M_max; // range of # buckets std::size_t _M_max; // range of # buckets
size_t _M_min; std::size_t _M_min;
size_t _M_total; std::size_t _M_total;
size_t _M_item_min; // range of # items std::size_t _M_item_min; // range of # items
size_t _M_item_max; std::size_t _M_item_max;
size_t _M_item_total; std::size_t _M_item_total;
size_t _M_count; std::size_t _M_count;
size_t _M_resize; std::size_t _M_resize;
size_t _M_cost; std::size_t _M_cost;
}; };
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H #ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1 #define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -66,9 +57,9 @@ namespace __gnu_profile ...@@ -66,9 +57,9 @@ namespace __gnu_profile
__hashfunc_info(__stack_t __stack) __hashfunc_info(__stack_t __stack)
: __object_info_base(__stack), : __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){ } _M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
virtual ~__hashfunc_info() {} virtual ~__hashfunc_info() { }
void void
__merge(const __hashfunc_info& __o) __merge(const __hashfunc_info& __o)
...@@ -79,7 +70,8 @@ namespace __gnu_profile ...@@ -79,7 +70,8 @@ namespace __gnu_profile
} }
void void
__destruct(size_t __chain, size_t __accesses, size_t __hops) __destruct(std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{ {
_M_longest_chain = std::max(_M_longest_chain, __chain); _M_longest_chain = std::max(_M_longest_chain, __chain);
_M_accesses += __accesses; _M_accesses += __accesses;
...@@ -88,20 +80,21 @@ namespace __gnu_profile ...@@ -88,20 +80,21 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); } { std::fprintf(__f, "%Zu %Zu %Zu\n", _M_hops,
_M_accesses, _M_longest_chain); }
float float
__magnitude() const __magnitude() const
{ return static_cast<float>(_M_hops); } { return static_cast<float>(_M_hops); }
const char* std::string
__advice() const __advice() const
{ return strdup("change hash function"); } { return "change hash function"; }
private: private:
size_t _M_longest_chain; std::size_t _M_longest_chain;
size_t _M_accesses; std::size_t _M_accesses;
size_t _M_hops; std::size_t _M_hops;
}; };
...@@ -133,8 +126,8 @@ namespace __gnu_profile ...@@ -133,8 +126,8 @@ namespace __gnu_profile
// Call at destruction/clean to set container final size. // Call at destruction/clean to set container final size.
void void
__destruct(const void* __obj, size_t __chain, __destruct(const void* __obj, std::size_t __chain,
size_t __accesses, size_t __hops) std::size_t __accesses, std::size_t __hops)
{ {
if (!__is_on()) if (!__is_on())
return; return;
...@@ -174,14 +167,14 @@ namespace __gnu_profile ...@@ -174,14 +167,14 @@ namespace __gnu_profile
} }
inline void inline void
__trace_hash_func_destruct(const void* __obj, size_t __chain, __trace_hash_func_destruct(const void* __obj, std::size_t __chain,
size_t __accesses, size_t __hops) std::size_t __accesses, std::size_t __hops)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses, _GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain,
__hops); __accesses, __hops);
} }
} // namespace __gnu_profile } // namespace __gnu_profile
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H #ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1 #define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -80,7 +71,7 @@ namespace __gnu_profile ...@@ -80,7 +71,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_hashtable_size_construct(const void* __obj, size_t __num) __trace_hashtable_size_construct(const void* __obj, std::size_t __num)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -90,8 +81,8 @@ namespace __gnu_profile ...@@ -90,8 +81,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_hashtable_size_destruct(const void* __obj, size_t __num, __trace_hashtable_size_destruct(const void* __obj, std::size_t __num,
size_t __inum) std::size_t __inum)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -100,8 +91,8 @@ namespace __gnu_profile ...@@ -100,8 +91,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_hashtable_size_resize(const void* __obj, size_t __from, __trace_hashtable_size_resize(const void* __obj, std::size_t __from,
size_t __to) std::size_t __to)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1 #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -90,11 +81,11 @@ namespace __gnu_profile ...@@ -90,11 +81,11 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); } { std::fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
const char* std::string
__advice() const __advice() const
{ return strdup("change std::list to std::forward_list"); } { return "change std::list to std::forward_list"; }
void void
__opr_rewind() __opr_rewind()
...@@ -113,7 +104,7 @@ namespace __gnu_profile ...@@ -113,7 +104,7 @@ namespace __gnu_profile
private: private:
bool _M_rewind; bool _M_rewind;
size_t _M_operations; std::size_t _M_operations;
}; };
class __list2slist_stack_info class __list2slist_stack_info
......
...@@ -37,17 +37,8 @@ ...@@ -37,17 +37,8 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H #ifndef _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H
#define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1 #define _GLIBCXX_PROFILE_PROFILER_LIST_TO_VECTOR_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdlib>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include <string>
#include <sstream> #include <sstream>
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -91,29 +82,29 @@ namespace __gnu_profile ...@@ -91,29 +82,29 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ {
fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize, std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_iterate, _M_vector_cost, _M_list_cost); _M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
} }
float float
__magnitude() const __magnitude() const
{ return _M_list_cost - _M_vector_cost; } { return _M_list_cost - _M_vector_cost; }
const char* std::string
__advice() const __advice() const
{ {
std::stringstream __sstream; std::stringstream __sstream;
__sstream __sstream
<< "change std::list to std::vector and its initial size from 0 to " << "change std::list to std::vector and its initial size from 0 to "
<< _M_max_size; << _M_max_size;
return strdup(__sstream.str().c_str()); return __sstream.str();
} }
size_t std::size_t
__shift_count() __shift_count()
{ return _M_shift_count; } { return _M_shift_count; }
size_t std::size_t
__iterate() __iterate()
{ return _M_iterate; } { return _M_iterate; }
...@@ -121,7 +112,7 @@ namespace __gnu_profile ...@@ -121,7 +112,7 @@ namespace __gnu_profile
__list_cost() __list_cost()
{ return _M_list_cost; } { return _M_list_cost; }
size_t std::size_t
__resize() __resize()
{ return _M_resize; } { return _M_resize; }
...@@ -142,28 +133,28 @@ namespace __gnu_profile ...@@ -142,28 +133,28 @@ namespace __gnu_profile
{ _M_valid = false; } { _M_valid = false; }
void void
__opr_insert(size_t __shift, size_t __size) __opr_insert(std::size_t __shift, std::size_t __size)
{ {
_M_shift_count += __shift; _M_shift_count += __shift;
_M_max_size = std::max(_M_max_size, __size); _M_max_size = std::max(_M_max_size, __size);
} }
void void
__opr_iterate(size_t __num) __opr_iterate(std::size_t __num)
{ _M_iterate += __num;} { _M_iterate += __num;}
void void
__resize(size_t __from, size_t) __resize(std::size_t __from, std::size_t)
{ _M_resize += __from; } { _M_resize += __from; }
private: private:
size_t _M_shift_count; std::size_t _M_shift_count;
size_t _M_iterate; std::size_t _M_iterate;
size_t _M_resize; std::size_t _M_resize;
float _M_list_cost; float _M_list_cost;
float _M_vector_cost; float _M_vector_cost;
bool _M_valid; bool _M_valid;
size_t _M_max_size; std::size_t _M_max_size;
}; };
class __list2vector_stack_info class __list2vector_stack_info
...@@ -212,7 +203,7 @@ namespace __gnu_profile ...@@ -212,7 +203,7 @@ namespace __gnu_profile
// Collect cost of operations. // Collect cost of operations.
void void
__opr_insert(const void* __obj, size_t __shift, size_t __size) __opr_insert(const void* __obj, std::size_t __shift, std::size_t __size)
{ {
__list2vector_info* __res = __get_object_info(__obj); __list2vector_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -220,7 +211,7 @@ namespace __gnu_profile ...@@ -220,7 +211,7 @@ namespace __gnu_profile
} }
void void
__opr_iterate(const void* __obj, size_t __num) __opr_iterate(const void* __obj, std::size_t __num)
{ {
__list2vector_info* __res = __get_object_info(__obj); __list2vector_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -236,7 +227,7 @@ namespace __gnu_profile ...@@ -236,7 +227,7 @@ namespace __gnu_profile
} }
void void
__resize(const void* __obj, size_t __from, size_t __to) __resize(const void* __obj, std::size_t __from, std::size_t __to)
{ {
__list2vector_info* __res = __get_object_info(__obj); __list2vector_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -244,7 +235,7 @@ namespace __gnu_profile ...@@ -244,7 +235,7 @@ namespace __gnu_profile
} }
float float
__vector_cost(size_t __shift, size_t __iterate) __vector_cost(std::size_t __shift, std::size_t __iterate)
{ {
// The resulting vector will use a 'reserve' method. // The resulting vector will use a 'reserve' method.
return (__shift return (__shift
...@@ -254,7 +245,7 @@ namespace __gnu_profile ...@@ -254,7 +245,7 @@ namespace __gnu_profile
} }
float float
__list_cost(size_t __shift, size_t __iterate) __list_cost(std::size_t __shift, std::size_t __iterate)
{ {
return (__shift return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
...@@ -299,7 +290,7 @@ namespace __gnu_profile ...@@ -299,7 +290,7 @@ namespace __gnu_profile
inline void inline void
__trace_list_to_vector_insert(const void* __obj, __trace_list_to_vector_insert(const void* __obj,
size_t __shift, size_t __size) std::size_t __shift, std::size_t __size)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -309,7 +300,7 @@ namespace __gnu_profile ...@@ -309,7 +300,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_list_to_vector_iterate(const void* __obj, size_t __num = 1) __trace_list_to_vector_iterate(const void* __obj, std::size_t __num = 1)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -328,7 +319,7 @@ namespace __gnu_profile ...@@ -328,7 +319,7 @@ namespace __gnu_profile
inline void inline void
__trace_list_to_vector_resize(const void* __obj, __trace_list_to_vector_resize(const void* __obj,
size_t __from, size_t __to) std::size_t __from, std::size_t __to)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H #ifndef _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H
#define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1 #define _GLIBCXX_PROFILE_PROFILER_MAP_TO_UNORDERED_MAP_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -53,9 +44,9 @@ ...@@ -53,9 +44,9 @@
namespace __gnu_profile namespace __gnu_profile
{ {
inline int inline int
__log2(size_t __size) __log2(std::size_t __size)
{ {
for (int __bit_count = sizeof(size_t) - 1; __bit_count >= 0; for (int __bit_count = sizeof(std::size_t) - 1; __bit_count >= 0;
-- __bit_count) -- __bit_count)
if ((2 << __bit_count) & __size) if ((2 << __bit_count) & __size)
return __bit_count; return __bit_count;
...@@ -63,17 +54,17 @@ namespace __gnu_profile ...@@ -63,17 +54,17 @@ namespace __gnu_profile
} }
inline float inline float
__map_insert_cost(size_t __size) __map_insert_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value { return (_GLIBCXX_PROFILE_DATA(__map_insert_cost_factor).__value
* static_cast<float>(__log2(__size))); } * static_cast<float>(__log2(__size))); }
inline float inline float
__map_erase_cost(size_t __size) __map_erase_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value { return (_GLIBCXX_PROFILE_DATA(__map_erase_cost_factor).__value
* static_cast<float>(__log2(__size))); } * static_cast<float>(__log2(__size))); }
inline float inline float
__map_find_cost(size_t __size) __map_find_cost(std::size_t __size)
{ return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value { return (_GLIBCXX_PROFILE_DATA(__map_find_cost_factor).__value
* static_cast<float>(__log2(__size))); } * static_cast<float>(__log2(__size))); }
...@@ -113,7 +104,7 @@ namespace __gnu_profile ...@@ -113,7 +104,7 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ {
fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n", std::fprintf(__f, "%Zu %Zu %Zu %Zu %.0f %.0f %s\n",
_M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost, _M_insert, _M_erase, _M_find, _M_iterate, _M_map_cost,
_M_umap_cost, _M_valid ? "valid" : "invalid"); _M_umap_cost, _M_valid ? "valid" : "invalid");
} }
...@@ -122,12 +113,12 @@ namespace __gnu_profile ...@@ -122,12 +113,12 @@ namespace __gnu_profile
__magnitude() const __magnitude() const
{ return _M_map_cost - _M_umap_cost; } { return _M_map_cost - _M_umap_cost; }
const char* std::string
__advice() const __advice() const
{ return strdup("change std::map to std::unordered_map"); } { return "change std::map to std::unordered_map"; }
void void
__record_insert(size_t __size, size_t __count) __record_insert(std::size_t __size, std::size_t __count)
{ {
_M_insert += __count; _M_insert += __count;
_M_map_cost += __count * __map_insert_cost(__size); _M_map_cost += __count * __map_insert_cost(__size);
...@@ -137,7 +128,7 @@ namespace __gnu_profile ...@@ -137,7 +128,7 @@ namespace __gnu_profile
} }
void void
__record_erase(size_t __size, size_t __count) __record_erase(std::size_t __size, std::size_t __count)
{ {
_M_erase += __count; _M_erase += __count;
_M_map_cost += __count * __map_erase_cost(__size); _M_map_cost += __count * __map_erase_cost(__size);
...@@ -147,7 +138,7 @@ namespace __gnu_profile ...@@ -147,7 +138,7 @@ namespace __gnu_profile
} }
void void
__record_find(size_t __size) __record_find(std::size_t __size)
{ {
_M_find += 1; _M_find += 1;
_M_map_cost += __map_find_cost(__size); _M_map_cost += __map_find_cost(__size);
...@@ -155,7 +146,7 @@ namespace __gnu_profile ...@@ -155,7 +146,7 @@ namespace __gnu_profile
} }
void void
__record_iterate(size_t __count) __record_iterate(std::size_t __count)
{ {
_M_iterate += __count; _M_iterate += __count;
_M_map_cost _M_map_cost
...@@ -171,10 +162,10 @@ namespace __gnu_profile ...@@ -171,10 +162,10 @@ namespace __gnu_profile
{ _M_valid = false; } { _M_valid = false; }
private: private:
size_t _M_insert; std::size_t _M_insert;
size_t _M_erase; std::size_t _M_erase;
size_t _M_find; std::size_t _M_find;
size_t _M_iterate; std::size_t _M_iterate;
float _M_umap_cost; float _M_umap_cost;
float _M_map_cost; float _M_map_cost;
bool _M_valid; bool _M_valid;
...@@ -237,7 +228,7 @@ namespace __gnu_profile ...@@ -237,7 +228,7 @@ namespace __gnu_profile
inline void inline void
__trace_map_to_unordered_map_insert(const void* __obj, __trace_map_to_unordered_map_insert(const void* __obj,
size_t __size, size_t __count) std::size_t __size, std::size_t __count)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -251,7 +242,7 @@ namespace __gnu_profile ...@@ -251,7 +242,7 @@ namespace __gnu_profile
inline void inline void
__trace_map_to_unordered_map_erase(const void* __obj, __trace_map_to_unordered_map_erase(const void* __obj,
size_t __size, size_t __count) std::size_t __size, std::size_t __count)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -264,7 +255,7 @@ namespace __gnu_profile ...@@ -264,7 +255,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_map_to_unordered_map_find(const void* __obj, size_t __size) __trace_map_to_unordered_map_find(const void* __obj, std::size_t __size)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -277,7 +268,7 @@ namespace __gnu_profile ...@@ -277,7 +268,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_map_to_unordered_map_iterate(const void* __obj, size_t __count) __trace_map_to_unordered_map_iterate(const void* __obj, std::size_t __count)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
......
...@@ -37,15 +37,8 @@ ...@@ -37,15 +37,8 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H #ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H
#define _GLIBCXX_PROFILE_PROFILER_NODE_H 1 #define _GLIBCXX_PROFILE_PROFILER_NODE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #include <cstdio> // FILE, fprintf
#include <cstdio>
#include <cstdint>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include <vector> #include <vector>
#if defined _GLIBCXX_HAVE_EXECINFO_H #if defined _GLIBCXX_HAVE_EXECINFO_H
#include <execinfo.h> #include <execinfo.h>
...@@ -58,26 +51,27 @@ namespace __gnu_profile ...@@ -58,26 +51,27 @@ namespace __gnu_profile
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt; typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t; typedef __stack_npt* __stack_t;
size_t __stack_max_depth(); std::size_t __stack_max_depth();
inline __stack_t inline __stack_t
__get_stack() __get_stack()
{ {
#if defined _GLIBCXX_HAVE_EXECINFO_H #if defined _GLIBCXX_HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth(); std::size_t __max_depth = __stack_max_depth();
if (__max_depth == 0) if (__max_depth == 0)
return 0; return 0;
__stack_npt __buffer(__max_depth); __stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth); int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth); __stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t)); __builtin_memcpy(&(*__stack)[0], &__buffer[0],
__depth * sizeof(__object_t));
return __stack; return __stack;
#else #else
return 0; return 0;
#endif #endif
} }
inline size_t inline std::size_t
__size(__stack_t __stack) __size(__stack_t __stack)
{ {
if (!__stack) if (!__stack)
...@@ -95,23 +89,23 @@ namespace __gnu_profile ...@@ -95,23 +89,23 @@ namespace __gnu_profile
__stack_npt::const_iterator __it; __stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it) for (__it = __stack->begin(); __it != __stack->end(); ++__it)
fprintf(__f, "%p ", *__it); std::fprintf(__f, "%p ", *__it);
} }
/** @brief Hash function for summary trace using call stack as index. */ /** @brief Hash function for summary trace using call stack as index. */
class __stack_hash class __stack_hash
{ {
public: public:
size_t std::size_t
operator()(__stack_t __s) const operator()(__stack_t __s) const
{ {
if (!__s) if (!__s)
return 0; return 0;
uintptr_t __index = 0; __UINTPTR_TYPE__ __index = 0;
__stack_npt::const_iterator __it; __stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it) for (__it = __s->begin(); __it != __s->end(); ++__it)
__index += reinterpret_cast<uintptr_t>(*__it); __index += reinterpret_cast<__UINTPTR_TYPE__>(*__it);
return __index; return __index;
} }
...@@ -124,8 +118,10 @@ namespace __gnu_profile ...@@ -124,8 +118,10 @@ namespace __gnu_profile
if (__stack1->size() != __stack2->size()) if (__stack1->size() != __stack2->size())
return false; return false;
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type); std::size_t __byte_size
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0; = __stack1->size() * sizeof(__stack_npt::value_type);
return __builtin_memcmp(&(*__stack1)[0], &(*__stack2)[0],
__byte_size) == 0;
} }
}; };
......
...@@ -37,18 +37,14 @@ ...@@ -37,18 +37,14 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_TRACE_H #ifndef _GLIBCXX_PROFILE_PROFILER_TRACE_H
#define _GLIBCXX_PROFILE_PROFILER_TRACE_H 1 #define _GLIBCXX_PROFILE_PROFILER_TRACE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #include <cstdio> // fopen, fclose, fprintf, FILE
#include <cerrno> #include <cerrno>
#include <cstdint> #include <cstdlib> // atof, atoi, strtol, getenv, atexit, abort
#include <cstdio>
#include <cstdlib> #ifdef __GXX_EXPERIMENTAL_CXX0X__
#define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_PR::unordered_map #define _GLIBCXX_IMPL_UNORDERED_MAP std::_GLIBCXX_STD_PR::unordered_map
#include <unordered_map> #include <unordered_map>
#else #else
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <tr1/unordered_map> #include <tr1/unordered_map>
#define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map #define _GLIBCXX_IMPL_UNORDERED_MAP std::tr1::unordered_map
#endif #endif
...@@ -86,18 +82,18 @@ namespace __gnu_profile ...@@ -86,18 +82,18 @@ namespace __gnu_profile
float __magnitude; float __magnitude;
__stack_t __context; __stack_t __context;
const char* __warning_id; const char* __warning_id;
const char* __warning_message; std::string __warning_message;
__warning_data() __warning_data()
: __magnitude(0.0), __context(0), __warning_id(0), : __magnitude(0.0), __context(0), __warning_id(0) { }
__warning_message(0) { }
__warning_data(float __m, __stack_t __c, const char* __id, __warning_data(float __m, __stack_t __c, const char* __id,
const char* __msg) const std::string& __msg)
: __magnitude(__m), __context(__c), __warning_id(__id), : __magnitude(__m), __context(__c), __warning_id(__id),
__warning_message(__msg) { } __warning_message(__msg) { }
bool bool
operator<(const struct __warning_data& __other) const operator<(const __warning_data& __other) const
{ return __magnitude < __other.__magnitude; } { return __magnitude < __other.__magnitude; }
}; };
...@@ -174,18 +170,18 @@ namespace __gnu_profile ...@@ -174,18 +170,18 @@ namespace __gnu_profile
_GLIBCXX_PROFILE_DEFINE_DATA(const char*, _S_trace_file_name, _GLIBCXX_PROFILE_DEFINE_DATA(const char*, _S_trace_file_name,
_GLIBCXX_PROFILE_TRACE_PATH_ROOT); _GLIBCXX_PROFILE_TRACE_PATH_ROOT);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_warn_count, _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_warn_count,
_GLIBCXX_PROFILE_MAX_WARN_COUNT); _GLIBCXX_PROFILE_MAX_WARN_COUNT);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_stack_depth, _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_stack_depth,
_GLIBCXX_PROFILE_MAX_STACK_DEPTH); _GLIBCXX_PROFILE_MAX_STACK_DEPTH);
_GLIBCXX_PROFILE_DEFINE_DATA(size_t, _S_max_mem, _GLIBCXX_PROFILE_DEFINE_DATA(std::size_t, _S_max_mem,
_GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC); _GLIBCXX_PROFILE_MEM_PER_DIAGNOSTIC);
inline size_t inline std::size_t
__stack_max_depth() __stack_max_depth()
{ return _GLIBCXX_PROFILE_DATA(_S_max_stack_depth); } { return _GLIBCXX_PROFILE_DATA(_S_max_stack_depth); }
inline size_t inline std::size_t
__max_mem() __max_mem()
{ return _GLIBCXX_PROFILE_DATA(_S_max_mem); } { return _GLIBCXX_PROFILE_DATA(_S_max_mem); }
...@@ -200,7 +196,7 @@ namespace __gnu_profile ...@@ -200,7 +196,7 @@ namespace __gnu_profile
void __add_object(__object_t object, __object_info __info); void __add_object(__object_t object, __object_info __info);
__object_info* __get_object_info(__object_t __object); __object_info* __get_object_info(__object_t __object);
void __retire_object(__object_t __object); void __retire_object(__object_t __object);
void __write(FILE* f); void __write(FILE* __f);
void __collect_warnings(__warning_vector_t& __warnings); void __collect_warnings(__warning_vector_t& __warnings);
private: private:
...@@ -213,7 +209,7 @@ namespace __gnu_profile ...@@ -213,7 +209,7 @@ namespace __gnu_profile
__stack_hash> __stack_table_t; __stack_hash> __stack_table_t;
__object_table_t __object_table; __object_table_t __object_table;
__stack_table_t __stack_table; __stack_table_t __stack_table;
size_t __stack_table_byte_size; std::size_t __stack_table_byte_size;
protected: protected:
const char* __id; const char* __id;
...@@ -336,30 +332,32 @@ namespace __gnu_profile ...@@ -336,30 +332,32 @@ namespace __gnu_profile
{ {
if (__it->second.__is_valid()) if (__it->second.__is_valid())
{ {
fprintf(__f, __id); std::fprintf(__f, __id);
fprintf(__f, "|"); std::fprintf(__f, "|");
__gnu_profile::__write(__f, __it->first); __gnu_profile::__write(__f, __it->first);
fprintf(__f, "|"); std::fprintf(__f, "|");
__it->second.__write(__f); __it->second.__write(__f);
} }
} }
} }
inline size_t inline std::size_t
__env_to_size_t(const char* __env_var, size_t __default_value) __env_to_size_t(const char* __env_var, std::size_t __default_value)
{ {
char* __env_value = getenv(__env_var); char* __env_value = std::getenv(__env_var);
if (__env_value) if (__env_value)
{ {
long __converted_value = strtol(__env_value, 0, 10); errno = 0;
long __converted_value = std::strtol(__env_value, 0, 10);
if (errno || __converted_value < 0) if (errno || __converted_value < 0)
{ {
fprintf(stderr, "Bad value for environment variable '%s'.\n", std::fprintf(stderr,
"Bad value for environment variable '%s'.\n",
__env_var); __env_var);
abort(); std::abort();
} }
else else
return static_cast<size_t>(__converted_value); return static_cast<std::size_t>(__converted_value);
} }
else else
return __default_value; return __default_value;
...@@ -406,39 +404,47 @@ namespace __gnu_profile ...@@ -406,39 +404,47 @@ namespace __gnu_profile
__open_output_file(const char* __extension) __open_output_file(const char* __extension)
{ {
// The path is made of _S_trace_file_name + "." + extension. // The path is made of _S_trace_file_name + "." + extension.
size_t __root_len = strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name)); std::size_t __root_len
size_t __ext_len = strlen(__extension); = __builtin_strlen(_GLIBCXX_PROFILE_DATA(_S_trace_file_name));
std::size_t __ext_len = __builtin_strlen(__extension);
char* __file_name = new char[__root_len + 1 + __ext_len + 1]; char* __file_name = new char[__root_len + 1 + __ext_len + 1];
memcpy(__file_name, _GLIBCXX_PROFILE_DATA(_S_trace_file_name), __builtin_memcpy(__file_name,
_GLIBCXX_PROFILE_DATA(_S_trace_file_name),
__root_len); __root_len);
*(__file_name + __root_len) = '.'; *(__file_name + __root_len) = '.';
memcpy(__file_name + __root_len + 1, __extension, __ext_len + 1); __builtin_memcpy(__file_name + __root_len + 1,
FILE* __out_file = fopen(__file_name, "w"); __extension, __ext_len + 1);
FILE* __out_file = std::fopen(__file_name, "w");
if (__out_file) if (__out_file)
{
delete[] __file_name;
return __out_file; return __out_file;
}
else else
{ {
fprintf(stderr, "Could not open trace file '%s'.\n", __file_name); std::fprintf(stderr, "Could not open trace file '%s'.\n",
abort(); __file_name);
std::abort();
} }
} }
struct __warn struct __warn
{ {
FILE* __file; FILE* __file;
__warn(FILE* __f) { __file = __f; }
__warn(FILE* __f)
{ __file = __f; }
void void
operator() (const __warning_data& __info) operator()(const __warning_data& __info)
{ {
fprintf(__file, __info.__warning_id); std::fprintf(__file, __info.__warning_id);
fprintf(__file, ": improvement = %d", std::fprintf(__file, ": improvement = %d",
__log_magnitude(__info.__magnitude)); __log_magnitude(__info.__magnitude));
fprintf(__file, ": call stack = "); std::fprintf(__file, ": call stack = ");
__gnu_profile::__write(__file, __info.__context); __gnu_profile::__write(__file, __info.__context);
fprintf(__file, ": advice = %s\n", __info.__warning_message); std::fprintf(__file, ": advice = %s\n",
free(const_cast<void*> __info.__warning_message.c_str());
(reinterpret_cast<const void*>(__info.__warning_message)));
} }
}; };
...@@ -464,7 +470,7 @@ namespace __gnu_profile ...@@ -464,7 +470,7 @@ namespace __gnu_profile
__trace_list_to_slist_report(__raw_file, __warnings); __trace_list_to_slist_report(__raw_file, __warnings);
__trace_list_to_vector_report(__raw_file, __warnings); __trace_list_to_vector_report(__raw_file, __warnings);
__trace_map_to_unordered_map_report(__raw_file, __warnings); __trace_map_to_unordered_map_report(__raw_file, __warnings);
fclose(__raw_file); std::fclose(__raw_file);
// Sort data by magnitude, keeping just top N. // Sort data by magnitude, keeping just top N.
size_t __cutoff = std::min(_GLIBCXX_PROFILE_DATA(_S_max_warn_count), size_t __cutoff = std::min(_GLIBCXX_PROFILE_DATA(_S_max_warn_count),
...@@ -474,7 +480,7 @@ namespace __gnu_profile ...@@ -474,7 +480,7 @@ namespace __gnu_profile
FILE* __warn_file = __open_output_file("txt"); FILE* __warn_file = __open_output_file("txt");
__for_each(__top_warnings.begin(), __top_warnings.end(), __for_each(__top_warnings.begin(), __top_warnings.end(),
__warn(__warn_file)); __warn(__warn_file));
fclose(__warn_file); std::fclose(__warn_file);
_GLIBCXX_PROFILE_DATA(__global_lock).unlock(); _GLIBCXX_PROFILE_DATA(__global_lock).unlock();
} }
...@@ -482,24 +488,24 @@ namespace __gnu_profile ...@@ -482,24 +488,24 @@ namespace __gnu_profile
inline void inline void
__set_trace_path() __set_trace_path()
{ {
char* __env_trace_file_name = getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR); char* __env_trace_file_name = std::getenv(_GLIBCXX_PROFILE_TRACE_ENV_VAR);
if (__env_trace_file_name) if (__env_trace_file_name)
_GLIBCXX_PROFILE_DATA(_S_trace_file_name) = __env_trace_file_name; _GLIBCXX_PROFILE_DATA(_S_trace_file_name) = __env_trace_file_name;
// Make sure early that we can create the trace file. // Make sure early that we can create the trace file.
fclose(__open_output_file("txt")); std::fclose(__open_output_file("txt"));
} }
inline void inline void
__set_max_warn_count() __set_max_warn_count()
{ {
char* __env_max_warn_count_str char* __env_max_warn_count_str
= getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR); = std::getenv(_GLIBCXX_PROFILE_MAX_WARN_COUNT_ENV_VAR);
if (__env_max_warn_count_str) if (__env_max_warn_count_str)
_GLIBCXX_PROFILE_DATA(_S_max_warn_count) _GLIBCXX_PROFILE_DATA(_S_max_warn_count)
= static_cast<size_t>(atoi(__env_max_warn_count_str)); = static_cast<std::size_t>(std::atoi(__env_max_warn_count_str));
} }
inline void inline void
...@@ -542,7 +548,8 @@ namespace __gnu_profile ...@@ -542,7 +548,8 @@ namespace __gnu_profile
void void
operator() (const __cost_factor* __factor) operator() (const __cost_factor* __factor)
{ fprintf(__file, "%s = %f\n", __factor->__env_var, __factor->__value); } { std::fprintf(__file, "%s = %f\n", __factor->__env_var,
__factor->__value); }
}; };
inline void inline void
...@@ -552,7 +559,7 @@ namespace __gnu_profile ...@@ -552,7 +559,7 @@ namespace __gnu_profile
__for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(), __for_each(_GLIBCXX_PROFILE_DATA(__cost_factors)->begin(),
_GLIBCXX_PROFILE_DATA(__cost_factors)->end(), _GLIBCXX_PROFILE_DATA(__cost_factors)->end(),
__cost_factor_writer(__file)); __cost_factor_writer(__file));
fclose(__file); std::fclose(__file);
} }
struct __cost_factor_setter struct __cost_factor_setter
...@@ -561,7 +568,7 @@ namespace __gnu_profile ...@@ -561,7 +568,7 @@ namespace __gnu_profile
operator() (__cost_factor* __factor) operator() (__cost_factor* __factor)
{ {
// Look it up in the process environment first. // Look it up in the process environment first.
const char* __env_value = getenv(__factor->__env_var); const char* __env_value = std::getenv(__factor->__env_var);
if (!__env_value) if (!__env_value)
{ {
...@@ -573,7 +580,7 @@ namespace __gnu_profile ...@@ -573,7 +580,7 @@ namespace __gnu_profile
} }
if (__env_value) if (__env_value)
__factor->__value = atof(__env_value); __factor->__value = std::atof(__env_value);
} }
}; };
...@@ -642,7 +649,7 @@ namespace __gnu_profile ...@@ -642,7 +649,7 @@ namespace __gnu_profile
__trace_list_to_vector_init(); __trace_list_to_vector_init();
__trace_map_to_unordered_map_init(); __trace_map_to_unordered_map_init();
atexit(__report); std::atexit(__report);
__turn_on(); __turn_on();
} }
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1 #define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
#include <cstdio>
#include <cstring>
#else
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -79,7 +70,7 @@ namespace __gnu_profile ...@@ -79,7 +70,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_size_construct(const void* __obj, size_t __num) __trace_vector_size_construct(const void* __obj, std::size_t __num)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -89,7 +80,8 @@ namespace __gnu_profile ...@@ -89,7 +80,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum) __trace_vector_size_destruct(const void* __obj, std::size_t __num,
std::size_t __inum)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -98,7 +90,8 @@ namespace __gnu_profile ...@@ -98,7 +90,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_size_resize(const void* __obj, size_t __from, size_t __to) __trace_vector_size_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
......
...@@ -37,15 +37,6 @@ ...@@ -37,15 +37,6 @@
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H #ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1 #define _GLIBCXX_PROFILE_PROFILER_VECTOR_TO_LIST_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
#include <cstdlib>
#include <cstring>
#else
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#endif
#include "profile/impl/profiler.h" #include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h" #include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h" #include "profile/impl/profiler_trace.h"
...@@ -87,29 +78,30 @@ namespace __gnu_profile ...@@ -87,29 +78,30 @@ namespace __gnu_profile
void void
__write(FILE* __f) const __write(FILE* __f) const
{ {
fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count, _M_resize, std::fprintf(__f, "%Zu %Zu %Zu %.0f %.0f\n", _M_shift_count,
_M_iterate, _M_vector_cost, _M_list_cost); _M_resize, _M_iterate, _M_vector_cost, _M_list_cost);
} }
float float
__magnitude() const __magnitude() const
{ return _M_vector_cost - _M_list_cost; } { return _M_vector_cost - _M_list_cost; }
const char* __advice() const std::string
{ return strdup("change std::vector to std::list"); } __advice() const
{ return "change std::vector to std::list"; }
size_t std::size_t
__shift_count() __shift_count()
{ return _M_shift_count; } { return _M_shift_count; }
size_t std::size_t
__iterate() __iterate()
{ return _M_iterate; } { return _M_iterate; }
float __list_cost() float __list_cost()
{ return _M_list_cost; } { return _M_list_cost; }
size_t std::size_t
__resize() __resize()
{ return _M_resize; } { return _M_resize; }
...@@ -130,27 +122,28 @@ namespace __gnu_profile ...@@ -130,27 +122,28 @@ namespace __gnu_profile
{ _M_valid = false; } { _M_valid = false; }
void void
__opr_insert(size_t __pos, size_t __num) __opr_insert(std::size_t __pos, std::size_t __num)
{ _M_shift_count += __num - __pos; } { _M_shift_count += __num - __pos; }
void void
__opr_iterate(size_t __num) __opr_iterate(std::size_t __num)
{ _M_iterate += __num; } { _M_iterate += __num; }
void void
__resize(size_t __from, size_t) __resize(std::size_t __from, std::size_t)
{ _M_resize += __from; } { _M_resize += __from; }
void __opr_find(size_t __size) void
__opr_find(std::size_t __size)
{ {
// Use average case complexity. // Use average case complexity.
_M_iterate += 3.0 / 4.0 * __size; _M_iterate += 3.0 / 4.0 * __size;
} }
private: private:
size_t _M_shift_count; std::size_t _M_shift_count;
size_t _M_iterate; std::size_t _M_iterate;
size_t _M_resize; std::size_t _M_resize;
float _M_list_cost; float _M_list_cost;
float _M_vector_cost; float _M_vector_cost;
bool _M_valid; bool _M_valid;
...@@ -210,7 +203,7 @@ namespace __gnu_profile ...@@ -210,7 +203,7 @@ namespace __gnu_profile
// Collect cost of operations. // Collect cost of operations.
void void
__opr_insert(const void* __obj, size_t __pos, size_t __num) __opr_insert(const void* __obj, std::size_t __pos, std::size_t __num)
{ {
__vector2list_info* __res = __get_object_info(__obj); __vector2list_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -218,7 +211,7 @@ namespace __gnu_profile ...@@ -218,7 +211,7 @@ namespace __gnu_profile
} }
void void
__opr_iterate(const void* __obj, size_t __num) __opr_iterate(const void* __obj, std::size_t __num)
{ {
__vector2list_info* __res = __get_object_info(__obj); __vector2list_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -234,7 +227,7 @@ namespace __gnu_profile ...@@ -234,7 +227,7 @@ namespace __gnu_profile
} }
void void
__resize(const void* __obj, size_t __from, size_t __to) __resize(const void* __obj, std::size_t __from, std::size_t __to)
{ {
__vector2list_info* __res = __get_object_info(__obj); __vector2list_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -242,7 +235,8 @@ namespace __gnu_profile ...@@ -242,7 +235,8 @@ namespace __gnu_profile
} }
float float
__vector_cost(size_t __shift, size_t __iterate, size_t __resize) __vector_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{ {
return (__shift return (__shift
* _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value * _GLIBCXX_PROFILE_DATA(__vector_shift_cost_factor).__value
...@@ -253,7 +247,8 @@ namespace __gnu_profile ...@@ -253,7 +247,8 @@ namespace __gnu_profile
} }
float float
__list_cost(size_t __shift, size_t __iterate, size_t __resize) __list_cost(std::size_t __shift, std::size_t __iterate,
std::size_t __resize)
{ {
return (__shift return (__shift
* _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value * _GLIBCXX_PROFILE_DATA(__list_shift_cost_factor).__value
...@@ -264,7 +259,7 @@ namespace __gnu_profile ...@@ -264,7 +259,7 @@ namespace __gnu_profile
} }
void void
__opr_find(const void* __obj, size_t __size) __opr_find(const void* __obj, std::size_t __size)
{ {
__vector2list_info* __res = __get_object_info(__obj); __vector2list_info* __res = __get_object_info(__obj);
if (__res) if (__res)
...@@ -307,7 +302,8 @@ namespace __gnu_profile ...@@ -307,7 +302,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_to_list_insert(const void* __obj, size_t __pos, size_t __num) __trace_vector_to_list_insert(const void* __obj, std::size_t __pos,
std::size_t __num)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -317,7 +313,7 @@ namespace __gnu_profile ...@@ -317,7 +313,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_to_list_iterate(const void* __obj, size_t __num = 1) __trace_vector_to_list_iterate(const void* __obj, std::size_t __num = 1)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -335,7 +331,8 @@ namespace __gnu_profile ...@@ -335,7 +331,8 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_to_list_resize(const void* __obj, size_t __from, size_t __to) __trace_vector_to_list_resize(const void* __obj, std::size_t __from,
std::size_t __to)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
...@@ -344,7 +341,7 @@ namespace __gnu_profile ...@@ -344,7 +341,7 @@ namespace __gnu_profile
} }
inline void inline void
__trace_vector_to_list_find(const void* __obj, size_t __size) __trace_vector_to_list_find(const void* __obj, std::size_t __size)
{ {
if (!__profcxx_init()) if (!__profcxx_init())
return; return;
......
...@@ -36,12 +36,14 @@ namespace std ...@@ -36,12 +36,14 @@ namespace std
namespace __profile namespace __profile
{ {
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
class __iterator_tracker class __iterator_tracker
{ {
typedef __iterator_tracker _Self; typedef __iterator_tracker _Self;
// The underlying iterator // The underlying iterator
_Iterator _M_current; _Iterator _M_current;
// The underlying data structure // The underlying data structure
const _Sequence* _M_ds; const _Sequence* _M_ds;
typedef std::iterator_traits<_Iterator> _Traits; typedef std::iterator_traits<_Iterator> _Traits;
...@@ -54,17 +56,26 @@ class __iterator_tracker ...@@ -54,17 +56,26 @@ class __iterator_tracker
typedef typename _Traits::reference reference; typedef typename _Traits::reference reference;
typedef typename _Traits::pointer pointer; typedef typename _Traits::pointer pointer;
__iterator_tracker() : _M_current(), _M_ds(0) { } __iterator_tracker()
__iterator_tracker(const _Iterator& __i, const _Sequence* seq) : _M_current(), _M_ds(0) { }
: _M_current(__i), _M_ds(seq) { }
__iterator_tracker(const _Iterator& __i, const _Sequence* __seq)
: _M_current(__i), _M_ds(__seq) { }
__iterator_tracker(const __iterator_tracker& __x) __iterator_tracker(const __iterator_tracker& __x)
: _M_current(__x._M_current), _M_ds(__x._M_ds) { } : _M_current(__x._M_current), _M_ds(__x._M_ds) { }
template<typename _MutableIterator> template<typename _MutableIterator>
__iterator_tracker(const __iterator_tracker<_MutableIterator, typename __gnu_cxx::__enable_if<(std::__are_same<_MutableIterator, typename _Sequence::iterator::_Base_iterator>::__value), _Sequence>::__type>& __x) __iterator_tracker(const __iterator_tracker<_MutableIterator,
typename __gnu_cxx::__enable_if
<(std::__are_same<_MutableIterator, typename
_Sequence::iterator::_Base_iterator>::__value),
_Sequence>::__type>& __x)
: _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { } : _M_current(__x.base()), _M_ds(__x._M_get_sequence()) { }
_Iterator _Iterator
base() const { return _M_current; } base() const { return _M_current; }
/** /**
* @brief Conversion to underlying non-debug iterator to allow * @brief Conversion to underlying non-debug iterator to allow
* better interaction with non-profile containers. * better interaction with non-profile containers.
...@@ -117,16 +128,12 @@ class __iterator_tracker ...@@ -117,16 +128,12 @@ class __iterator_tracker
reference reference
operator*() const operator*() const
{ { return *_M_current; }
return *_M_current;
}
// ------ Random access iterator requirements ------ // ------ Random access iterator requirements ------
reference reference
operator[](const difference_type& __n) const operator[](const difference_type& __n) const
{ { return _M_current[__n]; }
return _M_current[__n];
}
__iterator_tracker& __iterator_tracker&
operator+=(const difference_type& __n) operator+=(const difference_type& __n)
...@@ -160,141 +167,107 @@ class __iterator_tracker ...@@ -160,141 +167,107 @@ class __iterator_tracker
void void
_M_find() _M_find()
{ { _M_ds->_M_profile_find(); }
_M_ds->_M_profile_find();
}
const _Sequence* const _Sequence*
_M_get_sequence() const _M_get_sequence() const
{ { return static_cast<const _Sequence*>(_M_ds); }
return static_cast<const _Sequence*>(_M_ds); };
}
};
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator==(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() == __rhs.base(); }
return __lhs.base() == __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator==(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() == __rhs.base(); }
return __lhs.base() == __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator!=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() != __rhs.base(); }
return __lhs.base() != __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator!=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() != __rhs.base(); }
return __lhs.base() != __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator<(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() < __rhs.base(); }
return __lhs.base() < __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator<(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() < __rhs.base(); }
return __lhs.base() < __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator<=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() <= __rhs.base(); }
return __lhs.base() <= __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator<=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() <= __rhs.base(); }
return __lhs.base() <= __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator>(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() > __rhs.base(); }
return __lhs.base() > __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator>(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() > __rhs.base(); }
return __lhs.base() > __rhs.base();
}
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline bool inline bool
operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator>=(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() >= __rhs.base(); }
return __lhs.base() >= __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline bool inline bool
operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator>=(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() >= __rhs.base(); }
return __lhs.base() >= __rhs.base();
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// According to the resolution of DR179 not only the various comparison // According to the resolution of DR179 not only the various comparison
// operators but also operator- must accept mixed iterator/const_iterator // operators but also operator- must accept mixed iterator/const_iterator
// parameters. // parameters.
template<typename _IteratorL, typename _IteratorR, typename _Sequence> template<typename _IteratorL, typename _IteratorR, typename _Sequence>
inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type inline typename __iterator_tracker<_IteratorL, _Sequence>::difference_type
operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs, operator-(const __iterator_tracker<_IteratorL, _Sequence>& __lhs,
const __iterator_tracker<_IteratorR, _Sequence>& __rhs) const __iterator_tracker<_IteratorR, _Sequence>& __rhs)
{ { return __lhs.base() - __rhs.base(); }
return __lhs.base() - __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type inline typename __iterator_tracker<_Iterator, _Sequence>::difference_type
operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs, operator-(const __iterator_tracker<_Iterator, _Sequence>& __lhs,
const __iterator_tracker<_Iterator, _Sequence>& __rhs) const __iterator_tracker<_Iterator, _Sequence>& __rhs)
{ { return __lhs.base() - __rhs.base(); }
return __lhs.base() - __rhs.base();
}
template<typename _Iterator, typename _Sequence> template<typename _Iterator, typename _Sequence>
inline __iterator_tracker<_Iterator, _Sequence> inline __iterator_tracker<_Iterator, _Sequence>
operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type operator+(typename __iterator_tracker<_Iterator,_Sequence>::difference_type
__n, __n,
const __iterator_tracker<_Iterator, _Sequence>& __i) const __iterator_tracker<_Iterator, _Sequence>& __i)
{ { return __i + __n; }
return __i + __n;
}
} // namespace __profile } // namespace __profile
} // namespace std } // namespace std
......
...@@ -71,29 +71,26 @@ namespace __profile ...@@ -71,29 +71,26 @@ namespace __profile
using _Base::value_compare; using _Base::value_compare;
// 23.3.1.1 construct/copy/destroy: // 23.3.1.1 construct/copy/destroy:
explicit map(const _Compare& __comp = _Compare(), explicit
map(const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__comp, __a) { : _Base(__comp, __a)
__profcxx_map_to_unordered_map_construct(this); { __profcxx_map_to_unordered_map_construct(this); }
}
template<typename _InputIterator> template<typename _InputIterator>
map(_InputIterator __first, _InputIterator __last, map(_InputIterator __first, _InputIterator __last,
const _Compare& __comp = _Compare(), const _Compare& __comp = _Compare(),
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__first, __last, __comp, __a) { : _Base(__first, __last, __comp, __a)
__profcxx_map_to_unordered_map_construct(this); { __profcxx_map_to_unordered_map_construct(this); }
}
map(const map& __x) map(const map& __x)
: _Base(__x) { : _Base(__x)
__profcxx_map_to_unordered_map_construct(this); { __profcxx_map_to_unordered_map_construct(this); }
}
map(const _Base& __x) map(const _Base& __x)
: _Base(__x) { : _Base(__x)
__profcxx_map_to_unordered_map_construct(this); { __profcxx_map_to_unordered_map_construct(this); }
}
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
map(map&& __x) map(map&& __x)
...@@ -106,9 +103,8 @@ namespace __profile ...@@ -106,9 +103,8 @@ namespace __profile
: _Base(__l, __c, __a) { } : _Base(__l, __c, __a) { }
#endif #endif
~map() { ~map()
__profcxx_map_to_unordered_map_destruct(this); { __profcxx_map_to_unordered_map_destruct(this); }
}
map& map&
operator=(const map& __x) operator=(const map& __x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment