parent
562fc946c7
commit
509aee4b8b
86 changed files with 5058 additions and 3604 deletions
@ -1,3 +1,4 @@ |
||||
# These are fetched as external repositories. |
||||
third_party/benchmark |
||||
third_party/googletest |
||||
_build/ |
||||
|
@ -0,0 +1,4 @@ |
||||
To report security concerns or vulnerabilities within protobuf, please use |
||||
Google's official channel for reporting these. |
||||
|
||||
https://www.google.com/appserve/security-bugs/m2/new |
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@ |
||||
|
||||
cd $(dirname $0) |
||||
|
||||
if [[ -f ext/google/protobuf/third_party/wyhash/wyhash.h && -z $(find ../third_party/wyhash -newer ext/google/protobuf/third_party) ]]; then |
||||
# Generated protos are already present and up to date, so we can skip protoc. |
||||
# |
||||
# Protoc is very fast, but sometimes it is not available (like if we haven't |
||||
# built it in Docker). Skipping it helps us proceed in this case. |
||||
echo "wyhash is up to date, skipping." |
||||
exit 0 |
||||
fi |
||||
|
||||
# wyhash has to live in the base third_party directory. |
||||
# We copy it into the ext/google/protobuf directory for the build |
||||
# (and for the release to PECL). |
||||
rm -rf ext/google/protobuf/third_party |
||||
mkdir -p ext/google/protobuf/third_party/wyhash |
||||
cp ../third_party/wyhash/* ext/google/protobuf/third_party/wyhash |
||||
|
||||
echo "Copied wyhash from ../third_party -> ext/google/protobuf/third_party" |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <google/protobuf/field_access_listener.h> |
@ -0,0 +1,125 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <google/protobuf/generated_message_bases.h> |
||||
|
||||
#include <google/protobuf/parse_context.h> |
||||
#include <google/protobuf/io/coded_stream.h> |
||||
#include <google/protobuf/io/zero_copy_stream_impl.h> |
||||
#include <google/protobuf/unknown_field_set.h> |
||||
#include <google/protobuf/wire_format.h> |
||||
#include <google/protobuf/wire_format_lite.h> |
||||
|
||||
// Must be last:
|
||||
#include <google/protobuf/port_def.inc> |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace internal { |
||||
|
||||
// =============================================================================
|
||||
// ZeroFieldsBase
|
||||
|
||||
void ZeroFieldsBase::Clear() { |
||||
_internal_metadata_.Clear<UnknownFieldSet>(); //
|
||||
} |
||||
|
||||
ZeroFieldsBase::~ZeroFieldsBase() { |
||||
if (GetArenaForAllocation() != nullptr) return; |
||||
_internal_metadata_.Delete<UnknownFieldSet>(); |
||||
} |
||||
|
||||
size_t ZeroFieldsBase::ByteSizeLong() const { |
||||
return MaybeComputeUnknownFieldsSize(0, &_cached_size_); |
||||
} |
||||
|
||||
const char* ZeroFieldsBase::_InternalParse(const char* ptr, |
||||
internal::ParseContext* ctx) { |
||||
#define CHK_(x) \ |
||||
if (PROTOBUF_PREDICT_FALSE(!(x))) { \
|
||||
goto failure; \
|
||||
} |
||||
|
||||
while (!ctx->Done(&ptr)) { |
||||
uint32_t tag; |
||||
ptr = internal::ReadTag(ptr, &tag); |
||||
if ((tag == 0) || ((tag & 7) == 4)) { |
||||
CHK_(ptr); |
||||
ctx->SetLastTag(tag); |
||||
goto message_done; |
||||
} |
||||
ptr = UnknownFieldParse( |
||||
tag, _internal_metadata_.mutable_unknown_fields<UnknownFieldSet>(), ptr, |
||||
ctx); |
||||
CHK_(ptr); |
||||
} // while
|
||||
message_done: |
||||
return ptr; |
||||
failure: |
||||
ptr = nullptr; |
||||
goto message_done; |
||||
#undef CHK_ |
||||
} |
||||
|
||||
::uint8_t* ZeroFieldsBase::_InternalSerialize( |
||||
::uint8_t* target, io::EpsCopyOutputStream* stream) const { |
||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { |
||||
target = internal::WireFormat::InternalSerializeUnknownFieldsToArray( |
||||
_internal_metadata_.unknown_fields<UnknownFieldSet>( |
||||
UnknownFieldSet::default_instance), |
||||
target, stream); |
||||
} |
||||
return target; |
||||
} |
||||
|
||||
void ZeroFieldsBase::MergeImpl(Message* to_param, const Message& from_param) { |
||||
auto* to = static_cast<ZeroFieldsBase*>(to_param); |
||||
const auto* from = static_cast<const ZeroFieldsBase*>(&from_param); |
||||
GOOGLE_DCHECK_NE(from, to); |
||||
to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_); |
||||
} |
||||
|
||||
void ZeroFieldsBase::CopyImpl(Message* to_param, const Message& from_param) { |
||||
auto* to = static_cast<ZeroFieldsBase*>(to_param); |
||||
const auto* from = static_cast<const ZeroFieldsBase*>(&from_param); |
||||
if (from == to) return; |
||||
to->_internal_metadata_.Clear<UnknownFieldSet>(); |
||||
to->_internal_metadata_.MergeFrom<UnknownFieldSet>(from->_internal_metadata_); |
||||
} |
||||
|
||||
void ZeroFieldsBase::InternalSwap(ZeroFieldsBase* other) { |
||||
_internal_metadata_.Swap<UnknownFieldSet>(&other->_internal_metadata_); |
||||
} |
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#include <google/protobuf/port_undef.inc> |
@ -0,0 +1,87 @@ |
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// This file contains helpers for generated code.
|
||||
//
|
||||
// Nothing in this file should be directly referenced by users of protobufs.
|
||||
|
||||
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ |
||||
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__ |
||||
|
||||
#include <google/protobuf/parse_context.h> |
||||
#include <google/protobuf/io/zero_copy_stream_impl.h> |
||||
#include <google/protobuf/arena.h> |
||||
#include <google/protobuf/generated_message_util.h> |
||||
#include <google/protobuf/message.h> |
||||
|
||||
// Must come last:
|
||||
#include <google/protobuf/port_def.inc> |
||||
|
||||
namespace google { |
||||
namespace protobuf { |
||||
namespace internal { |
||||
|
||||
// To save code size, protos without any fields are derived from ZeroFieldsBase
|
||||
// rather than Message.
|
||||
class PROTOBUF_EXPORT ZeroFieldsBase : public Message { |
||||
public: |
||||
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; |
||||
bool IsInitialized() const final { return true; } |
||||
size_t ByteSizeLong() const final; |
||||
int GetCachedSize() const final { return _cached_size_.Get(); } |
||||
const char* _InternalParse(const char* ptr, |
||||
internal::ParseContext* ctx) final; |
||||
::uint8_t* _InternalSerialize(::uint8_t* target, |
||||
io::EpsCopyOutputStream* stream) const final; |
||||
|
||||
protected: |
||||
constexpr ZeroFieldsBase() {} |
||||
explicit ZeroFieldsBase(Arena* arena, bool is_message_owned) |
||||
: Message(arena, is_message_owned) {} |
||||
ZeroFieldsBase(const ZeroFieldsBase&) = delete; |
||||
ZeroFieldsBase& operator=(const ZeroFieldsBase&) = delete; |
||||
~ZeroFieldsBase() override; |
||||
|
||||
void SetCachedSize(int size) const final { _cached_size_.Set(size); } |
||||
|
||||
static void MergeImpl(Message* to, const Message& from); |
||||
static void CopyImpl(Message* to, const Message& from); |
||||
void InternalSwap(ZeroFieldsBase* other); |
||||
|
||||
mutable internal::CachedSize _cached_size_; |
||||
}; |
||||
|
||||
} // namespace internal
|
||||
} // namespace protobuf
|
||||
} // namespace google
|
||||
|
||||
#include <google/protobuf/port_undef.inc> |
||||
|
||||
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
|
@ -1,25 +0,0 @@ |
||||
This is free and unencumbered software released into the public domain. |
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or |
||||
distribute this software, either in source code form or as a compiled |
||||
binary, for any purpose, commercial or non-commercial, and by any |
||||
means. |
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors |
||||
of this software dedicate any and all copyright interest in the |
||||
software to the public domain. We make this dedication for the benefit |
||||
of the public at large and to the detriment of our heirs and |
||||
successors. We intend this dedication to be an overt act of |
||||
relinquishment in perpetuity of all present and future rights to this |
||||
software under copyright law. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||
OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
For more information, please refer to <http://unlicense.org/> |
||||
|
@ -1,145 +0,0 @@ |
||||
/* Copyright 2020 王一 Wang Yi <godspeed_china@yeah.net>
|
||||
This is free and unencumbered software released into the public domain. http://unlicense.org/
|
||||
See github.com/wangyi-fudan/wyhash/ LICENSE |
||||
*/ |
||||
#ifndef wyhash_final_version |
||||
#define wyhash_final_version |
||||
//defines that change behavior
|
||||
#ifndef WYHASH_CONDOM |
||||
#define WYHASH_CONDOM 1 //0: read 8 bytes before and after boundaries, dangerous but fastest. 1: normal valid behavior 2: extra protection against entropy loss (probability=2^-63), aka. "blind multiplication"
|
||||
#endif |
||||
#define WYHASH_32BIT_MUM 0 //faster on 32 bit system
|
||||
//includes
|
||||
#include <stdint.h> |
||||
#include <string.h> |
||||
#if defined(_MSC_VER) && defined(_M_X64) |
||||
#include <intrin.h> |
||||
#pragma intrinsic(_umul128) |
||||
#endif |
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) |
||||
#define _likely_(x) __builtin_expect(x,1) |
||||
#define _unlikely_(x) __builtin_expect(x,0) |
||||
#else |
||||
#define _likely_(x) (x) |
||||
#define _unlikely_(x) (x) |
||||
#endif |
||||
//mum function
|
||||
static inline uint64_t _wyrot(uint64_t x) { return (x>>32)|(x<<32); } |
||||
static inline void _wymum(uint64_t *A, uint64_t *B){ |
||||
#if(WYHASH_32BIT_MUM) |
||||
uint64_t hh=(*A>>32)*(*B>>32), hl=(*A>>32)*(unsigned)*B, lh=(unsigned)*A*(*B>>32), ll=(uint64_t)(unsigned)*A*(unsigned)*B; |
||||
#if(WYHASH_CONDOM>1) |
||||
*A^=_wyrot(hl)^hh; *B^=_wyrot(lh)^ll; |
||||
#else |
||||
*A=_wyrot(hl)^hh; *B=_wyrot(lh)^ll; |
||||
#endif |
||||
#elif defined(__SIZEOF_INT128__) |
||||
__uint128_t r=*A; r*=*B;
|
||||
#if(WYHASH_CONDOM>1) |
||||
*A^=(uint64_t)r; *B^=(uint64_t)(r>>64); |
||||
#else |
||||
*A=(uint64_t)r; *B=(uint64_t)(r>>64); |
||||
#endif |
||||
#elif defined(_MSC_VER) && defined(_M_X64) |
||||
#if(WYHASH_CONDOM>1) |
||||
uint64_t a, b; |
||||
a=_umul128(*A,*B,&b); |
||||
*A^=a; *B^=b; |
||||
#else |
||||
*A=_umul128(*A,*B,B); |
||||
#endif |
||||
#else |
||||
uint64_t ha=*A>>32, hb=*B>>32, la=(uint32_t)*A, lb=(uint32_t)*B, hi, lo; |
||||
uint64_t rh=ha*hb, rm0=ha*lb, rm1=hb*la, rl=la*lb, t=rl+(rm0<<32), c=t<rl; |
||||
lo=t+(rm1<<32); c+=lo<t; hi=rh+(rm0>>32)+(rm1>>32)+c; |
||||
#if(WYHASH_CONDOM>1) |
||||
*A^=lo; *B^=hi; |
||||
#else |
||||
*A=lo; *B=hi; |
||||
#endif |
||||
#endif |
||||
} |
||||
static inline uint64_t _wymix(uint64_t A, uint64_t B){ _wymum(&A,&B); return A^B; } |
||||
//read functions
|
||||
#ifndef WYHASH_LITTLE_ENDIAN |
||||
#if defined(_WIN32) || defined(__LITTLE_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
||||
#define WYHASH_LITTLE_ENDIAN 1 |
||||
#elif defined(__BIG_ENDIAN__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) |
||||
#define WYHASH_LITTLE_ENDIAN 0 |
||||
#endif |
||||
#endif |
||||
#if (WYHASH_LITTLE_ENDIAN) |
||||
static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return v;} |
||||
static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return v;} |
||||
#elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) |
||||
static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return __builtin_bswap64(v);} |
||||
static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return __builtin_bswap32(v);} |
||||
#elif defined(_MSC_VER) |
||||
static inline uint64_t _wyr8(const uint8_t *p) { uint64_t v; memcpy(&v, p, 8); return _byteswap_uint64(v);} |
||||
static inline uint64_t _wyr4(const uint8_t *p) { unsigned v; memcpy(&v, p, 4); return _byteswap_ulong(v);} |
||||
#endif |
||||
static inline uint64_t _wyr3(const uint8_t *p, unsigned k) { return (((uint64_t)p[0])<<16)|(((uint64_t)p[k>>1])<<8)|p[k-1];} |
||||
//wyhash function
|
||||
static inline uint64_t _wyfinish16(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){ |
||||
#if(WYHASH_CONDOM>0) |
||||
uint64_t a, b; |
||||
if(_likely_(i<=8)){ |
||||
if(_likely_(i>=4)){ a=_wyr4(p); b=_wyr4(p+i-4); } |
||||
else if (_likely_(i)){ a=_wyr3(p,i); b=0; } |
||||
else a=b=0; |
||||
}
|
||||
else{ a=_wyr8(p); b=_wyr8(p+i-8); } |
||||
return _wymix(secret[1]^len,_wymix(a^secret[1], b^seed)); |
||||
#else |
||||
#define oneshot_shift ((i<8)*((8-i)<<3)) |
||||
return _wymix(secret[1]^len,_wymix((_wyr8(p)<<oneshot_shift)^secret[1],(_wyr8(p+i-8)>>oneshot_shift)^seed)); |
||||
#endif |
||||
} |
||||
|
||||
static inline uint64_t _wyfinish(const uint8_t *p, uint64_t len, uint64_t seed, const uint64_t *secret, uint64_t i){ |
||||
if(_likely_(i<=16)) return _wyfinish16(p,len,seed,secret,i); |
||||
return _wyfinish(p+16,len,_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed),secret,i-16); |
||||
} |
||||
|
||||
static inline uint64_t wyhash(const void *key, uint64_t len, uint64_t seed, const uint64_t *secret){ |
||||
const uint8_t *p=(const uint8_t *)key; |
||||
uint64_t i=len; seed^=*secret; |
||||
if(_unlikely_(i>64)){ |
||||
uint64_t see1=seed; |
||||
do{ |
||||
seed=_wymix(_wyr8(p)^secret[1],_wyr8(p+8)^seed)^_wymix(_wyr8(p+16)^secret[2],_wyr8(p+24)^seed); |
||||
see1=_wymix(_wyr8(p+32)^secret[3],_wyr8(p+40)^see1)^_wymix(_wyr8(p+48)^secret[4],_wyr8(p+56)^see1); |
||||
p+=64; i-=64; |
||||
}while(i>64); |
||||
seed^=see1; |
||||
} |
||||
return _wyfinish(p,len,seed,secret,i); |
||||
} |
||||
//utility functions
|
||||
static const uint64_t _wyp[5] = {0xa0761d6478bd642full, 0xe7037ed1a0b428dbull, 0x8ebc6af09c88c6e3ull, 0x589965cc75374cc3ull, 0x1d8e4e27c47d124full}; |
||||
static inline uint64_t wyhash64(uint64_t A, uint64_t B){ A^=_wyp[0]; B^=_wyp[1]; _wymum(&A,&B); return _wymix(A^_wyp[0],B^_wyp[1]);} |
||||
static inline uint64_t wyrand(uint64_t *seed){ *seed+=_wyp[0]; return _wymix(*seed,*seed^_wyp[1]);} |
||||
static inline double wy2u01(uint64_t r){ const double _wynorm=1.0/(1ull<<52); return (r>>12)*_wynorm;} |
||||
static inline double wy2gau(uint64_t r){ const double _wynorm=1.0/(1ull<<20); return ((r&0x1fffff)+((r>>21)&0x1fffff)+((r>>42)&0x1fffff))*_wynorm-3.0;} |
||||
static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; } |
||||
|
||||
static inline void make_secret(uint64_t seed, uint64_t *secret){ |
||||
uint8_t c[] = {15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 71, 75, 77, 78, 83, 85, 86, 89, 90, 92, 99, 101, 102, 105, 106, 108, 113, 114, 116, 120, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240 }; |
||||
for(size_t i=0;i<5;i++){ |
||||
uint8_t ok; |
||||
do{ |
||||
ok=1; secret[i]=0; |
||||
for(size_t j=0;j<64;j+=8) secret[i]|=((uint64_t)c[wyrand(&seed)%sizeof(c)])<<j; |
||||
if(secret[i]%2==0){ ok=0; continue; } |
||||
for(size_t j=0;j<i;j++) |
||||
#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__) |
||||
if(__builtin_popcountll(secret[j]^secret[i])!=32){ ok=0; break; } |
||||
#elif defined(_MSC_VER) && defined(_M_X64) |
||||
if(_mm_popcnt_u64(secret[j]^secret[i])!=32){ ok=0; break; } |
||||
#endif |
||||
if(!ok)continue; |
||||
for(uint64_t j=3;j<0x100000000ull;j+=2) if(secret[i]%j==0){ ok=0; break; } |
||||
}while(!ok); |
||||
} |
||||
} |
||||
#endif |
Loading…
Reference in new issue