diff options
Diffstat (limited to 'contrib/src/boost/uuid')
-rw-r--r-- | contrib/src/boost/uuid/detail/uuid_x86.hpp | 10 | ||||
-rw-r--r-- | contrib/src/boost/uuid/name_generator.hpp | 125 | ||||
-rw-r--r-- | contrib/src/boost/uuid/nil_generator.hpp | 34 | ||||
-rw-r--r-- | contrib/src/boost/uuid/random_generator.hpp | 12 | ||||
-rw-r--r-- | contrib/src/boost/uuid/seed_rng.hpp | 12 | ||||
-rw-r--r-- | contrib/src/boost/uuid/string_generator.hpp | 185 | ||||
-rw-r--r-- | contrib/src/boost/uuid/uuid_generators.hpp | 19 | ||||
-rw-r--r-- | contrib/src/boost/uuid/uuid_io.hpp | 6 |
8 files changed, 22 insertions, 381 deletions
diff --git a/contrib/src/boost/uuid/detail/uuid_x86.hpp b/contrib/src/boost/uuid/detail/uuid_x86.hpp index 5c73670..120b8d6 100644 --- a/contrib/src/boost/uuid/detail/uuid_x86.hpp +++ b/contrib/src/boost/uuid/detail/uuid_x86.hpp @@ -49,7 +49,7 @@ BOOST_FORCEINLINE __m128i load_unaligned_si128(const uint8_t* p) BOOST_NOEXCEPT return _mm_lddqu_si128(reinterpret_cast< const __m128i* >(p)); #elif !defined(BOOST_UUID_DETAIL_MSVC_BUG981648) return _mm_loadu_si128(reinterpret_cast< const __m128i* >(p)); -#elif BOOST_MSVC >= 1600 +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1600 __m128i mm = _mm_loadu_si128(reinterpret_cast< const __m128i* >(p)); // Make sure this load doesn't get merged with the subsequent instructions _ReadWriteBarrier(); @@ -68,7 +68,7 @@ inline bool uuid::is_nil() const BOOST_NOEXCEPT #if defined(BOOST_UUID_USE_SSE41) return _mm_test_all_zeros(mm, mm) != 0; #else - mm = _mm_cmpeq_epi8(mm, _mm_setzero_si128()); + mm = _mm_cmpeq_epi32(mm, _mm_setzero_si128()); return _mm_movemask_epi8(mm) == 0xFFFF; #endif } @@ -86,11 +86,11 @@ inline bool operator== (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT __m128i mm_left = uuids::detail::load_unaligned_si128(lhs.data); __m128i mm_right = uuids::detail::load_unaligned_si128(rhs.data); - __m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right); - #if defined(BOOST_UUID_USE_SSE41) - return _mm_test_all_ones(mm_cmp) != 0; + __m128i mm = _mm_xor_si128(mm_left, mm_right); + return _mm_test_all_zeros(mm, mm) != 0; #else + __m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right); return _mm_movemask_epi8(mm_cmp) == 0xFFFF; #endif } diff --git a/contrib/src/boost/uuid/name_generator.hpp b/contrib/src/boost/uuid/name_generator.hpp deleted file mode 100644 index 2e5d8c1..0000000 --- a/contrib/src/boost/uuid/name_generator.hpp +++ /dev/null @@ -1,125 +0,0 @@ -// Boost name_generator.hpp header file ----------------------------------------------// - -// Copyright 2010 Andy Tompkins. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_UUID_NAME_GENERATOR_HPP -#define BOOST_UUID_NAME_GENERATOR_HPP - -#include <boost/uuid/uuid.hpp> -#include <boost/uuid/sha1.hpp> -#include <boost/assert.hpp> -#include <string> -#include <cstring> // for strlen, wcslen - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { - using ::strlen; - using ::wcslen; -} //namespace std -#endif //BOOST_NO_STDC_NAMESPACE - -namespace boost { -namespace uuids { - -// generate a name-based uuid -// TODO: add in common namesspace uuids -class name_generator { -public: - typedef uuid result_type; - - explicit name_generator(uuid const& namespace_uuid_) - : namespace_uuid(namespace_uuid_) - {} - - uuid operator()(const char* name) { - reset(); - process_characters(name, std::strlen(name)); - return sha_to_uuid(); - } - - uuid operator()(const wchar_t* name) { - reset(); - process_characters(name, std::wcslen(name)); - return sha_to_uuid(); - } - - template <typename ch, typename char_traits, typename alloc> - uuid operator()(std::basic_string<ch, char_traits, alloc> const& name) { - reset(); - process_characters(name.c_str(), name.length()); - return sha_to_uuid(); - } - - uuid operator()(void const* buffer, std::size_t byte_count) { - reset(); - sha.process_bytes(buffer, byte_count); - return sha_to_uuid(); - }; - -private: - // we convert all characters to uint32_t so that each - // character is 4 bytes reguardless of sizeof(char) or - // sizeof(wchar_t). We want the name string on any - // platform / compiler to generate the same uuid - // except for char - template <typename char_type> - void process_characters(char_type const*const characters, size_t count) { - BOOST_ASSERT(sizeof(uint32_t) >= sizeof(char_type)); - - for (size_t i=0; i<count; i++) { - uint32_t c = characters[i]; - sha.process_byte(static_cast<unsigned char>((c >> 0) & 0xFF)); - sha.process_byte(static_cast<unsigned char>((c >> 8) & 0xFF)); - sha.process_byte(static_cast<unsigned char>((c >> 16) & 0xFF)); - sha.process_byte(static_cast<unsigned char>((c >> 24) & 0xFF)); - } - } - - void process_characters(char const*const characters, size_t count) { - sha.process_bytes(characters, count); - } - - void reset() - { - sha.reset(); - sha.process_bytes(namespace_uuid.begin(), namespace_uuid.size()); - } - - uuid sha_to_uuid() - { - unsigned int digest[5]; - - sha.get_digest(digest); - - uuid u; - for (int i=0; i<4; ++i) { - *(u.begin() + i*4+0) = static_cast<uint8_t>((digest[i] >> 24) & 0xFF); - *(u.begin() + i*4+1) = static_cast<uint8_t>((digest[i] >> 16) & 0xFF); - *(u.begin() + i*4+2) = static_cast<uint8_t>((digest[i] >> 8) & 0xFF); - *(u.begin() + i*4+3) = static_cast<uint8_t>((digest[i] >> 0) & 0xFF); - } - - // set variant - // must be 0b10xxxxxx - *(u.begin()+8) &= 0xBF; - *(u.begin()+8) |= 0x80; - - // set version - // must be 0b0101xxxx - *(u.begin()+6) &= 0x5F; //0b01011111 - *(u.begin()+6) |= 0x50; //0b01010000 - - return u; - } - -private: - uuid namespace_uuid; - detail::sha1 sha; -}; - -}} // namespace boost::uuids - -#endif // BOOST_UUID_NAME_GENERATOR_HPP diff --git a/contrib/src/boost/uuid/nil_generator.hpp b/contrib/src/boost/uuid/nil_generator.hpp deleted file mode 100644 index c3c5818..0000000 --- a/contrib/src/boost/uuid/nil_generator.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Boost nil_generator.hpp header file ----------------------------------------------// - -// Copyright 2010 Andy Tompkins. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_UUID_NIL_GENERATOR_HPP -#define BOOST_UUID_NIL_GENERATOR_HPP - -#include <boost/uuid/uuid.hpp> - -namespace boost { -namespace uuids { - -// generate a nil uuid -struct nil_generator { - typedef uuid result_type; - - uuid operator()() const { - // initialize to all zeros - uuid u = {{0}}; - return u; - } -}; - -inline uuid nil_uuid() { - return nil_generator()(); -} - -}} // namespace boost::uuids - -#endif // BOOST_UUID_NIL_GENERATOR_HPP - diff --git a/contrib/src/boost/uuid/random_generator.hpp b/contrib/src/boost/uuid/random_generator.hpp index 0f4a0ab..7ca025b 100644 --- a/contrib/src/boost/uuid/random_generator.hpp +++ b/contrib/src/boost/uuid/random_generator.hpp @@ -34,7 +34,7 @@ private: public: typedef uuid result_type; - + // default constructor creates the random number generator basic_random_generator() : pURNG(new UniformRandomNumberGenerator) @@ -49,7 +49,7 @@ public: // seed the random number generator detail::seed(*pURNG); } - + // keep a reference to a random number generator // don't seed a given random number generator explicit basic_random_generator(UniformRandomNumberGenerator& gen) @@ -62,7 +62,7 @@ public: ) ) {} - + // keep a pointer to a random number generator // don't seed a given random number generator explicit basic_random_generator(UniformRandomNumberGenerator* pGen) @@ -77,11 +77,11 @@ public: { BOOST_ASSERT(pURNG); } - + uuid operator()() { uuid u; - + int i=0; unsigned long random_value = generator(); for (uuid::iterator it=u.begin(); it!=u.end(); ++it, ++i) { @@ -90,7 +90,7 @@ public: i = 0; } - // static_cast gets rid of warnings of converting unsigned long to boost::uint8_t + // static_cast gets rid of warnings of converting unsigned long to boost::uint8_t *it = static_cast<uuid::value_type>((random_value >> (i*8)) & 0xFF); } diff --git a/contrib/src/boost/uuid/seed_rng.hpp b/contrib/src/boost/uuid/seed_rng.hpp index 5299b04..388a8f9 100644 --- a/contrib/src/boost/uuid/seed_rng.hpp +++ b/contrib/src/boost/uuid/seed_rng.hpp @@ -40,14 +40,18 @@ #if defined(_MSC_VER) # pragma warning(push) // Save warning settings. # pragma warning(disable : 4996) // Disable deprecated std::fopen +#if defined(_WIN32_WCE) +# pragma comment(lib, "coredll.lib") +#else # pragma comment(lib, "advapi32.lib") #endif +#endif #if defined(BOOST_WINDOWS) # include <boost/detail/winapi/crypt.hpp> // for CryptAcquireContextA, CryptGenRandom, CryptReleaseContext # include <boost/detail/winapi/timers.hpp> -# include <boost/detail/winapi/process.hpp> -# include <boost/detail/winapi/thread.hpp> +# include <boost/detail/winapi/get_current_process_id.hpp> +# include <boost/detail/winapi/get_current_thread_id.hpp> #else # include <sys/time.h> // for gettimeofday # include <sys/types.h> // for pid_t @@ -92,7 +96,7 @@ public: , random_(NULL) { #if defined(BOOST_WINDOWS) - if (!boost::detail::winapi::CryptAcquireContextA( + if (!boost::detail::winapi::CryptAcquireContextW( &random_, NULL, NULL, @@ -107,7 +111,7 @@ public: std::memset(rd_, 0, sizeof(rd_)); } - + ~seed_rng() BOOST_NOEXCEPT { if (random_) { diff --git a/contrib/src/boost/uuid/string_generator.hpp b/contrib/src/boost/uuid/string_generator.hpp deleted file mode 100644 index 538ebe8..0000000 --- a/contrib/src/boost/uuid/string_generator.hpp +++ /dev/null @@ -1,185 +0,0 @@ -// Boost string_generator.hpp header file ----------------------------------------------// - -// Copyright 2010 Andy Tompkins. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_UUID_STRING_GENERATOR_HPP -#define BOOST_UUID_STRING_GENERATOR_HPP - -#include <boost/uuid/uuid.hpp> -#include <string> -#include <cstring> // for strlen, wcslen -#include <iterator> -#include <algorithm> // for find -#include <stdexcept> -#include <boost/throw_exception.hpp> - -#ifdef BOOST_NO_STDC_NAMESPACE -namespace std { - using ::strlen; - using ::wcslen; -} //namespace std -#endif //BOOST_NO_STDC_NAMESPACE - -namespace boost { -namespace uuids { - -// generate a uuid from a string -// lexical_cast works fine using uuid_io.hpp -// but this generator should accept more forms -// and be more efficient -// would like to accept the following forms: -// 0123456789abcdef0123456789abcdef -// 01234567-89ab-cdef-0123456789abcdef -// {01234567-89ab-cdef-0123456789abcdef} -// {0123456789abcdef0123456789abcdef} -// others? -struct string_generator { - typedef uuid result_type; - - template <typename ch, typename char_traits, typename alloc> - uuid operator()(std::basic_string<ch, char_traits, alloc> const& s) const { - return operator()(s.begin(), s.end()); - } - - uuid operator()(char const*const s) const { - return operator()(s, s+std::strlen(s)); - } - - uuid operator()(wchar_t const*const s) const { - return operator()(s, s+std::wcslen(s)); - } - - template <typename CharIterator> - uuid operator()(CharIterator begin, CharIterator end) const - { - typedef typename std::iterator_traits<CharIterator>::value_type char_type; - - // check open brace - char_type c = get_next_char(begin, end); - bool has_open_brace = is_open_brace(c); - char_type open_brace_char = c; - if (has_open_brace) { - c = get_next_char(begin, end); - } - - bool has_dashes = false; - - uuid u; - int i=0; - for (uuid::iterator it_byte=u.begin(); it_byte!=u.end(); ++it_byte, ++i) { - if (it_byte != u.begin()) { - c = get_next_char(begin, end); - } - - if (i == 4) { - has_dashes = is_dash(c); - if (has_dashes) { - c = get_next_char(begin, end); - } - } - - if (has_dashes) { - if (i == 6 || i == 8 || i == 10) { - if (is_dash(c)) { - c = get_next_char(begin, end); - } else { - throw_invalid(); - } - } - } - - *it_byte = get_value(c); - - c = get_next_char(begin, end); - *it_byte <<= 4; - *it_byte |= get_value(c); - } - - // check close brace - if (has_open_brace) { - c = get_next_char(begin, end); - check_close_brace(c, open_brace_char); - } - - return u; - } - -private: - template <typename CharIterator> - typename std::iterator_traits<CharIterator>::value_type - get_next_char(CharIterator& begin, CharIterator end) const { - if (begin == end) { - throw_invalid(); - } - return *begin++; - } - - unsigned char get_value(char c) const { - static char const*const digits_begin = "0123456789abcdefABCDEF"; - static char const*const digits_end = digits_begin + 22; - - static unsigned char const values[] = - { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15 - , static_cast<unsigned char>(-1) }; - - char const* d = std::find(digits_begin, digits_end, c); - return values[d - digits_begin]; - } - - unsigned char get_value(wchar_t c) const { - static wchar_t const*const digits_begin = L"0123456789abcdefABCDEF"; - static wchar_t const*const digits_end = digits_begin + 22; - - static unsigned char const values[] = - { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15 - , static_cast<unsigned char>(-1) }; - - wchar_t const* d = std::find(digits_begin, digits_end, c); - return values[d - digits_begin]; - } - - bool is_dash(char c) const { - return c == '-'; - } - - bool is_dash(wchar_t c) const { - return c == L'-'; - } - - // return closing brace - bool is_open_brace(char c) const { - return (c == '{'); - } - - bool is_open_brace(wchar_t c) const { - return (c == L'{'); - } - - void check_close_brace(char c, char open_brace) const { - if (open_brace == '{' && c == '}') { - //great - } else { - throw_invalid(); - } - } - - void check_close_brace(wchar_t c, wchar_t open_brace) const { - if (open_brace == L'{' && c == L'}') { - // great - } else { - throw_invalid(); - } - } - - void throw_invalid() const { - BOOST_THROW_EXCEPTION(std::runtime_error("invalid uuid string")); - } -}; - -}} // namespace boost::uuids - -#endif //BOOST_UUID_STRING_GENERATOR_HPP - diff --git a/contrib/src/boost/uuid/uuid_generators.hpp b/contrib/src/boost/uuid/uuid_generators.hpp deleted file mode 100644 index 29d39cc..0000000 --- a/contrib/src/boost/uuid/uuid_generators.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Boost uuid_generators.hpp header file ----------------------------------------------// - -// Copyright 2006 Andy Tompkins. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -// Revision History -// 06 Feb 2006 - Initial Revision - -#ifndef BOOST_UUID_GENERATORS_HPP -#define BOOST_UUID_GENERATORS_HPP - -#include <boost/uuid/nil_generator.hpp> -#include <boost/uuid/string_generator.hpp> -#include <boost/uuid/name_generator.hpp> -#include <boost/uuid/random_generator.hpp> - -#endif //BOOST_UUID_GENERATORS_HPP diff --git a/contrib/src/boost/uuid/uuid_io.hpp b/contrib/src/boost/uuid/uuid_io.hpp index 1d30618..e92e881 100644 --- a/contrib/src/boost/uuid/uuid_io.hpp +++ b/contrib/src/boost/uuid/uuid_io.hpp @@ -46,7 +46,7 @@ template <typename ch, typename char_traits> } } - os << std::hex; + os << std::hex << std::right; os.fill(os.widen('0')); std::size_t i=0; @@ -57,13 +57,13 @@ template <typename ch, typename char_traits> os << os.widen('-'); } } - + if (flags & std::ios_base::left) { for (std::streamsize s=uuid_width; s<width; s++) { os << fill; } } - + os.width(0); //used the width so reset it } return os; |