aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas@google.com>2018-04-20 14:10:55 +0200
committerGitHub <noreply@github.com>2018-04-20 14:10:55 +0200
commit6000396155a418aba75c0dab1d97cf5124aa4fb2 (patch)
tree2999142be20fab368275e97cdcc7d3e7d6b8dca8
parent68db5c0272d46f316efab575b67dae5b9ce4378d (diff)
downloadbrotli-6000396155a418aba75c0dab1d97cf5124aa4fb2.zip
brotli-6000396155a418aba75c0dab1d97cf5124aa4fb2.tar.gz
brotli-6000396155a418aba75c0dab1d97cf5124aa4fb2.tar.bz2
Remove unprefixed macros from public headers (#662)
-rwxr-xr-xc/common/platform.h24
-rw-r--r--c/enc/fast_log.h3
-rw-r--r--c/include/brotli/port.h19
-rw-r--r--java/org/brotli/dec/State.java1
4 files changed, 20 insertions, 27 deletions
diff --git a/c/common/platform.h b/c/common/platform.h
index 8d14290..b4e435a 100755
--- a/c/common/platform.h
+++ b/c/common/platform.h
@@ -32,6 +32,18 @@
#include <stdio.h>
#endif
+#if defined(__has_builtin)
+#define BROTLI_HAS_BUILTIN(x) __has_builtin(x)
+#else
+#define BROTLI_HAS_BUILTIN(x) 0
+#endif
+
+#if defined(__has_attribute)
+#define BROTLI_HAS_ATTRIBUTE(x) __has_attribute(x)
+#else
+#define BROTLI_HAS_ATTRIBUTE(x) 0
+#endif
+
/* Macros for compiler / platform specific features and build options.
Build options are:
@@ -48,7 +60,7 @@
* BROTLI_ENABLE_LOG enables asserts and dumps various state information
*/
-#if BROTLI_MODERN_COMPILER || __has_attribute(always_inline)
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_ATTRIBUTE(always_inline)
#define BROTLI_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
#else
#define BROTLI_ATTRIBUTE_ALWAYS_INLINE
@@ -56,7 +68,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
#define BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN
-#elif BROTLI_MODERN_COMPILER || __has_attribute(visibility)
+#elif BROTLI_MODERN_COMPILER || BROTLI_HAS_ATTRIBUTE(visibility)
#define BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN \
__attribute__ ((visibility ("hidden")))
#else
@@ -78,7 +90,7 @@
#define BROTLI_INLINE __forceinline
#endif /* _MSC_VER */
-#if BROTLI_MODERN_COMPILER || __has_attribute(unused)
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_ATTRIBUTE(unused)
#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused))
#else
#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE
@@ -93,7 +105,7 @@
#define BROTLI_RESTRICT
#endif
-#if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_ATTRIBUTE(noinline)
#define BROTLI_NOINLINE __attribute__((noinline))
#else
#define BROTLI_NOINLINE
@@ -324,7 +336,7 @@ OR:
}
*/
-#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_expect)
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_BUILTIN(__builtin_expect)
#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
#else
@@ -333,7 +345,7 @@ OR:
#endif
/* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */
-#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_constant_p)
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_BUILTIN(__builtin_constant_p)
#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
#else
#define BROTLI_IS_CONSTANT(x) (!!0)
diff --git a/c/enc/fast_log.h b/c/enc/fast_log.h
index d45a528..1472cce 100644
--- a/c/enc/fast_log.h
+++ b/c/enc/fast_log.h
@@ -19,7 +19,8 @@ extern "C" {
#endif
static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) {
-#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_clz)
+ /* TODO: generalize and move to platform.h */
+#if BROTLI_MODERN_COMPILER || BROTLI_HAS_BUILTIN(__builtin_clz)
return 31u ^ (uint32_t)__builtin_clz((uint32_t)n);
#else
uint32_t result = 0;
diff --git a/c/include/brotli/port.h b/c/include/brotli/port.h
index 88cdbf4..d49fa6a 100644
--- a/c/include/brotli/port.h
+++ b/c/include/brotli/port.h
@@ -14,19 +14,6 @@
#ifndef BROTLI_COMMON_PORT_H_
#define BROTLI_COMMON_PORT_H_
-/* Compatibility with non-clang compilers. */
-#ifndef __has_builtin
-#define __has_builtin(x) 0
-#endif
-
-#ifndef __has_attribute
-#define __has_attribute(x) 0
-#endif
-
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif
-
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
#define BROTLI_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
@@ -69,10 +56,4 @@
#define BROTLI_ENC_API
#endif
-#if BROTLI_MODERN_COMPILER || __has_attribute(deprecated)
-#define BROTLI_DEPRECATED __attribute__((deprecated))
-#else
-#define BROTLI_DEPRECATED
-#endif
-
#endif /* BROTLI_COMMON_PORT_H_ */
diff --git a/java/org/brotli/dec/State.java b/java/org/brotli/dec/State.java
index 16d1072..2dc46d5 100644
--- a/java/org/brotli/dec/State.java
+++ b/java/org/brotli/dec/State.java
@@ -66,7 +66,6 @@ final class State {
int maxBackwardDistance;
int maxRingBufferSize;
int ringBufferSize;
- int ringBufferFence;
int expectedTotalSize;
int outputOffset;
int outputLength;