~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libcxx/memory

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-09-20 22:44:35 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130920224435-apuwj4fsl3fqv1a6
Tags: 1.5.6~20130920~6010666-1
* New snapshot release
* Update the list of supported architectures to the same as libv8
  (Closes: #723129)
* emlibtool has been removed from upstream.
* Fix warning syntax-error-in-dep5-copyright
* Refresh of the patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
    bad_weak_ptr() noexcept;
351
351
};
352
352
 
 
353
template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args);     // C++14
 
354
template<class T>                unique_ptr<T> make_unique(size_t n);           // C++14
 
355
template<class T, class... Args> unspecified   make_unique(Args&&...) = delete; // C++14, T == U[N]
 
356
 
353
357
template<class T>
354
358
class shared_ptr
355
359
{
621
625
_Tp*
622
626
addressof(_Tp& __x) _NOEXCEPT
623
627
{
624
 
    return (_Tp*)&(char&)__x;
 
628
    return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
625
629
}
626
630
 
627
631
#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
1750
1754
    typedef const _Tp*        const_pointer;
1751
1755
    typedef const _Tp&        reference;
1752
1756
    typedef const _Tp&        const_reference;
1753
 
    typedef _Tp               value_type;
 
1757
    typedef const _Tp         value_type;
1754
1758
 
1755
1759
    typedef true_type propagate_on_container_move_assignment;
1756
1760
 
2036
2040
            return *this;
2037
2041
        }
2038
2042
 
 
2043
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
2044
 
 
2045
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
2046
 
2039
2047
#ifndef _LIBCPP_HAS_NO_VARIADICS
2040
2048
 
2041
2049
    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2051
2059
 
2052
2060
#endif  // _LIBCPP_HAS_NO_VARIADICS
2053
2061
 
2054
 
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2055
 
 
2056
 
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2057
 
 
2058
2062
    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
2059
2063
    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
2060
2064
 
2131
2135
            return *this;
2132
2136
        }
2133
2137
 
 
2138
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
2139
 
 
2140
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
2141
 
2134
2142
#ifndef _LIBCPP_HAS_NO_VARIADICS
2135
2143
 
2136
2144
    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2146
2154
 
2147
2155
#endif  // _LIBCPP_HAS_NO_VARIADICS
2148
2156
 
2149
 
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2150
 
 
2151
 
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2152
 
 
2153
2157
    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
2154
2158
    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
2155
2159
 
2227
2231
            return *this;
2228
2232
        }
2229
2233
 
 
2234
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
2235
 
 
2236
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
2237
 
2230
2238
#ifndef _LIBCPP_HAS_NO_VARIADICS
2231
2239
 
2232
2240
    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2243
2251
 
2244
2252
#endif  // _LIBCPP_HAS_NO_VARIADICS
2245
2253
 
2246
 
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2247
 
 
2248
 
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2249
 
 
2250
2254
    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return __first_;}
2251
2255
    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return __first_;}
2252
2256
 
2321
2325
            return *this;
2322
2326
        }
2323
2327
 
 
2328
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
2329
 
 
2330
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
2331
 
2324
2332
#ifndef _LIBCPP_HAS_NO_VARIADICS
2325
2333
 
2326
2334
    template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
2336
2344
 
2337
2345
#endif  // _LIBCPP_HAS_NO_VARIADICS
2338
2346
 
2339
 
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2340
 
 
2341
 
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2342
 
 
2343
2347
    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return *this;}
2344
2348
    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return *this;}
2345
2349
 
2409
2413
            return *this;
2410
2414
        }
2411
2415
 
 
2416
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
2417
 
 
2418
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 
2419
 
2412
2420
#ifndef _LIBCPP_HAS_NO_VARIADICS
2413
2421
 
2414
2422
    template <class... _Args1, class... _Args2>
2422
2430
 
2423
2431
#endif  // _LIBCPP_HAS_NO_VARIADICS
2424
2432
 
2425
 
#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2426
 
 
2427
 
#endif  // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
2428
 
 
2429
2433
    _LIBCPP_INLINE_VISIBILITY _T1_reference       first() _NOEXCEPT       {return base::first();}
2430
2434
    _LIBCPP_INLINE_VISIBILITY _T1_const_reference first() const _NOEXCEPT {return base::first();}
2431
2435
 
2485
2489
    _LIBCPP_INLINE_VISIBILITY void operator() (_Tp* __ptr) const _NOEXCEPT
2486
2490
        {
2487
2491
            static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
 
2492
            static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
2488
2493
            delete __ptr;
2489
2494
        }
2490
2495
};
2507
2512
                         typename enable_if<__same_or_less_cv_qualified<_Up*, _Tp*>::value>::type* = 0) const _NOEXCEPT
2508
2513
        {
2509
2514
            static_assert(sizeof(_Tp) > 0, "default_delete can not delete incomplete type");
 
2515
            static_assert(!is_void<_Tp>::value, "default_delete can not delete incomplete type");
2510
2516
            delete [] __ptr;
2511
2517
        }
2512
2518
};
3077
3083
 
3078
3084
#endif
3079
3085
 
 
3086
#if _LIBCPP_STD_VER > 11
 
3087
 
 
3088
template<class _Tp>
 
3089
struct __unique_if
 
3090
{
 
3091
    typedef unique_ptr<_Tp> __unique_single;
 
3092
};
 
3093
 
 
3094
template<class _Tp>
 
3095
struct __unique_if<_Tp[]>
 
3096
{
 
3097
    typedef unique_ptr<_Tp[]> __unique_array_unknown_bound;
 
3098
};
 
3099
 
 
3100
template<class _Tp, size_t _Np>
 
3101
struct __unique_if<_Tp[_Np]>
 
3102
{
 
3103
    typedef void __unique_array_known_bound;
 
3104
};
 
3105
 
 
3106
template<class _Tp, class... _Args>
 
3107
inline _LIBCPP_INLINE_VISIBILITY
 
3108
typename __unique_if<_Tp>::__unique_single
 
3109
make_unique(_Args&&... __args)
 
3110
{
 
3111
    return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
 
3112
}
 
3113
 
 
3114
template<class _Tp>
 
3115
inline _LIBCPP_INLINE_VISIBILITY
 
3116
typename __unique_if<_Tp>::__unique_array_unknown_bound
 
3117
make_unique(size_t __n)
 
3118
{
 
3119
    typedef typename remove_extent<_Tp>::type _Up;
 
3120
    return unique_ptr<_Tp>(new _Up[__n]());
 
3121
}
 
3122
 
 
3123
template<class _Tp, class... _Args>
 
3124
    typename __unique_if<_Tp>::__unique_array_known_bound
 
3125
    make_unique(_Args&&...) = delete;
 
3126
 
 
3127
#endif  // _LIBCPP_STD_VER > 11
 
3128
 
3080
3129
template <class _Tp> struct hash;
3081
3130
 
 
3131
template <class _Size>
 
3132
inline _LIBCPP_INLINE_VISIBILITY
 
3133
_Size
 
3134
__loadword(const void* __p)
 
3135
{
 
3136
    _Size __r;
 
3137
    std::memcpy(&__r, __p, sizeof(__r));
 
3138
    return __r;
 
3139
}
 
3140
 
3082
3141
// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
3083
3142
// is 64 bits.  This is because cityhash64 uses 64bit x 64bit
3084
3143
// multiplication, which can be very slow on 32-bit systems.
3102
3161
    const unsigned char* __data = static_cast<const unsigned char*>(__key);
3103
3162
    for (; __len >= 4; __data += 4, __len -= 4)
3104
3163
    {
3105
 
        _Size __k = *(const _Size*)__data;
 
3164
        _Size __k = __loadword<_Size>(__data);
3106
3165
        __k *= __m;
3107
3166
        __k ^= __k >> __r;
3108
3167
        __k *= __m;
3161
3220
 
3162
3221
  static _Size __hash_len_0_to_16(const char* __s, _Size __len) {
3163
3222
    if (__len > 8) {
3164
 
      const _Size __a = *(const _Size*)__s;
3165
 
      const _Size __b = *(const _Size*)(__s + __len - 8);
 
3223
      const _Size __a = __loadword<_Size>(__s);
 
3224
      const _Size __b = __loadword<_Size>(__s + __len - 8);
3166
3225
      return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
3167
3226
    }
3168
3227
    if (__len >= 4) {
3169
 
      const uint32_t __a = *(const uint32_t*)(__s);
3170
 
      const uint32_t __b = *(const uint32_t*)(__s + __len - 4);
 
3228
      const uint32_t __a = __loadword<uint32_t>(__s);
 
3229
      const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
3171
3230
      return __hash_len_16(__len + (__a << 3), __b);
3172
3231
    }
3173
3232
    if (__len > 0) {
3183
3242
  }
3184
3243
 
3185
3244
  static _Size __hash_len_17_to_32(const char *__s, _Size __len) {
3186
 
    const _Size __a = *(const _Size*)(__s) * __k1;
3187
 
    const _Size __b = *(const _Size*)(__s + 8);
3188
 
    const _Size __c = *(const _Size*)(__s + __len - 8) * __k2;
3189
 
    const _Size __d = *(const _Size*)(__s + __len - 16) * __k0;
 
3245
    const _Size __a = __loadword<_Size>(__s) * __k1;
 
3246
    const _Size __b = __loadword<_Size>(__s + 8);
 
3247
    const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2;
 
3248
    const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0;
3190
3249
    return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d,
3191
3250
                         __a + __rotate(__b ^ __k3, 20) - __c + __len);
3192
3251
  }
3207
3266
  // Return a 16-byte hash for s[0] ... s[31], a, and b.  Quick and dirty.
3208
3267
  static pair<_Size, _Size> __weak_hash_len_32_with_seeds(
3209
3268
      const char* __s, _Size __a, _Size __b) {
3210
 
    return __weak_hash_len_32_with_seeds(*(const _Size*)(__s),
3211
 
                                         *(const _Size*)(__s + 8),
3212
 
                                         *(const _Size*)(__s + 16),
3213
 
                                         *(const _Size*)(__s + 24),
 
3269
    return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s),
 
3270
                                         __loadword<_Size>(__s + 8),
 
3271
                                         __loadword<_Size>(__s + 16),
 
3272
                                         __loadword<_Size>(__s + 24),
3214
3273
                                         __a,
3215
3274
                                         __b);
3216
3275
  }
