From 84d6d15bd61571d3a355a2a4f767834a78ff321b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 11 Apr 2009 11:34:06 +0000 Subject: [PATCH] 2009-04-11 13:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbapi.h * include/hbver.ch * source/common/hbver.c * source/rtl/version.c + Added target CPU detection. c: hb_verCPU() -> "x86" prg: hb_version( HB_VERSION_CPU ) -> "x86" ; TODO: Host CPU detection. * contrib/rddsql/sddfb/Makefile + Enabled for msvc64 --- harbour/ChangeLog | 13 +++ harbour/contrib/rddsql/sddfb/Makefile | 4 - harbour/include/hbapi.h | 1 + harbour/include/hbver.ch | 3 +- harbour/source/common/hbver.c | 125 ++++++++++++++++++++++++++ harbour/source/rtl/version.c | 4 + 6 files changed, 145 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f212291f0d..db08b790fe 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,19 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-11 13:25 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbapi.h + * include/hbver.ch + * source/common/hbver.c + * source/rtl/version.c + + Added target CPU detection. + c: hb_verCPU() -> "x86" + prg: hb_version( HB_VERSION_CPU ) -> "x86" + ; TODO: Host CPU detection. + + * contrib/rddsql/sddfb/Makefile + + Enabled for msvc64 + 2009-04-11 13:04 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbstack.h * harbour/source/vm/macro.c diff --git a/harbour/contrib/rddsql/sddfb/Makefile b/harbour/contrib/rddsql/sddfb/Makefile index 6ef60b97db..3f745d25b9 100644 --- a/harbour/contrib/rddsql/sddfb/Makefile +++ b/harbour/contrib/rddsql/sddfb/Makefile @@ -7,7 +7,6 @@ ROOT = ../../../ LIBNAME=sddfb ifneq ($(HB_COMPILER),pocc64) -ifneq ($(HB_COMPILER),msvc64) ifeq ($(HB_INC_FIREBIRD),) ifeq ($(HB_XBUILD),) @@ -31,6 +30,3 @@ endif else include $(TOP)$(ROOT)config/none.cf endif -else -include $(TOP)$(ROOT)config/none.cf -endif diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index 241d18956d..fd28a3efb2 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -1063,6 +1063,7 @@ extern void * hb_i18n_alloc( void * cargo ); extern HB_EXPORT void hb_vmSetLinkedMain( const char * szMain ); /* misc */ +extern HB_EXPORT const char * hb_verCPU( void ); /* retrieves a constant string with CPU architecture */ extern HB_EXPORT char * hb_verPlatform( void ); /* retrieves a newly allocated buffer containing platform version */ extern HB_EXPORT char * hb_verCompiler( void ); /* retrieves a newly allocated buffer containing compiler version */ extern HB_EXPORT char * hb_verHarbour( void ); /* retrieves a newly allocated buffer containing harbour version */ diff --git a/harbour/include/hbver.ch b/harbour/include/hbver.ch index 33cc684c4b..52f4663cd5 100644 --- a/harbour/include/hbver.ch +++ b/harbour/include/hbver.ch @@ -71,7 +71,7 @@ #define HB_VERSION_BUILD_DATE 12 #define HB_VERSION_BUILD_TIME 13 #define HB_VERSION_BUILD_ARCH 22 -#define HB_VERSION_BUILD_COMP 23 /* Last. Please continue from here. */ +#define HB_VERSION_BUILD_COMP 23 #define HB_VERSION_FLAG_PRG 14 #define HB_VERSION_FLAG_C 15 #define HB_VERSION_FLAG_LINKER 16 @@ -80,6 +80,7 @@ #define HB_VERSION_MT 19 #define HB_VERSION_UNIX_COMPAT 20 #define HB_VERSION_PLATFORM 21 +#define HB_VERSION_CPU 24 /* Last. Please continue from here. */ /* hb_version( HB_VERSION_ENDIANNESS ) return values. */ #define HB_VERSION_ENDIAN_LITTLE 1 diff --git a/harbour/source/common/hbver.c b/harbour/source/common/hbver.c index c8c3a6a1a3..2da917280f 100644 --- a/harbour/source/common/hbver.c +++ b/harbour/source/common/hbver.c @@ -62,6 +62,7 @@ * hb_verCompiler() (support for determining some compiler version/revision) * * Copyright 2000-2009 Viktor Szakats + * hb_verCPU() * hb_verPlatform() (support for detecting Windows NT on DOS) * hb_verPlatform() (rearrangment and cleanup) * hb_verPlatform() (Wine detection and some more) @@ -93,6 +94,130 @@ #endif +/* Partially based on: + http://predef.sourceforge.net/prearch.html + http://poshlib.hookatooka.com/poshlib/trac.cgi/browser/posh.h + */ + +#if defined(__alpha__) || \ + defined(__alpha) || \ + defined(alpha) || \ + defined(_M_ALPHA) + #define HB_CPU_STR "Alpha" + +#elif defined(__amd64__) || \ + defined(__amd64) || \ + defined(__x86_64__) || \ + defined(__x86_64) || \ + defined(_M_AMD64) || \ + defined(_M_X64) || \ + defined(__MINGW64__) + #define HB_CPU_STR "x86-64" + +#elif defined(__arm__) || \ + defined(ARM) || \ + defined(_ARM) || \ + defined(_M_ARM) + #define HB_CPU_STR "ARM" + +#elif defined(__hppa__) || \ + defined(__hppa) || \ + defined(hppa) + #define HB_CPU_STR "PA-RISC" + +#elif defined(i386) || \ + defined(__i386__) || \ + defined(__i386) || \ + defined(_M_IX86) || \ + defined(__X86__) || \ + defined(_X86_) || \ + defined(__I86__) || \ + defined(__THW_INTEL__) || \ + defined(__INTEL__) + #define HB_CPU_STR "x86" + +#elif defined(__ia64__) || \ + defined(__ia64) || \ + defined(_IA64) || \ + defined(__IA64__) || \ + defined(_M_IA64) + #define HB_CPU_STR "IA-64" + +#elif defined(__m68k__) || \ + defined(M68000) + #define HB_CPU_STR "m68k" + +#elif defined(__mips__) || \ + defined(__mips) || \ + defined(__MIPS__) || \ + defined(mips) || \ + defined(_MIPS) || \ + defined(__MIPS__) || \ + defined(_M_MRX000) || \ + defined(_M_MIPS) + #define HB_CPU_STR "MIPS" + +#elif defined(__powerpc64__) + #define HB_CPU_STR "PPC64" + +#elif defined(__powerpc__) || \ + defined(__powerpc) || \ + defined(__POWERPC__) || \ + defined(__ppc__) || \ + defined(__PPC__) || \ + defined(_ARCH_PPC) || \ + defined(_M_MPPC) || \ + defined(_M_PPC) + #define HB_CPU_STR "PPC" + +#elif defined(__THW_RS6000) || \ + defined(_IBMR2) || \ + defined(_POWER) || \ + defined(_ARCH_PWR) || \ + defined(_ARCH_PWR2) + #define HB_CPU_STR "POWER" + +#elif defined(__sparc__) || \ + defined(__sparc) + #if defined(__arch64__) || \ + defined(__sparcv9) || \ + defined(__sparc_v9__) + #define HB_CPU_STR "Sparc/64" + #else + #define HB_CPU_STR "Sparc/32" + #endif + +#elif defined(__sh__) || \ + defined(_SH3) || \ + defined(__sh4__) || \ + defined(__SH4__) || \ + defined(_M_SH) + #define HB_CPU_STR "SuperH" + +#elif defined(__370__) || \ + defined(__THW_370__) + #define HB_CPU_STR "System/370" + +#elif defined(__s390__) || \ + defined(__s390x__) + #define HB_CPU_STR "System/390" + +#elif defined(__SYSC_ZARCH__) + #define HB_CPU_STR "z/Architecture" + +#endif + +#ifndef HB_CPU_STR + #define HB_CPU_STR "(unknown)" +#endif + +const char * hb_verCPU( void ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_verCPU()")); + + return HB_CPU_STR; +} + /* NOTE: OS() function, as a primary goal will detect the version number of the target platform. As an extra it may also detect the host OS. The latter is mainly an issue in DOS, where the host OS can be OS/2 diff --git a/harbour/source/rtl/version.c b/harbour/source/rtl/version.c index 3dcdc6cd7f..5793deb6ce 100644 --- a/harbour/source/rtl/version.c +++ b/harbour/source/rtl/version.c @@ -160,6 +160,10 @@ HB_FUNC( HB_VERSION ) #endif break; + case HB_VERSION_CPU: + hb_retc_const( hb_verCPU() ); + break; + case HB_VERSION_ENDIANNESS: #if defined( HB_LITTLE_ENDIAN ) hb_retni( HB_VERSION_ENDIAN_LITTLE );