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:
Andres Freund 2015-03-11 14:19:54 +01:00
parent 66ece312f9
commit bbfd7edae5
68 changed files with 167 additions and 132 deletions

View File

@ -60,7 +60,7 @@ float ({integer}|{real})([eE]{integer})?
%% %%
void __attribute__((noreturn)) void pg_attribute_noreturn
yyerror(NDBOX **result, const char *message) yyerror(NDBOX **result, const char *message)
{ {
if (*yytext == YY_END_OF_BUFFER_CHAR) if (*yytext == YY_END_OF_BUFFER_CHAR)

View File

@ -359,7 +359,7 @@ void optionally_create_toast_tables(void);
bool bool
exec_prog(const char *log_file, const char *opt_log_file, exec_prog(const char *log_file, const char *opt_log_file,
bool throw_error, const char *fmt,...) bool throw_error, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 4, 5))); pg_attribute_printf(4, 5);
void verify_directories(void); void verify_directories(void);
bool pid_lock_file_exists(const char *datadir); bool pid_lock_file_exists(const char *datadir);
@ -445,7 +445,7 @@ void init_tablespaces(void);
PGconn *connectToServer(ClusterInfo *cluster, const char *db_name); PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
PGresult * PGresult *
executeQueryOrDie(PGconn *conn, const char *fmt,...) executeQueryOrDie(PGconn *conn, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
char *cluster_conn_opts(ClusterInfo *cluster); char *cluster_conn_opts(ClusterInfo *cluster);
@ -462,17 +462,17 @@ int get_user_info(char **user_name_p);
void check_ok(void); void check_ok(void);
void void
report_status(eLogType type, const char *fmt,...) report_status(eLogType type, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
void void
pg_log(eLogType type, const char *fmt,...) pg_log(eLogType type, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
void void
pg_fatal(const char *fmt,...) 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 end_progress_output(void);
void void
prep_status(const char *fmt,...) prep_status(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
void check_ok(void); void check_ok(void);
const char *getErrorText(int errNum); const char *getErrorText(int errNum);
unsigned int str2uint(const char *str); unsigned int str2uint(const char *str);
@ -489,7 +489,7 @@ void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
void void
parallel_exec_prog(const char *log_file, const char *opt_log_file, parallel_exec_prog(const char *log_file, const char *opt_log_file,
const char *fmt,...) 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, void parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
char *old_pgdata, char *new_pgdata, char *old_pgdata, char *new_pgdata,
char *old_tablespace); char *old_tablespace);

View File

@ -82,7 +82,7 @@ prep_status(const char *fmt,...)
static static
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))) pg_attribute_printf(2, 0)
void void
pg_log_v(eLogType type, const char *fmt, va_list ap) pg_log_v(eLogType type, const char *fmt, va_list ap)
{ {

View File

@ -69,7 +69,7 @@ typedef struct XLogDumpStats
static void static void
fatal_error(const char *fmt,...) 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. * Big red button to push when things go horribly wrong.

View File

@ -208,7 +208,7 @@ void px_memset(void *ptr, int c, size_t len);
#ifdef PX_DEBUG #ifdef PX_DEBUG
void void
px_debug(const char *fmt,...) px_debug(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
#else #else
#define px_debug(...) #define px_debug(...)
#endif #endif

View File

@ -59,7 +59,7 @@ float ({integer}|{real})([eE]{integer})?
%% %%
void __attribute__((noreturn)) void pg_attribute_noreturn
yyerror(SEG *result, const char *message) yyerror(SEG *result, const char *message)
{ {
if (*yytext == YY_END_OF_BUFFER_CHAR) if (*yytext == YY_END_OF_BUFFER_CHAR)

View File

@ -36,7 +36,7 @@ static void
report_invalid_record(XLogReaderState *state, const char *fmt,...) report_invalid_record(XLogReaderState *state, const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
static void ResetDecoder(XLogReaderState *state); static void ResetDecoder(XLogReaderState *state);

View File

@ -286,8 +286,8 @@ int AutovacuumLauncherPid = 0;
static pid_t avlauncher_forkexec(void); static pid_t avlauncher_forkexec(void);
static pid_t avworker_forkexec(void); static pid_t avworker_forkexec(void);
#endif #endif
NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]) __attribute__((noreturn)); NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn;
NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]) __attribute__((noreturn)); NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn;
static Oid do_start_worker(void); static Oid do_start_worker(void);
static void launcher_determine_sleep(bool canlaunch, bool recursing, static void launcher_determine_sleep(bool canlaunch, bool recursing,

View File

@ -86,7 +86,7 @@ static volatile sig_atomic_t ready_to_stop = false;
static pid_t pgarch_forkexec(void); static pid_t pgarch_forkexec(void);
#endif #endif
NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]) __attribute__((noreturn)); NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]) pg_attribute_noreturn;
static void pgarch_exit(SIGNAL_ARGS); static void pgarch_exit(SIGNAL_ARGS);
static void ArchSigHupHandler(SIGNAL_ARGS); static void ArchSigHupHandler(SIGNAL_ARGS);
static void ArchSigTermHandler(SIGNAL_ARGS); static void ArchSigTermHandler(SIGNAL_ARGS);

View File

@ -251,7 +251,7 @@ static instr_time total_func_time;
static pid_t pgstat_forkexec(void); static pid_t pgstat_forkexec(void);
#endif #endif
NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) __attribute__((noreturn)); NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn;
static void pgstat_exit(SIGNAL_ARGS); static void pgstat_exit(SIGNAL_ARGS);
static void pgstat_beshutdown_hook(int code, Datum arg); static void pgstat_beshutdown_hook(int code, Datum arg);
static void pgstat_sighup_handler(SIGNAL_ARGS); static void pgstat_sighup_handler(SIGNAL_ARGS);

View File

@ -380,8 +380,8 @@ static void LogChildExit(int lev, const char *procname,
int pid, int exitstatus); int pid, int exitstatus);
static void PostmasterStateMachine(void); static void PostmasterStateMachine(void);
static void BackendInitialize(Port *port); static void BackendInitialize(Port *port);
static void BackendRun(Port *port) __attribute__((noreturn)); static void BackendRun(Port *port) pg_attribute_noreturn;
static void ExitPostmaster(int status) __attribute__((noreturn)); static void ExitPostmaster(int status) pg_attribute_noreturn;
static int ServerLoop(void); static int ServerLoop(void);
static int BackendStartup(Port *port); static int BackendStartup(Port *port);
static int ProcessStartupPacket(Port *port, bool SSLdone); static int ProcessStartupPacket(Port *port, bool SSLdone);

View File

@ -130,7 +130,7 @@ static volatile sig_atomic_t rotation_requested = false;
static pid_t syslogger_forkexec(void); static pid_t syslogger_forkexec(void);
static void syslogger_parseArgs(int argc, char *argv[]); static void syslogger_parseArgs(int argc, char *argv[]);
#endif #endif
NON_EXEC_STATIC void SysLoggerMain(int argc, char *argv[]) __attribute__((noreturn)); NON_EXEC_STATIC void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn;
static void process_pipe_input(char *logbuffer, int *bytes_in_logbuffer); static void process_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
static void flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer); static void flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
static void open_csvlogfile(void); static void open_csvlogfile(void);

View File

