mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 13:03:45 +02:00
Fix symbol issues in static build.
This commit is contained in:
parent
1a38dfdbde
commit
346d4b572b
5 changed files with 14 additions and 8 deletions
|
@ -43,7 +43,7 @@ void *Buf::operator new(std::size_t sz)
|
||||||
s_pool.store(0);
|
s_pool.store(0);
|
||||||
b = (Buf *) malloc(sz);
|
b = (Buf *) malloc(sz);
|
||||||
if (!b)
|
if (!b)
|
||||||
throw std::bad_alloc();
|
throw Utils::BadAllocException;
|
||||||
++s_allocated;
|
++s_allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
|
@ -114,14 +115,14 @@ public:
|
||||||
{
|
{
|
||||||
if (likely(i < _s))
|
if (likely(i < _s))
|
||||||
return reinterpret_cast<T *>(_m)[i];
|
return reinterpret_cast<T *>(_m)[i];
|
||||||
throw std::out_of_range("i > capacity");
|
throw Utils::OutOfRangeException;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZT_INLINE const T &operator[](const unsigned int i) const
|
ZT_INLINE const T &operator[](const unsigned int i) const
|
||||||
{
|
{
|
||||||
if (likely(i < _s))
|
if (likely(i < _s))
|
||||||
return reinterpret_cast<const T *>(_m)[i];
|
return reinterpret_cast<const T *>(_m)[i];
|
||||||
throw std::out_of_range("i > capacity");
|
throw Utils::OutOfRangeException;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr unsigned int capacity() noexcept
|
static constexpr unsigned int capacity() noexcept
|
||||||
|
@ -150,7 +151,7 @@ public:
|
||||||
{
|
{
|
||||||
if (likely(_s < C))
|
if (likely(_s < C))
|
||||||
new(reinterpret_cast<T *>(_m) + _s++) T(v);
|
new(reinterpret_cast<T *>(_m) + _s++) T(v);
|
||||||
else throw std::out_of_range("capacity exceeded");
|
throw Utils::OutOfRangeException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,7 +201,7 @@ public:
|
||||||
ZT_INLINE void resize(unsigned int ns)
|
ZT_INLINE void resize(unsigned int ns)
|
||||||
{
|
{
|
||||||
if (unlikely(ns > C))
|
if (unlikely(ns > C))
|
||||||
throw std::out_of_range("capacity exceeded");
|
throw Utils::OutOfRangeException;
|
||||||
unsigned int s = _s;
|
unsigned int s = _s;
|
||||||
while (s < ns)
|
while (s < ns)
|
||||||
new(reinterpret_cast<T *>(_m) + s++) T();
|
new(reinterpret_cast<T *>(_m) + s++) T();
|
||||||
|
|
|
@ -84,6 +84,8 @@ CPUIDRegisters::CPUIDRegisters() noexcept
|
||||||
const CPUIDRegisters CPUID;
|
const CPUIDRegisters CPUID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const std::bad_alloc BadAllocException;
|
||||||
|
const std::out_of_range OutOfRangeException("access out of range");
|
||||||
const uint64_t ZERO256[4] = {0, 0, 0, 0};
|
const uint64_t ZERO256[4] = {0, 0, 0, 0};
|
||||||
const char HEXCHARS[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
const char HEXCHARS[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
const uint64_t s_mapNonce = getSecureRandomU64();
|
const uint64_t s_mapNonce = getSecureRandomU64();
|
||||||
|
|
|
@ -69,6 +69,9 @@ struct CPUIDRegisters
|
||||||
extern const CPUIDRegisters CPUID;
|
extern const CPUIDRegisters CPUID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern const std::bad_alloc BadAllocException;
|
||||||
|
extern const std::out_of_range OutOfRangeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 256 zero bits / 32 zero bytes
|
* 256 zero bits / 32 zero bytes
|
||||||
*/
|
*/
|
||||||
|
@ -862,7 +865,7 @@ struct Mallocator
|
||||||
return nullptr;
|
return nullptr;
|
||||||
pointer temp = (pointer)malloc(s * sizeof(T));
|
pointer temp = (pointer)malloc(s * sizeof(T));
|
||||||
if (temp == nullptr)
|
if (temp == nullptr)
|
||||||
throw std::bad_alloc();
|
throw BadAllocException;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
package zerotier
|
package zerotier
|
||||||
|
|
||||||
// #cgo CFLAGS: -O3 -I${SRCDIR}/../../build/core
|
// #cgo CFLAGS: -O3 -I${SRCDIR}/../../build/core
|
||||||
// #cgo darwin LDFLAGS: -Wl,-undefined -Wl,dynamic_lookup
|
// #cgo darwin LDFLAGS: -Wl,-undefined -Wl,dynamic_lookup -lc++
|
||||||
// #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all
|
// #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all -lstdc++
|
||||||
// #include "../../serviceiocore/GoGlue.h"
|
// #include "../../serviceiocore/GoGlue.h"
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue