From c042850637347047c12f33b655e259f37060cea3 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 2 Mar 2020 13:50:31 +0100 Subject: [PATCH] Clean up bigint.h header. --- TODO.md | 2 - {legacy => include}/lol/math/bigint.h | 18 +--- legacy/lol/base/features.h | 147 -------------------------- 3 files changed, 5 insertions(+), 162 deletions(-) rename {legacy => include}/lol/math/bigint.h (98%) delete mode 100644 legacy/lol/base/features.h diff --git a/TODO.md b/TODO.md index 7b9b7bf6..485dbf2a 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,6 @@ ## `lol` headers to keep src/lol/base/types.h (vec_t shortcuts eg. vec2, ivec2, u8vec3 etc.) - src/lol/math/bigint.h src/lol/math/constants.h src/lol/math/functions.h src/lol/math/noise/* @@ -31,7 +30,6 @@ src/lol/algorithm/portal.h src/lol/audio/* - src/lol/base/features.h (a bit dangerous to ship) src/lol/base/log.h src/lol/debug/* src/lol/engine.h diff --git a/legacy/lol/math/bigint.h b/include/lol/math/bigint.h similarity index 98% rename from legacy/lol/math/bigint.h rename to include/lol/math/bigint.h index f00cfb95..c5080d95 100644 --- a/legacy/lol/math/bigint.h +++ b/include/lol/math/bigint.h @@ -14,21 +14,15 @@ // // The bigint class -// ---------------- +// ———————————————— // -#include - -#include -#include +#include // std::array +#include // uint32_t etc. namespace lol { -/* This is OUR namespace. Don't let Windows headers mess with it. */ -#undef min -#undef max - /* * A bigint stores its digits in an array of integers. The MSB of the * integers are unused. The highest used bit is the sign bit. @@ -43,9 +37,7 @@ class [[nodiscard]] bigint static T const digit_mask = ~((T)1 << bits_per_digit); public: - inline bigint() - { - } + inline bigint() = default; explicit bigint(int32_t x) { @@ -416,5 +408,5 @@ typedef bigint<16, uint32_t> int496_t; typedef bigint<32, uint32_t> int992_t; typedef bigint<64, uint32_t> int1984_t; -} /* namespace lol */ +} // namespace lol diff --git a/legacy/lol/base/features.h b/legacy/lol/base/features.h deleted file mode 100644 index f542ce9d..00000000 --- a/legacy/lol/base/features.h +++ /dev/null @@ -1,147 +0,0 @@ -// -// Lol Engine -// -// Copyright © 2010—2019 Sam Hocevar -// -// Lol Engine is free software. It comes without any warranty, to -// the extent permitted by applicable law. You can redistribute it -// and/or modify it under the terms of the Do What the Fuck You Want -// to Public License, Version 2, as published by the WTFPL Task Force. -// See http://www.wtfpl.net/ for more details. -// - -#pragma once - -// -// The build-time features -// ----------------------- -// - -/* - * Check for C++11 and later features. - */ - -/* These features aren't necessarily supported by all compilers */ -#undef LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS -#undef LOL_FEATURE_CXX11_ISNAN /* FIXME: is this the right place? */ -#undef LOL_FEATURE_CXX11_NULLPTR -#undef LOL_FEATURE_CXX11_TEMPLATE_ALIASES -#undef LOL_FEATURE_CXX11_SFINAE_FOR_CTORS - -/* Features supported by GCC */ -#if defined __GNUC__ -# if !defined(__GXX_EXPERIMENTAL_CXX0X) && __cplusplus < 201103L -# error "sorry, this version of GCC does not support constexpr" -# endif -# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 -# define LOL_FEATURE_CXX11_ISNAN 1 -# define LOL_FEATURE_CXX11_NULLPTR 1 -# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 470 -# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 -# endif -#endif - -/* Features supported by Clang */ -#if !defined __GNUC__ && defined __has_feature -# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 -# if !__has_feature(cxx_constexpr) -# error "sorry, this version of clang does not support constexpr" -# endif -# define LOL_FEATURE_CXX11_ISNAN 1 -# if __has_feature(cxx_nullptr) -# define LOL_FEATURE_CXX11_NULLPTR 1 -# endif -# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 -# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 -#endif - -/* Features supported by Visual Studio */ -#if defined _MSC_VER -# if _MSC_VER < 1910 -# error "sorry, Visual Studio 2017 or later is needed" -# endif -# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 -# define LOL_FEATURE_CXX11_ISNAN 1 -# define LOL_FEATURE_CXX11_NULLPTR 1 -# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 -# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 -#endif - - -/* - * Ensure we have ptrdiff_t. - */ - -#include - - -/* - * Ensure we have nullptr. - */ - -#if !LOL_FEATURE_CXX11_NULLPTR -# if defined nullptr - /* do nothing */ -# elif defined __GNUC__ -# define nullptr __null -# else -# include -# define nullptr NULL -# endif -#endif - - -/* - * Ensure isnan() is present even on systems that don't define it, or - * when -ffast-math is being used. - */ - -#include -#if defined __FAST_MATH__ -# undef isnan -#endif -#if !defined isnan && !LOL_FEATURE_CXX11_ISNAN -# define isnan isnan -# include -static inline int isnan(float f) -{ - union { float f; uint32_t x; } u = { f }; - return (u.x << 1) > 0xff000000u; -} -#endif - - -// -// Some feature test functions -// - -namespace lol -{ - // A handy endianness test function - static inline bool is_big_endian() - { - union { int i; char c; } u; - u.i = 1; - return u.c == 0; - } -} - - -// -// Ensure CreateFile2() is available on Mingw -// - -#if defined _WIN32 && !defined _MSC_VER && \ - (!defined _WIN32_WINNT || _WIN32_WINNT < 0x0602) -# undef _WIN32_WINNT -# define _WIN32_WINNT 0x0602 -#endif - - -/* XXX: workaround for X11 headers that try to #define these */ -#undef Always -#define Always Always -#undef None -#define None None -