summaryrefslogtreecommitdiff
path: root/contrib/pg_upgrade
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-03-11 14:19:54 +0100
committerAndres Freund <andres@anarazel.de>2015-03-11 14:30:01 +0100
commitbbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 (patch)
treed230d006ceb7bf350abd5c3c25a89b660a8d3193 /contrib/pg_upgrade
parent66ece312f99f384bd33e4342580e78b0eebf0e74 (diff)
downloadpostgresql-bbfd7edae5aa5ad5553d3c7e102f2e450d4380d4.tar.gz
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/pg_upgrade')
-rw-r--r--contrib/pg_upgrade/pg_upgrade.h14
-rw-r--r--contrib/pg_upgrade/util.c2
2 files changed, 8 insertions, 8 deletions
diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h
index 19d59f5237..9b873adbc0 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 ec18526d96..ce17aa0d47 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)
{