summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2021-06-19 02:05:32 +0000
committerJames Zern <jzern@google.com>2021-06-18 19:30:38 -0700
commitb1cf887f8637762d51247f77b441f093ddd15541 (patch)
tree9c6694ae0b1fa9135b266a20d155b15d53a81fed
parent3e26513656bff4e70ab14b9a3913b98068950d9a (diff)
downloadlibwebp-b1cf887f8637762d51247f77b441f093ddd15541.tar.gz
define WEBP_RESTRICT for MSVC
__restrict is supported: https://docs.microsoft.com/en-us/cpp/cpp/extension-restrict?view=msvc-160 + add a comment and simplify the __restrict__ check, clang defines __GNUC__ Change-Id: I76d8d3cbd1b730f492c6fc0b2114f1897886b677
-rw-r--r--src/utils/utils.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 0026a747..6cb14415 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -25,20 +25,27 @@
#include "src/dsp/dsp.h"
#include "src/webp/types.h"
-//------------------------------------------------------------------------------
-// restrict
+#ifdef __cplusplus
+extern "C" {
+#endif
-#if defined(__GNUC__) || defined(__clang__)
+//------------------------------------------------------------------------------
+// WEBP_RESTRICT
+
+// Declares a pointer with the restrict type qualifier if available.
+// This allows code to hint to the compiler that only this pointer references a
+// particular object or memory region within the scope of the block in which it
+// is declared. This may allow for improved optimizations due to the lack of
+// pointer aliasing. See also:
+// https://en.cppreference.com/w/c/language/restrict
+#if defined(__GNUC__)
+#define WEBP_RESTRICT __restrict__
+#elif defined(_MSC_VER)
#define WEBP_RESTRICT __restrict
#else
#define WEBP_RESTRICT
#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
//------------------------------------------------------------------------------
// Memory allocation