From 0046cb2b8cf9fb535500d80c18551f672e9fb217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 15 Mar 2017 13:54:27 +0100 Subject: [PATCH] 2017-03-15 13:54 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/hbdefs.h * include/hbmather.h * src/common/hbprintf.c * contrib/gtwvg/wvgwing.c * contrib/hbfbird/firebird.c * contrib/hbxdiff/3rd/libxdiff/_hbconf.h * contrib/sddfb/core.c * use hexadecimal numbers checking __BORLAND__ macro * src/rtl/sha2.c * use standard harbour macros from hbdefs.h --- ChangeLog.txt | 13 +++ contrib/gtwvg/wvgwing.c | 2 +- contrib/hbfbird/firebird.c | 2 +- contrib/hbxdiff/3rd/libxdiff/_hbconf.h | 2 +- contrib/sddfb/core.c | 2 +- include/hbdefs.h | 18 ++-- include/hbmather.h | 4 +- src/common/hbprintf.c | 2 +- src/rtl/sha2.c | 109 +++++++++++-------------- 9 files changed, 78 insertions(+), 76 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 55d234b675..9ef4f4890d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,19 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2017-03-15 13:54 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/hbdefs.h + * include/hbmather.h + * src/common/hbprintf.c + * contrib/gtwvg/wvgwing.c + * contrib/hbfbird/firebird.c + * contrib/hbxdiff/3rd/libxdiff/_hbconf.h + * contrib/sddfb/core.c + * use hexadecimal numbers checking __BORLAND__ macro + + * src/rtl/sha2.c + * use standard harbour macros from hbdefs.h + 2017-03-15 09:50 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * package/harbour.spec * contrib/hbbz2/hbbz2.hbp diff --git a/contrib/gtwvg/wvgwing.c b/contrib/gtwvg/wvgwing.c index 18c14c37d8..1a430275eb 100644 --- a/contrib/gtwvg/wvgwing.c +++ b/contrib/gtwvg/wvgwing.c @@ -87,7 +87,7 @@ #include -#if defined( __BORLANDC__ ) && ( __BORLANDC__ >= 1552 ) +#if defined( __BORLANDC__ ) && ( __BORLANDC__ >= 0x610 ) # undef NONAMELESSUNION #endif diff --git a/contrib/hbfbird/firebird.c b/contrib/hbfbird/firebird.c index 2af025b500..36df6a7e9d 100644 --- a/contrib/hbfbird/firebird.c +++ b/contrib/hbfbird/firebird.c @@ -50,7 +50,7 @@ /* NOTE: Ugly hack to avoid this error when compiled with BCC 5.8.2 and above: Error E2238 C:\...\Firebird-2.1.1\include\ibase.h 82: Multiple declaration for 'intptr_t' */ -#if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 ) +#if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 0x582 ) /* Prevent inclusion of from hbdefs.h */ #define __STDINT_H #endif diff --git a/contrib/hbxdiff/3rd/libxdiff/_hbconf.h b/contrib/hbxdiff/3rd/libxdiff/_hbconf.h index 317f135f81..11d8bdd170 100644 --- a/contrib/hbxdiff/3rd/libxdiff/_hbconf.h +++ b/contrib/hbxdiff/3rd/libxdiff/_hbconf.h @@ -48,7 +48,7 @@ */ /* for BCC 5.5 */ -#if ( defined( __BORLANDC__ ) && ( __BORLANDC__ >= 1360 ) && ( __BORLANDC__ < 1400 ) ) || ( defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) && ! defined( __POCC__ ) ) +#if ( defined( __BORLANDC__ ) && ( __BORLANDC__ >= 0x550 ) && ( __BORLANDC__ < 0x578 ) ) || ( defined( _MSC_VER ) && ( _MSC_VER <= 1200 ) && ! defined( __POCC__ ) ) # define XRABPLY_TYPE64 __int64 # define XV64( v ) ( ( xply_word ) v##ui64 ) #endif diff --git a/contrib/sddfb/core.c b/contrib/sddfb/core.c index b289c07347..d05ec4bc0b 100644 --- a/contrib/sddfb/core.c +++ b/contrib/sddfb/core.c @@ -46,7 +46,7 @@ /* NOTE: Ugly hack to avoid this error when compiler with BCC 5.8.2 and above: Error E2238 C:\...\Firebird-2.1.1\include\ibase.h 82: Multiple declaration for 'intptr_t' */ -#if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 ) +#if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 0x582 ) /* Prevent inclusion of from hbdefs.h */ #define __STDINT_H #endif diff --git a/include/hbdefs.h b/include/hbdefs.h index cf64a5ab39..de905054d8 100644 --- a/include/hbdefs.h +++ b/include/hbdefs.h @@ -59,7 +59,7 @@ #if defined( __XCC__ ) || defined( __POCC__ ) || defined( __LCC__ ) || \ defined( __MINGW32__ ) || defined( __DMC__ ) || defined( __TINYC__ ) || \ ( defined( _MSC_VER ) && _MSC_VER >= 1600 ) || \ - ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 ) || \ + ( defined( __BORLANDC__ ) && __BORLANDC__ >= 0x0582 ) || \ ( defined( __WATCOMC__ ) && __WATCOMC__ >= 1270 ) || \ ( ( defined( __GNUC__ ) || defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) ) && \ ( defined( _ISOC99_SOURCE ) || defined( _STDC_C99 ) || \ @@ -79,7 +79,7 @@ # define _INTPTR_T # endif /* workaround for BCC 5.8 bug */ - #if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 1410 ) + #if ( defined( __BORLANDC__ ) && __BORLANDC__ >= 0x0582 ) #undef INT32_MIN #define INT32_MIN ((int32_t) (-INT32_MAX-1)) #undef INT64_MIN @@ -479,7 +479,7 @@ typedef HB_MAXUINT HB_VMMAXUINT; * without it they cut the number to HB_LONG */ #if defined( __BORLANDC__ ) -# if __BORLANDC__ >= 1328 +# if __BORLANDC__ >= 0x530 # define HB_LL( num ) num##i64 # define HB_ULL( num ) num##ui64 # else @@ -1391,29 +1391,29 @@ typedef HB_U32 HB_FATTR; ( ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 0 ] ) | \ ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 1 ] << 8 ) | \ ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 2 ] << 16 ) | \ - ( ( HB_I32 ) ((( const HB_BYTE * )( p ))[ 2 ] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) ) + ( ( HB_I32 ) (((( const HB_BYTE * )( p ))[ 2 ] & 0x80 ) ? 0xFF : 0x00 ) << 24 ) ) ) #define HB_GET_LE_UINT24( p ) ( ( HB_U32 ) \ ( ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 0 ] ) | \ ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 1 ] << 8 ) | \ ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 2 ] << 16 ) ) ) #define HB_PUT_LE_UINT24( p, u ) do { \ (( HB_BYTE * )( p ))[ 0 ] = ( HB_BYTE )( u ); \ - (( HB_BYTE * )( p ))[ 1 ] = ( HB_BYTE )( (u) >> 8 ); \ - (( HB_BYTE * )( p ))[ 2 ] = ( HB_BYTE )( (u) >> 16 ); \ + (( HB_BYTE * )( p ))[ 1 ] = ( HB_BYTE )( ( u ) >> 8 ); \ + (( HB_BYTE * )( p ))[ 2 ] = ( HB_BYTE )( ( u ) >> 16 ); \ } while( 0 ) #define HB_GET_BE_INT24( p ) ( ( HB_I32 ) \ ( ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 2 ] ) | \ ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 1 ] << 8 ) | \ ( ( HB_I32 ) (( const HB_BYTE * )( p ))[ 0 ] << 16 ) | \ - ( ( HB_I32 ) ((( const HB_BYTE * )( p ))[ 0 ] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) ) + ( ( HB_I32 ) (((( const HB_BYTE * )( p ))[ 0 ] & 0x80 ) ? 0xFF : 0x00 ) << 24 ) ) ) #define HB_GET_BE_UINT24( p ) ( ( HB_U32 ) \ ( ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 2 ] ) | \ ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 1 ] << 8 ) | \ ( ( HB_U32 ) (( const HB_BYTE * )( p ))[ 0 ] << 16 ) ) ) #define HB_PUT_BE_UINT24( p, u ) do { \ (( HB_BYTE * )( p ))[ 2 ] = ( HB_BYTE )( u ); \ - (( HB_BYTE * )( p ))[ 1 ] = ( HB_BYTE )( (u) >> 8 ); \ - (( HB_BYTE * )( p ))[ 0 ] = ( HB_BYTE )( (u) >> 16 ); \ + (( HB_BYTE * )( p ))[ 1 ] = ( HB_BYTE )( ( u ) >> 8 ); \ + (( HB_BYTE * )( p ))[ 0 ] = ( HB_BYTE )( ( u ) >> 16 ); \ } while( 0 ) diff --git a/include/hbmather.h b/include/hbmather.h index 7c75b1df7e..2af599f2b1 100644 --- a/include/hbmather.h +++ b/include/hbmather.h @@ -58,7 +58,7 @@ HB_EXTERN_BEGIN #define exception _exception #endif #elif defined( __BORLANDC__ ) - #if ( __BORLANDC__ == 1328 ) && defined( __cplusplus ) + #if ( __BORLANDC__ == 0x530 ) && defined( __cplusplus ) /* NOTE: There seem to be a bug in Borland C++ 5.3 C++ mode which prevents the redefinition of matherr, because nor "_exception" neither "exception" will work. [vszakats] */ @@ -66,7 +66,7 @@ HB_EXTERN_BEGIN #define HB_MATH_HANDLER #define matherr _matherr /* NOTE: This is needed for Borland C++ 5.5 in C++/STDC mode. [vszakats] */ - #if ( __BORLANDC__ >= 1360 ) + #if ( __BORLANDC__ >= 0x550 ) #define exception _exception #endif #endif diff --git a/src/common/hbprintf.c b/src/common/hbprintf.c index 37d235641f..da1cc5f903 100644 --- a/src/common/hbprintf.c +++ b/src/common/hbprintf.c @@ -109,7 +109,7 @@ /* few macros for some platform dependent floating point functions/macros */ -#if ( defined( __BORLANDC__ ) && __BORLANDC__ < 1410 ) || \ +#if ( defined( __BORLANDC__ ) && __BORLANDC__ < 0x582 ) || \ ( defined( __WATCOMC__ ) && __WATCOMC__ < 1270 ) || \ defined( HB_OS_QNX ) || defined( HB_OS_SYMBIAN ) || \ defined( __DCC__ ) || defined( __TINYC__ ) || \ diff --git a/src/rtl/sha2.c b/src/rtl/sha2.c index e057e316e0..ee2062b72c 100644 --- a/src/rtl/sha2.c +++ b/src/rtl/sha2.c @@ -38,6 +38,7 @@ #include #include "sha2.h" +#include "hbdefs.h" #define SHFR(x, n) (x >> n) #define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n))) @@ -127,18 +128,6 @@ wv[h] = t1 + t2; \ } -#if defined( __BORLANDC__ ) -# if __BORLANDC__ >= 1328 -# define _ULL( num ) num##ui64 -# else -# define _ULL( num ) num -# endif -#elif defined( _MSC_VER ) -# define _ULL( num ) num -#else -# define _ULL( num ) num##ULL -#endif - static const uint32 sha224_h0[8] = {0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4}; @@ -148,16 +137,16 @@ static const uint32 sha256_h0[8] = 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; static const uint64 sha384_h0[8] = - {_ULL( 0xcbbb9d5dc1059ed8 ), _ULL( 0x629a292a367cd507 ), - _ULL( 0x9159015a3070dd17 ), _ULL( 0x152fecd8f70e5939 ), - _ULL( 0x67332667ffc00b31 ), _ULL( 0x8eb44a8768581511 ), - _ULL( 0xdb0c2e0d64f98fa7 ), _ULL( 0x47b5481dbefa4fa4 )}; + {HB_ULL( 0xcbbb9d5dc1059ed8 ), HB_ULL( 0x629a292a367cd507 ), + HB_ULL( 0x9159015a3070dd17 ), HB_ULL( 0x152fecd8f70e5939 ), + HB_ULL( 0x67332667ffc00b31 ), HB_ULL( 0x8eb44a8768581511 ), + HB_ULL( 0xdb0c2e0d64f98fa7 ), HB_ULL( 0x47b5481dbefa4fa4 )}; static const uint64 sha512_h0[8] = - {_ULL( 0x6a09e667f3bcc908 ), _ULL( 0xbb67ae8584caa73b ), - _ULL( 0x3c6ef372fe94f82b ), _ULL( 0xa54ff53a5f1d36f1 ), - _ULL( 0x510e527fade682d1 ), _ULL( 0x9b05688c2b3e6c1f ), - _ULL( 0x1f83d9abfb41bd6b ), _ULL( 0x5be0cd19137e2179 )}; + {HB_ULL( 0x6a09e667f3bcc908 ), HB_ULL( 0xbb67ae8584caa73b ), + HB_ULL( 0x3c6ef372fe94f82b ), HB_ULL( 0xa54ff53a5f1d36f1 ), + HB_ULL( 0x510e527fade682d1 ), HB_ULL( 0x9b05688c2b3e6c1f ), + HB_ULL( 0x1f83d9abfb41bd6b ), HB_ULL( 0x5be0cd19137e2179 )}; static const uint32 sha256_k[64] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, @@ -178,46 +167,46 @@ static const uint32 sha256_k[64] = 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2}; static const uint64 sha512_k[80] = - {_ULL( 0x428a2f98d728ae22 ), _ULL( 0x7137449123ef65cd ), - _ULL( 0xb5c0fbcfec4d3b2f ), _ULL( 0xe9b5dba58189dbbc ), - _ULL( 0x3956c25bf348b538 ), _ULL( 0x59f111f1b605d019 ), - _ULL( 0x923f82a4af194f9b ), _ULL( 0xab1c5ed5da6d8118 ), - _ULL( 0xd807aa98a3030242 ), _ULL( 0x12835b0145706fbe ), - _ULL( 0x243185be4ee4b28c ), _ULL( 0x550c7dc3d5ffb4e2 ), - _ULL( 0x72be5d74f27b896f ), _ULL( 0x80deb1fe3b1696b1 ), - _ULL( 0x9bdc06a725c71235 ), _ULL( 0xc19bf174cf692694 ), - _ULL( 0xe49b69c19ef14ad2 ), _ULL( 0xefbe4786384f25e3 ), - _ULL( 0x0fc19dc68b8cd5b5 ), _ULL( 0x240ca1cc77ac9c65 ), - _ULL( 0x2de92c6f592b0275 ), _ULL( 0x4a7484aa6ea6e483 ), - _ULL( 0x5cb0a9dcbd41fbd4 ), _ULL( 0x76f988da831153b5 ), - _ULL( 0x983e5152ee66dfab ), _ULL( 0xa831c66d2db43210 ), - _ULL( 0xb00327c898fb213f ), _ULL( 0xbf597fc7beef0ee4 ), - _ULL( 0xc6e00bf33da88fc2 ), _ULL( 0xd5a79147930aa725 ), - _ULL( 0x06ca6351e003826f ), _ULL( 0x142929670a0e6e70 ), - _ULL( 0x27b70a8546d22ffc ), _ULL( 0x2e1b21385c26c926 ), - _ULL( 0x4d2c6dfc5ac42aed ), _ULL( 0x53380d139d95b3df ), - _ULL( 0x650a73548baf63de ), _ULL( 0x766a0abb3c77b2a8 ), - _ULL( 0x81c2c92e47edaee6 ), _ULL( 0x92722c851482353b ), - _ULL( 0xa2bfe8a14cf10364 ), _ULL( 0xa81a664bbc423001 ), - _ULL( 0xc24b8b70d0f89791 ), _ULL( 0xc76c51a30654be30 ), - _ULL( 0xd192e819d6ef5218 ), _ULL( 0xd69906245565a910 ), - _ULL( 0xf40e35855771202a ), _ULL( 0x106aa07032bbd1b8 ), - _ULL( 0x19a4c116b8d2d0c8 ), _ULL( 0x1e376c085141ab53 ), - _ULL( 0x2748774cdf8eeb99 ), _ULL( 0x34b0bcb5e19b48a8 ), - _ULL( 0x391c0cb3c5c95a63 ), _ULL( 0x4ed8aa4ae3418acb ), - _ULL( 0x5b9cca4f7763e373 ), _ULL( 0x682e6ff3d6b2b8a3 ), - _ULL( 0x748f82ee5defb2fc ), _ULL( 0x78a5636f43172f60 ), - _ULL( 0x84c87814a1f0ab72 ), _ULL( 0x8cc702081a6439ec ), - _ULL( 0x90befffa23631e28 ), _ULL( 0xa4506cebde82bde9 ), - _ULL( 0xbef9a3f7b2c67915 ), _ULL( 0xc67178f2e372532b ), - _ULL( 0xca273eceea26619c ), _ULL( 0xd186b8c721c0c207 ), - _ULL( 0xeada7dd6cde0eb1e ), _ULL( 0xf57d4f7fee6ed178 ), - _ULL( 0x06f067aa72176fba ), _ULL( 0x0a637dc5a2c898a6 ), - _ULL( 0x113f9804bef90dae ), _ULL( 0x1b710b35131c471b ), - _ULL( 0x28db77f523047d84 ), _ULL( 0x32caab7b40c72493 ), - _ULL( 0x3c9ebe0a15c9bebc ), _ULL( 0x431d67c49c100d4c ), - _ULL( 0x4cc5d4becb3e42b6 ), _ULL( 0x597f299cfc657e2a ), - _ULL( 0x5fcb6fab3ad6faec ), _ULL( 0x6c44198c4a475817 )}; + {HB_ULL( 0x428a2f98d728ae22 ), HB_ULL( 0x7137449123ef65cd ), + HB_ULL( 0xb5c0fbcfec4d3b2f ), HB_ULL( 0xe9b5dba58189dbbc ), + HB_ULL( 0x3956c25bf348b538 ), HB_ULL( 0x59f111f1b605d019 ), + HB_ULL( 0x923f82a4af194f9b ), HB_ULL( 0xab1c5ed5da6d8118 ), + HB_ULL( 0xd807aa98a3030242 ), HB_ULL( 0x12835b0145706fbe ), + HB_ULL( 0x243185be4ee4b28c ), HB_ULL( 0x550c7dc3d5ffb4e2 ), + HB_ULL( 0x72be5d74f27b896f ), HB_ULL( 0x80deb1fe3b1696b1 ), + HB_ULL( 0x9bdc06a725c71235 ), HB_ULL( 0xc19bf174cf692694 ), + HB_ULL( 0xe49b69c19ef14ad2 ), HB_ULL( 0xefbe4786384f25e3 ), + HB_ULL( 0x0fc19dc68b8cd5b5 ), HB_ULL( 0x240ca1cc77ac9c65 ), + HB_ULL( 0x2de92c6f592b0275 ), HB_ULL( 0x4a7484aa6ea6e483 ), + HB_ULL( 0x5cb0a9dcbd41fbd4 ), HB_ULL( 0x76f988da831153b5 ), + HB_ULL( 0x983e5152ee66dfab ), HB_ULL( 0xa831c66d2db43210 ), + HB_ULL( 0xb00327c898fb213f ), HB_ULL( 0xbf597fc7beef0ee4 ), + HB_ULL( 0xc6e00bf33da88fc2 ), HB_ULL( 0xd5a79147930aa725 ), + HB_ULL( 0x06ca6351e003826f ), HB_ULL( 0x142929670a0e6e70 ), + HB_ULL( 0x27b70a8546d22ffc ), HB_ULL( 0x2e1b21385c26c926 ), + HB_ULL( 0x4d2c6dfc5ac42aed ), HB_ULL( 0x53380d139d95b3df ), + HB_ULL( 0x650a73548baf63de ), HB_ULL( 0x766a0abb3c77b2a8 ), + HB_ULL( 0x81c2c92e47edaee6 ), HB_ULL( 0x92722c851482353b ), + HB_ULL( 0xa2bfe8a14cf10364 ), HB_ULL( 0xa81a664bbc423001 ), + HB_ULL( 0xc24b8b70d0f89791 ), HB_ULL( 0xc76c51a30654be30 ), + HB_ULL( 0xd192e819d6ef5218 ), HB_ULL( 0xd69906245565a910 ), + HB_ULL( 0xf40e35855771202a ), HB_ULL( 0x106aa07032bbd1b8 ), + HB_ULL( 0x19a4c116b8d2d0c8 ), HB_ULL( 0x1e376c085141ab53 ), + HB_ULL( 0x2748774cdf8eeb99 ), HB_ULL( 0x34b0bcb5e19b48a8 ), + HB_ULL( 0x391c0cb3c5c95a63 ), HB_ULL( 0x4ed8aa4ae3418acb ), + HB_ULL( 0x5b9cca4f7763e373 ), HB_ULL( 0x682e6ff3d6b2b8a3 ), + HB_ULL( 0x748f82ee5defb2fc ), HB_ULL( 0x78a5636f43172f60 ), + HB_ULL( 0x84c87814a1f0ab72 ), HB_ULL( 0x8cc702081a6439ec ), + HB_ULL( 0x90befffa23631e28 ), HB_ULL( 0xa4506cebde82bde9 ), + HB_ULL( 0xbef9a3f7b2c67915 ), HB_ULL( 0xc67178f2e372532b ), + HB_ULL( 0xca273eceea26619c ), HB_ULL( 0xd186b8c721c0c207 ), + HB_ULL( 0xeada7dd6cde0eb1e ), HB_ULL( 0xf57d4f7fee6ed178 ), + HB_ULL( 0x06f067aa72176fba ), HB_ULL( 0x0a637dc5a2c898a6 ), + HB_ULL( 0x113f9804bef90dae ), HB_ULL( 0x1b710b35131c471b ), + HB_ULL( 0x28db77f523047d84 ), HB_ULL( 0x32caab7b40c72493 ), + HB_ULL( 0x3c9ebe0a15c9bebc ), HB_ULL( 0x431d67c49c100d4c ), + HB_ULL( 0x4cc5d4becb3e42b6 ), HB_ULL( 0x597f299cfc657e2a ), + HB_ULL( 0x5fcb6fab3ad6faec ), HB_ULL( 0x6c44198c4a475817 )}; /* SHA-256 functions */