diff --git a/adapter.hpp b/adapter.hpp index 70b6a671..b25323fc 100644 --- a/adapter.hpp +++ b/adapter.hpp @@ -17,9 +17,9 @@ #ifndef __UTIL_ADAPTER_HPP #define __UTIL_ADAPTER_HPP +#include #include #include -#include namespace util { namespace adapter { namespace container { diff --git a/alloc/linear.hpp b/alloc/linear.hpp index 51ce133f..07c4d82e 100644 --- a/alloc/linear.hpp +++ b/alloc/linear.hpp @@ -52,6 +52,4 @@ namespace util::alloc { }; } -#include "./linear.hpp" - #endif diff --git a/alloc/null.cpp b/alloc/null.cpp index a4fd5e9a..7e041fa6 100644 --- a/alloc/null.cpp +++ b/alloc/null.cpp @@ -19,7 +19,7 @@ #include "../debug.hpp" -#include +#include using util::alloc::null; diff --git a/alloc/stack.hpp b/alloc/stack.hpp index 633da6ce..272ba54a 100644 --- a/alloc/stack.hpp +++ b/alloc/stack.hpp @@ -18,7 +18,6 @@ #define __UTIL_ALLOC_STACK_HPP #include -#include namespace util::alloc { diff --git a/backtrace_execinfo.cpp b/backtrace_execinfo.cpp index 22815f33..4bb0c8d4 100644 --- a/backtrace_execinfo.cpp +++ b/backtrace_execinfo.cpp @@ -23,11 +23,9 @@ #include "./cast.hpp" #include -#include #include #include #include -#include #include diff --git a/bitwise.cpp b/bitwise.cpp index fadd425f..5fb921a5 100644 --- a/bitwise.cpp +++ b/bitwise.cpp @@ -18,27 +18,29 @@ //----------------------------------------------------------------------------- -template <> -uint8_t -reverse (uint8_t value) { - static const uint8_t LOOKUP[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF - }; +namespace util { + template <> + uint8_t + reverse (uint8_t value) { + static const uint8_t LOOKUP[256] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, + 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, + 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, + 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, + 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, + 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, + 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, + 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, + 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, + 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, + 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, + 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, + 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, + 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, + 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, + 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF + }; - return LOOKUP[value]; + return LOOKUP[value]; + } } diff --git a/bitwise.hpp b/bitwise.hpp index 62c052bd..e1c97a16 100644 --- a/bitwise.hpp +++ b/bitwise.hpp @@ -17,62 +17,63 @@ #ifndef __UTIL_BITWISE_HPP #define __UTIL_BITWISE_HPP +#include #include -#include "debug.hpp" -const uint8_t BITMASK_1BITS = 0x01; -const uint8_t BITMASK_2BITS = 0x03; -const uint8_t BITMASK_3BITS = 0x07; -const uint8_t BITMASK_4BITS = 0x0F; -const uint8_t BITMASK_5BITS = 0x1F; -const uint8_t BITMASK_6BITS = 0x3F; -const uint8_t BITMASK_7BITS = 0x7F; -const uint8_t BITMASK_8BITS = 0xFF; +namespace util { + const uint8_t BITMASK_1BITS = 0x01; + const uint8_t BITMASK_2BITS = 0x03; + const uint8_t BITMASK_3BITS = 0x07; + const uint8_t BITMASK_4BITS = 0x0F; + const uint8_t BITMASK_5BITS = 0x1F; + const uint8_t BITMASK_6BITS = 0x3F; + const uint8_t BITMASK_7BITS = 0x7F; + const uint8_t BITMASK_8BITS = 0xFF; -/////////////////////////////////////////////////////////////////////////////// -template -constexpr T -rotatel [[gnu::pure]] (const T value, size_t magnitude) -{ - return (value << magnitude) | (value >> sizeof (value) * 8 - magnitude); -} - - -template -constexpr T -rotater [[gnu::pure]] (const T value, size_t magnitude) -{ - return (value >> magnitude) | (value << sizeof (value) * 8 - magnitude); -} - - -/////////////////////////////////////////////////////////////////////////////// -// TODO: make constexpr for C++14 -template -T -reverse (T value) { - T out = value; - - size_t bits = sizeof (value) * 8 - 1; - for (value >>= 1; value; value >>= 1) { - out <<= 1; - out |= value & 0x01; - --bits; + /////////////////////////////////////////////////////////////////////////// + template + constexpr T + rotatel [[gnu::pure]] (const T value, std::size_t magnitude) + { + return (value << magnitude) | (value >> sizeof (value) * 8 - magnitude); } - out <<= bits; - return out; -} + + template + constexpr T + rotater [[gnu::pure]] (const T value, std::size_t magnitude) + { + return (value >> magnitude) | (value << sizeof (value) * 8 - magnitude); + } -/////////////////////////////////////////////////////////////////////////////// -template -constexpr T -popcount (std::enable_if_t::value,T> t) -{ - return __builtin_popcount (t); + /////////////////////////////////////////////////////////////////////////// + // TODO: make constexpr for C++14 + template + T + reverse (T value) { + T out = value; + + std::size_t bits = sizeof (value) * 8 - 1; + for (value >>= 1; value; value >>= 1) { + out <<= 1; + out |= value & 0x01; + --bits; + } + + out <<= bits; + return out; + } + + + /////////////////////////////////////////////////////////////////////////// + template + constexpr T + popcount (std::enable_if_t::value,T> t) + { + return __builtin_popcount (t); + } } #endif - diff --git a/cmdopt.hpp b/cmdopt.hpp index 079bf3e0..5ede712a 100644 --- a/cmdopt.hpp +++ b/cmdopt.hpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/colour.cpp b/colour.cpp index 2f6b7cfb..2e6afee7 100644 --- a/colour.cpp +++ b/colour.cpp @@ -19,7 +19,6 @@ #include "./debug.hpp" #include "./range.hpp" #include "./random.hpp" -#include "./stream.hpp" #include #include diff --git a/crypto/ice.cpp b/crypto/ice.cpp index 43d67a06..ac5f2501 100644 --- a/crypto/ice.cpp +++ b/crypto/ice.cpp @@ -273,7 +273,7 @@ ice::encrypt (const uint64_t _ptext) const uint8_t pbytes[8]; }; - pword = hton (_ptext); + pword = util::hton (_ptext); uint32_t l, r; @@ -304,7 +304,7 @@ ice::encrypt (const uint64_t _ptext) const l >>= 8u; } - return hton (cword); + return util::hton (cword); } @@ -320,7 +320,7 @@ ice::decrypt (const uint64_t _ctext) const uint8_t cbytes[8]; }; - cword = hton (_ctext); + cword = util::hton (_ctext); uint32_t l, r; @@ -351,7 +351,7 @@ ice::decrypt (const uint64_t _ctext) const l >>= 8; } - return hton (pword); + return util::hton (pword); } diff --git a/debug.cpp b/debug.cpp index 5a6eea98..5ff4aeb6 100644 --- a/debug.cpp +++ b/debug.cpp @@ -17,7 +17,6 @@ #include "backtrace.hpp" #include "debug.hpp" #include "log.hpp" -#include "platform.hpp" #include #include diff --git a/debug_posix.cpp b/debug_posix.cpp index 610a01b1..12348312 100644 --- a/debug_posix.cpp +++ b/debug_posix.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/endian.hpp b/endian.hpp index 4b0adc0e..f2777775 100644 --- a/endian.hpp +++ b/endian.hpp @@ -22,88 +22,89 @@ #include #include -//----------------------------------------------------------------------------- -// Uses the TIFF header values. Just because. Don't rely on this. -enum class endian : uint16_t { - BIG = 0x4D4D, - LITTLE = 0x4949, -}; - -//----------------------------------------------------------------------------- -template -constexpr T -bswap (T); - -//template <> constexpr int8_t bswap ( int8_t v) { return v; } -//template <> constexpr int16_t bswap (int16_t v) { return __builtin_bswap16 (v); } -//template <> constexpr int32_t bswap (int32_t v) { return __builtin_bswap32 (v); } -//template <> constexpr int64_t bswap (int64_t v) { return __builtin_bswap64 (v); } - -template <> constexpr uint8_t bswap ( uint8_t v) { return v; } -template <> constexpr uint16_t bswap (uint16_t v) { return __builtin_bswap16 (v); } -template <> constexpr uint32_t bswap (uint32_t v) { return __builtin_bswap32 (v); } -template <> constexpr uint64_t bswap (uint64_t v) { return __builtin_bswap64 (v); } - - -//----------------------------------------------------------------------------- -template -constexpr T -identity (T &&v) { - return v; -} - - -//----------------------------------------------------------------------------- -#if defined(WORDS_BIGENDIAN) -template constexpr T hton (T v) { return v; } -template constexpr T ntoh (T v) { return v; } - -template constexpr T htob (T v) { return v; } -template constexpr T htol (T v) { return bswap (v); } - -template constexpr T btoh (T v) { return v; } -template constexpr T ltoh (T v) { return bswap (v); } -#else -template constexpr T hton (T v) { return bswap (v); } -template constexpr T ntoh (T v) { return bswap (v); } - -template constexpr T htob (T v) { return bswap (v); } -template constexpr T htol (T v) { return v; } - -template constexpr T btoh (T v) { return bswap (v); } -template constexpr T ltoh (T v) { return v; } -#endif - -//----------------------------------------------------------------------------- -struct from_endian { - explicit from_endian (endian _endian): - src (_endian) - { ; } +namespace util { + //------------------------------------------------------------------------- + // Uses the TIFF header values. Just because. Don't rely on this. + enum class endian : uint16_t { + BIG = 0x4D4D, + LITTLE = 0x4949, + }; + //------------------------------------------------------------------------- template - T operator() (const T v) const { - static_assert (std::is_integral::value || std::is_enum::value, - "endian conversion is only defined for integrals currently"); + constexpr T + bswap (T); - union { - typename sized_type::sint sint; - typename sized_type::uint uint; - }; + //template <> constexpr int8_t bswap ( int8_t v) { return v; } + //template <> constexpr int16_t bswap (int16_t v) { return __builtin_bswap16 (v); } + //template <> constexpr int32_t bswap (int32_t v) { return __builtin_bswap32 (v); } + //template <> constexpr int64_t bswap (int64_t v) { return __builtin_bswap64 (v); } - if (std::is_signed::value) - sint = v; - else - uint = v; + template <> constexpr uint8_t bswap ( uint8_t v) { return v; } + template <> constexpr uint16_t bswap (uint16_t v) { return __builtin_bswap16 (v); } + template <> constexpr uint32_t bswap (uint32_t v) { return __builtin_bswap32 (v); } + template <> constexpr uint64_t bswap (uint64_t v) { return __builtin_bswap64 (v); } - uint = (src == endian::LITTLE) ? ltoh (uint) : btoh (uint); - if (std::is_signed::value) - return T (sint); - else - return T (uint); + //------------------------------------------------------------------------- + template + constexpr T + identity (T &&v) { + return v; } - endian src; -}; + //------------------------------------------------------------------------- +#if defined(WORDS_BIGENDIAN) + template constexpr T hton (T v) { return v; } + template constexpr T ntoh (T v) { return v; } + + template constexpr T htob (T v) { return v; } + template constexpr T htol (T v) { return bswap (v); } + + template constexpr T btoh (T v) { return v; } + template constexpr T ltoh (T v) { return bswap (v); } +#else + template constexpr T hton (T v) { return bswap (v); } + template constexpr T ntoh (T v) { return bswap (v); } + + template constexpr T htob (T v) { return bswap (v); } + template constexpr T htol (T v) { return v; } + + template constexpr T btoh (T v) { return bswap (v); } + template constexpr T ltoh (T v) { return v; } +#endif + + //------------------------------------------------------------------------- + struct from_endian { + explicit from_endian (endian _endian): + src (_endian) + { ; } + + template + T operator() (const T v) const { + static_assert (std::is_integral::value || std::is_enum::value, + "endian conversion is only defined for integrals currently"); + + union { + typename sized_type::sint sint; + typename sized_type::uint uint; + }; + + if (std::is_signed::value) + sint = v; + else + uint = v; + + uint = (src == endian::LITTLE) ? ltoh (uint) : btoh (uint); + + if (std::is_signed::value) + return T (sint); + else + return T (uint); + } + + endian src; + }; +} #endif diff --git a/except.cpp b/except.cpp index 446118e6..012a0178 100644 --- a/except.cpp +++ b/except.cpp @@ -15,10 +15,9 @@ */ #include "./except.hpp" + #include "./debug.hpp" #include "./platform.hpp" -#include "./cast.hpp" -#include "./types.hpp" #include #include diff --git a/extent.cpp b/extent.cpp index df08e0eb..568b31bb 100644 --- a/extent.cpp +++ b/extent.cpp @@ -18,7 +18,6 @@ #include "./debug.hpp" #include "./maths.hpp" -#include "./stream.hpp" #include #include diff --git a/extent.hpp b/extent.hpp index f700b04f..50cbecbd 100644 --- a/extent.hpp +++ b/extent.hpp @@ -17,7 +17,7 @@ #ifndef __UTIL_EXTENT_HPP #define __UTIL_EXTENT_HPP -#include "coord.hpp" +#include "coord/base.hpp" #include "vector.hpp" #include "point.hpp" diff --git a/fixed.cpp b/fixed.cpp index 9a0ba91f..e62e706e 100644 --- a/fixed.cpp +++ b/fixed.cpp @@ -18,10 +18,9 @@ #include "maths.hpp" -#include - using namespace util; + /////////////////////////////////////////////////////////////////////////////// // Constructors template diff --git a/fixed.hpp b/fixed.hpp index 5992a43a..c38361bf 100644 --- a/fixed.hpp +++ b/fixed.hpp @@ -19,7 +19,6 @@ #include "types/bits.hpp" -#include #include namespace util { diff --git a/float.cpp b/float.cpp index 430569cf..6465a0e9 100644 --- a/float.cpp +++ b/float.cpp @@ -19,6 +19,8 @@ #include +using util::ieee_float; + /////////////////////////////////////////////////////////////////////////////// template @@ -155,6 +157,6 @@ ieee_float::almost_equal (floating_t _a, /////////////////////////////////////////////////////////////////////////////// -template class ieee_float< 5, 10>; // ieee_half -template class ieee_float< 8, 23>; // ieee_single; -template class ieee_float<11, 52>; // ieee_double; +template class util::ieee_float< 5, 10>; // ieee_half +template class util::ieee_float< 8, 23>; // ieee_single; +template class util::ieee_float<11, 52>; // ieee_double; diff --git a/float.hpp b/float.hpp index 8c697f06..99f830ae 100644 --- a/float.hpp +++ b/float.hpp @@ -21,64 +21,65 @@ /////////////////////////////////////////////////////////////////////////////// -template -class ieee_float -{ -public: - static const unsigned int EXPONENT_BITS = EXPONENT; - static const unsigned int SIGNIFICAND_BITS = SIGNIFICAND; - static const unsigned int TOTAL_BITS = 1 + EXPONENT + SIGNIFICAND; +namespace util { + template + class ieee_float + { + public: + static const unsigned int EXPONENT_BITS = EXPONENT; + static const unsigned int SIGNIFICAND_BITS = SIGNIFICAND; + static const unsigned int TOTAL_BITS = 1 + EXPONENT + SIGNIFICAND; - static const unsigned int BIAS = (1 << (EXPONENT - 1)) - 1; + static const unsigned int BIAS = (1 << (EXPONENT - 1)) - 1; - typedef typename bits_type::sint sint_t; - typedef typename bits_type::uint uint_t; - typedef typename bits_type::floating floating_t; + typedef typename bits_type::sint sint_t; + typedef typename bits_type::uint uint_t; + typedef typename bits_type::floating floating_t; -protected: - union { - uint_t m_bits; - floating_t m_floating; + protected: + union { + uint_t m_bits; + floating_t m_floating; - struct { - uint_t sign : 1; - uint_t exponent : EXPONENT; - uint_t significand : SIGNIFICAND; - } m_components; + struct { + uint_t sign : 1; + uint_t exponent : EXPONENT; + uint_t significand : SIGNIFICAND; + } m_components; + }; + + public: + ieee_float (void); + ieee_float (floating_t _floating); + ieee_float (const ieee_float &rhs); + + static unsigned int bias (void) + { return BIAS; } + + void set_bits (uint_t _bits) { m_bits = _bits; } + uint_t bits (void) const { return m_bits; } + + bool negative (void) const { return m_components.sign; } + void negate (void) { m_components.sign ^= m_components.sign; } + + bool is_zero (void) const; + bool is_subnormal (void) const; + bool is_inifinity (void) const; + bool is_nan (void) const; + bool operator== (floating_t) const; + + static bool almost_equal (floating_t, floating_t); + static bool almost_equal (floating_t, floating_t, unsigned ulps); }; -public: - ieee_float (void); - ieee_float (floating_t _floating); - ieee_float (const ieee_float &rhs); - static unsigned int bias (void) - { return BIAS; } - - void set_bits (uint_t _bits) { m_bits = _bits; } - uint_t bits (void) const { return m_bits; } - - bool negative (void) const { return m_components.sign; } - void negate (void) { m_components.sign ^= m_components.sign; } - - bool is_zero (void) const; - bool is_subnormal (void) const; - bool is_inifinity (void) const; - bool is_nan (void) const; - bool operator== (floating_t) const; - - static bool almost_equal (floating_t, floating_t); - static bool almost_equal (floating_t, floating_t, unsigned ulps); -}; + typedef ieee_float< 5, 10> ieee_half; + typedef ieee_float< 8, 23> ieee_single; + typedef ieee_float<11, 52> ieee_double; -typedef ieee_float< 5, 10> ieee_half; -typedef ieee_float< 8, 23> ieee_single; -typedef ieee_float<11, 52> ieee_double; - - -static_assert (sizeof(ieee_half ) == 2, "ieee_half must be 2 bytes"); -static_assert (sizeof(ieee_single ) == 4, "ieee_single must be 4 bytes"); -static_assert (sizeof(ieee_double ) == 8, "ieee_double must be 8 bytes"); - + static_assert (sizeof(ieee_half ) == 2, "ieee_half must be 2 bytes"); + static_assert (sizeof(ieee_single ) == 4, "ieee_single must be 4 bytes"); + static_assert (sizeof(ieee_double ) == 8, "ieee_double must be 8 bytes"); +} #endif // __FLOAT_HPP diff --git a/geom/aabb.cpp b/geom/aabb.cpp index 3aac3ff9..0fdf302a 100644 --- a/geom/aabb.cpp +++ b/geom/aabb.cpp @@ -18,6 +18,7 @@ #include "./aabb.hpp" #include "./iostream.hpp" +#include "../coord/iostream.hpp" #include "../debug.hpp" using util::geom::AABB; diff --git a/geom/aabb.hpp b/geom/aabb.hpp index bed5e572..583455be 100644 --- a/geom/aabb.hpp +++ b/geom/aabb.hpp @@ -20,7 +20,6 @@ #include "../point.hpp" #include "../extent.hpp" -#include "../coord/iostream.hpp" #include diff --git a/geom/ray.cpp b/geom/ray.cpp index 07e86edb..41fa0d76 100644 --- a/geom/ray.cpp +++ b/geom/ray.cpp @@ -18,7 +18,7 @@ #include "./iostream.hpp" #include "./ops.hpp" - +#include "../coord/iostream.hpp" #include "../debug.hpp" using util::geom::ray; diff --git a/geom/ray.hpp b/geom/ray.hpp index 264b1baf..58e86403 100644 --- a/geom/ray.hpp +++ b/geom/ray.hpp @@ -23,8 +23,6 @@ #include "../vector.hpp" #include "../point.hpp" -#include - namespace util { namespace geom { template struct ray { diff --git a/guid.cpp b/guid.cpp index 88d060fd..c2451db5 100644 --- a/guid.cpp +++ b/guid.cpp @@ -14,13 +14,12 @@ * Copyright 2011 Danny Robson */ -#include "guid.hpp" +#include "./guid.hpp" -#include "debug.hpp" -#include "endian.hpp" -#include "types.hpp" +#include "./debug.hpp" #include +#include #include #include @@ -36,7 +35,7 @@ guid::guid (uint32_t _data1, data2 (_data2), data3 (_data3) { - std::copy (_data4, _data4 + elems (data4), data4); + std::copy (_data4, _data4 + std::size (data4), data4); } @@ -66,7 +65,7 @@ guid::operator= (const guid &rhs) { data1 = rhs.data1; data2 = rhs.data2; data3 = rhs.data3; - std::copy (rhs.data4 + 0, rhs.data4 + elems (rhs.data4), data4 + 0); + std::copy (rhs.data4 + 0, rhs.data4 + std::size (rhs.data4), data4 + 0); return *this; } @@ -133,7 +132,7 @@ guid::operator< (const guid &rhs) const { if (data3 != rhs.data3) return data3 < rhs.data3; - for (unsigned i = 0; i < elems (data4); ++i) { + for (unsigned i = 0; i < std::size (data4); ++i) { if (data4[i] == rhs.data4[i]) return data4[i] < rhs.data4[i]; } diff --git a/hash/adler.hpp b/hash/adler.hpp index 37b99f66..35c9f645 100644 --- a/hash/adler.hpp +++ b/hash/adler.hpp @@ -20,7 +20,6 @@ #include "./fletcher.hpp" #include -#include /////////////////////////////////////////////////////////////////////////////// diff --git a/hash/hmac.cpp b/hash/hmac.cpp index 8534d580..c565d7b6 100644 --- a/hash/hmac.cpp +++ b/hash/hmac.cpp @@ -118,7 +118,7 @@ HMAC::digest (void) #include "md5.hpp" #include "sha1.hpp" -namespace util { namespace hash { +namespace util::hash { template class HMAC; template class HMAC; -} } +} diff --git a/hash/keccak.cpp b/hash/keccak.cpp index 848af729..224c4116 100644 --- a/hash/keccak.cpp +++ b/hash/keccak.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #if 0 #define FOR(i,n) for(i=0; i - void keccak::update ( diff --git a/hash/md4.cpp b/hash/md4.cpp index a396315f..4857c51f 100644 --- a/hash/md4.cpp +++ b/hash/md4.cpp @@ -18,8 +18,6 @@ #include "../bitwise.hpp" #include "../debug.hpp" -#include "../endian.hpp" -#include "../types.hpp" #include diff --git a/hash/md5.cpp b/hash/md5.cpp index 35ce8a29..07056bcf 100644 --- a/hash/md5.cpp +++ b/hash/md5.cpp @@ -17,6 +17,7 @@ #include "md5.hpp" #include "../bitwise.hpp" +#include "../debug.hpp" #include diff --git a/hash/murmur/murmur3.cpp b/hash/murmur/murmur3.cpp index 5910707e..9e7b47e5 100644 --- a/hash/murmur/murmur3.cpp +++ b/hash/murmur/murmur3.cpp @@ -73,11 +73,11 @@ util::hash::murmur3::hash_32(const void *restrict key, uint32_t k1 = *cursor; k1 *= c1; - k1 = rotatel (k1, 15); + k1 = util::rotatel (k1, 15); k1 *= c2; h1 ^= k1; - h1 = rotatel (h1, 13); + h1 = util::rotatel (h1, 13); h1 += 0; h1 = h1 * 5 + 0xe6546b64; } @@ -88,7 +88,7 @@ util::hash::murmur3::hash_32(const void *restrict key, uint32_t k1 = 0 ^ murmur::tail (cursor, len); k1 *= c1; - k1 = rotatel (k1, 15); + k1 = util::rotatel (k1, 15); k1 *= c2; h1 ^= k1; } @@ -153,7 +153,7 @@ half_round (std::array::COMPONENTS> h, auto i_ = (i + 1) % COMPONENTS; k[i] *= CONSTANTS[i].c; - k[i] = rotatel (k[i], CONSTANTS[i].Ks); + k[i] = util::rotatel (k[i], CONSTANTS[i].Ks); k[i] *= CONSTANTS[i_].c; return h[i] ^= k[i]; @@ -173,7 +173,7 @@ full_round (std::array::COMPONENTS> h, h[i] = half_round (h, k, i); auto i_ = (i + 1) % COMPONENTS; - h[i] = rotatel (h[i], CONSTANTS[i].Hs); + h[i] = util::rotatel (h[i], CONSTANTS[i].Hs); h[i] += h[i_]; h[i] = h[i] * 5 + CONSTANTS[i].O; } diff --git a/hash/ripemd.cpp b/hash/ripemd.cpp index 73f9c415..369561a2 100644 --- a/hash/ripemd.cpp +++ b/hash/ripemd.cpp @@ -21,11 +21,10 @@ #include "../bitwise.hpp" #include -#include - using util::hash::RIPEMD; + /////////////////////////////////////////////////////////////////////////////// RIPEMD::RIPEMD() { diff --git a/hash/sha1.cpp b/hash/sha1.cpp index 50d5c545..3f26a780 100644 --- a/hash/sha1.cpp +++ b/hash/sha1.cpp @@ -19,11 +19,9 @@ #include "../bitwise.hpp" #include "../debug.hpp" #include "../endian.hpp" -#include "../types.hpp" #include "../cast.hpp" #include -#include #include #include #include diff --git a/hash/sha2.cpp b/hash/sha2.cpp index 1ff0e098..cb9103de 100644 --- a/hash/sha2.cpp +++ b/hash/sha2.cpp @@ -85,9 +85,9 @@ Maj (uint32_t x, uint32_t y, uint32_t z) { #define FUNC(NAME,r0,r1,r2) \ static constexpr uint32_t \ NAME (uint32_t x) { \ - return rotater (x, (r0)) ^ \ - rotater (x, (r1)) ^ \ - rotater (x, (r2)); \ + return util::rotater (x, (r0)) ^ \ + util::rotater (x, (r1)) ^ \ + util::rotater (x, (r2)); \ } @@ -101,8 +101,8 @@ FUNC(S1, 6, 11, 25) #define FUNC(NAME,r0,r1,s) \ static constexpr \ uint32_t NAME (uint32_t x) { \ - return rotater (x, (r0)) ^ \ - rotater (x, (r1)) ^ \ + return util::rotater (x, (r0)) ^ \ + util::rotater (x, (r1)) ^ \ (x >> (s)); \ } diff --git a/io.cpp b/io.cpp index bc769f78..704a437a 100644 --- a/io.cpp +++ b/io.cpp @@ -18,13 +18,11 @@ #include "debug.hpp" #include "except.hpp" -#include "platform.hpp" #include "cast.hpp" #include #include #include -#include #include #include diff --git a/io.hpp b/io.hpp index 3fb61dac..d05ec09a 100644 --- a/io.hpp +++ b/io.hpp @@ -17,16 +17,11 @@ #ifndef __UTIL_IO_HPP #define __UTIL_IO_HPP -#include "types.hpp" #include "platform.hpp" -#include "nocopy.hpp" #include "posix/fd.hpp" -#include - #include #include -#include #include #ifdef PLATFORM_WIN32 diff --git a/io_posix.cpp b/io_posix.cpp index da0e017c..840590c8 100644 --- a/io_posix.cpp +++ b/io_posix.cpp @@ -20,9 +20,7 @@ #include "except.hpp" #include "posix/fd.hpp" -#include #include -#include using util::detail::posix::mapped_file; diff --git a/json/flat.cpp.rl b/json/flat.cpp.rl index 6b78f31a..bf577c3d 100644 --- a/json/flat.cpp.rl +++ b/json/flat.cpp.rl @@ -20,8 +20,6 @@ #include "json/flat.hpp" #include "json/except.hpp" -#include "debug.hpp" -#include "io.hpp" #include "preprocessor.hpp" #include diff --git a/json/flat.hpp b/json/flat.hpp index b0b56c8c..0c567bd2 100644 --- a/json/flat.hpp +++ b/json/flat.hpp @@ -17,8 +17,8 @@ #ifndef __UTIL_JSON_FLAT_HPP #define __UTIL_JSON_FLAT_HPP -#include #include +#include #include "../view.hpp" diff --git a/json/schema.cpp b/json/schema.cpp index 05fa7ffd..0ec5165a 100644 --- a/json/schema.cpp +++ b/json/schema.cpp @@ -19,7 +19,6 @@ #include "./tree.hpp" #include "./except.hpp" -#include "../debug.hpp" #include "../io.hpp" #include "../maths.hpp" diff --git a/json/schema.hpp b/json/schema.hpp index ec941fe2..4e828103 100644 --- a/json/schema.hpp +++ b/json/schema.hpp @@ -19,7 +19,6 @@ #include "./fwd.hpp" -#include #include namespace json { namespace schema { diff --git a/json/tree.cpp b/json/tree.cpp index 0be6686b..a4069a8a 100644 --- a/json/tree.cpp +++ b/json/tree.cpp @@ -20,7 +20,6 @@ #include "./except.hpp" #include "./flat.hpp" -#include "../cast.hpp" #include "../debug.hpp" #include "../io.hpp" #include "../maths.hpp" @@ -28,15 +27,7 @@ #include #include -#include #include -#include - -#include -#include -#include -#include - using json::tree::node; using json::tree::object; diff --git a/log.cpp b/log.cpp index dbd82ae6..ab17e01b 100644 --- a/log.cpp +++ b/log.cpp @@ -20,10 +20,8 @@ #include "debug.hpp" #include "term.hpp" #include "time.hpp" -#include "types.hpp" #include "cast.hpp" -#include #include #include #include diff --git a/maths.cpp b/maths.cpp index aac72953..1dfc701d 100644 --- a/maths.cpp +++ b/maths.cpp @@ -16,11 +16,6 @@ #include "maths.hpp" -#include "debug.hpp" - -#include "float.hpp" - -#include #include diff --git a/maths.hpp b/maths.hpp index 712cf7ab..4b681fdb 100644 --- a/maths.hpp +++ b/maths.hpp @@ -30,7 +30,6 @@ #include #include #include -#include /////////////////////////////////////////////////////////////////////////////// diff --git a/memory/buffer/circular.cpp b/memory/buffer/circular.cpp index 0195d76e..2f8a5948 100644 --- a/memory/buffer/circular.cpp +++ b/memory/buffer/circular.cpp @@ -23,8 +23,6 @@ #include "../../raii.hpp" #include "../../random.hpp" -#include -#include #include #include #include diff --git a/point.cpp b/point.cpp index 3c772a4d..d75fcdf1 100644 --- a/point.cpp +++ b/point.cpp @@ -17,9 +17,7 @@ #include "./point.hpp" #include "./debug.hpp" -#include "./maths.hpp" -#include #include using util::point; diff --git a/point.hpp b/point.hpp index b0bd5f32..d3cda6aa 100644 --- a/point.hpp +++ b/point.hpp @@ -17,12 +17,9 @@ #ifndef __UTIL_POINT_HPP #define __UTIL_POINT_HPP -#include "extent.hpp" #include "vector.hpp" #include "coord.hpp" -#include -#include #include namespace util { diff --git a/polynomial.cpp b/polynomial.cpp index 367ab6f5..445d048d 100644 --- a/polynomial.cpp +++ b/polynomial.cpp @@ -21,7 +21,6 @@ #include #include -#include static const size_t NEWTON_ITERATIONS = 1u; diff --git a/posix/dir.hpp b/posix/dir.hpp index 1f448aab..53890ed7 100644 --- a/posix/dir.hpp +++ b/posix/dir.hpp @@ -17,7 +17,6 @@ #ifndef __UTIL_POSIX_DIR_HPP #define __UTIL_POSIX_DIR_HPP -#include #include #include diff --git a/posix/fd.hpp b/posix/fd.hpp index 67e8d9b7..7573e9c6 100644 --- a/posix/fd.hpp +++ b/posix/fd.hpp @@ -17,8 +17,6 @@ #ifndef __CRUFT_UTIL_POSIX_FD_HPP #define __CRUFT_UTIL_POSIX_FD_HPP -#include - #include #include diff --git a/quaternion.cpp b/quaternion.cpp index 0dc5afb5..cd30ded5 100644 --- a/quaternion.cpp +++ b/quaternion.cpp @@ -18,10 +18,9 @@ #include "./quaternion.hpp" #include "./debug.hpp" -#include "./maths.hpp" #include "./vector.hpp" -#include +#include //----------------------------------------------------------------------------- using util::quaternion; diff --git a/rand/lcg.cpp b/rand/lcg.cpp index 37937407..893c59a6 100644 --- a/rand/lcg.cpp +++ b/rand/lcg.cpp @@ -16,6 +16,8 @@ #include "lcg.hpp" +#include "../maths.hpp" + using util::rand::lcg; diff --git a/rand/lcg.hpp b/rand/lcg.hpp index e87ff243..1cacc885 100644 --- a/rand/lcg.hpp +++ b/rand/lcg.hpp @@ -17,7 +17,8 @@ #ifndef __UTIL_RAND_LCG_HPP #define __UTIL_RAND_LCG_HPP -#include "../maths.hpp" +#include +#include namespace util { namespace rand { diff --git a/region.cpp b/region.cpp index 72369252..067f000c 100644 --- a/region.cpp +++ b/region.cpp @@ -18,13 +18,9 @@ #include "./region.hpp" #include "./debug.hpp" -#include "./cast.hpp" #include "./coord/iostream.hpp" -#include -#include - //----------------------------------------------------------------------------- template diff --git a/signal.hpp b/signal.hpp index e673cffc..aed2ea45 100644 --- a/signal.hpp +++ b/signal.hpp @@ -17,12 +17,10 @@ #ifndef __UTIL_SIGNAL_HPP #define __UTIL_SIGNAL_HPP -#include "nocopy.hpp" #include "types/traits.hpp" #include #include -#include namespace util { namespace combine { diff --git a/signal.ipp b/signal.ipp index d210c68b..56f4e5e5 100644 --- a/signal.ipp +++ b/signal.ipp @@ -19,6 +19,7 @@ #endif #include "debug.hpp" +#include "nocopy.hpp" #include diff --git a/stats.cpp b/stats.cpp index b25b816a..6603eb99 100644 --- a/stats.cpp +++ b/stats.cpp @@ -16,7 +16,6 @@ #include "stats.hpp" -#include #include diff --git a/stringid.cpp b/stringid.cpp index fbf8e385..f38c2d61 100644 --- a/stringid.cpp +++ b/stringid.cpp @@ -16,8 +16,6 @@ #include "stringid.hpp" -#include "raii.hpp" - #include #include diff --git a/tap.cpp b/tap.cpp index 905eea1a..5dedf7ab 100644 --- a/tap.cpp +++ b/tap.cpp @@ -16,8 +16,6 @@ #include "tap.hpp" -#include "debug.hpp" - #include using util::TAP::logger; diff --git a/tap.hpp b/tap.hpp index 8bb82893..613468bf 100644 --- a/tap.hpp +++ b/tap.hpp @@ -18,8 +18,6 @@ #define __UTIL_TAP_HPP #include -#include -#include namespace util { namespace TAP { /// A simple TAP (Test Anything Protocol) test case output diff --git a/test/bitwise.cpp b/test/bitwise.cpp index 8c20480e..8cfb6dcf 100644 --- a/test/bitwise.cpp +++ b/test/bitwise.cpp @@ -6,33 +6,33 @@ static void test_rotate (util::TAP::logger &tap) { - tap.expect_eq (rotatel (uint8_t (0x0F), 0), 0x0Fu, "rotate-left u8"); - tap.expect_eq (rotatel (uint8_t (0x0F), 4), 0xF0u, "rotate-left u8"); - tap.expect_eq (rotatel (uint8_t (0xF0), 4), 0x0Fu, "rotate-left u8"); - tap.expect_eq (rotatel (uint8_t (0x0F), 8), 0x0Fu, "rotate-left u8"); + tap.expect_eq (util::rotatel (uint8_t (0x0F), 0), 0x0Fu, "rotate-left u8"); + tap.expect_eq (util::rotatel (uint8_t (0x0F), 4), 0xF0u, "rotate-left u8"); + tap.expect_eq (util::rotatel (uint8_t (0xF0), 4), 0x0Fu, "rotate-left u8"); + tap.expect_eq (util::rotatel (uint8_t (0x0F), 8), 0x0Fu, "rotate-left u8"); - tap.expect_eq (rotater (uint8_t (0x0F), 0), 0x0Fu, "rotate-right u8"); - tap.expect_eq (rotater (uint8_t (0x0F), 4), 0xF0u, "rotate-right u8"); - tap.expect_eq (rotater (uint8_t (0xF0), 4), 0x0Fu, "rotate-right u8"); - tap.expect_eq (rotater (uint8_t (0x0F), 8), 0x0Fu, "rotate-right u8"); + tap.expect_eq (util::rotater (uint8_t (0x0F), 0), 0x0Fu, "rotate-right u8"); + tap.expect_eq (util::rotater (uint8_t (0x0F), 4), 0xF0u, "rotate-right u8"); + tap.expect_eq (util::rotater (uint8_t (0xF0), 4), 0x0Fu, "rotate-right u8"); + tap.expect_eq (util::rotater (uint8_t (0x0F), 8), 0x0Fu, "rotate-right u8"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 0), 0xABCDu, "rotate-left u16"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 4), 0xBCDAu, "rotate-left u16"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 8), 0xCDABu, "rotate-left u16"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 12), 0xDABCu, "rotate-left u16"); - tap.expect_eq (rotatel (uint16_t (0xABCD), 16), 0xABCDu, "rotate-left u16"); + tap.expect_eq (util::rotatel (uint16_t (0xABCD), 0), 0xABCDu, "rotate-left u16"); + tap.expect_eq (util::rotatel (uint16_t (0xABCD), 4), 0xBCDAu, "rotate-left u16"); + tap.expect_eq (util::rotatel (uint16_t (0xABCD), 8), 0xCDABu, "rotate-left u16"); + tap.expect_eq (util::rotatel (uint16_t (0xABCD), 12), 0xDABCu, "rotate-left u16"); + tap.expect_eq (util::rotatel (uint16_t (0xABCD), 16), 0xABCDu, "rotate-left u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 0), 0xABCDu, "rotate-right u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 4), 0xDABCu, "rotate-right u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 8), 0xCDABu, "rotate-right u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 12), 0xBCDAu, "rotate-right u16"); - tap.expect_eq (rotater (uint16_t (0xABCD), 16), 0xABCDu, "rotate-right u16"); + tap.expect_eq (util::rotater (uint16_t (0xABCD), 0), 0xABCDu, "rotate-right u16"); + tap.expect_eq (util::rotater (uint16_t (0xABCD), 4), 0xDABCu, "rotate-right u16"); + tap.expect_eq (util::rotater (uint16_t (0xABCD), 8), 0xCDABu, "rotate-right u16"); + tap.expect_eq (util::rotater (uint16_t (0xABCD), 12), 0xBCDAu, "rotate-right u16"); + tap.expect_eq (util::rotater (uint16_t (0xABCD), 16), 0xABCDu, "rotate-right u16"); - tap.expect_eq (rotatel (uint32_t (0x12345670), 12), 0x45670123u, "rotate-left u32"); - tap.expect_eq (rotater (uint32_t (0x12345670), 12), 0x67012345u, "rotate-right u32"); + tap.expect_eq (util::rotatel (uint32_t (0x12345670), 12), 0x45670123u, "rotate-left u32"); + tap.expect_eq (util::rotater (uint32_t (0x12345670), 12), 0x67012345u, "rotate-right u32"); - tap.expect_eq (rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123u, "rotate-left u64"); - tap.expect_eq (rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABCu, "rotate-right u64"); + tap.expect_eq (util::rotatel (uint64_t (0x1234567890ABCDEF), 12), 0x4567890ABCDEF123u, "rotate-left u64"); + tap.expect_eq (util::rotater (uint64_t (0x1234567890ABCDEF), 12), 0xDEF1234567890ABCu, "rotate-right u64"); } @@ -42,8 +42,8 @@ test_reverse (util::TAP::logger &tap) { size_t matches = 0; for (unsigned i = 0; i < 256; ++i) { - auto first = reverse (i); - auto last = reverse (first); + auto first = util::reverse (i); + auto last = util::reverse (first); if (last == i) matches++; } diff --git a/test/crypto/arc4.cpp b/test/crypto/arc4.cpp index 6e3c2b1e..11c653e8 100644 --- a/test/crypto/arc4.cpp +++ b/test/crypto/arc4.cpp @@ -2,6 +2,7 @@ #include "tap.hpp" #include "types.hpp" +#include int main () diff --git a/test/crypto/ice.cpp b/test/crypto/ice.cpp index 0c6403e0..8eb0abd1 100644 --- a/test/crypto/ice.cpp +++ b/test/crypto/ice.cpp @@ -28,7 +28,7 @@ main (int, char**) for (const auto &t: TESTS) { std::vector k (t.key.cbegin (), t.key.cend ()); - std::transform (k.cbegin (), k.cend (), k.begin (), hton); + std::transform (k.cbegin (), k.cend (), k.begin (), util::hton); ice key (t.level, k.data (), k.data () + k.size ()); diff --git a/test/crypto/xxtea.cpp b/test/crypto/xxtea.cpp index a568196c..bb1faa92 100644 --- a/test/crypto/xxtea.cpp +++ b/test/crypto/xxtea.cpp @@ -3,6 +3,7 @@ #include "tap.hpp" #include "types.hpp" +#include int main () diff --git a/test/float.cpp b/test/float.cpp index 0c32263f..7e9db339 100644 --- a/test/float.cpp +++ b/test/float.cpp @@ -12,8 +12,8 @@ void test_double (util::TAP::logger &tap) { struct sized_test { - ieee_double::uint_t bits; - double floating; + util::ieee_double::uint_t bits; + double floating; }; sized_test tests[] = { @@ -35,7 +35,7 @@ test_double (util::TAP::logger &tap) bool success = true; for (unsigned int i = 0; i < elems (tests); ++i) { - ieee_double val; + util::ieee_double val; val.set_bits (tests[i].bits); success = success && util::exactly_equal (val, tests[i].floating); @@ -50,8 +50,8 @@ void test_single (util::TAP::logger &tap) { struct sized_test { - ieee_single::uint_t bits; - float floating; + util::ieee_single::uint_t bits; + float floating; }; sized_test tests[] = { @@ -71,7 +71,7 @@ test_single (util::TAP::logger &tap) bool success = true; for (unsigned int i = 0; i < elems (tests); ++i) { - ieee_single val; + util::ieee_single val; val.set_bits (tests[i].bits); success = success && util::exactly_equal (val, tests[i].floating); diff --git a/test/hash/keccak.cpp b/test/hash/keccak.cpp index 45fc7487..24f938d8 100644 --- a/test/hash/keccak.cpp +++ b/test/hash/keccak.cpp @@ -3,6 +3,7 @@ #include "tap.hpp" #include +#include static constexpr diff --git a/test/hton.cpp b/test/hton.cpp index 8927a92f..85ada833 100644 --- a/test/hton.cpp +++ b/test/hton.cpp @@ -21,11 +21,11 @@ main (void) uint16_t u16 = 0x1358; uint32_t u32 = 0x12345678; - tap.expect_eq (htons (u16), hton (u16), "htons"); - tap.expect_eq (htonl (u32), hton (u32), "htonl"); + tap.expect_eq (htons (u16), util::hton (u16), "htons"); + tap.expect_eq (htonl (u32), util::hton (u32), "htonl"); - tap.expect_eq (ntohs (u16), hton (u16), "ntohs"); - tap.expect_eq (ntohl (u32), hton (u32), "ntohl"); + tap.expect_eq (ntohs (u16), util::hton (u16), "ntohs"); + tap.expect_eq (ntohl (u32), util::hton (u32), "ntohl"); return tap.status (); } diff --git a/test/tuple.cpp b/test/tuple.cpp index f5e945ea..382e5faf 100644 --- a/test/tuple.cpp +++ b/test/tuple.cpp @@ -3,6 +3,8 @@ #include "tap.hpp" #include +#include + template struct int_mapper diff --git a/time.cpp b/time.cpp index 42ff1966..fba55178 100644 --- a/time.cpp +++ b/time.cpp @@ -16,10 +16,7 @@ #include "./time.hpp" -#include "./debug.hpp" #include "./log.hpp" -#include "./platform.hpp" -#include "./cast.hpp" #include diff --git a/tools/hash.cpp b/tools/hash.cpp index 5f1961c5..1176b321 100644 --- a/tools/hash.cpp +++ b/tools/hash.cpp @@ -16,10 +16,6 @@ */ #include -#include -#include -#include - #include #include @@ -30,7 +26,6 @@ #include "hash/adler.hpp" #include "hash/bsdsum.cpp" #include "hash/crc.hpp" -#include "hash/fletcher.hpp" #include "hash/md2.hpp" #include "hash/md4.hpp" #include "hash/md5.hpp" @@ -45,7 +40,6 @@ const char* NAMES[] = { "adler32", "bsdsum", "crc32", - "fletcher" "MD2", "MD4", "MD5", diff --git a/tools/json-clean.cpp b/tools/json-clean.cpp index f595cb22..5edbf9a0 100644 --- a/tools/json-clean.cpp +++ b/tools/json-clean.cpp @@ -21,8 +21,6 @@ #include #include -#include - /////////////////////////////////////////////////////////////////////////////// enum { diff --git a/tools/json-schema.cpp b/tools/json-schema.cpp index f0ada5ef..6a61b224 100644 --- a/tools/json-schema.cpp +++ b/tools/json-schema.cpp @@ -16,9 +16,8 @@ #include "json/except.hpp" -#include "json/tree.hpp" #include "json/schema.hpp" -#include "json/except.hpp" +#include "json/tree.hpp" #include "io.hpp" diff --git a/tools/json-validate.cpp b/tools/json-validate.cpp index 1caff3b6..f83e8b56 100644 --- a/tools/json-validate.cpp +++ b/tools/json-validate.cpp @@ -21,7 +21,6 @@ #include #include -#include enum { diff --git a/tuple.hpp b/tuple.hpp index 7104072b..d7b4245d 100644 --- a/tuple.hpp +++ b/tuple.hpp @@ -22,7 +22,6 @@ #include #include -#include namespace util { namespace tuple { diff --git a/types/bits.hpp b/types/bits.hpp index b0f2e6a8..5227e253 100644 --- a/types/bits.hpp +++ b/types/bits.hpp @@ -20,53 +20,54 @@ #include #include -template -struct bits_type; +namespace util { + template + struct bits_type; -template <> struct bits_type< 8u> { - static const bool has_floating = false; + template <> struct bits_type< 8u> { + static const bool has_floating = false; - typedef uint8_t uint; - typedef int8_t sint; - typedef uint8_t floating; -}; + typedef uint8_t uint; + typedef int8_t sint; + typedef uint8_t floating; + }; -template <> struct bits_type<16u> { - static const bool has_floating = false; + template <> struct bits_type<16u> { + static const bool has_floating = false; - typedef uint16_t uint; - typedef int16_t sint; - typedef uint16_t floating; -}; + typedef uint16_t uint; + typedef int16_t sint; + typedef uint16_t floating; + }; -template <> struct bits_type<32u> { - static const bool has_floating = true; + template <> struct bits_type<32u> { + static const bool has_floating = true; - typedef uint32_t uint; - typedef int32_t sint; - typedef float floating; -}; + typedef uint32_t uint; + typedef int32_t sint; + typedef float floating; + }; -template <> struct bits_type<64u> { - static const bool has_floating = true; + template <> struct bits_type<64u> { + static const bool has_floating = true; - typedef uint64_t uint; - typedef int64_t sint; - typedef double floating; -}; + typedef uint64_t uint; + typedef int64_t sint; + typedef double floating; + }; -template -struct bytes_type : public bits_type -{ }; + template + struct bytes_type : public bits_type + { }; -template -struct sized_type : public bits_type -{ }; - + template + struct sized_type : public bits_type + { }; +} #endif diff --git a/vector.cpp b/vector.cpp index 81d1471c..29f025ab 100644 --- a/vector.cpp +++ b/vector.cpp @@ -17,13 +17,11 @@ #include "vector.hpp" #include "debug.hpp" -#include "maths.hpp" #include "random.hpp" -#include +#include "json/tree.hpp" + #include -#include -#include using util::vector; using util::vector3f; diff --git a/vector.hpp b/vector.hpp index db46b713..5f27091d 100644 --- a/vector.hpp +++ b/vector.hpp @@ -17,11 +17,8 @@ #ifndef __UTIL_VECTOR_HPP #define __UTIL_VECTOR_HPP -#include "json/tree.hpp" #include "coord.hpp" - -#include -#include +#include "json/fwd.hpp" namespace util { template