From 438a7f86b839cb8bc143daa21b8ce3cf977e1dc1 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Wed, 17 Feb 2010 19:11:16 +0000 Subject: [PATCH] 2010-02-17 20:11 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbdefs.h * use '__int64' instead of 'long long' only in non GCC MS-Windows builds * harbour/tests/bldtest/bldtest.c * use '__int64' instead of 'long long' only in non GCC MS-Windows builds * formatting --- harbour/ChangeLog | 8 +++ harbour/include/hbdefs.h | 20 +++---- harbour/tests/bldtest/bldtest.c | 101 +++++++++++++++----------------- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 290ed78f51..ebaf68f93a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-17 20:11 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbdefs.h + * use '__int64' instead of 'long long' only in non GCC MS-Windows builds + + * harbour/tests/bldtest/bldtest.c + * use '__int64' instead of 'long long' only in non GCC MS-Windows builds + * formatting + 2010-02-17 18:02 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * include/hbdyn.ch * src/rtl/hbdyn.c diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index f048327878..7d45c86e4e 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -259,28 +259,28 @@ typedef HB_UCHAR HB_BYTE; #ifndef HB_LONG_LONG_OFF - #if defined( __GNUC__ ) || defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) - typedef signed long long HB_LONGLONG; - typedef unsigned long long HB_ULONGLONG; - #else + #if defined( HB_OS_WIN ) && !defined( __GNUC__ ) typedef __int64 HB_LONGLONG; typedef unsigned __int64 HB_ULONGLONG; + #else + typedef signed long long HB_LONGLONG; + typedef unsigned long long HB_ULONGLONG; #endif #if ! defined( HB_LEGACY_TYPES_OFF ) #if ! defined( HB_DONT_DEFINE_BASIC_TYPES ) && ! defined( _WINNT_H ) #if !defined( LONGLONG ) - #if defined( __GNUC__ ) || defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) - typedef signed long long LONGLONG; - #else + #if defined( HB_OS_WIN ) && !defined( __GNUC__ ) typedef __int64 LONGLONG; + #else + typedef signed long long LONGLONG; #endif #endif #if !defined( ULONGLONG ) - #if defined( __GNUC__ ) || defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) - typedef unsigned long long ULONGLONG; - #else + #if defined( HB_OS_WIN ) && !defined( __GNUC__ ) typedef unsigned __int64 ULONGLONG; + #else + typedef unsigned long long ULONGLONG; #endif #endif #endif diff --git a/harbour/tests/bldtest/bldtest.c b/harbour/tests/bldtest/bldtest.c index 3bc0c1eaca..4003c7f543 100644 --- a/harbour/tests/bldtest/bldtest.c +++ b/harbour/tests/bldtest/bldtest.c @@ -6,44 +6,44 @@ int main() { - char buf[16]; + char buf[ 16 ]; int n, i, l, f, iRet = 0; - printf("\nStandard C types:\n"); - printf("\t sizeof(void*)=%d\n", (int) sizeof(void*)); - printf("\t sizeof(char)=%d\n", (int) sizeof(char) ); - printf("\t sizeof(short int)=%d\n", (int) sizeof(short int) ); - printf("\t sizeof(int)=%d\n", (int) sizeof(int) ); - printf("\t sizeof(long int)=%d\n", (int) sizeof(long int) ); -#if defined( __BORLANDC__ ) - printf("\tsizeof(long long int)=%d\n", (int) sizeof(__int64) ); + printf( "\nStandard C types:\n" ); + printf( "\t sizeof(void*)=%d\n", ( int ) sizeof( void* ) ); + printf( "\t sizeof(char)=%d\n", ( int ) sizeof( char ) ); + printf( "\t sizeof(short int)=%d\n", ( int ) sizeof( short int ) ); + printf( "\t sizeof(int)=%d\n", ( int ) sizeof( int ) ); + printf( "\t sizeof(long int)=%d\n", ( int ) sizeof( long int ) ); +#if defined( HB_OS_WIN ) && !defined( __GNUC__ ) + printf( "\t sizeof(__int64)=%d\n", ( int ) sizeof( __int64 ) ); #else - printf("\tsizeof(long long int)=%d\n", (int) sizeof(long long int) ); + printf( "\tsizeof(long long int)=%d\n", ( int ) sizeof( long long int ) ); #endif - printf("\t sizeof(float)=%d\n", (int) sizeof(float)); - printf("\t sizeof(double)=%d\n", (int) sizeof(double)); - printf("\t sizeof(long double)=%d\n", (int) sizeof(long double)); + printf( "\t sizeof(float)=%d\n", ( int ) sizeof( float ) ); + printf( "\t sizeof(double)=%d\n", ( int ) sizeof( double ) ); + printf( "\t sizeof(long double)=%d\n", ( int ) sizeof( long double ) ); - printf("\nHarbour types:\n"); - printf("\t sizeof(HB_BYTE)=%d %s\n", (int) sizeof(HB_BYTE ), sizeof(HB_BYTE )==1 ? "OK" : "BAD" ); - printf("\t sizeof(HB_SHORT)=%d %s\n", (int) sizeof(HB_SHORT ), sizeof(HB_SHORT )==2 ? "OK" : "BAD" ); - printf("\t sizeof(HB_UINT)=%d %s\n", (int) sizeof(HB_UINT ), sizeof(HB_UINT )==4 || sizeof(HB_UINT)==8 ? "OK" : "BAD" ); - printf("\t sizeof(HB_LONG)=%d %s\n", (int) sizeof(HB_LONG ), sizeof(HB_LONG )==4 || sizeof(HB_LONG)==8 ? "OK" : "BAD" ); - printf("\tsizeof(HB_LONGLONG)=%d %s\n", (int) sizeof(HB_LONGLONG), sizeof(HB_LONGLONG)==8 ? "OK" : "BAD" ); - printf("\t sizeof(double)=%d %s\n", (int) sizeof(double ), sizeof(double )==8 ? "OK" : "BAD" ); + printf( "\nHarbour types:\n" ); + printf( "\t sizeof(HB_BYTE)=%d %s\n", ( int ) sizeof( HB_BYTE ), sizeof( HB_BYTE ) == 1 ? "OK" : "BAD" ); + printf( "\t sizeof(HB_SHORT)=%d %s\n", ( int ) sizeof( HB_SHORT ), sizeof( HB_SHORT ) == 2 ? "OK" : "BAD" ); + printf( "\t sizeof(HB_UINT)=%d %s\n", ( int ) sizeof( HB_UINT ), sizeof( HB_UINT ) == 4 || sizeof( HB_UINT ) == 8 ? "OK" : "BAD" ); + printf( "\t sizeof(HB_LONG)=%d %s\n", ( int ) sizeof( HB_LONG ), sizeof( HB_LONG ) == 4 || sizeof( HB_LONG ) == 8 ? "OK" : "BAD" ); + printf( "\tsizeof(HB_LONGLONG)=%d %s\n", ( int ) sizeof( HB_LONGLONG ), sizeof( HB_LONGLONG ) == 8 ? "OK" : "BAD" ); + printf( "\t sizeof(double)=%d %s\n", ( int ) sizeof( double ), sizeof( double ) == 8 ? "OK" : "BAD" ); - if ( sizeof(HB_BYTE)!=1 || - sizeof(HB_SHORT)!=2 || - (sizeof(HB_LONG)!=4 && sizeof(HB_LONG)!=8) || - (sizeof(HB_LONGLONG)!=4 && sizeof(HB_LONGLONG)!=8) || - sizeof(double)!=8 ) + if( sizeof( HB_BYTE )!=1 || + sizeof( HB_SHORT )!=2 || + ( sizeof( HB_LONG )!=4 && sizeof( HB_LONG )!=8 ) || + sizeof( HB_LONGLONG )!=8 || + sizeof( double )!=8 ) { iRet = 1; } n = 0x31323334; memcpy( buf, &n, sizeof( n ) ); - buf[sizeof( n )] = '\0'; + buf[ sizeof( n ) ] = '\0'; i = atoi( buf ); #if defined(HB_PDP_ENDIAN) l = 2143; @@ -62,51 +62,44 @@ int main() iRet = 1; } - buf[0] = 0x12; - buf[1] = 0x34; - buf[2] = 0x56; - buf[3] = 0x78; - buf[4] = 0x65; + buf[ 0 ] = 0x12; + buf[ 1 ] = 0x34; + buf[ 2 ] = 0x56; + buf[ 3 ] = 0x78; + buf[ 4 ] = 0x65; i = ( HB_GET_BE_UINT32( buf ) == 0x12345678L && HB_GET_LE_UINT32( buf ) == 0x78563412L ); - if ( ! i ) - { + if( ! i ) iRet = 1; - } + printf( "byte order translation: %s\n", i ? "OK" : "BAD" ); for ( l = 0; l < 4; l++ ) { - n = HB_GET_BE_UINT16( &buf[l] ); - f = n == (buf[l] * 256 + buf[l+1]) ? 1 : 0; - if ( ! f ) - { + n = HB_GET_BE_UINT16( &buf[ l ] ); + f = n == ( buf[ l ] * 256 + buf[ l + 1 ] ) ? 1 : 0; + if( ! f ) iRet = 1; - } - printf( "HB_GET_BE_UINT16(%x,%x) = %x -> %s\n", buf[l], buf[l+1], n, + printf( "HB_GET_BE_UINT16(%x,%x) = %x -> %s\n", buf[ l ], buf[ l + 1 ], n, f ? "OK" : "BAD" ); - n = HB_GET_LE_UINT16( &buf[l] ); - f = n == (buf[l] + 256 * buf[l+1]) ? 1 : 0; - if ( ! f ) - { + n = HB_GET_LE_UINT16( &buf[ l] ); + f = n == ( buf[ l ] + 256 * buf[ l + 1 ] ) ? 1 : 0; + if( ! f ) iRet = 1; - } - printf( "HB_GET_LE_UINT16(%x,%x) = %x -> %s\n", buf[l], buf[l+1], n, + printf( "HB_GET_LE_UINT16(%x,%x) = %x -> %s\n", buf[ l ], buf[ l + 1 ], n, + f ? "OK" : "BAD" ); } - n = (char)255; + n = ( char ) 255; + printf( "n=%d -> (char) type is %ssigned\n", n, n < 0 ? "" : "un" ); - if ( iRet ) - { - printf("\nHarbour cannot be compiled !!!\n"); - } + if( iRet ) + printf( "\nHarbour cannot be compiled !!!\n" ); else - { - printf("\nBasic test is correct, try to compile Harbour.\n"); - } + printf( "\nBasic test is correct, try to compile Harbour.\n" ); return iRet; }