Commit 041401ba authored by Kenton Varda's avatar Kenton Varda

Fix build on GCC.

parent f215c5f0
...@@ -367,7 +367,7 @@ struct WireHelpers { ...@@ -367,7 +367,7 @@ struct WireHelpers {
} }
template <typename T> template <typename T>
static KJ_ALWAYS_INLINE(void zeroMemory(kj::ArrayPtr<T> array)) { static inline void zeroMemory(kj::ArrayPtr<T> array) {
memset(array.begin(), 0, array.size() * sizeof(array[0])); memset(array.begin(), 0, array.size() * sizeof(array[0]));
} }
...@@ -385,17 +385,17 @@ struct WireHelpers { ...@@ -385,17 +385,17 @@ struct WireHelpers {
} }
template <typename T> template <typename T>
static KJ_ALWAYS_INLINE(void copyMemory(T* to, const T* from)) { static inline void copyMemory(T* to, const T* from) {
memcpy(to, from, sizeof(*from)); memcpy(to, from, sizeof(*from));
} }
// TODO(cleanup): Turn these into a .copyTo() method of ArrayPtr? // TODO(cleanup): Turn these into a .copyTo() method of ArrayPtr?
template <typename T> template <typename T>
static KJ_ALWAYS_INLINE(void copyMemory(T* to, kj::ArrayPtr<T> from)) { static inline void copyMemory(T* to, kj::ArrayPtr<T> from) {
memcpy(to, from.begin(), from.size() * sizeof(from[0])); memcpy(to, from.begin(), from.size() * sizeof(from[0]));
} }
template <typename T> template <typename T>
static KJ_ALWAYS_INLINE(void copyMemory(T* to, kj::ArrayPtr<const T> from)) { static inline void copyMemory(T* to, kj::ArrayPtr<const T> from) {
memcpy(to, from.begin(), from.size() * sizeof(from[0])); memcpy(to, from.begin(), from.size() * sizeof(from[0]));
} }
static KJ_ALWAYS_INLINE(void copyMemory(char* to, kj::StringPtr from)) { static KJ_ALWAYS_INLINE(void copyMemory(char* to, kj::StringPtr from)) {
......
...@@ -724,21 +724,6 @@ private: ...@@ -724,21 +724,6 @@ private:
template <uint64_t, typename> template <uint64_t, typename>
friend class Bounded; friend class Bounded;
template <uint64_t aN, uint64_t bN, typename A, typename B>
friend constexpr Bounded<kj::min(aN, bN), WiderType<A, B>>
min(Bounded<aN, A> a, Bounded<bN, B> b);
template <uint64_t aN, uint b, typename A>
friend constexpr Bounded<kj::min(aN, b), A> min(Bounded<aN, A> a, BoundedConst<b>);
template <uint64_t aN, uint b, typename A>
friend constexpr Bounded<kj::min(aN, b), A> min(BoundedConst<b>, Bounded<aN, A> a);
template <uint64_t aN, uint64_t bN, typename A, typename B>
friend constexpr Bounded<kj::max(aN, bN), WiderType<A, B>>
max(Bounded<aN, A> a, Bounded<bN, B> b);
template <uint64_t aN, uint b, typename A>
friend constexpr Bounded<kj::max(aN, b), A> max(Bounded<aN, A> a, BoundedConst<b>);
template <uint64_t aN, uint b, typename A>
friend constexpr Bounded<kj::max(aN, b), A> max(BoundedConst<b>, Bounded<aN, A> a);
}; };
template <typename Number> template <typename Number>
...@@ -893,12 +878,12 @@ inline auto trySubtract(Quantity<T, Unit> value, Quantity<U, Unit> other) ...@@ -893,12 +878,12 @@ inline auto trySubtract(Quantity<T, Unit> value, Quantity<U, Unit> other)
template <uint64_t aN, uint64_t bN, typename A, typename B> template <uint64_t aN, uint64_t bN, typename A, typename B>
inline constexpr Bounded<kj::min(aN, bN), WiderType<A, B>> inline constexpr Bounded<kj::min(aN, bN), WiderType<A, B>>
min(Bounded<aN, A> a, Bounded<bN, B> b) { min(Bounded<aN, A> a, Bounded<bN, B> b) {
return Bounded<kj::min(aN, bN), WiderType<A, B>>(kj::min(a.value, b.value), unsafe); return Bounded<kj::min(aN, bN), WiderType<A, B>>(kj::min(a.unwrap(), b.unwrap()), unsafe);
} }
template <uint64_t aN, uint64_t bN, typename A, typename B> template <uint64_t aN, uint64_t bN, typename A, typename B>
inline constexpr Bounded<kj::max(aN, bN), WiderType<A, B>> inline constexpr Bounded<kj::max(aN, bN), WiderType<A, B>>
max(Bounded<aN, A> a, Bounded<bN, B> b) { max(Bounded<aN, A> a, Bounded<bN, B> b) {
return Bounded<kj::max(aN, bN), WiderType<A, B>>(kj::max(a.value, b.value), unsafe); return Bounded<kj::max(aN, bN), WiderType<A, B>>(kj::max(a.unwrap(), b.unwrap()), unsafe);
} }
// We need to override min() and max() because: // We need to override min() and max() because:
// 1) WiderType<> might not choose the correct bounds. // 1) WiderType<> might not choose the correct bounds.
...@@ -982,19 +967,19 @@ inline constexpr Bounded<cvalue, decltype(uint() - T())> ...@@ -982,19 +967,19 @@ inline constexpr Bounded<cvalue, decltype(uint() - T())>
template <uint64_t aN, uint b, typename A> template <uint64_t aN, uint b, typename A>
inline constexpr Bounded<kj::min(aN, b), A> min(Bounded<aN, A> a, BoundedConst<b>) { inline constexpr Bounded<kj::min(aN, b), A> min(Bounded<aN, A> a, BoundedConst<b>) {
return Bounded<kj::min(aN, b), A>(kj::min(b, a.value), unsafe); return Bounded<kj::min(aN, b), A>(kj::min(b, a.unwrap()), unsafe);
} }
template <uint64_t aN, uint b, typename A> template <uint64_t aN, uint b, typename A>
inline constexpr Bounded<kj::min(aN, b), A> min(BoundedConst<b>, Bounded<aN, A> a) { inline constexpr Bounded<kj::min(aN, b), A> min(BoundedConst<b>, Bounded<aN, A> a) {
return Bounded<kj::min(aN, b), A>(kj::min(a.value, b), unsafe); return Bounded<kj::min(aN, b), A>(kj::min(a.unwrap(), b), unsafe);
} }
template <uint64_t aN, uint b, typename A> template <uint64_t aN, uint b, typename A>
inline constexpr Bounded<kj::max(aN, b), A> max(Bounded<aN, A> a, BoundedConst<b>) { inline constexpr Bounded<kj::max(aN, b), A> max(Bounded<aN, A> a, BoundedConst<b>) {
return Bounded<kj::max(aN, b), A>(kj::max(b, a.value), unsafe); return Bounded<kj::max(aN, b), A>(kj::max(b, a.unwrap()), unsafe);
} }
template <uint64_t aN, uint b, typename A> template <uint64_t aN, uint b, typename A>
inline constexpr Bounded<kj::max(aN, b), A> max(BoundedConst<b>, Bounded<aN, A> a) { inline constexpr Bounded<kj::max(aN, b), A> max(BoundedConst<b>, Bounded<aN, A> a) {
return Bounded<kj::max(aN, b), A>(kj::max(a.value, b), unsafe); return Bounded<kj::max(aN, b), A>(kj::max(a.unwrap(), b), unsafe);
} }
// We need to override min() between a Bounded and a constant since: // We need to override min() between a Bounded and a constant since:
// 1) WiderType<> might choose BoundedConst over a 1-byte Bounded, which is wrong. // 1) WiderType<> might choose BoundedConst over a 1-byte Bounded, which is wrong.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment