Переглянути джерело

Clean up bigint.h header.

wip/core-clipp
Sam Hocevar 4 роки тому
джерело
коміт
c042850637
3 змінених файлів з 5 додано та 162 видалено
  1. +0
    -2
      TODO.md
  2. +5
    -13
      include/lol/math/bigint.h
  3. +0
    -147
      legacy/lol/base/features.h

+ 0
- 2
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


legacy/lol/math/bigint.h → include/lol/math/bigint.h Переглянути файл

@@ -14,21 +14,15 @@

//
// The bigint class
// ----------------
// ————————————————
//

#include <lol/base/types.h>

#include <array>
#include <stdint.h>
#include <array> // std::array
#include <stdint.h> // 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


+ 0
- 147
legacy/lol/base/features.h Переглянути файл

@@ -1,147 +0,0 @@
//
// Lol Engine
//
// Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net>
//
// 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 <cstddef>


/*
* Ensure we have nullptr.
*/

#if !LOL_FEATURE_CXX11_NULLPTR
# if defined nullptr
/* do nothing */
# elif defined __GNUC__
# define nullptr __null
# else
# include <cstddef>
# 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 <cmath>
#if defined __FAST_MATH__
# undef isnan
#endif
#if !defined isnan && !LOL_FEATURE_CXX11_ISNAN
# define isnan isnan
# include <stdint.h>
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


Завантаження…
Відмінити
Зберегти