mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Remove awful Mingw32 workarounds
Instead a warning is triggered if an affected compiler is detected. closes #12022
This commit is contained in:
parent
ce199d6f9e
commit
ba6fbc417e
@ -65,6 +65,14 @@ extern "C" {
|
||||
#error Minetest cannot be built without exceptions or RTTI
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64__) && !defined(__clang__) && \
|
||||
(__GNUC__ < 11 || (__GNUC__ == 11 && __GNUC_MINOR__ < 1))
|
||||
// see e.g. https://github.com/minetest/minetest/issues/10137
|
||||
#warning ==================================
|
||||
#warning 32-bit MinGW gcc before 11.1 has known issues with crashes on thread exit, you should upgrade.
|
||||
#warning ==================================
|
||||
#endif
|
||||
|
||||
#define DEBUGFILE "debug.txt"
|
||||
#define DEFAULT_SERVER_PORT 30000
|
||||
|
||||
|
@ -452,17 +452,9 @@ size_t read_stringlist(lua_State *L, int index, std::vector<std::string> *result
|
||||
Table field getters
|
||||
*/
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
/* MinGW 32-bit somehow crashes in the std::set destructor when this
|
||||
* variable is thread-local, so just don't do that. */
|
||||
static std::set<u64> warned_msgs;
|
||||
#endif
|
||||
|
||||
bool check_field_or_nil(lua_State *L, int index, int type, const char *fieldname)
|
||||
{
|
||||
#if !defined(__MINGW32__) || defined(__MINGW64__)
|
||||
thread_local std::set<u64> warned_msgs;
|
||||
#endif
|
||||
|
||||
int t = lua_type(L, index);
|
||||
if (t == LUA_TNIL)
|
||||
|
@ -208,30 +208,11 @@ struct ZSTD_Deleter {
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
/*
|
||||
* This is exactly as dumb as it looks.
|
||||
* Yes, this is a memory leak. No, we don't have better solution right now.
|
||||
*/
|
||||
template<typename T> class leaky_ptr
|
||||
{
|
||||
T *value;
|
||||
public:
|
||||
leaky_ptr(T *value) : value(value) {};
|
||||
T *get() { return value; }
|
||||
};
|
||||
#endif
|
||||
|
||||
void compressZstd(const u8 *data, size_t data_size, std::ostream &os, int level)
|
||||
{
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
// leaks one context per thread but doesn't crash :shrug:
|
||||
thread_local leaky_ptr<ZSTD_CStream> stream(ZSTD_createCStream());
|
||||
#else
|
||||
// reusing the context is recommended for performance
|
||||
// it will destroyed when the thread ends
|
||||
// it will be destroyed when the thread ends
|
||||
thread_local std::unique_ptr<ZSTD_CStream, ZSTD_Deleter> stream(ZSTD_createCStream());
|
||||
#endif
|
||||
|
||||
|
||||
ZSTD_initCStream(stream.get(), level);
|
||||
@ -276,14 +257,9 @@ void compressZstd(const std::string &data, std::ostream &os, int level)
|
||||
|
||||
void decompressZstd(std::istream &is, std::ostream &os)
|
||||
{
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
// leaks one context per thread but doesn't crash :shrug:
|
||||
thread_local leaky_ptr<ZSTD_DStream> stream(ZSTD_createDStream());
|
||||
#else
|
||||
// reusing the context is recommended for performance
|
||||
// it will destroyed when the thread ends
|
||||
// it will be destroyed when the thread ends
|
||||
thread_local std::unique_ptr<ZSTD_DStream, ZSTD_Deleter> stream(ZSTD_createDStream());
|
||||
#endif
|
||||
|
||||
ZSTD_initDStream(stream.get());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user