mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user