@ -205,7 +205,7 @@ addlitchar(unsigned char ychar)
appendStringInfoChar(&litbuf, ychar); appendStringInfoChar(&litbuf, ychar);
} }
void __attribute__((noreturn)) void pg_attribute_noreturn
yyerror(const char *message) yyerror(const char *message)
{ {
ereport(ERROR, ereport(ERROR,

View File

@ -193,7 +193,7 @@ typedef void (*WalSndSendDataCallback) (void);
static void WalSndLoop(WalSndSendDataCallback send_data); static void WalSndLoop(WalSndSendDataCallback send_data);
static void InitWalSenderSlot(void); static void InitWalSenderSlot(void);
static void WalSndKill(int code, Datum arg); static void WalSndKill(int code, Datum arg);
static void WalSndShutdown(void) __attribute__((noreturn)); static void WalSndShutdown(void) pg_attribute_noreturn;
static void XLogSendPhysical(void); static void XLogSendPhysical(void);
static void XLogSendLogical(void); static void XLogSendLogical(void);
static void WalSndDone(WalSndSendDataCallback send_data); static void WalSndDone(WalSndSendDataCallback send_data);

View File

@ -86,7 +86,7 @@ static const char *
err_gettext(const char *str) err_gettext(const char *str)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format_arg(1))); pg_attribute_format_arg(1);
static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str); static void set_errdata_field(MemoryContextData *cxt, char **ptr, const char *str);
/* Global variables */ /* Global variables */

View File

@ -132,7 +132,7 @@ char *GUC_check_errhint_string;
static void static void
do_serialize(char **destptr, Size *maxbytes, const char *fmt,...) do_serialize(char **destptr, Size *maxbytes, const char *fmt,...)
/* This lets gcc check the format string for consistency. */ /* This lets gcc check the format string for consistency. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); pg_attribute_printf(3, 4);
static void set_config_sourcefile(const char *name, char *sourcefile, static void set_config_sourcefile(const char *name, char *sourcefile,
int sourceline); int sourceline);

View File

@ -120,7 +120,7 @@ static void
write_stderr(const char *fmt,...) write_stderr(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
static void do_advice(void); static void do_advice(void);
static void do_help(void); static void do_help(void);
static void set_mode(char *modeopt); static void set_mode(char *modeopt);

View File

@ -81,7 +81,7 @@ static ParallelSlot *GetMyPSlot(ParallelState *pstate);
static void static void
parallel_msg_master(ParallelSlot *slot, const char *modulename, parallel_msg_master(ParallelSlot *slot, const char *modulename,
const char *fmt, va_list ap) const char *fmt, va_list ap)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); pg_attribute_printf(3, 0);
static void archive_close_connection(int code, void *arg); static void archive_close_connection(int code, void *arg);
static void ShutdownWorkersHard(ParallelState *pstate); static void ShutdownWorkersHard(ParallelState *pstate);
static void WaitForTerminatingWorkers(ParallelState *pstate); static void WaitForTerminatingWorkers(ParallelState *pstate);

View File

@ -280,7 +280,7 @@ extern void archputs(const char *s, Archive *AH);
extern int extern int
archprintf(Archive *AH, const char *fmt,...) archprintf(Archive *AH, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
#define appendStringLiteralAH(buf,str,AH) \ #define appendStringLiteralAH(buf,str,AH) \
appendStringLiteral(buf, str, (AH)->encoding, (AH)->std_strings) appendStringLiteral(buf, str, (AH)->encoding, (AH)->std_strings)

View File

@ -378,7 +378,7 @@ struct _tocEntry
extern int parallel_restore(struct ParallelArgs *args); extern int parallel_restore(struct ParallelArgs *args);
extern void on_exit_close_archive(Archive *AHX); extern void on_exit_close_archive(Archive *AHX);
extern void warn_or_exit_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); extern void warn_or_exit_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) pg_attribute_printf(3, 4);
extern void WriteTOC(ArchiveHandle *AH); extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH); extern void ReadTOC(ArchiveHandle *AH);
@ -429,8 +429,8 @@ extern int ReconnectToServer(ArchiveHandle *AH, const char *dbname, const char *
extern void DropBlobIfExists(ArchiveHandle *AH, Oid oid); extern void DropBlobIfExists(ArchiveHandle *AH, Oid oid);
void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH); void ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH);
int ahprintf(ArchiveHandle *AH, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); int ahprintf(ArchiveHandle *AH, const char *fmt,...) pg_attribute_printf(2, 3);
void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); void ahlog(ArchiveHandle *AH, int level, const char *fmt,...) pg_attribute_printf(3, 4);
#endif #endif

View File

@ -115,7 +115,7 @@ static void tarClose(ArchiveHandle *AH, TAR_MEMBER *TH);
#ifdef __NOT_USED__ #ifdef __NOT_USED__
static char *tarGets(char *buf, size_t len, TAR_MEMBER *th); static char *tarGets(char *buf, size_t len, TAR_MEMBER *th);
#endif #endif
static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); static int tarPrintf(ArchiveHandle *AH, TAR_MEMBER *th, const char *fmt,...) pg_attribute_printf(3, 4);
static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th); static void _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th);
static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename); static TAR_MEMBER *_tarPositionTo(ArchiveHandle *AH, const char *filename);

View File

@ -30,15 +30,15 @@ extern const char *progname;
extern void set_dump_section(const char *arg, int *dumpSections); extern void set_dump_section(const char *arg, int *dumpSections);
extern void extern void
write_msg(const char *modulename, const char *fmt,...) write_msg(const char *modulename, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern void extern void
vwrite_msg(const char *modulename, const char *fmt, va_list ap) vwrite_msg(const char *modulename, const char *fmt, va_list ap)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); pg_attribute_printf(2, 0);
extern void on_exit_nicely(on_exit_nicely_callback function, void *arg); extern void on_exit_nicely(on_exit_nicely_callback function, void *arg);
extern void exit_nicely(int code) __attribute__((noreturn)); extern void exit_nicely(int code) pg_attribute_noreturn;
extern void extern void
exit_horribly(const char *modulename, const char *fmt,...) exit_horribly(const char *modulename, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn)); pg_attribute_printf(2, 3) pg_attribute_noreturn;
#endif /* PG_BACKUP_UTILS_H */ #endif /* PG_BACKUP_UTILS_H */

View File

@ -21,7 +21,7 @@ extern bool setQFout(const char *fname);
extern void extern void
psql_error(const char *fmt,...) psql_error(const char *fmt,...)
/* This lets gcc check the format string for consistency. */ /* This lets gcc check the format string for consistency. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern void NoticeProcessor(void *arg, const char *message); extern void NoticeProcessor(void *arg, const char *message);

View File

@ -14,7 +14,7 @@
static void static void
print_lo_result(const char *fmt,...) print_lo_result(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
static void static void
print_lo_result(const char *fmt,...) print_lo_result(const char *fmt,...)

View File

@ -32,7 +32,7 @@ extern Form_pg_attribute attrtypes[MAXATTR];
extern int numattr; extern int numattr;
extern void AuxiliaryProcessMain(int argc, char *argv[]) __attribute__((noreturn)); extern void AuxiliaryProcessMain(int argc, char *argv[]) pg_attribute_noreturn;
extern void err_out(void); extern void err_out(void);
@ -61,6 +61,6 @@ extern void boot_get_type_io_data(Oid typid,
extern int boot_yyparse(void); extern int boot_yyparse(void);
extern int boot_yylex(void); extern int boot_yylex(void);
extern void boot_yyerror(const char *str) __attribute__((noreturn)); extern void boot_yyerror(const char *str) pg_attribute_noreturn;
#endif /* BOOTSTRAP_H */ #endif /* BOOTSTRAP_H */

View File

@ -156,10 +156,6 @@
#define dummyret char #define dummyret char
#endif #endif
#ifndef __GNUC__
#define __attribute__(_arg_)
#endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Section 2: bool, true, false, TRUE, FALSE, NULL * Section 2: bool, true, false, TRUE, FALSE, NULL
* ---------------------------------------------------------------- * ----------------------------------------------------------------
@ -560,6 +556,47 @@ typedef NameData *Name;
/* we don't currently need wider versions of the other ALIGN macros */ /* we don't currently need wider versions of the other ALIGN macros */
#define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN)) #define MAXALIGN64(LEN) TYPEALIGN64(MAXIMUM_ALIGNOF, (LEN))
/* ----------------
* Attribute macros
*
* GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
* GCC: https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
* Sunpro: https://docs.oracle.com/cd/E18659_01/html/821-1384/gjzke.html
* XLC: http://www-01.ibm.com/support/knowledgecenter/SSGH2K_11.1.0/com.ibm.xlc111.aix.doc/language_ref/function_attributes.html
* XLC: http://www-01.ibm.com/support/knowledgecenter/SSGH2K_11.1.0/com.ibm.xlc111.aix.doc/language_ref/type_attrib.html
* ----------------
*/
/* only GCC supports the unused attribute */
#ifdef __GNUC__
#define pg_attribute_unused __attribute__((unused))
#else
#define pg_attribute_unused
#endif
/* GCC and XLC support format attributes */
#if defined(__GNUC__) || defined(__IBMC__)
#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
#else
#define pg_attribute_format_arg(a)
#define pg_attribute_printf(f,a)
#endif
/* GCC, Sunpro and XLC support aligned, packed and noreturn */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#define pg_attribute_noreturn __attribute__((noreturn))
#define pg_attribute_packed __attribute__((packed))
#else
/*
* NB: aligned and packed are not defined as empty as they affect code
* functionality; they must be implemented by the compiler if they are to be
* used.
*/
#define pg_attribute_noreturn
#endif
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* Section 6: assertions * Section 6: assertions
* ---------------------------------------------------------------- * ----------------------------------------------------------------
@ -906,7 +943,7 @@ typedef NameData *Name;
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
#define PG_USED_FOR_ASSERTS_ONLY #define PG_USED_FOR_ASSERTS_ONLY
#else #else
#define PG_USED_FOR_ASSERTS_ONLY __attribute__((unused)) #define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused
#endif #endif
@ -973,7 +1010,7 @@ typedef NameData *Name;
extern int extern int
snprintf(char *str, size_t count, const char *fmt,...) snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); pg_attribute_printf(3, 4);
#endif #endif
#if !HAVE_DECL_VSNPRINTF #if !HAVE_DECL_VSNPRINTF

