Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Dec 2017 01:16:26 +0000 (UTC)
From:      Allan Jude <allanjude@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326506 - in head/sys/contrib/zstd/lib: common compress
Message-ID:  <201712040116.vB41GQ41078524@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: allanjude
Date: Mon Dec  4 01:16:26 2017
New Revision: 326506
URL: https://svnweb.freebsd.org/changeset/base/326506

Log:
  Use __has_builtin() to ensure clz and clzll builtins are available
  
  The existing check of the GCC version number is not sufficient
  
  This fixes the build on sparc64 in preparation for integrating ZSTD into
  the kernel for ZFS and Crash Dumps.

Modified:
  head/sys/contrib/zstd/lib/common/bitstream.h
  head/sys/contrib/zstd/lib/common/zstd_internal.h
  head/sys/contrib/zstd/lib/compress/zstd_compress.h

Modified: head/sys/contrib/zstd/lib/common/bitstream.h
==============================================================================
--- head/sys/contrib/zstd/lib/common/bitstream.h	Mon Dec  4 01:14:17 2017	(r326505)
+++ head/sys/contrib/zstd/lib/common/bitstream.h	Mon Dec  4 01:16:26 2017	(r326506)
@@ -175,7 +175,7 @@ MEM_STATIC unsigned BIT_highbit32 (register U32 val)
         unsigned long r=0;
         _BitScanReverse ( &r, val );
         return (unsigned) r;
-#   elif defined(__GNUC__) && (__GNUC__ >= 3)   /* Use GCC Intrinsic */
+#   elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz)   /* Use GCC Intrinsic */
         return 31 - __builtin_clz (val);
 #   else   /* Software version */
         static const unsigned DeBruijnClz[32] = { 0,  9,  1, 10, 13, 21,  2, 29,

Modified: head/sys/contrib/zstd/lib/common/zstd_internal.h
==============================================================================
--- head/sys/contrib/zstd/lib/common/zstd_internal.h	Mon Dec  4 01:14:17 2017	(r326505)
+++ head/sys/contrib/zstd/lib/common/zstd_internal.h	Mon Dec  4 01:16:26 2017	(r326506)
@@ -327,7 +327,7 @@ MEM_STATIC U32 ZSTD_highbit32(U32 val)
         unsigned long r=0;
         _BitScanReverse(&r, val);
         return (unsigned)r;
-#   elif defined(__GNUC__) && (__GNUC__ >= 3)   /* GCC Intrinsic */
+#   elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz)   /* GCC Intrinsic */
         return 31 - __builtin_clz(val);
 #   else   /* Software version */
         static const int DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };

Modified: head/sys/contrib/zstd/lib/compress/zstd_compress.h
==============================================================================
--- head/sys/contrib/zstd/lib/compress/zstd_compress.h	Mon Dec  4 01:14:17 2017	(r326505)
+++ head/sys/contrib/zstd/lib/compress/zstd_compress.h	Mon Dec  4 01:16:26 2017	(r326506)
@@ -203,7 +203,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t va
             unsigned long r = 0;
             _BitScanReverse64( &r, val );
             return (unsigned)(r>>3);
-#       elif defined(__GNUC__) && (__GNUC__ >= 4)
+#       elif defined(__GNUC__) && (__GNUC__ >= 4) && __has_builtin(__builtin_clzll)
             return (__builtin_clzll(val) >> 3);
 #       else
             unsigned r;
@@ -218,7 +218,7 @@ static unsigned ZSTD_NbCommonBytes (register size_t va
             unsigned long r = 0;
             _BitScanReverse( &r, (unsigned long)val );
             return (unsigned)(r>>3);
-#       elif defined(__GNUC__) && (__GNUC__ >= 3)
+#       elif defined(__GNUC__) && (__GNUC__ >= 3) && __has_builtin(__builtin_clz)
             return (__builtin_clz((U32)val) >> 3);
 #       else
             unsigned r;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712040116.vB41GQ41078524>