PRJosh / lz4

Automatically exported from code.google.com/p/lz4
0 stars 0 forks source link

Visual Studio 2010 does not auto detect amd64 architecture #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Lz4.c, Line 67 where CPU Feature detection is done, I had to add the 
following to have Visual Studio 2010 set LZ4_ARCH64 to the correct value.

defined(_M_AMD64) || defined(_M_X64)

So the new line looks like this...

//**************************************
// CPU Feature Detection
//**************************************
// 32 or 64 bits ?
#if (defined(_M_AMD64) || defined(_M_X64) || defined(__x86_64__) || 
defined(__x86_64) || defined(__amd64__) || defined(__amd64) \
  || defined(__ppc64__) || defined(_WIN64) || defined(__LP64__) || defined(_LP64) \
  || defined(__ia64__) )   // Detects 64 bits mode
#  define LZ4_ARCH64 1
#else
#  define LZ4_ARCH64 0
#endif 

Original issue reported on code.google.com by dkar...@gmail.com on 28 May 2013 at 9:23

GoogleCodeExporter commented 9 years ago
Thanks for reporting and very clear input.

I've looked for guidance, and found this link :
http://nadeausoftware.com/articles/2012/02/c_c_tip_how_detect_processor_type_usi
ng_compiler_predefined_macros#x86andx8664

It basically states that 
#if defined(__x86_64__) || defined(_M_X64)
is enough to guarantee detection of AMD64 systems across all major compilers.

Would you mind testing this hypothesis ?

Regards

Original comment by yann.col...@gmail.com on 29 May 2013 at 8:25

GoogleCodeExporter commented 9 years ago

Original comment by yann.col...@gmail.com on 29 May 2013 at 8:25

GoogleCodeExporter commented 9 years ago
I changed my code to look like this:

#if defined(__x86_64__) || defined(_M_X64)
#  define LZ4_ARCH64 1
#else
#  define LZ4_ARCH64 0
#endif

That was sufficient to work for Visual Studio 2010.  I do not have any other 
compilers to verify with.

Original comment by dkar...@gmail.com on 29 May 2013 at 1:49

GoogleCodeExporter commented 9 years ago
OK, thanks,
we'll trust this reference, since it seems very well documented,

this will be corrected in next release.

Refards

Original comment by yann.col...@gmail.com on 29 May 2013 at 1:51

GoogleCodeExporter commented 9 years ago
Corrected into r97

Original comment by yann.col...@gmail.com on 10 Jun 2013 at 6:42