View File

@ -26,9 +26,9 @@ extern void pfree(void *pointer);
/* sprintf into a palloc'd buffer --- these are in psprintf.c */ /* sprintf into a palloc'd buffer --- these are in psprintf.c */
extern char * extern char *
psprintf(const char *fmt,...) psprintf(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern size_t extern size_t
pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pvsnprintf(char *buf, size_t len, const char *fmt, va_list args)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); pg_attribute_printf(3, 0);
#endif /* FE_MEMUTILS_H */ #endif /* FE_MEMUTILS_H */

View File

@ -95,7 +95,7 @@ extern void resetStringInfo(StringInfo str);
extern void extern void
appendStringInfo(StringInfo str, const char *fmt,...) appendStringInfo(StringInfo str, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
/*------------------------ /*------------------------
* appendStringInfoVA * appendStringInfoVA
@ -108,7 +108,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
*/ */
extern int extern int
appendStringInfoVA(StringInfo str, const char *fmt, va_list args) appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); pg_attribute_printf(2, 0);
/*------------------------ /*------------------------
* appendStringInfoString * appendStringInfoString

View File

@ -514,9 +514,9 @@ extern void check_encoding_conversion_args(int src_encoding,
int expected_src_encoding, int expected_src_encoding,
int expected_dest_encoding); int expected_dest_encoding);
extern void report_invalid_encoding(int encoding, const char *mbstr, int len) __attribute__((noreturn)); extern void report_invalid_encoding(int encoding, const char *mbstr, int len) pg_attribute_noreturn;
extern void report_untranslatable_char(int src_encoding, int dest_encoding, extern void report_untranslatable_char(int src_encoding, int dest_encoding,
const char *mbstr, int len) __attribute__((noreturn)); const char *mbstr, int len) pg_attribute_noreturn;
extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len); extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len);
extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len); extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len);

View File

@ -85,9 +85,9 @@ extern bool isLockedRefname(ParseState *pstate, const char *refname);
extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte, extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
bool addToJoinList, bool addToJoinList,
bool addToRelNameSpace, bool addToVarNameSpace); bool addToRelNameSpace, bool addToVarNameSpace);
extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) __attribute__((noreturn)); extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn;
extern void errorMissingColumn(ParseState *pstate, extern void errorMissingColumn(ParseState *pstate,
char *relname, char *colname, int location) __attribute__((noreturn)); char *relname, char *colname, int location) pg_attribute_noreturn;
extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
int location, bool include_dropped, int location, bool include_dropped,
List **colnames, List **colvars); List **colnames, List **colvars);

View File

@ -124,6 +124,6 @@ extern void scanner_finish(core_yyscan_t yyscanner);
extern int core_yylex(core_YYSTYPE *lvalp, YYLTYPE *llocp, extern int core_yylex(core_YYSTYPE *lvalp, YYLTYPE *llocp,
core_yyscan_t yyscanner); core_yyscan_t yyscanner);
extern int scanner_errposition(int location, core_yyscan_t yyscanner); extern int scanner_errposition(int location, core_yyscan_t yyscanner);
extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) __attribute__((noreturn)); extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) pg_attribute_noreturn;
#endif /* SCANNER_H */ #endif /* SCANNER_H */

View File

