From 3d6095e1ddb104986728fce2a6fb28fb28f9e005 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 15 May 2021 08:26:15 +0200 Subject: Created branch for CLANG 12 expeiments --- src/StormPort.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/StormPort.h b/src/StormPort.h index ba78d7f..4cd967f 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -95,7 +95,10 @@ #define PKEXPORT #define __SYS_ZLIB - #define __SYS_BZLIB + + #ifndef __SYS_BZLIB + #define __SYS_BZLIB + #endif #ifndef __BIG_ENDIAN__ #define STORMLIB_LITTLE_ENDIAN -- cgit v1.2.3 From 013b12f860ccb2e418bb10766c57fcc18b7b966a Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 15 May 2021 17:49:53 +0200 Subject: Fixed thread_local --- src/FileStream.cpp | 2 +- src/StormPort.h | 44 +++++++++++++------------------------------- 2 files changed, 14 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/FileStream.cpp b/src/FileStream.cpp index 2266518..a3c8e9b 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -34,7 +34,7 @@ // Local functions - platform-specific functions #ifndef STORMLIB_WINDOWS -static thread_local DWORD nLastError = ERROR_SUCCESS; +static THREAD_LOCAL DWORD nLastError = ERROR_SUCCESS; DWORD GetLastError() { diff --git a/src/StormPort.h b/src/StormPort.h index 4cd967f..ec9fc07 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -94,7 +94,10 @@ #endif #define PKEXPORT - #define __SYS_ZLIB + + #ifndef __SYS_ZLIB + #define __SYS_ZLIB + #endif #ifndef __SYS_BZLIB #define __SYS_BZLIB @@ -274,7 +277,7 @@ #define STORMLIB_LITTLE_ENDIAN #endif - #define STORMLIB_LINUX + #define THREAD_LOCAL thread_local // Platforms with mmap support #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) @@ -282,6 +285,7 @@ #define STORMLIB_HAS_MMAP #endif + #define STORMLIB_LINUX #define STORMLIB_PLATFORM_DEFINED #endif @@ -366,8 +370,8 @@ #define O_LARGEFILE 0 #endif -// Platform-specific error codes for UNIX-based platforms -#if defined(STORMLIB_MAC) || defined(STORMLIB_LINUX) +// Platform-specific error codes for non-Windows platforms +#ifndef ERROR_SUCCESS #define ERROR_SUCCESS 0 #define ERROR_FILE_NOT_FOUND ENOENT #define ERROR_ACCESS_DENIED EPERM @@ -386,10 +390,15 @@ #define ERROR_FILE_CORRUPT 1004 // No such error code under Linux #endif +// Macros that can sometimes be missing #ifndef _countof #define _countof(x) (sizeof(x) / sizeof(x[0])) #endif +#ifndef THREAD_LOCAL + #define THREAD_LOCAL +#endif + //----------------------------------------------------------------------------- // Swapping functions @@ -439,31 +448,4 @@ #define BSWAP_TMPKHEADER(a) ConvertTMPKHeader((a)) #endif -//----------------------------------------------------------------------------- -// Macro for deprecated symbols - -/* -#ifdef _MSC_VER - #if _MSC_FULL_VER >= 140050320 - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated(_Text)) - #else - #define STORMLIB_DEPRECATED(_Text) __declspec(deprecated) - #endif -#else - #ifdef __GNUC__ - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated)) - #else - #define STORMLIB_DEPRECATED(_Text) __attribute__((deprecated(_Text))) - #endif -#endif - -// When a flag is deprecated, use this macro -#ifndef _STORMLIB_NO_DEPRECATE - #define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) \ - const STORMLIB_DEPRECATED(#oldflag " is deprecated. Use " #newflag ". To supress this warning, define _STORMLIB_NO_DEPRECATE") static type oldflag = (type)newflag; -#else -#define STORMLIB_DEPRECATED_FLAG(type, oldflag, newflag) static type oldflag = (type)newflag; -#endif -*/ - #endif // __STORMPORT_H__ -- cgit v1.2.3 From 94e32487c14d75d63618a8b617dcfe4673f5c34c Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 15 May 2021 18:33:19 +0200 Subject: Added C++11 support in MAKEFILE --- CMakeLists.txt | 11 +++++++---- src/FileStream.cpp | 2 +- src/StormPort.h | 6 ------ 3 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/CMakeLists.txt b/CMakeLists.txt index bd8d336..a44170c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ project(StormLib) cmake_minimum_required(VERSION 2.8.12) set(LIBRARY_NAME storm) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) include(CMakeDependentOption) @@ -330,10 +333,10 @@ else() endif() if (NOT STORM_SKIP_INSTALL) - install(TARGETS ${LIBRARY_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + install(TARGETS ${LIBRARY_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib FRAMEWORK DESTINATION /Library/Frameworks PUBLIC_HEADER DESTINATION include INCLUDES DESTINATION include) diff --git a/src/FileStream.cpp b/src/FileStream.cpp index a3c8e9b..2266518 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -34,7 +34,7 @@ // Local functions - platform-specific functions #ifndef STORMLIB_WINDOWS -static THREAD_LOCAL DWORD nLastError = ERROR_SUCCESS; +static thread_local DWORD nLastError = ERROR_SUCCESS; DWORD GetLastError() { diff --git a/src/StormPort.h b/src/StormPort.h index ec9fc07..d386414 100644 --- a/src/StormPort.h +++ b/src/StormPort.h @@ -277,8 +277,6 @@ #define STORMLIB_LITTLE_ENDIAN #endif - #define THREAD_LOCAL thread_local - // Platforms with mmap support #if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include @@ -395,10 +393,6 @@ #define _countof(x) (sizeof(x) / sizeof(x[0])) #endif -#ifndef THREAD_LOCAL - #define THREAD_LOCAL -#endif - //----------------------------------------------------------------------------- // Swapping functions -- cgit v1.2.3 From 026e9b23ad7fd105b2b171cce0ea4ea965a30dd9 Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 15 May 2021 19:32:17 +0200 Subject: LTC_NO_PROTOTYPES splitted into multiple sub-macros --- src/libtomcrypt/src/headers/tomcrypt_cfg.h | 12 ++++++++++-- src/libtomcrypt/src/headers/tomcrypt_custom.h | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/libtomcrypt/src/headers/tomcrypt_cfg.h b/src/libtomcrypt/src/headers/tomcrypt_cfg.h index e266a49..15f4933 100644 --- a/src/libtomcrypt/src/headers/tomcrypt_cfg.h +++ b/src/libtomcrypt/src/headers/tomcrypt_cfg.h @@ -30,17 +30,25 @@ LTC_EXPORT void LTC_CALL XFREE(void *p); LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(LTC_CALL * compar)(const void *, const void *)); - /* change the clock function too */ LTC_EXPORT clock_t LTC_CALL XCLOCK(void); +#endif LTC_NO_PROTOTYPES /* various other functions */ +#ifndef LTC_NO_PROTOTYPES_MEMCPY LTC_EXPORT void * LTC_CALL XMEMCPY(void *dest, const void *src, size_t n); +#endif + +#ifndef LTC_NO_PROTOTYPES_MEMCMP LTC_EXPORT int LTC_CALL XMEMCMP(const void *s1, const void *s2, size_t n); +#endif + +#ifndef LTC_NO_PROTOTYPES_MEMSET LTC_EXPORT void * LTC_CALL XMEMSET(void *s, int c, size_t n); +#endif +#ifndef LTC_NO_PROTOTYPES_STRCMP LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2); - #endif /* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */ diff --git a/src/libtomcrypt/src/headers/tomcrypt_custom.h b/src/libtomcrypt/src/headers/tomcrypt_custom.h index 88ec8f9..312a4c2 100644 --- a/src/libtomcrypt/src/headers/tomcrypt_custom.h +++ b/src/libtomcrypt/src/headers/tomcrypt_custom.h @@ -47,25 +47,25 @@ #ifndef XMEMSET #ifdef memset - #define LTC_NO_PROTOTYPES + #define LTC_NO_PROTOTYPES_MEMSET #endif #define XMEMSET memset #endif #ifndef XMEMCPY #ifdef memcpy - #define LTC_NO_PROTOTYPES + #define LTC_NO_PROTOTYPES_MEMCPY #endif #define XMEMCPY memcpy #endif #ifndef XMEMCMP #ifdef memcmp - #define LTC_NO_PROTOTYPES + #define LTC_NO_PROTOTYPES_MEMCMP #endif #define XMEMCMP memcmp #endif #ifndef XSTRCMP #ifdef strcmp - #define LTC_NO_PROTOTYPES + #define LTC_NO_PROTOTYPES_STRCMP #endif #define XSTRCMP strcmp #endif -- cgit v1.2.3 From 05d3a57b8a1ac88e22657290396a9b334a2bee1a Mon Sep 17 00:00:00 2001 From: Ladislav Zezula Date: Sat, 15 May 2021 19:34:58 +0200 Subject: Fixed #endif --- src/libtomcrypt/src/headers/tomcrypt_cfg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libtomcrypt/src/headers/tomcrypt_cfg.h b/src/libtomcrypt/src/headers/tomcrypt_cfg.h index 15f4933..335d55f 100644 --- a/src/libtomcrypt/src/headers/tomcrypt_cfg.h +++ b/src/libtomcrypt/src/headers/tomcrypt_cfg.h @@ -32,7 +32,7 @@ LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(LTC_C /* change the clock function too */ LTC_EXPORT clock_t LTC_CALL XCLOCK(void); -#endif LTC_NO_PROTOTYPES +#endif // LTC_NO_PROTOTYPES /* various other functions */ #ifndef LTC_NO_PROTOTYPES_MEMCPY -- cgit v1.2.3