Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
19 #ifndef _STLP_BITSET_C
20 # define _STLP_BITSET_C
22 # ifndef _STLP_BITSET_H
23 # include <stl/_bitset.h>
26 # define __BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))
31 // Definitions of non-inline functions from _Base_bitset.
36 void _STLP_IMPORT_METHOD _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift)
40 const size_t __wshift = __shift / __BITS_PER_WORD;
41 const size_t __offset = __shift % __BITS_PER_WORD;
44 for (size_t __n = _Nw - 1; __n >= __wshift; --__n)
45 _M_w[__n] = _M_w[__n - __wshift];
48 const size_t __sub_offset = __BITS_PER_WORD - __offset;
49 for (size_t __n = _Nw - 1; __n > __wshift; --__n)
50 _M_w[__n] = (_M_w[__n - __wshift] << __offset) |
51 (_M_w[__n - __wshift - 1] >> __sub_offset);
52 _M_w[__wshift] = _M_w[0] << __offset;
55 fill(_M_w + 0, _M_w + __wshift, __STATIC_CAST(_WordT,0));
60 void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift)
64 const size_t __wshift = __shift / __BITS_PER_WORD;
65 const size_t __offset = __shift % __BITS_PER_WORD;
66 const size_t __limit = _Nw - __wshift - 1;
69 for (size_t __n = 0; __n <= __limit; ++__n)
70 _M_w[__n] = _M_w[__n + __wshift];
73 const size_t __sub_offset = __BITS_PER_WORD - __offset;
74 for (size_t __n = 0; __n < __limit; ++__n)
75 _M_w[__n] = (_M_w[__n + __wshift] >> __offset) |
76 (_M_w[__n + __wshift + 1] << __sub_offset);
77 _M_w[__limit] = _M_w[_Nw-1] >> __offset;
80 fill(_M_w + __limit + 1, _M_w + _Nw, __STATIC_CAST(_WordT,0));
85 unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const
87 for (size_t __i = 1; __i < _Nw; ++__i)
89 __stl_throw_overflow_error("bitset");
91 } // End _M_do_to_ulong
94 size_t _Base_bitset<_Nw>::_M_do_find_first(size_t __not_found) const
96 for ( size_t __i = 0; __i < _Nw; __i++ ) {
97 _WordT __thisword = _M_w[__i];
98 if ( __thisword != __STATIC_CAST(_WordT,0) ) {
99 // find byte within word
100 for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
101 unsigned char __this_byte
102 = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
104 return __i*__BITS_PER_WORD + __j*CHAR_BIT +
105 _Bs_G<bool>::_S_first_one[__this_byte];
107 __thisword >>= CHAR_BIT;
111 // not found, so return an indication of failure.
117 _Base_bitset<_Nw>::_M_do_find_next(size_t __prev,
118 size_t __not_found) const
120 // make bound inclusive
123 // check out of bounds
124 if ( __prev >= _Nw * __BITS_PER_WORD )
128 size_t __i = _S_whichword(__prev);
129 _WordT __thisword = _M_w[__i];
131 // mask off bits below bound
132 __thisword &= (~__STATIC_CAST(_WordT,0)) << _S_whichbit(__prev);
134 if ( __thisword != __STATIC_CAST(_WordT,0) ) {
135 // find byte within word
136 // get first byte into place
137 __thisword >>= _S_whichbyte(__prev) * CHAR_BIT;
138 for ( size_t __j = _S_whichbyte(__prev); __j < sizeof(_WordT); __j++ ) {
139 unsigned char __this_byte
140 = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
142 return __i*__BITS_PER_WORD + __j*CHAR_BIT +
143 _Bs_G<bool>::_S_first_one[__this_byte];
145 __thisword >>= CHAR_BIT;
149 // check subsequent words
151 for ( ; __i < _Nw; __i++ ) {
152 /* _WordT */ __thisword = _M_w[__i];
153 if ( __thisword != __STATIC_CAST(_WordT,0) ) {
154 // find byte within word
155 for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
156 unsigned char __this_byte
157 = __STATIC_CAST(unsigned char,(__thisword & (~(unsigned char)0)));
159 return __i*__BITS_PER_WORD + __j*CHAR_BIT +
160 _Bs_G<bool>::_S_first_one[__this_byte];
162 __thisword >>= CHAR_BIT;
167 // not found, so return an indication of failure.
169 } // end _M_do_find_next
173 # if ! defined (_STLP_NON_TYPE_TMPL_PARAM_BUG)
175 #if defined ( _STLP_USE_NEW_IOSTREAMS)
177 template <class _CharT, class _Traits, size_t _Nb>
178 basic_istream<_CharT, _Traits>& _STLP_CALL
179 operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
181 basic_string<_CharT, _Traits> __tmp;
185 typename basic_istream<_CharT, _Traits>::sentry __sentry(__is);
187 basic_streambuf<_CharT, _Traits>* __buf = __is.rdbuf();
188 for (size_t __i = 0; __i < _Nb; ++__i) {
189 static typename _Traits::int_type __eof = _Traits::eof();
191 typename _Traits::int_type __c1 = __buf->sbumpc();
192 if (_Traits::eq_int_type(__c1, __eof)) {
193 __is.setstate(ios_base::eofbit);
197 char __c2 = _Traits::to_char_type(__c1);
198 char __c = __is.narrow(__c2, '*');
200 if (__c == '0' || __c == '1')
201 __tmp.push_back(__c);
202 else if (_Traits::eq_int_type(__buf->sputbackc(__c2), __eof)) {
203 __is.setstate(ios_base::failbit);
210 __is.setstate(ios_base::failbit);
212 __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
218 template <class _CharT, class _Traits, size_t _Nb>
219 basic_ostream<_CharT, _Traits>& _STLP_CALL
220 operator<<(basic_ostream<_CharT, _Traits>& __os,
221 const bitset<_Nb>& __x)
223 basic_string<_CharT, _Traits> __tmp;
224 __x._M_copy_to_string(__tmp);
225 return __os << __tmp;
228 #elif ! defined ( _STLP_USE_NO_IOSTREAMS )
230 // (reg) For Watcom IO, this tells if ostream class is in .exe or in .dll
231 template <size_t _Nb>
232 _ISTREAM_DLL& _STLP_CALL
233 operator>>(_ISTREAM_DLL& __is, bitset<_Nb>& __x) {
237 // In new templatized iostreams, use istream::sentry
238 if (__is.flags() & ios::skipws) {
242 while (__is && isspace(__c));
247 for (size_t __i = 0; __i < _Nb; ++__i) {
253 else if (__c != '0' && __c != '1') {
258 __tmp.push_back(__c);
262 __is.clear(__is.rdstate() | ios::failbit);
264 __x._M_copy_from_string(__tmp, __STATIC_CAST(size_t,0), _Nb);
269 # endif /* _STLP_USE_NEW_IOSTREAMS */
271 # endif /* _STLP_NON_TYPE_TMPL_PARAM_BUG */
274 # if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
276 // ------------------------------------------------------------
277 // Lookup tables for find and count operations.
279 # if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
280 template<class _Dummy>
281 const unsigned char _Bs_G<_Dummy>::_S_bit_count[256] = {
283 const unsigned char _Bs_G<bool>::_S_bit_count[256] _STLP_WEAK = {
285 0, /* 0 */ 1, /* 1 */ 1, /* 2 */ 2, /* 3 */ 1, /* 4 */
286 2, /* 5 */ 2, /* 6 */ 3, /* 7 */ 1, /* 8 */ 2, /* 9 */
287 2, /* 10 */ 3, /* 11 */ 2, /* 12 */ 3, /* 13 */ 3, /* 14 */
288 4, /* 15 */ 1, /* 16 */ 2, /* 17 */ 2, /* 18 */ 3, /* 19 */
289 2, /* 20 */ 3, /* 21 */ 3, /* 22 */ 4, /* 23 */ 2, /* 24 */
290 3, /* 25 */ 3, /* 26 */ 4, /* 27 */ 3, /* 28 */ 4, /* 29 */
291 4, /* 30 */ 5, /* 31 */ 1, /* 32 */ 2, /* 33 */ 2, /* 34 */
292 3, /* 35 */ 2, /* 36 */ 3, /* 37 */ 3, /* 38 */ 4, /* 39 */
293 2, /* 40 */ 3, /* 41 */ 3, /* 42 */ 4, /* 43 */ 3, /* 44 */
294 4, /* 45 */ 4, /* 46 */ 5, /* 47 */ 2, /* 48 */ 3, /* 49 */
295 3, /* 50 */ 4, /* 51 */ 3, /* 52 */ 4, /* 53 */ 4, /* 54 */
296 5, /* 55 */ 3, /* 56 */ 4, /* 57 */ 4, /* 58 */ 5, /* 59 */
297 4, /* 60 */ 5, /* 61 */ 5, /* 62 */ 6, /* 63 */ 1, /* 64 */
298 2, /* 65 */ 2, /* 66 */ 3, /* 67 */ 2, /* 68 */ 3, /* 69 */
299 3, /* 70 */ 4, /* 71 */ 2, /* 72 */ 3, /* 73 */ 3, /* 74 */
300 4, /* 75 */ 3, /* 76 */ 4, /* 77 */ 4, /* 78 */ 5, /* 79 */
301 2, /* 80 */ 3, /* 81 */ 3, /* 82 */ 4, /* 83 */ 3, /* 84 */
302 4, /* 85 */ 4, /* 86 */ 5, /* 87 */ 3, /* 88 */ 4, /* 89 */
303 4, /* 90 */ 5, /* 91 */ 4, /* 92 */ 5, /* 93 */ 5, /* 94 */
304 6, /* 95 */ 2, /* 96 */ 3, /* 97 */ 3, /* 98 */ 4, /* 99 */
305 3, /* 100 */ 4, /* 101 */ 4, /* 102 */ 5, /* 103 */ 3, /* 104 */
306 4, /* 105 */ 4, /* 106 */ 5, /* 107 */ 4, /* 108 */ 5, /* 109 */
307 5, /* 110 */ 6, /* 111 */ 3, /* 112 */ 4, /* 113 */ 4, /* 114 */
308 5, /* 115 */ 4, /* 116 */ 5, /* 117 */ 5, /* 118 */ 6, /* 119 */
309 4, /* 120 */ 5, /* 121 */ 5, /* 122 */ 6, /* 123 */ 5, /* 124 */
310 6, /* 125 */ 6, /* 126 */ 7, /* 127 */ 1, /* 128 */ 2, /* 129 */
311 2, /* 130 */ 3, /* 131 */ 2, /* 132 */ 3, /* 133 */ 3, /* 134 */
312 4, /* 135 */ 2, /* 136 */ 3, /* 137 */ 3, /* 138 */ 4, /* 139 */
313 3, /* 140 */ 4, /* 141 */ 4, /* 142 */ 5, /* 143 */ 2, /* 144 */
314 3, /* 145 */ 3, /* 146 */ 4, /* 147 */ 3, /* 148 */ 4, /* 149 */
315 4, /* 150 */ 5, /* 151 */ 3, /* 152 */ 4, /* 153 */ 4, /* 154 */
316 5, /* 155 */ 4, /* 156 */ 5, /* 157 */ 5, /* 158 */ 6, /* 159 */
317 2, /* 160 */ 3, /* 161 */ 3, /* 162 */ 4, /* 163 */ 3, /* 164 */
318 4, /* 165 */ 4, /* 166 */ 5, /* 167 */ 3, /* 168 */ 4, /* 169 */
319 4, /* 170 */ 5, /* 171 */ 4, /* 172 */ 5, /* 173 */ 5, /* 174 */
320 6, /* 175 */ 3, /* 176 */ 4, /* 177 */ 4, /* 178 */ 5, /* 179 */
321 4, /* 180 */ 5, /* 181 */ 5, /* 182 */ 6, /* 183 */ 4, /* 184 */
322 5, /* 185 */ 5, /* 186 */ 6, /* 187 */ 5, /* 188 */ 6, /* 189 */
323 6, /* 190 */ 7, /* 191 */ 2, /* 192 */ 3, /* 193 */ 3, /* 194 */
324 4, /* 195 */ 3, /* 196 */ 4, /* 197 */ 4, /* 198 */ 5, /* 199 */
325 3, /* 200 */ 4, /* 201 */ 4, /* 202 */ 5, /* 203 */ 4, /* 204 */
326 5, /* 205 */ 5, /* 206 */ 6, /* 207 */ 3, /* 208 */ 4, /* 209 */
327 4, /* 210 */ 5, /* 211 */ 4, /* 212 */ 5, /* 213 */ 5, /* 214 */
328 6, /* 215 */ 4, /* 216 */ 5, /* 217 */ 5, /* 218 */ 6, /* 219 */
329 5, /* 220 */ 6, /* 221 */ 6, /* 222 */ 7, /* 223 */ 3, /* 224 */
330 4, /* 225 */ 4, /* 226 */ 5, /* 227 */ 4, /* 228 */ 5, /* 229 */
331 5, /* 230 */ 6, /* 231 */ 4, /* 232 */ 5, /* 233 */ 5, /* 234 */
332 6, /* 235 */ 5, /* 236 */ 6, /* 237 */ 6, /* 238 */ 7, /* 239 */
333 4, /* 240 */ 5, /* 241 */ 5, /* 242 */ 6, /* 243 */ 5, /* 244 */
334 6, /* 245 */ 6, /* 246 */ 7, /* 247 */ 5, /* 248 */ 6, /* 249 */
335 6, /* 250 */ 7, /* 251 */ 6, /* 252 */ 7, /* 253 */ 7, /* 254 */
337 }; // end _Bitset_global
339 # if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
340 template<class _Dummy>
341 const unsigned char _Bs_G<_Dummy>::_S_first_one[256] = {
343 const unsigned char _Bs_G<bool>::_S_first_one[256] _STLP_WEAK = {
346 0, /* 0 */ 0, /* 1 */ 1, /* 2 */ 0, /* 3 */ 2, /* 4 */
347 0, /* 5 */ 1, /* 6 */ 0, /* 7 */ 3, /* 8 */ 0, /* 9 */
348 1, /* 10 */ 0, /* 11 */ 2, /* 12 */ 0, /* 13 */ 1, /* 14 */
349 0, /* 15 */ 4, /* 16 */ 0, /* 17 */ 1, /* 18 */ 0, /* 19 */
350 2, /* 20 */ 0, /* 21 */ 1, /* 22 */ 0, /* 23 */ 3, /* 24 */
351 0, /* 25 */ 1, /* 26 */ 0, /* 27 */ 2, /* 28 */ 0, /* 29 */
352 1, /* 30 */ 0, /* 31 */ 5, /* 32 */ 0, /* 33 */ 1, /* 34 */
353 0, /* 35 */ 2, /* 36 */ 0, /* 37 */ 1, /* 38 */ 0, /* 39 */
354 3, /* 40 */ 0, /* 41 */ 1, /* 42 */ 0, /* 43 */ 2, /* 44 */
355 0, /* 45 */ 1, /* 46 */ 0, /* 47 */ 4, /* 48 */ 0, /* 49 */
356 1, /* 50 */ 0, /* 51 */ 2, /* 52 */ 0, /* 53 */ 1, /* 54 */
357 0, /* 55 */ 3, /* 56 */ 0, /* 57 */ 1, /* 58 */ 0, /* 59 */
358 2, /* 60 */ 0, /* 61 */ 1, /* 62 */ 0, /* 63 */ 6, /* 64 */
359 0, /* 65 */ 1, /* 66 */ 0, /* 67 */ 2, /* 68 */ 0, /* 69 */
360 1, /* 70 */ 0, /* 71 */ 3, /* 72 */ 0, /* 73 */ 1, /* 74 */
361 0, /* 75 */ 2, /* 76 */ 0, /* 77 */ 1, /* 78 */ 0, /* 79 */
362 4, /* 80 */ 0, /* 81 */ 1, /* 82 */ 0, /* 83 */ 2, /* 84 */
363 0, /* 85 */ 1, /* 86 */ 0, /* 87 */ 3, /* 88 */ 0, /* 89 */
364 1, /* 90 */ 0, /* 91 */ 2, /* 92 */ 0, /* 93 */ 1, /* 94 */
365 0, /* 95 */ 5, /* 96 */ 0, /* 97 */ 1, /* 98 */ 0, /* 99 */
366 2, /* 100 */ 0, /* 101 */ 1, /* 102 */ 0, /* 103 */ 3, /* 104 */
367 0, /* 105 */ 1, /* 106 */ 0, /* 107 */ 2, /* 108 */ 0, /* 109 */
368 1, /* 110 */ 0, /* 111 */ 4, /* 112 */ 0, /* 113 */ 1, /* 114 */
369 0, /* 115 */ 2, /* 116 */ 0, /* 117 */ 1, /* 118 */ 0, /* 119 */
370 3, /* 120 */ 0, /* 121 */ 1, /* 122 */ 0, /* 123 */ 2, /* 124 */
371 0, /* 125 */ 1, /* 126 */ 0, /* 127 */ 7, /* 128 */ 0, /* 129 */
372 1, /* 130 */ 0, /* 131 */ 2, /* 132 */ 0, /* 133 */ 1, /* 134 */
373 0, /* 135 */ 3, /* 136 */ 0, /* 137 */ 1, /* 138 */ 0, /* 139 */
374 2, /* 140 */ 0, /* 141 */ 1, /* 142 */ 0, /* 143 */ 4, /* 144 */
375 0, /* 145 */ 1, /* 146 */ 0, /* 147 */ 2, /* 148 */ 0, /* 149 */
376 1, /* 150 */ 0, /* 151 */ 3, /* 152 */ 0, /* 153 */ 1, /* 154 */
377 0, /* 155 */ 2, /* 156 */ 0, /* 157 */ 1, /* 158 */ 0, /* 159 */
378 5, /* 160 */ 0, /* 161 */ 1, /* 162 */ 0, /* 163 */ 2, /* 164 */
379 0, /* 165 */ 1, /* 166 */ 0, /* 167 */ 3, /* 168 */ 0, /* 169 */
380 1, /* 170 */ 0, /* 171 */ 2, /* 172 */ 0, /* 173 */ 1, /* 174 */
381 0, /* 175 */ 4, /* 176 */ 0, /* 177 */ 1, /* 178 */ 0, /* 179 */
382 2, /* 180 */ 0, /* 181 */ 1, /* 182 */ 0, /* 183 */ 3, /* 184 */
383 0, /* 185 */ 1, /* 186 */ 0, /* 187 */ 2, /* 188 */ 0, /* 189 */
384 1, /* 190 */ 0, /* 191 */ 6, /* 192 */ 0, /* 193 */ 1, /* 194 */
385 0, /* 195 */ 2, /* 196 */ 0, /* 197 */ 1, /* 198 */ 0, /* 199 */
386 3, /* 200 */ 0, /* 201 */ 1, /* 202 */ 0, /* 203 */ 2, /* 204 */
387 0, /* 205 */ 1, /* 206 */ 0, /* 207 */ 4, /* 208 */ 0, /* 209 */
388 1, /* 210 */ 0, /* 211 */ 2, /* 212 */ 0, /* 213 */ 1, /* 214 */
389 0, /* 215 */ 3, /* 216 */ 0, /* 217 */ 1, /* 218 */ 0, /* 219 */
390 2, /* 220 */ 0, /* 221 */ 1, /* 222 */ 0, /* 223 */ 5, /* 224 */
391 0, /* 225 */ 1, /* 226 */ 0, /* 227 */ 2, /* 228 */ 0, /* 229 */
392 1, /* 230 */ 0, /* 231 */ 3, /* 232 */ 0, /* 233 */ 1, /* 234 */
393 0, /* 235 */ 2, /* 236 */ 0, /* 237 */ 1, /* 238 */ 0, /* 239 */
394 4, /* 240 */ 0, /* 241 */ 1, /* 242 */ 0, /* 243 */ 2, /* 244 */
395 0, /* 245 */ 1, /* 246 */ 0, /* 247 */ 3, /* 248 */ 0, /* 249 */
396 1, /* 250 */ 0, /* 251 */ 2, /* 252 */ 0, /* 253 */ 1, /* 254 */
398 }; // end _Bitset_global
400 # endif /* defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION) */
404 # undef __BITS_PER_WORD
407 #endif /* _STLP_BITSET_C */