@ -875,7 +875,7 @@ extern void pgstat_reset_all(void);
extern void allow_immediate_pgstat_restart(void); extern void allow_immediate_pgstat_restart(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void PgstatCollectorMain(int argc, char *argv[]) __attribute__((noreturn)); extern void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn;
#endif #endif

View File

@ -156,25 +156,25 @@ extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
extern int extern int
pg_snprintf(char *str, size_t count, const char *fmt,...) pg_snprintf(char *str, size_t count, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); pg_attribute_printf(3, 4);
extern int extern int
pg_sprintf(char *str, const char *fmt,...) pg_sprintf(char *str, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern int pg_vfprintf(FILE *stream, const char *fmt, va_list args); extern int pg_vfprintf(FILE *stream, const char *fmt, va_list args);
extern int extern int
pg_fprintf(FILE *stream, const char *fmt,...) pg_fprintf(FILE *stream, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern int extern int
pg_printf(const char *fmt,...) pg_printf(const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
/* /*
* The GCC-specific code below prevents the __attribute__(... 'printf') * The GCC-specific code below prevents the pg_attribute_printf above from
* above from being replaced, and this is required because gcc doesn't * being replaced, and this is required because gcc doesn't know anything
* know anything about pg_printf. * about pg_printf.
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) #define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)

View File

@ -98,7 +98,7 @@ typedef struct pg_atomic_uint32
typedef struct pg_atomic_uint64 typedef struct pg_atomic_uint64
{ {
volatile uint64 value __attribute__((aligned(8))); volatile uint64 value pg_attribute_aligned(8);
} pg_atomic_uint64; } pg_atomic_uint64;
#endif /* defined(HAVE_GCC__ATOMIC_INT64_CAS) || defined(HAVE_GCC__SYNC_INT64_CAS) */ #endif /* defined(HAVE_GCC__ATOMIC_INT64_CAS) || defined(HAVE_GCC__SYNC_INT64_CAS) */

View File

@ -61,7 +61,7 @@ typedef struct pg_atomic_uint64
* it proves to be a problem, we'll have to add more version checks for 64 * it proves to be a problem, we'll have to add more version checks for 64
* bit support. * bit support.
*/ */
volatile uint64 value __attribute__((__aligned__(8))); volatile uint64 value pg_attribute_aligned(8);
} pg_atomic_uint64; } pg_atomic_uint64;
#endif /* HAVE_ATOMIC_H */ #endif /* HAVE_ATOMIC_H */

View File

@ -32,7 +32,7 @@ typedef struct pg_atomic_uint32
#define PG_HAVE_ATOMIC_U64_SUPPORT #define PG_HAVE_ATOMIC_U64_SUPPORT
typedef struct pg_atomic_uint64 typedef struct pg_atomic_uint64
{ {
volatile uint64 value __attribute__((__aligned__(8))); volatile uint64 value pg_attribute_aligned(8);
} pg_atomic_uint64; } pg_atomic_uint64;
#endif /* __64BIT__ */ #endif /* __64BIT__ */

View File

@ -687,6 +687,6 @@ extern Datum Float8GetDatum(float8 X);
*/ */
extern void ExceptionalCondition(const char *conditionName, extern void ExceptionalCondition(const char *conditionName,
const char *errorType, const char *errorType,
const char *fileName, int lineNumber) __attribute__((noreturn)); const char *fileName, int lineNumber) pg_attribute_noreturn;
#endif /* POSTGRES_H */ #endif /* POSTGRES_H */

View File

@ -54,8 +54,8 @@ extern void AutoVacWorkerFailed(void);
extern void AutoVacuumUpdateDelay(void); extern void AutoVacuumUpdateDelay(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void AutoVacLauncherMain(int argc, char *argv[]) __attribute__((noreturn)); extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn;
extern void AutoVacWorkerMain(int argc, char *argv[]) __attribute__((noreturn)); extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn;
extern void AutovacuumWorkerIAm(void); extern void AutovacuumWorkerIAm(void);
extern void AutovacuumLauncherIAm(void); extern void AutovacuumLauncherIAm(void);
#endif #endif

View File

@ -46,7 +46,7 @@ extern void BackgroundWorkerStopNotifications(pid_t pid);
extern void ResetBackgroundWorkerCrashTimes(void); extern void ResetBackgroundWorkerCrashTimes(void);
/* Function to start a background worker, called from postmaster.c */ /* Function to start a background worker, called from postmaster.c */
extern void StartBackgroundWorker(void) __attribute__((noreturn)); extern void StartBackgroundWorker(void) pg_attribute_noreturn;
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern BackgroundWorker *BackgroundWorkerEntry(int slotno); extern BackgroundWorker *BackgroundWorkerEntry(int slotno);

View File

@ -25,8 +25,8 @@ extern int CheckPointTimeout;
extern int CheckPointWarning; extern int CheckPointWarning;
extern double CheckPointCompletionTarget; extern double CheckPointCompletionTarget;
extern void BackgroundWriterMain(void) __attribute__((noreturn)); extern void BackgroundWriterMain(void) pg_attribute_noreturn;
extern void CheckpointerMain(void) __attribute__((noreturn)); extern void CheckpointerMain(void) pg_attribute_noreturn;
extern void RequestCheckpoint(int flags); extern void RequestCheckpoint(int flags);
extern void CheckpointWriteDelay(int flags, double progress); extern void CheckpointWriteDelay(int flags, double progress);

View File

@ -33,7 +33,7 @@
extern int pgarch_start(void); extern int pgarch_start(void);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void PgArchiverMain(int argc, char *argv[]) __attribute__((noreturn)); extern void PgArchiverMain(int argc, char *argv[]) pg_attribute_noreturn;
#endif #endif
#endif /* _PGARCH_H */ #endif /* _PGARCH_H */

View File

@ -46,7 +46,7 @@ extern int postmaster_alive_fds[2];
extern const char *progname; extern const char *progname;
extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn)); extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn;
extern void ClosePostmasterPorts(bool am_syslogger); extern void ClosePostmasterPorts(bool am_syslogger);
extern int MaxLivePostmasterChildren(void); extern int MaxLivePostmasterChildren(void);
@ -56,7 +56,7 @@ extern bool PostmasterMarkPIDForWorkerNotify(int);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern pid_t postmaster_forkexec(int argc, char *argv[]); extern pid_t postmaster_forkexec(int argc, char *argv[]);
extern void SubPostmasterMain(int argc, char *argv[]) __attribute__((noreturn)); extern void SubPostmasterMain(int argc, char *argv[]) pg_attribute_noreturn;
extern Size ShmemBackendArraySize(void); extern Size ShmemBackendArraySize(void);
extern void ShmemBackendArrayAllocation(void); extern void ShmemBackendArrayAllocation(void);

View File

@ -13,7 +13,7 @@
#define _STARTUP_H #define _STARTUP_H
extern void HandleStartupProcInterrupts(void); extern void HandleStartupProcInterrupts(void);
extern void StartupProcessMain(void) __attribute__((noreturn)); extern void StartupProcessMain(void) pg_attribute_noreturn;
extern void PreRestoreCommand(void); extern void PreRestoreCommand(void);
extern void PostRestoreCommand(void); extern void PostRestoreCommand(void);
extern bool IsPromoteTriggered(void); extern bool IsPromoteTriggered(void);

View File

@ -84,7 +84,7 @@ extern int SysLogger_Start(void);
extern void write_syslogger_file(const char *buffer, int count, int dest); extern void write_syslogger_file(const char *buffer, int count, int dest);
#ifdef EXEC_BACKEND #ifdef EXEC_BACKEND
extern void SysLoggerMain(int argc, char *argv[]) __attribute__((noreturn)); extern void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn;
#endif #endif
#endif /* _SYSLOGGER_H */ #endif /* _SYSLOGGER_H */

View File

@ -15,6 +15,6 @@
/* GUC options */ /* GUC options */
extern int WalWriterDelay; extern int WalWriterDelay;
extern void WalWriterMain(void) __attribute__((noreturn)); extern void WalWriterMain(void) pg_attribute_noreturn;
#endif /* _WALWRITER_H */ #endif /* _WALWRITER_H */

View File

@ -147,7 +147,7 @@ typedef void (*walrcv_disconnect_type) (void);
extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect; extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect;
/* prototypes for functions in walreceiver.c */ /* prototypes for functions in walreceiver.c */
extern void WalReceiverMain(void) __attribute__((noreturn)); extern void WalReceiverMain(void) pg_attribute_noreturn;
/* prototypes for functions in walreceiverfuncs.c */ /* prototypes for functions in walreceiverfuncs.c */
extern Size WalRcvShmemSize(void); extern Size WalRcvShmemSize(void);

View File

@ -64,7 +64,7 @@ typedef void (*shmem_startup_hook_type) (void);
/* ipc.c */ /* ipc.c */
extern PGDLLIMPORT bool proc_exit_inprogress; extern PGDLLIMPORT bool proc_exit_inprogress;
extern void proc_exit(int code) __attribute__((noreturn)); extern void proc_exit(int code) pg_attribute_noreturn;
extern void shmem_exit(int code); extern void shmem_exit(int code);
extern void on_proc_exit(pg_on_exit_callback function, Datum arg); extern void on_proc_exit(pg_on_exit_callback function, Datum arg);
extern void on_shmem_exit(pg_on_exit_callback function, Datum arg); extern void on_shmem_exit(pg_on_exit_callback function, Datum arg);

View File

@ -41,7 +41,7 @@ typedef struct ItemPointerData
} }
#ifdef __arm__ #ifdef __arm__
__attribute__((packed)) /* Appropriate whack upside the head for ARM */ pg_attribute_packed /* Appropriate whack upside the head for ARM */
#endif #endif
ItemPointerData; ItemPointerData;

