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
This commit is contained in:
James Zern 2021-06-19 02:05:32 +00:00
parent 3e26513656
commit b1cf887f86

View File

@ -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