aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/snappy-add-inline-for-GCC.patch
blob: 04d35f56ee98ab28b403d70680cb4699e97999d8 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 0c716d435abe65250100c2caea0e5126ac4e14bd Mon Sep 17 00:00:00 2001
From: "Georgi D. Sotirov" <gdsotirov@gmail.com>
Date: Wed, 5 May 2021 14:16:46 +0300
Subject: [PATCH] Add inline with SNAPPY_ATTRIBUTE_ALWAYS_INLINE

Add inline with SNAPPY_ATTRIBUTE_ALWAYS_INLINE on AdvanceToNextTag to
fix the following compilation errors and a warning with GCC:

[  2%] Building CXX object CMakeFiles/snappy.dir/snappy.cc.o
/usr/bin/c++   -DHAVE_CONFIG_H -Dsnappy_EXPORTS
-I/tmp/snappy-1.1.9/build -I/tmp/snappy-1.1.9  -O3
-march=i586 -mtune=i686 -Wall -Wextra -fno-exceptions -fno-rtti -O3
-DNDEBUG -fPIC   -std=c++11 -o CMakeFiles/snappy.dir/snappy.cc.o -c
/tmp/snappy-1.1.9/snappy.cc
/tmp/snappy-1.1.9/snappy.cc:1017:8: warning: always_inline
function might not be inlinable [-Wattributes]
 size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
        ^
/tmp/snappy-1.1.9/snappy.cc: In function 'std::pair<const
unsigned char*, int> snappy::DecompressBranchless(const uint8_t*, const
uint8_t*, ptrdiff_t, T, ptrdiff_t) [with T = char*; uint8_t = unsigned
char; ptrdiff_t = int]':
/tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in
call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**,
size_t*)': function body can be overwritten at link time
/tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here
         size_t tag_type = AdvanceToNextTag(&ip, &tag);
                                                     ^
/tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in
call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**,
size_t*)': function body can be overwritten at link time
 size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
        ^
/tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here
         size_t tag_type = AdvanceToNextTag(&ip, &tag);
                                                     ^
/tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in
call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**,
size_t*)': function body can be overwritten at link time
 size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
        ^
/tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here
         size_t tag_type = AdvanceToNextTag(&ip, &tag);
                                                     ^
CMakeFiles/snappy.dir/build.make:137: recipe for target
'CMakeFiles/snappy.dir/snappy.cc.o' failed

Just like with other functions using SNAPPY_ATTRIBUTE_ALWAYS_INLINE
macro (i.e. __attribute__((always_inline)) ) it is necessary to use C++
inline specifier.
---
 snappy.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/snappy.cc b/snappy.cc
index 79dc0e8..51157be 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -1014,7 +1014,7 @@ void MemMove(ptrdiff_t dst, const void* src, size_t size) {
 }
 
 SNAPPY_ATTRIBUTE_ALWAYS_INLINE
-size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
+inline size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
   const uint8_t*& ip = *ip_p;
   // This section is crucial for the throughput of the decompression loop.
   // The latency of an iteration is fundamentally constrained by the