View File

@ -547,7 +547,7 @@ extern void lock_twophase_standby_recover(TransactionId xid, uint16 info,
extern DeadLockState DeadLockCheck(PGPROC *proc); extern DeadLockState DeadLockCheck(PGPROC *proc);
extern PGPROC *GetBlockingAutoVacuumPgproc(void); extern PGPROC *GetBlockingAutoVacuumPgproc(void);
extern void DeadLockReport(void) __attribute__((noreturn)); extern void DeadLockReport(void) pg_attribute_noreturn;
extern void RememberSimpleDeadLock(PGPROC *proc1, extern void RememberSimpleDeadLock(PGPROC *proc1,
LOCKMODE lockmode, LOCKMODE lockmode,
LOCK *lock, LOCK *lock,

View File

@ -62,9 +62,9 @@ extern bool check_max_stack_depth(int *newval, void **extra, GucSource source);
extern void assign_max_stack_depth(int newval, void *extra); extern void assign_max_stack_depth(int newval, void *extra);
extern void die(SIGNAL_ARGS); extern void die(SIGNAL_ARGS);
extern void quickdie(SIGNAL_ARGS) __attribute__((noreturn)); extern void quickdie(SIGNAL_ARGS) pg_attribute_noreturn;
extern void StatementCancelHandler(SIGNAL_ARGS); extern void StatementCancelHandler(SIGNAL_ARGS);
extern void FloatExceptionHandler(SIGNAL_ARGS) __attribute__((noreturn)); extern void FloatExceptionHandler(SIGNAL_ARGS) pg_attribute_noreturn;
extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from SIGUSR1 extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from SIGUSR1
* handler */ * handler */
extern void ProcessClientReadInterrupt(bool blocked); extern void ProcessClientReadInterrupt(bool blocked);
@ -74,7 +74,7 @@ extern void process_postgres_switches(int argc, char *argv[],
GucContext ctx, const char **dbname); GucContext ctx, const char **dbname);
extern void PostgresMain(int argc, char *argv[], extern void PostgresMain(int argc, char *argv[],
const char *dbname, const char *dbname,
const char *username) __attribute__((noreturn)); const char *username) pg_attribute_noreturn;
extern long get_stack_depth_rlimit(void); extern long get_stack_depth_rlimit(void);
extern void ResetUsage(void); extern void ResetUsage(void);
extern void ShowUsage(const char *title); extern void ShowUsage(const char *title);

View File

@ -315,7 +315,7 @@ extern int DecodeISO8601Interval(char *str,
int *dtype, struct pg_tm * tm, fsec_t *fsec); int *dtype, struct pg_tm * tm, fsec_t *fsec);
extern void DateTimeParseError(int dterr, const char *str, extern void DateTimeParseError(int dterr, const char *str,
const char *datatype) __attribute__((noreturn)); const char *datatype) pg_attribute_noreturn;
extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp); extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp);
extern int DetermineTimeZoneAbbrevOffset(struct pg_tm * tm, const char *abbr, pg_tz *tzp); extern int DetermineTimeZoneAbbrevOffset(struct pg_tm * tm, const char *abbr, pg_tz *tzp);

View File

