aboutsummaryrefslogtreecommitdiff
path: root/meta-linaro-toolchain/recipes-devtools/binutils/binutils-2.23.2/replace_macros_with_static_inline.patch
blob: 834f55cf6da41d126e65b224cfddc45254fade91 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Upstream-Status: Backport

From 27b829ee701e29804216b3803fbaeb629be27491 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Wed, 29 Jan 2014 13:46:39 +0000
Subject: [PATCH 1/1] Following up on Tom's suggestion I am checking in a patch to replace the various
 bfd_xxx_set macros with static inline functions, so that we can avoid compile time
 warnings about comma expressions with unused values.

	* bfd-in.h (bfd_set_section_vma): Delete.
	(bfd_set_section_alignment): Delete.
	(bfd_set_section_userdata): Delete.
	(bfd_set_cacheable): Delete.
	* bfd.c (bfd_set_cacheable): New static inline function.
	* section.c (bfd_set_section_userdata): Likewise.
	(bfd_set_section_vma): Likewise.
	(bfd_set_section_alignment): Likewise.
	* bfd-in2.h: Regenerate.
---
 bfd/ChangeLog |   12 ++++++++++++
 bfd/bfd-in.h  |    5 -----
 bfd/bfd-in2.h |   41 +++++++++++++++++++++++++++++++++++------
 bfd/bfd.c     |    8 ++++++++
 bfd/section.c |   26 ++++++++++++++++++++++++++
 5 files changed, 81 insertions(+), 11 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 3afd71b..c7c5a7d 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -292,9 +292,6 @@ typedef struct bfd_section *sec_ptr;
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
 /* Find the address one past the end of SEC.  */
 #define bfd_get_section_limit(bfd, sec) \
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
@@ -517,8 +514,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
 
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 71996db..b5aeb40 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -299,9 +299,6 @@ typedef struct bfd_section *sec_ptr;
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
 /* Find the address one past the end of SEC.  */
 #define bfd_get_section_limit(bfd, sec) \
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
@@ -524,8 +521,6 @@ extern void warn_deprecated (const char *, const char *, int, const char *);
 
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
@@ -1029,7 +1024,7 @@ bfd *bfd_openr (const char *filename, const char *target);
 
 bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
 
-bfd *bfd_openstreamr (const char *, const char *, void *);
+bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
 
 bfd *bfd_openr_iovec (const char *filename, const char *target,
     void *(*open_func) (struct bfd *nbfd,
@@ -1596,6 +1591,32 @@ struct relax_table {
   int size;
 };
 
+/* Note: the following are provided as inline functions rather than macros
+   because not all callers use the return value.  A macro implementation
+   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
+   compilers will complain about comma expressions that have no effect.  */
+static inline bfd_boolean
+bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
+{
+  ptr->userdata = val;
+  return TRUE;
+}
+
+static inline bfd_boolean
+bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
+{
+  ptr->vma = ptr->lma = val;
+  ptr->user_set_vma = TRUE;
+  return TRUE;
+}
+
+static inline bfd_boolean
+bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
+{
+  ptr->alignment_power = val;
+  return TRUE;
+}
+
 /* These sections are global, and are managed by BFD.  The application
    and target back end are not permitted to change the values in
    these sections.  */
@@ -6415,6 +6436,14 @@ struct bfd
   unsigned int selective_search : 1;
 };
 
+/* See note beside bfd_set_section_userdata.  */
+static inline bfd_boolean
+bfd_set_cacheable (bfd * abfd, bfd_boolean val)
+{
+  abfd->cacheable = val;
+  return TRUE;
+}
+
 typedef enum bfd_error
 {
   bfd_error_no_error = 0,
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 8d0580c..2d174f3 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -311,6 +311,14 @@ CODE_FRAGMENT
 .  unsigned int selective_search : 1;
 .};
 .
+.{* See note beside bfd_set_section_userdata.  *}
+.static inline bfd_boolean
+.bfd_set_cacheable (bfd * abfd, bfd_boolean val)
+.{
+.  abfd->cacheable = val;
+.  return TRUE;
+.}
+.
 */
 
 #include "sysdep.h"
diff --git a/bfd/section.c b/bfd/section.c
index fb19d8c..a661228 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -542,6 +542,32 @@ CODE_FRAGMENT
 .  int size;
 .};
 .
+.{* Note: the following are provided as inline functions rather than macros
+.   because not all callers use the return value.  A macro implementation
+.   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
+.   compilers will complain about comma expressions that have no effect.  *}
+.static inline bfd_boolean
+.bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
+.{
+.  ptr->userdata = val;
+.  return TRUE;
+.}
+.
+.static inline bfd_boolean
+.bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
+.{
+.  ptr->vma = ptr->lma = val;
+.  ptr->user_set_vma = TRUE;
+.  return TRUE;
+.}
+.
+.static inline bfd_boolean
+.bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
+.{
+.  ptr->alignment_power = val;
+.  return TRUE;
+.}
+.
 .{* These sections are global, and are managed by BFD.  The application
 .   and target back end are not permitted to change the values in
 .   these sections.  *}
-- 
1.7.1