summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorAndres Freund2015-03-11 13:19:54 +0000
committerAndres Freund2015-03-11 13:30:01 +0000
commitbbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 (patch)
treed230d006ceb7bf350abd5c3c25a89b660a8d3193 /contrib
parent66ece312f99f384bd33e4342580e78b0eebf0e74 (diff)
Add macros wrapping all usage of gcc's __attribute__.
Until now __attribute__() was defined to be empty for all compilers but gcc. That's problematic because it prevents using it in other compilers; which is necessary e.g. for atomics portability. It's also just generally dubious to do so in a header as widely included as c.h. Instead add pg_attribute_format_arg, pg_attribute_printf, pg_attribute_noreturn macros which are implemented in the compilers that understand them. Also add pg_attribute_noreturn and pg_attribute_packed, but don't provide fallbacks, since they can affect functionality. This means that external code that, possibly unwittingly, relied on __attribute__ defined to be empty on !gcc compilers may now run into warnings or errors on those compilers. But there shouldn't be many occurances of that and it's hard to work around... Discussion: 54B58BA3.8040302@ohmu.fi Author: Oskari Saarenmaa, with some minor changes by me.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/cube/cubescan.l2
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h14
-rw-r--r--contrib/pg_upgrade/util.c2
-rw-r--r--contrib/pg_xlogdump/pg_xlogdump.c2
-rw-r--r--contrib/pgcrypto/px.h2
-rw-r--r--contrib/seg/segscan.l2
6 files changed, 12 insertions, 12 deletions
diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l
index e383b59d3d0..1c2522a2398 100644
--- a/contrib/cube/cubescan.l
+++ b/contrib/cube/cubescan.l
@@ -60,7 +60,7 @@ float ({integer}|{real})([eE]{integer})?
%%
-void __attribute__((noreturn))
+void pg_attribute_noreturn
yyerror(NDBOX **result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 19d59f52374..9b873adbc08 100644
--- a/contrib/pg_upgrade/pg_upgrade.h
+++ b/contrib/pg_upgrade/pg_upgrade.h
@@ -359,7 +359,7 @@ void optionally_create_toast_tables(void);
bool
exec_prog(const char *log_file, const char *opt_log_file,
bool throw_error, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 4, 5)));
+pg_attribute_printf(4, 5);
void verify_directories(void);
bool pid_lock_file_exists(const char *datadir);
@@ -445,7 +445,7 @@ void init_tablespaces(void);
PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
PGresult *
executeQueryOrDie(PGconn *conn, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
+pg_attribute_printf(2, 3);
char *cluster_conn_opts(ClusterInfo *cluster);
@@ -462,17 +462,17 @@ int get_user_info(char **user_name_p);
void check_ok(void);
void
report_status(eLogType type, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
+pg_attribute_printf(2, 3);
void
pg_log(eLogType type, const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
+pg_attribute_printf(2, 3);
void
pg_fatal(const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2), noreturn));
+pg_attribute_printf(1, 2) pg_attribute_noreturn;
void end_progress_output(void);
void
prep_status(const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+pg_attribute_printf(1, 2);
void check_ok(void);
const char *getErrorText(int errNum);
unsigned int str2uint(const char *str);
@@ -489,7 +489,7 @@ void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
void
parallel_exec_prog(const char *log_file, const char *opt_log_file,
const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
+pg_attribute_printf(3, 4);
void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata,
char *old_tablespace);
diff --git a/contrib/pg_upgrade/util.c b/contrib/pg_upgrade/util.c
index ec18526d96e..ce17aa0d476 100644
--- a/contrib/pg_upgrade/util.c
+++ b/contrib/pg_upgrade/util.c
@@ -82,7 +82,7 @@ prep_status(const char *fmt,...)
static
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)))
+pg_attribute_printf(2, 0)
void
pg_log_v(eLogType type, const char *fmt, va_list ap)
{
diff --git a/contrib/pg_xlogdump/pg_xlogdump.c b/contrib/pg_xlogdump/pg_xlogdump.c
index c471267fde7..15805be2940 100644
--- a/contrib/pg_xlogdump/pg_xlogdump.c
+++ b/contrib/pg_xlogdump/pg_xlogdump.c
@@ -69,7 +69,7 @@ typedef struct XLogDumpStats
static void
fatal_error(const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+pg_attribute_printf(1, 2);
/*
* Big red button to push when things go horribly wrong.
diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h
index a01a58e29c0..297747c60a3 100644
--- a/contrib/pgcrypto/px.h
+++ b/contrib/pgcrypto/px.h
@@ -208,7 +208,7 @@ void px_memset(void *ptr, int c, size_t len);
#ifdef PX_DEBUG
void
px_debug(const char *fmt,...)
-__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+pg_attribute_printf(1, 2);
#else
#define px_debug(...)
#endif
diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l
index a3e685488a8..5fe4a2c4537 100644
--- a/contrib/seg/segscan.l
+++ b/contrib/seg/segscan.l
@@ -59,7 +59,7 @@ float ({integer}|{real})([eE]{integer})?
%%
-void __attribute__((noreturn))
+void pg_attribute_noreturn
yyerror(SEG *result, const char *message)
{
if (*yytext == YY_END_OF_BUFFER_CHAR)