@ -147,61 +147,61 @@ extern int
errmsg(const char *fmt,...) errmsg(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int extern int
errmsg_internal(const char *fmt,...) errmsg_internal(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int extern int
errmsg_plural(const char *fmt_singular, const char *fmt_plural, errmsg_plural(const char *fmt_singular, const char *fmt_plural,
unsigned long n,...) unsigned long n,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4))) pg_attribute_printf(1, 4)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4))); pg_attribute_printf(2, 4);
extern int extern int
errdetail(const char *fmt,...) errdetail(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int extern int
errdetail_internal(const char *fmt,...) errdetail_internal(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int extern int
errdetail_log(const char *fmt,...) errdetail_log(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int extern int
errdetail_log_plural(const char *fmt_singular, const char *fmt_plural, errdetail_log_plural(const char *fmt_singular, const char *fmt_plural,
unsigned long n,...) unsigned long n,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4))) pg_attribute_printf(1, 4)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4))); pg_attribute_printf(2, 4);
extern int extern int
errdetail_plural(const char *fmt_singular, const char *fmt_plural, errdetail_plural(const char *fmt_singular, const char *fmt_plural,
unsigned long n,...) unsigned long n,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 4))) pg_attribute_printf(1, 4)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 4))); pg_attribute_printf(2, 4);
extern int extern int
errhint(const char *fmt,...) errhint(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
/* /*
* errcontext() is typically called in error context callback functions, not * errcontext() is typically called in error context callback functions, not
@ -218,7 +218,7 @@ extern int
errcontext_msg(const char *fmt,...) errcontext_msg(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern int errhidestmt(bool hide_stmt); extern int errhidestmt(bool hide_stmt);
extern int errhidecontext(bool hide_ctx); extern int errhidecontext(bool hide_ctx);
@ -278,7 +278,7 @@ extern void
elog_finish(int elevel, const char *fmt,...) elog_finish(int elevel, const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
/* Support for constructing error strings separately from ereport() calls */ /* Support for constructing error strings separately from ereport() calls */
@ -288,7 +288,7 @@ extern char *
format_elog_string(const char *fmt,...) format_elog_string(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
/* Support for attaching context information to error reports */ /* Support for attaching context information to error reports */
@ -364,7 +364,7 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
} while (0) } while (0)
/* /*
* gcc understands __attribute__((noreturn)); for other compilers, insert * gcc understands pg_attribute_noreturn; for other compilers, insert
* pg_unreachable() so that the compiler gets the point. * pg_unreachable() so that the compiler gets the point.
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
@ -423,9 +423,9 @@ extern void EmitErrorReport(void);
extern ErrorData *CopyErrorData(void); extern ErrorData *CopyErrorData(void);
extern void FreeErrorData(ErrorData *edata); extern void FreeErrorData(ErrorData *edata);
extern void FlushErrorState(void); extern void FlushErrorState(void);
extern void ReThrowError(ErrorData *edata) __attribute__((noreturn)); extern void ReThrowError(ErrorData *edata) pg_attribute_noreturn;
extern void ThrowErrorData(ErrorData *edata); extern void ThrowErrorData(ErrorData *edata);
extern void pg_re_throw(void) __attribute__((noreturn)); extern void pg_re_throw(void) pg_attribute_noreturn;
extern char *GetErrorContextStack(void); extern char *GetErrorContextStack(void);
@ -472,6 +472,6 @@ extern void
write_stderr(const char *fmt,...) write_stderr(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
#endif /* ELOG_H */ #endif /* ELOG_H */

View File

@ -12,6 +12,6 @@
#ifndef HELP_CONFIG_H #ifndef HELP_CONFIG_H
#define HELP_CONFIG_H 1 #define HELP_CONFIG_H 1
extern void GucInfoMain(void) __attribute__((noreturn)); extern void GucInfoMain(void) pg_attribute_noreturn;
#endif #endif

View File

@ -138,9 +138,9 @@ extern char *pnstrdup(const char *in, Size len);
/* sprintf into a palloc'd buffer --- these are in psprintf.c */ /* sprintf into a palloc'd buffer --- these are in psprintf.c */
extern char * extern char *
psprintf(const char *fmt,...) psprintf(const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
extern size_t extern size_t
pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pvsnprintf(char *buf, size_t len, const char *fmt, va_list args)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))); pg_attribute_printf(3, 0);
#endif /* PALLOC_H */ #endif /* PALLOC_H */

View File

@ -185,7 +185,7 @@ void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat); void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
char *ecpg_prepared(const char *, struct connection *); char *ecpg_prepared(const char *, struct connection *);
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn); bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn);
void ecpg_log(const char *format,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); void ecpg_log(const char *format,...) pg_attribute_printf(1, 2);
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *); bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
void ecpg_init_sqlca(struct sqlca_t * sqlca); void ecpg_init_sqlca(struct sqlca_t * sqlca);

View File

@ -15,7 +15,7 @@
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
extern char * extern char *
ecpg_gettext(const char *msgid) ecpg_gettext(const char *msgid)
__attribute__((format_arg(1))); pg_attribute_format_arg(1);
#else #else
#define ecpg_gettext(x) (x) #define ecpg_gettext(x) (x)
#endif #endif

View File

