From 623a64f2c96b71f8609eccb81cb04886ae390c7b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 19 Jan 2017 16:08:43 +0300 Subject: Dump on startup linked and loaded lib versions. For now only zlib supported. Also detect zlib by pkgconfig in configure. --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 2 ++ src/client.cpp | 2 ++ src/localconsts.h | 2 -- src/net/download.cpp | 4 ++-- src/resources/mapreader.cpp | 6 +++--- src/utils/dumplibs.cpp | 35 +++++++++++++++++++++++++++++++++++ src/utils/dumplibs.h | 28 ++++++++++++++++++++++++++++ 8 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 src/utils/dumplibs.cpp create mode 100644 src/utils/dumplibs.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f67fb94b3..4432d86e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -853,6 +853,8 @@ SET(SRCS utils/cpu.h utils/delete2.h utils/dtor.h + utils/dumplibs.cpp + utils/dumplibs.h utils/env.cpp utils/env.h utils/files.cpp diff --git a/src/Makefile.am b/src/Makefile.am index a1726b768..d3c664606 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -499,6 +499,8 @@ SRC += events/actionevent.h \ utils/cpu.h \ utils/delete2.h \ utils/dtor.h \ + utils/dumplibs.cpp \ + utils/dumplibs.h \ utils/env.cpp \ utils/env.h \ utils/files.cpp \ diff --git a/src/client.cpp b/src/client.cpp index be9143062..344d5d7a4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -134,6 +134,7 @@ #include "utils/cpu.h" #include "utils/delete2.h" +#include "utils/dumplibs.h" #include "utils/env.h" #include "utils/fuzzer.h" #include "utils/gettext.h" @@ -351,6 +352,7 @@ void Client::gameInit() Dirs::initScreenshotDir(); updateEnv(); + dumpLibs(); // Initialize SDL logger->log1("Initializing SDL..."); diff --git a/src/localconsts.h b/src/localconsts.h index d5bd0ebc1..08623b2b5 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -87,8 +87,6 @@ #endif // GCC_VERSION < 40900 #endif // GCC_VERSION < 40700 -#undef Z_NULL -#define Z_NULL nullptr #define M_TCPOK #define A_DELETE(func) func = delete #define A_DELETE_COPY(name) name(const name &) = delete; \ diff --git a/src/net/download.cpp b/src/net/download.cpp index 7d7869001..ad66fa121 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -143,7 +143,7 @@ unsigned long Download::fadler32(FILE *const file) // Calculate Adler-32 checksum char *const buffer = new char[CAST_SIZE(fileSize)]; const uInt read = static_cast(fread(buffer, 1, fileSize, file)); - unsigned long adler = adler32(0L, Z_NULL, 0); + unsigned long adler = adler32(0L, nullptr, 0); adler = adler32(static_cast(adler), reinterpret_cast(buffer), read); delete [] buffer; @@ -153,7 +153,7 @@ unsigned long Download::fadler32(FILE *const file) unsigned long Download::adlerBuffer(const char *const buffer, int size) { FUNC_BLOCK("Download::adlerBuffer", 1) - unsigned long adler = adler32(0L, Z_NULL, 0); + unsigned long adler = adler32(0L, nullptr, 0); return adler32(static_cast(adler), reinterpret_cast(buffer), size); } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 9156f334d..cfce7c397 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -128,9 +128,9 @@ int inflateMemory(unsigned char *restrict const in, out = static_cast(calloc(bufferSize, 1)); z_stream strm; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = nullptr; + strm.zfree = nullptr; + strm.opaque = nullptr; strm.next_in = in; strm.avail_in = inLength; strm.next_out = out; diff --git a/src/utils/dumplibs.cpp b/src/utils/dumplibs.cpp new file mode 100644 index 000000000..6a6e378ba --- /dev/null +++ b/src/utils/dumplibs.cpp @@ -0,0 +1,35 @@ +/* + * The ManaPlus Client + * Copyright (C) 2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "utils/dumplibs.h" + +#include "logger.h" + +#include + +#include "debug.h" + +void dumpLibs() +{ + logger->log("Compiled with zLib: %s", ZLIB_VERSION); +#if ZLIB_VERNUM >= 0x1020 + logger->log("Linked with zLib: %s", zlibVersion()); +#endif // ZLIB_VERNUM >= 0x1020 +} diff --git a/src/utils/dumplibs.h b/src/utils/dumplibs.h new file mode 100644 index 000000000..1013026f1 --- /dev/null +++ b/src/utils/dumplibs.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2017 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UTILS_DUMPLIBS_H +#define UTILS_DUMPLIBS_H + +#include "localconsts.h" + +void dumpLibs(); + +#endif // UTILS_DUMPLIBS_H -- cgit v1.2.3-60-g2f50