Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0727ae

Browse filesBrowse files
committed
Tidy up definitions of pg_attribute_hot and pg_attribute_cold
1fa22a4 was a quick fix for portability problem I introduced in 697e1d0. 1fa22a4 adds a few more cases to the preprocessor logic than I'd have liked. Andres Freund and Dagfinn Ilmari Mannsåker suggested a better way to do this. In passing, also adjust the only current usage of these macros so that the macro comes before the function's return type in the declaration of the function. This now matches what the definition of the function does. Discussion: https://postgr.es/m/20200625163553.lt6wocbjhklp5pl4@alap3.anarazel.de Discussion: https://postgr.es/m/87pn43bmok.fsf@wibble.ilmari.org
1 parent ec05baf commit b0727ae
Copy full SHA for b0727ae

File tree

Expand file treeCollapse file tree

2 files changed

+10
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-8
lines changed

‎src/include/c.h

Copy file name to clipboardExpand all lines: src/include/c.h
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,15 @@
104104
* XLC: https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.2/com.ibm.xlc131.aix.doc/language_ref/type_attrib.html
105105
*/
106106

107+
/*
108+
* For compilers which don't support __has_attribute, we just define
109+
* __has_attribute(x) to 0 so that we can define macros for various
110+
* __attribute__s more easily below.
111+
*/
112+
#ifndef __has_attribute
113+
#define __has_attribute(attribute) 0
114+
#endif
115+
107116
/* only GCC supports the unused attribute */
108117
#ifdef __GNUC__
109118
#define pg_attribute_unused() __attribute__((unused))
@@ -195,8 +204,6 @@
195204
* Marking certain functions as "hot" or "cold" can be useful to assist the
196205
* compiler in arranging the assembly code in a more efficient way.
197206
*/
198-
#if defined(__has_attribute)
199-
200207
#if __has_attribute (cold)
201208
#define pg_attribute_cold __attribute__((cold))
202209
#else
@@ -209,11 +216,6 @@
209216
#define pg_attribute_hot
210217
#endif
211218

212-
#else
213-
#define pg_attribute_hot
214-
#define pg_attribute_cold
215-
#endif
216-
217219
/*
218220
* Mark a point as unreachable in a portable fashion. This should preferably
219221
* be something that the compiler understands, to aid code generation.

‎src/include/utils/elog.h

Copy file name to clipboardExpand all lines: src/include/utils/elog.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
extern bool message_level_is_interesting(int elevel);
161161

162162
extern bool errstart(int elevel, const char *domain);
163-
extern bool pg_attribute_cold errstart_cold(int elevel, const char *domain);
163+
extern pg_attribute_cold bool errstart_cold(int elevel, const char *domain);
164164
extern void errfinish(const char *filename, int lineno, const char *funcname);
165165

166166
extern int errcode(int sqlerrcode);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.