@ -64,7 +64,7 @@ static struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NUL
/* /*
* Handle parsing errors and warnings * Handle parsing errors and warnings
*/ */
static void __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0))) static void pg_attribute_printf(3, 0)
vmmerror(int error_code, enum errortype type, const char *error, va_list ap) vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
{ {
/* localize the error message string */ /* localize the error message string */

View File

@ -77,8 +77,8 @@ extern int base_yylex(void);
extern void base_yyerror(const char *); extern void base_yyerror(const char *);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t); extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *); extern char *mm_strdup(const char *);
extern void mmerror(int errorcode, enum errortype type, const char *error,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); extern void mmerror(int errorcode, enum errortype type, const char *error,...) pg_attribute_printf(3, 4);
extern void mmfatal(int errorcode, const char *error,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3), noreturn)); extern void mmfatal(int errorcode, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn;
extern void output_get_descr_header(char *); extern void output_get_descr_header(char *);
extern void output_get_descr(char *, char *); extern void output_get_descr(char *, char *);
extern void output_set_descr_header(char *); extern void output_set_descr_header(char *);

View File

@ -548,7 +548,7 @@ extern PGresult *pqPrepareAsyncResult(PGconn *conn);
extern void extern void
pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...) pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
/* This lets gcc check the format string for consistency. */ /* This lets gcc check the format string for consistency. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern void pqSaveMessageField(PGresult *res, char code, extern void pqSaveMessageField(PGresult *res, char code,
const char *value); const char *value);
extern void pqSaveParameterStatus(PGconn *conn, const char *name, extern void pqSaveParameterStatus(PGconn *conn, const char *name,
@ -653,10 +653,10 @@ extern ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len);
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
extern char * extern char *
libpq_gettext(const char *msgid) libpq_gettext(const char *msgid)
__attribute__((format_arg(1))); pg_attribute_format_arg(1);
extern char * extern char *
libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n) libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n)
__attribute__((format_arg(1))) __attribute__((format_arg(2))); pg_attribute_format_arg(1) pg_attribute_format_arg(2);
#else #else
#define libpq_gettext(x) (x) #define libpq_gettext(x) (x)
#define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p)) #define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p))

View File

@ -39,7 +39,7 @@ static const char oom_buffer[1] = "";
static bool static bool
appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args) appendPQExpBufferVA(PQExpBuffer str, const char *fmt, va_list args)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0))); pg_attribute_printf(2, 0);
/* /*

View File

@ -149,7 +149,7 @@ extern int enlargePQExpBuffer(PQExpBuffer str, size_t needed);
extern void extern void
printfPQExpBuffer(PQExpBuffer str, const char *fmt,...) printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
/*------------------------ /*------------------------
* appendPQExpBuffer * appendPQExpBuffer
@ -161,7 +161,7 @@ __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
extern void extern void
appendPQExpBuffer(PQExpBuffer str, const char *fmt,...) appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
/* This extension allows gcc to check the format string */ /* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
/*------------------------ /*------------------------
* appendPQExpBufferStr * appendPQExpBufferStr

View File

@ -36,7 +36,7 @@
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
extern char * extern char *
libpq_gettext(const char *msgid) libpq_gettext(const char *msgid)
__attribute__((format_arg(1))); pg_attribute_format_arg(1);
#else #else
#define libpq_gettext(x) (x) #define libpq_gettext(x) (x)
#endif #endif

View File

@ -30,9 +30,7 @@
* Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one * Supply a value of PERL_UNUSED_DECL that will satisfy gcc - the one
* perl itself supplies doesn't seem to. * perl itself supplies doesn't seem to.
*/ */
#if defined(__GNUC__) #define PERL_UNUSED_DECL pg_attribute_unused
#define PERL_UNUSED_DECL __attribute__ ((unused))
#endif
/* /*
* Sometimes perl carefully scribbles on our *printf macros. * Sometimes perl carefully scribbles on our *printf macros.

View File

@ -608,7 +608,7 @@ plpgsql_scanner_errposition(int location)
* be misleading! * be misleading!
*/ */
void void
__attribute__((noreturn)) pg_attribute_noreturn
plpgsql_yyerror(const char *message) plpgsql_yyerror(const char *message)
{ {
char *yytext = core_yy.scanbuf + plpgsql_yylloc; char *yytext = core_yy.scanbuf + plpgsql_yylloc;

View File

@ -12,16 +12,16 @@ extern PyObject *PLy_exc_spi_error;
extern void extern void
PLy_elog(int elevel, const char *fmt,...) PLy_elog(int elevel, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern void extern void
PLy_exception_set(PyObject *exc, const char *fmt,...) PLy_exception_set(PyObject *exc, const char *fmt,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
extern void extern void
PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural, PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural,
unsigned long n,...) unsigned long n,...)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 5))) pg_attribute_printf(2, 5)
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 5))); pg_attribute_printf(3, 5);
#endif /* PLPY_ELOG_H */ #endif /* PLPY_ELOG_H */

View File

@ -40,6 +40,6 @@ extern void test_shm_mq_setup(int64 queue_size, int32 nworkers,
shm_mq_handle **input); shm_mq_handle **input);
/* Main entrypoint for a worker. */ /* Main entrypoint for a worker. */
extern void test_shm_mq_main(Datum) __attribute__((noreturn)); extern void test_shm_mq_main(Datum) pg_attribute_noreturn;
#endif #endif

View File

@ -46,7 +46,7 @@ PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(worker_spi_launch); PG_FUNCTION_INFO_V1(worker_spi_launch);
void _PG_init(void); void _PG_init(void);
void worker_spi_main(Datum) __attribute__((noreturn)); void worker_spi_main(Datum) pg_attribute_noreturn;
/* flags set by signal handlers */ /* flags set by signal handlers */
static volatile sig_atomic_t got_sighup = false; static volatile sig_atomic_t got_sighup = false;

View File

@ -135,17 +135,17 @@ static void
header(const char *fmt,...) header(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
static void static void
status(const char *fmt,...) status(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2))); pg_attribute_printf(1, 2);
static void static void
psql_command(const char *database, const char *query,...) psql_command(const char *database, const char *query,...)
/* This extension allows gcc to check the format string for consistency with /* This extension allows gcc to check the format string for consistency with
the supplied arguments. */ the supplied arguments. */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); pg_attribute_printf(2, 3);
#ifdef WIN32 #ifdef WIN32
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE); typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);