3217
3276
 
3218
3277
  // Return an 8-byte hash for 33 to 64 bytes.
3219
3278
  static _Size __hash_len_33_to_64(const char *__s, size_t __len) {
3220
 
    _Size __z = *(const _Size*)(__s + 24);
3221
 
    _Size __a = *(const _Size*)(__s) +
3222
 
                (__len + *(const _Size*)(__s + __len - 16)) * __k0;
 
3279
    _Size __z = __loadword<_Size>(__s + 24);
 
3280
    _Size __a = __loadword<_Size>(__s) +
 
3281
                (__len + __loadword<_Size>(__s + __len - 16)) * __k0;
3223
3282
    _Size __b = __rotate(__a + __z, 52);
3224
3283
    _Size __c = __rotate(__a, 37);
3225
 
    __a += *(const _Size*)(__s + 8);
 
3284
    __a += __loadword<_Size>(__s + 8);
3226
3285
    __c += __rotate(__a, 7);
3227
 
    __a += *(const _Size*)(__s + 16);
 
3286
    __a += __loadword<_Size>(__s + 16);
3228
3287
    _Size __vf = __a + __z;
3229
3288
    _Size __vs = __b + __rotate(__a, 31) + __c;
3230
 
    __a = *(const _Size*)(__s + 16) + *(const _Size*)(__s + __len - 32);
3231
 
    __z += *(const _Size*)(__s + __len - 8);
 
3289
    __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32);
 
3290
    __z += __loadword<_Size>(__s + __len - 8);
3232
3291
    __b = __rotate(__a + __z, 52);
3233
3292
    __c = __rotate(__a, 37);
3234
 
    __a += *(const _Size*)(__s + __len - 24);
 
3293
    __a += __loadword<_Size>(__s + __len - 24);
3235
3294
    __c += __rotate(__a, 7);
3236
 
    __a += *(const _Size*)(__s + __len - 16);
 
3295
    __a += __loadword<_Size>(__s + __len - 16);
3237
3296
    _Size __wf = __a + __z;
3238
3297
    _Size __ws = __b + __rotate(__a, 31) + __c;
3239
3298
    _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
3259
3318
 
3260
3319
  // For strings over 64 bytes we hash the end first, and then as we
3261
3320
  // loop we keep 56 bytes of state: v, w, x, y, and z.
3262
 
  _Size __x = *(const _Size*)(__s + __len - 40);
3263
 
  _Size __y = *(const _Size*)(__s + __len - 16) +
3264
 
              *(const _Size*)(__s + __len - 56);
3265
 
  _Size __z = __hash_len_16(*(const _Size*)(__s + __len - 48) + __len,
3266
 
                          *(const _Size*)(__s + __len - 24));
 
3321
  _Size __x = __loadword<_Size>(__s + __len - 40);
 
3322
  _Size __y = __loadword<_Size>(__s + __len - 16) +
 
3323
              __loadword<_Size>(__s + __len - 56);
 
3324
  _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len,
 
3325
                          __loadword<_Size>(__s + __len - 24));
3267
3326
  pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
3268
3327
  pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
3269
 
  __x = __x * __k1 + *(const _Size*)(__s);
 
3328
  __x = __x * __k1 + __loadword<_Size>(__s);
3270
3329
 
3271
3330
  // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
3272
3331
  __len = (__len - 1) & ~static_cast<_Size>(63);
3273
3332
  do {
3274
 
    __x = __rotate(__x + __y + __v.first + *(const _Size*)(__s + 8), 37) * __k1;
3275
 
    __y = __rotate(__y + __v.second + *(const _Size*)(__s + 48), 42) * __k1;
 
3333
    __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1;
 
3334
    __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1;
3276
3335
    __x ^= __w.second;
3277
 
    __y += __v.first + *(const _Size*)(__s + 40);
 
3336
    __y += __v.first + __loadword<_Size>(__s + 40);
3278
3337
    __z = __rotate(__z + __w.first, 33) * __k1;
3279
3338
    __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
3280
3339
    __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second,
3281
 
                                        __y + *(const _Size*)(__s + 16));
 
3340
                                        __y + __loadword<_Size>(__s + 16));
3282
3341
    std::swap(__z, __x);
3283
3342
    __s += 64;
3284
3343
    __len -= 64;