-
Notifications
You must be signed in to change notification settings - Fork 1
/
STLport-fennel.patch
executable file
·163 lines (152 loc) · 5.43 KB
/
STLport-fennel.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff -urN ../stlport/stlport/stl/_threads.h stlport/stlport/stl/_threads.h
--- ../stlport/stlport/stl/_threads.h 2008-10-06 23:44:37.000000000 -0700
+++ stlport/stlport/stl/_threads.h 2009-06-01 19:19:00.000000000 -0700
@@ -458,5 +458,7 @@
// The data member _M_ref_count
#if defined (__DMC__)
public:
+#else
+protected:
#endif
_STLP_VOLATILE __stl_atomic_t _M_ref_count;
diff -urN ../stlport/stlport/stl/_hashtable.c stlport/stlport/stl/_hashtable.c
--- ../stlport/stlport/stl/_hashtable.c
+++ stlport/stlport/stl/_hashtable.c
@@ -249,9 +249,8 @@ hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
template <class _Val, class _Key, class _HF,
class _Traits, class _ExK, class _EqK, class _All>
-__reference__
-hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
- ::_M_insert(const value_type& __obj) {
+__reference__ hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_insert(const value_type& __obj)
+{
_M_enlarge(_M_num_elements + 1);
return *insert_unique_noresize(__obj).first;
}
@@ -293,7 +292,7 @@ hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
}
_M_num_elements -= __erased;
- _M_reduce();
+
return __erased;
}
@@ -325,7 +324,6 @@ void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
}
_M_num_elements -= __erased;
- _M_reduce();
}
template <class _Val, class _Key, class _HF,
@@ -356,35 +354,29 @@ void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
}
fill(_M_buckets.begin() + __f_bucket, _M_buckets.begin() + __l_bucket + 1, __cur._M_node);
_M_num_elements -= __erased;
- _M_reduce();
}
template <class _Val, class _Key, class _HF,
class _Traits, class _ExK, class _EqK, class _All>
-void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
- ::rehash(size_type __num_buckets_hint) {
- if (bucket_count() >= __num_buckets_hint) {
- // We are trying to reduce number of buckets, we have to validate it:
- size_type __limit_num_buckets = (size_type)((float)size() / max_load_factor());
- if (__num_buckets_hint < __limit_num_buckets) {
- // Targetted number of buckets __num_buckets_hint would break
- // load_factor() <= max_load_factor() rule.
- return;
- }
+void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::rehash(size_type __num_buckets_hint)
+{
+ if ( bucket_count() < __num_buckets_hint ) {
+ _M_rehash(__num_buckets_hint);
+ } else {
+ _M_reduce();
}
-
- _M_rehash(__num_buckets_hint);
}
template <class _Val, class _Key, class _HF,
class _Traits, class _ExK, class _EqK, class _All>
-void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
- ::_M_enlarge(size_type __to_size) {
+void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>::_M_enlarge( size_type __to_size )
+{
size_type __num_buckets = bucket_count();
size_type __num_buckets_hint = (size_type)((float)__to_size / max_load_factor());
- if (__num_buckets_hint <= __num_buckets) {
+ if ( __num_buckets_hint <= __num_buckets ) {
return;
}
+
__num_buckets = _STLP_PRIV _Stl_prime_type::_S_next_size(__num_buckets_hint);
_M_rehash(__num_buckets);
@@ -437,20 +429,6 @@ void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
template <class _Val, class _Key, class _HF,
class _Traits, class _ExK, class _EqK, class _All>
void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
- ::_M_resize() {
- if (load_factor() > max_load_factor()) {
- // We have to enlarge
- _M_enlarge(size());
- }
- else {
- // We can try to reduce size:
- _M_reduce();
- }
-}
-
-template <class _Val, class _Key, class _HF,
- class _Traits, class _ExK, class _EqK, class _All>
-void hashtable<_Val,_Key,_HF,_Traits,_ExK,_EqK,_All>
::_M_rehash(size_type __num_buckets) {
#if defined (_STLP_DEBUG)
_M_check();
diff -urN ../stlport/stlport/stl/_hashtable.h stlport/stlport/stl/_hashtable.h
--- ../stlport/stlport/stl/_hashtable.h
+++ stlport/stlport/stl/_hashtable.h
@@ -421,10 +421,15 @@ public:
// hash policy
float load_factor() const { return (float)size() / (float)bucket_count(); }
float max_load_factor() const { return _M_max_load_factor; }
- void max_load_factor(float __z) {
- _M_max_load_factor = __z;
- _M_resize();
- }
+ void max_load_factor(float __z)
+ {
+ _STLP_STD::swap( _M_max_load_factor, __z );
+ if ( __z > _M_max_load_factor ) { // max load was decreased
+ _M_enlarge(size()); // ... have to enlarge
+ } else { // We can try to reduce size
+ _M_reduce();
+ }
+ }
pair<iterator, bool> insert_unique(const value_type& __obj) {
_M_enlarge(_M_num_elements + 1);
@@ -558,12 +563,12 @@ public:
void erase(const_iterator __first, const_iterator __last);
private:
- void _M_enlarge(size_type __n);
- void _M_reduce();
- void _M_resize();
- void _M_rehash(size_type __num_buckets);
+ void _M_enlarge( size_type );
+ void _M_reduce();
+ void _M_resize();
+ void _M_rehash(size_type __num_buckets);
#if defined (_STLP_DEBUG)
- void _M_check() const;
+ void _M_check() const;
#endif
public:
diff -urN ../stlport/stlport/stl/_cstdlib.h stlport/stlport/stl/_cstdlib.h
--- ../stlport/stlport/stl/_cstdlib.h
+++ stlport/stlport/stl/_cstdlib.h
@@ -154,7 +154,7 @@
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
# endif
-# else
+# elif !defined _MSC_VER || _MSC_VER < 1600
inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
# endif
#endif