pg_noreturn to replace pg_attribute_noreturn()

We want to support a "noreturn" decoration on more compilers besides
just GCC-compatible ones, but for that we need to move the decoration
in front of the function declaration instead of either behind it or
wherever, which is the current style afforded by GCC-style attributes.
Also rename the macro to "pg_noreturn" to be similar to the C11
standard "noreturn".

pg_noreturn is now supported on all compilers that support C11 (using
_Noreturn), as well as GCC-compatible ones (using __attribute__, as
before), as well as MSVC (using __declspec).  (When PostgreSQL
requires C11, the latter two variants can be dropped.)

Now, all supported compilers effectively support pg_noreturn, so the
extra code for !HAVE_PG_ATTRIBUTE_NORETURN can be dropped.

This also fixes a possible problem if third-party code includes
stdnoreturn.h, because then the current definition of

    #define pg_attribute_noreturn() __attribute__((noreturn))

would cause an error.

Note that the C standard does not support a noreturn attribute on
function pointer types.  So we have to drop these here.  There are
only two instances at this time, so it's not a big loss.  In one case,
we can make up for it by adding the pg_noreturn to a wrapper function
and adding a pg_unreachable(), in the other case, the latter was
already done before.

Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/pxr5b3z7jmkpenssra5zroxi7qzzp6eswuggokw64axmdixpnk@zbwxuq7gbbcw
This commit is contained in:
Peter Eisentraut 2025-03-13 12:25:14 +01:00
parent cc5d98525d
commit 3691edfab9
54 changed files with 118 additions and 118 deletions

View File

@ -160,8 +160,7 @@ xpstrdup(const char *in)
return pstrdup(in);
}
static void
pg_attribute_noreturn()
pg_noreturn static void
dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2)
{
char *msg = pchomp(PQerrorMessage(conn));
@ -170,8 +169,7 @@ dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2)
elog(ERROR, "%s: %s", p2, msg);
}
static void
pg_attribute_noreturn()
pg_noreturn static void
dblink_conn_not_avail(const char *conname)
{
if (conname)

View File

@ -181,7 +181,7 @@ int px_find_hmac(const char *name, PX_HMAC **res);
int px_find_cipher(const char *name, PX_Cipher **res);
int px_find_combo(const char *name, PX_Combo **res);
void px_THROW_ERROR(int err) pg_attribute_noreturn();
pg_noreturn void px_THROW_ERROR(int err);
const char *px_strerror(int err);
const char *px_resolve_alias(const PX_Alias *list, const char *name);

View File

@ -4778,8 +4778,7 @@ check_primary_slot_name(char **newval, void **extra, GucSource source)
* that we have odd behaviors such as unexpected GUC ordering dependencies.
*/
static void
pg_attribute_noreturn()
pg_noreturn static void
error_multiple_recovery_targets(void)
{
ereport(ERROR,

View File

@ -139,9 +139,9 @@ static void manifest_process_wal_range(JsonManifestParseContext *context,
TimeLineID tli,
XLogRecPtr start_lsn,
XLogRecPtr end_lsn);
static void manifest_report_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3) pg_attribute_noreturn();
pg_noreturn static void manifest_report_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3);
static int compare_block_numbers(const void *a, const void *b);
/*

View File

@ -317,7 +317,7 @@ int AutovacuumLauncherPid = 0;
static Oid do_start_worker(void);
static void ProcessAutoVacLauncherInterrupts(void);
static void AutoVacLauncherShutdown(void) pg_attribute_noreturn();
pg_noreturn static void AutoVacLauncherShutdown(void);
static void launcher_determine_sleep(bool canlaunch, bool recursing,
struct timeval *nap);
static void launch_worker(TimestampTz now);

View File

@ -171,7 +171,7 @@ static pid_t internal_forkexec(const char *child_kind, int child_slot,
typedef struct
{
const char *name;
void (*main_fn) (const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
void (*main_fn) (const void *startup_data, size_t startup_data_len);
bool shmem_attach;
} child_process_kind;

View File

@ -425,7 +425,7 @@ static void LogChildExit(int lev, const char *procname,
static void PostmasterStateMachine(void);
static void UpdatePMState(PMState newState);
static void ExitPostmaster(int status) pg_attribute_noreturn();
pg_noreturn static void ExitPostmaster(int status);
static int ServerLoop(void);
static int BackendStartup(ClientSocket *client_sock);
static void report_fork_failure_to_client(ClientSocket *client_sock, int errnum);

View File

@ -139,8 +139,7 @@ static StringInfo copybuf = NULL;
/*
* Exit routine for synchronization worker.
*/
static void
pg_attribute_noreturn()
pg_noreturn static void
finish_sync_worker(void)
{
/*

View File

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

View File

@ -235,10 +235,10 @@ static bool ri_PerformCheck(const RI_ConstraintInfo *riinfo,
static void ri_ExtractValues(Relation rel, TupleTableSlot *slot,
const RI_ConstraintInfo *riinfo, bool rel_is_pk,
Datum *vals, char *nulls);
static void ri_ReportViolation(const RI_ConstraintInfo *riinfo,
Relation pk_rel, Relation fk_rel,
TupleTableSlot *violatorslot, TupleDesc tupdesc,
int queryno, bool is_restrict, bool partgone) pg_attribute_noreturn();
pg_noreturn static void ri_ReportViolation(const RI_ConstraintInfo *riinfo,
Relation pk_rel, Relation fk_rel,
TupleTableSlot *violatorslot, TupleDesc tupdesc,
int queryno, bool is_restrict, bool partgone);
/*

View File

@ -67,8 +67,8 @@ static DynamicFileList *file_tail = NULL;
char *Dynamic_library_path;
static void *internal_load_library(const char *libname);
static void incompatible_module_error(const char *libname,
const Pg_magic_struct *module_magic_data) pg_attribute_noreturn();
pg_noreturn static void incompatible_module_error(const char *libname,
const Pg_magic_struct *module_magic_data);
static char *expand_dynamic_library_name(const char *name);
static void check_restricted_library_name(const char *name);
static char *substitute_libpath_macro(const char *name);

View File

@ -272,7 +272,7 @@ static HASHBUCKET get_hash_entry(HTAB *hashp, int freelist_idx);
static void hdefault(HTAB *hashp);
static int choose_nelem_alloc(Size entrysize);
static bool init_htab(HTAB *hashp, long nelem);
static void hash_corrupted(HTAB *hashp) pg_attribute_noreturn();
pg_noreturn static void hash_corrupted(HTAB *hashp);
static uint32 hash_initial_lookup(HTAB *hashp, uint32 hashvalue,
HASHBUCKET **bucketptr);
static long next_pow2_long(long num);

View File

@ -601,8 +601,8 @@ SlabAllocFromNewBlock(MemoryContext context, Size size, int flags)
* want to avoid that.
*/
pg_noinline
pg_noreturn
static void
pg_attribute_noreturn()
SlabAllocInvalidSize(MemoryContext context, Size size)
{
SlabContext *slab = (SlabContext *) context;

View File

@ -68,9 +68,9 @@ static void combinebackup_per_wal_range_cb(JsonManifestParseContext *context,
TimeLineID tli,
XLogRecPtr start_lsn,
XLogRecPtr end_lsn);
static void report_manifest_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3) pg_attribute_noreturn();
pg_noreturn static void report_manifest_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3);
/*
* Load backup_manifest files from an array of backups and produces an array

View File

@ -29,7 +29,7 @@ extern const char *progname;
extern void set_dump_section(const char *arg, int *dumpSections);
extern void on_exit_nicely(on_exit_nicely_callback function, void *arg);
extern void exit_nicely(int code) pg_attribute_noreturn();
pg_noreturn extern void exit_nicely(int code);
/* In pg_dump, we modify pg_fatal to call exit_nicely instead of exit */
#undef pg_fatal

View File

@ -481,7 +481,7 @@ int get_user_info(char **user_name_p);
void check_ok(void);
void report_status(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2) pg_attribute_noreturn();
pg_noreturn void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2);
void end_progress_output(void);
void cleanup_output_dirs(void);
void prep_status(const char *fmt,...) pg_attribute_printf(1, 2);

View File

@ -69,9 +69,9 @@ static void verifybackup_per_wal_range_cb(JsonManifestParseContext *context,
TimeLineID tli,
XLogRecPtr start_lsn,
XLogRecPtr end_lsn);
static void report_manifest_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3) pg_attribute_noreturn();
pg_noreturn static void report_manifest_error(JsonManifestParseContext *context,
const char *fmt,...)
pg_attribute_printf(2, 3);
static void verify_tar_backup(verifier_context *context, DIR *dir);
static void verify_plain_backup_directory(verifier_context *context,

View File

@ -98,8 +98,8 @@ typedef struct verifier_context
extern void report_backup_error(verifier_context *context,
const char *pg_restrict fmt,...)
pg_attribute_printf(2, 3);
extern void report_fatal_error(const char *pg_restrict fmt,...)
pg_attribute_printf(1, 2) pg_attribute_noreturn();
pg_noreturn extern void report_fatal_error(const char *pg_restrict fmt,...)
pg_attribute_printf(1, 2);
extern bool should_ignore_relpath(verifier_context *context,
const char *relpath);

View File

@ -140,9 +140,9 @@ struct PgBenchExprList
extern int expr_yyparse(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner);
extern int expr_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner);
extern void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn();
extern void expr_yyerror_more(yyscan_t yyscanner, const char *message,
const char *more) pg_attribute_noreturn();
pg_noreturn extern void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message);
pg_noreturn extern void expr_yyerror_more(yyscan_t yyscanner, const char *message,
const char *more);
extern bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf,
int *offset);
extern yyscan_t expr_scanner_init(PsqlScanState state,
@ -153,9 +153,9 @@ extern char *expr_scanner_get_substring(PsqlScanState state,
int start_offset,
bool chomp);
extern void syntax_error(const char *source, int lineno, const char *line,
const char *command, const char *msg,
const char *more, int column) pg_attribute_noreturn();
pg_noreturn extern void syntax_error(const char *source, int lineno, const char *line,
const char *command, const char *msg,
const char *more, int column);
extern bool strtoint64(const char *str, bool errorOK, int64 *result);
extern bool strtodouble(const char *str, bool errorOK, double *dv);

View File

@ -114,8 +114,8 @@ static void json_manifest_finalize_wal_range(JsonManifestParseState *parse);
static void verify_manifest_checksum(JsonManifestParseState *parse,
const char *buffer, size_t size,
pg_cryptohash_ctx *incr_ctx);
static void json_manifest_parse_failure(JsonManifestParseContext *context,
char *msg);
pg_noreturn static void json_manifest_parse_failure(JsonManifestParseContext *context,
char *msg);
static int hexdecode_char(char c);
static bool hexdecode_string(uint8 *result, char *input, int nbytes);
@ -889,6 +889,7 @@ static void
json_manifest_parse_failure(JsonManifestParseContext *context, char *msg)
{
context->error_cb(context, "could not parse backup manifest: %s", msg);
pg_unreachable();
}
/*

View File

@ -33,7 +33,7 @@ extern PGDLLIMPORT Form_pg_attribute attrtypes[MAXATTR];
extern PGDLLIMPORT int numattr;
extern void BootstrapModeMain(int argc, char *argv[], bool check_only) pg_attribute_noreturn();
pg_noreturn extern void BootstrapModeMain(int argc, char *argv[], bool check_only);
extern void closerel(char *relname);
extern void boot_openrel(char *relname);
@ -64,6 +64,6 @@ typedef void *yyscan_t;
extern int boot_yyparse(yyscan_t yyscanner);
extern int boot_yylex_init(yyscan_t *yyscannerp);
extern int boot_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner);
extern void boot_yyerror(yyscan_t yyscanner, const char *message) pg_attribute_noreturn();
pg_noreturn extern void boot_yyerror(yyscan_t yyscanner, const char *message);
#endif /* BOOTSTRAP_H */

View File

@ -145,6 +145,26 @@
#define pg_nodiscard
#endif
/*
* pg_noreturn corresponds to the C11 noreturn/_Noreturn function specifier.
* We can't use the standard name "noreturn" because some third-party code
* uses __attribute__((noreturn)) in headers, which would get confused if
* "noreturn" is defined to "_Noreturn", as is done by <stdnoreturn.h>.
*
* In a declaration, function specifiers go before the function name. The
* common style is to put them before the return type. (The MSVC fallback has
* the same requirement. The GCC fallback is more flexible.)
*/
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define pg_noreturn _Noreturn
#elif defined(__GNUC__) || defined(__SUNPRO_C)
#define pg_noreturn __attribute__((noreturn))
#elif defined(_MSC_VER)
#define pg_noreturn __declspec(noreturn)
#else
#define pg_noreturn
#endif
/*
* This macro will disable address safety instrumentation for a function
* when running with "-fsanitize=address". Think twice before using this!
@ -213,30 +233,24 @@
#define pg_attribute_printf(f,a)
#endif
/* GCC and Sunpro support aligned, packed and noreturn */
/* GCC and Sunpro support aligned and packed */
#if defined(__GNUC__) || defined(__SUNPRO_C)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#define pg_attribute_noreturn() __attribute__((noreturn))
#define pg_attribute_packed() __attribute__((packed))
#define HAVE_PG_ATTRIBUTE_NORETURN 1
#elif defined(_MSC_VER)
/*
* MSVC supports aligned. noreturn is also possible but in MSVC it is
* declared before the definition while pg_attribute_noreturn() macro
* is currently used after the definition.
* MSVC supports aligned.
*
* Packing is also possible but only by wrapping the entire struct definition
* which doesn't fit into our current macro declarations.
*/
#define pg_attribute_aligned(a) __declspec(align(a))
#define pg_attribute_noreturn()
#else
/*
* NB: aligned and packed are not given default definitions because they
* affect code functionality; they *must* be implemented by the compiler
* if they are to be used.
*/
#define pg_attribute_noreturn()
#endif
/*
@ -858,8 +872,8 @@ typedef NameData *Name;
* we should declare it as long as !FRONTEND.
*/
#ifndef FRONTEND
extern void ExceptionalCondition(const char *conditionName,
const char *fileName, int lineNumber) pg_attribute_noreturn();
pg_noreturn extern void ExceptionalCondition(const char *conditionName,
const char *fileName, int lineNumber);
#endif
/*

View File

@ -160,6 +160,6 @@ extern List *defGetQualifiedName(DefElem *def);
extern TypeName *defGetTypeName(DefElem *def);
extern int defGetTypeLength(DefElem *def);
extern List *defGetStringList(DefElem *def);
extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate) pg_attribute_noreturn();
pg_noreturn extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate);
#endif /* DEFREM_H */

View File

@ -34,8 +34,7 @@ typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext *
TimeLineID tli,
XLogRecPtr start_lsn, XLogRecPtr end_lsn);
typedef void (*json_manifest_error_callback) (JsonManifestParseContext *,
const char *fmt,...) pg_attribute_printf(2, 3)
pg_attribute_noreturn();
const char *fmt,...) pg_attribute_printf(2, 3);
struct JsonManifestParseContext
{

View File

@ -768,9 +768,9 @@ extern void check_encoding_conversion_args(int src_encoding,
int expected_src_encoding,
int expected_dest_encoding);
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,
const char *mbstr, int len) pg_attribute_noreturn();
pg_noreturn extern void report_invalid_encoding(int encoding, const char *mbstr, int len);
pg_noreturn extern void report_untranslatable_char(int src_encoding, int dest_encoding,
const char *mbstr, int len);
extern int local2local(const unsigned char *l, unsigned char *p, int len,
int src_encoding, int dest_encoding,

View File

@ -110,9 +110,9 @@ extern bool isLockedRefname(ParseState *pstate, const char *refname);
extern void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem,
bool addToJoinList,
bool addToRelNameSpace, bool addToVarNameSpace);
extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn();
extern void errorMissingColumn(ParseState *pstate,
const char *relname, const char *colname, int location) pg_attribute_noreturn();
pg_noreturn extern void errorMissingRTE(ParseState *pstate, RangeVar *relation);
pg_noreturn extern void errorMissingColumn(ParseState *pstate,
const char *relname, const char *colname, int location);
extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
VarReturningType returning_type,
int location, bool include_dropped,

View File

@ -145,6 +145,6 @@ extern void setup_scanner_errposition_callback(ScannerCallbackState *scbstate,
core_yyscan_t yyscanner,
int location);
extern void cancel_scanner_errposition_callback(ScannerCallbackState *scbstate);
extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) pg_attribute_noreturn();
pg_noreturn extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner);
#endif /* SCANNER_H */

View File

@ -58,8 +58,8 @@ extern void autovac_init(void);
/* called from postmaster when a worker could not be forked */
extern void AutoVacWorkerFailed(void);
extern void AutoVacLauncherMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
extern void AutoVacWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void AutoVacLauncherMain(const void *startup_data, size_t startup_data_len);
pg_noreturn extern void AutoVacWorkerMain(const void *startup_data, size_t startup_data_len);
extern bool AutoVacuumRequestWork(AutoVacuumWorkItemType type,
Oid relationId, BlockNumber blkno);

View File

@ -52,6 +52,6 @@ extern void ForgetUnstartedBackgroundWorkers(void);
extern void ResetBackgroundWorkerCrashTimes(void);
/* Entry point for background worker processes */
extern void BackgroundWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void BackgroundWorkerMain(const void *startup_data, size_t startup_data_len);
#endif /* BGWORKER_INTERNALS_H */

View File

@ -27,8 +27,8 @@ extern PGDLLIMPORT int CheckPointTimeout;
extern PGDLLIMPORT int CheckPointWarning;
extern PGDLLIMPORT double CheckPointCompletionTarget;
extern void BackgroundWriterMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
extern void CheckpointerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void BackgroundWriterMain(const void *startup_data, size_t startup_data_len);
pg_noreturn extern void CheckpointerMain(const void *startup_data, size_t startup_data_len);
extern void RequestCheckpoint(int flags);
extern void CheckpointWriteDelay(int flags, double progress);

View File

@ -29,7 +29,7 @@
extern Size PgArchShmemSize(void);
extern void PgArchShmemInit(void);
extern bool PgArchCanRestart(void);
extern void PgArchiverMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void PgArchiverMain(const void *startup_data, size_t startup_data_len);
extern void PgArchWakeup(void);
extern void PgArchForceDirScan(void);

View File

@ -90,7 +90,7 @@ extern PGDLLIMPORT const char *progname;
extern PGDLLIMPORT bool redirection_done;
extern PGDLLIMPORT bool LoadedSSL;
extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
pg_noreturn extern void PostmasterMain(int argc, char *argv[]);
extern void ClosePostmasterPorts(bool am_syslogger);
extern void InitProcessGlobals(void);
@ -113,7 +113,7 @@ extern pid_t postmaster_child_launch(BackendType child_type,
struct ClientSocket *client_sock);
const char *PostmasterChildName(BackendType child_type);
#ifdef EXEC_BACKEND
extern void SubPostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
pg_noreturn extern void SubPostmasterMain(int argc, char *argv[]);
#endif
/* defined in pmchild.c */

View File

@ -26,7 +26,7 @@
extern PGDLLIMPORT int log_startup_progress_interval;
extern void ProcessStartupProcInterrupts(void);
extern void StartupProcessMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void StartupProcessMain(const void *startup_data, size_t startup_data_len);
extern void PreRestoreCommand(void);
extern void PostRestoreCommand(void);
extern bool IsPromoteSignaled(void);

View File

@ -90,7 +90,7 @@ extern int SysLogger_Start(int child_slot);
extern void write_syslogger_file(const char *buffer, int count, int destination);
extern void SysLoggerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void SysLoggerMain(const void *startup_data, size_t startup_data_len);
extern bool CheckLogrotateSignal(void);
extern void RemoveLogrotateSignalFiles(void);

View File

@ -21,7 +21,7 @@ extern PGDLLIMPORT int wal_summary_keep_time;
extern Size WalSummarizerShmemSize(void);
extern void WalSummarizerShmemInit(void);
extern void WalSummarizerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void WalSummarizerMain(const void *startup_data, size_t startup_data_len);
extern void GetWalSummarizerState(TimeLineID *summarized_tli,
XLogRecPtr *summarized_lsn,

View File

@ -18,6 +18,6 @@
extern PGDLLIMPORT int WalWriterDelay;
extern PGDLLIMPORT int WalWriterFlushAfter;
extern void WalWriterMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void WalWriterMain(const void *startup_data, size_t startup_data_len);
#endif /* _WALWRITER_H */

View File

@ -26,7 +26,7 @@ extern PGDLLIMPORT char *PrimarySlotName;
extern char *CheckAndGetDbnameFromConninfo(void);
extern bool ValidateSlotSyncParams(int elevel);
extern void ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len);
extern void ShutDownSlotSync(void);
extern bool SlotSyncWorkerCanRestart(void);

View File

@ -486,7 +486,7 @@ walrcv_clear_result(WalRcvExecResult *walres)
}
/* prototypes for functions in walreceiver.c */
extern void WalReceiverMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void WalReceiverMain(const void *startup_data, size_t startup_data_len);
extern void ProcessWalRcvInterrupts(void);
extern void WalRcvForceReply(void);

View File

@ -132,7 +132,7 @@ typedef void *yyscan_t;
#endif
extern int replication_yyparse(Node **replication_parse_result_p, yyscan_t yyscanner);
extern int replication_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner);
extern void replication_yyerror(Node **replication_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn();
pg_noreturn extern void replication_yyerror(Node **replication_parse_result_p, yyscan_t yyscanner, const char *message);
extern void replication_scanner_init(const char *str, yyscan_t *yyscannerp);
extern void replication_scanner_finish(yyscan_t yyscanner);
extern bool replication_scanner_is_replication_command(yyscan_t yyscanner);

View File

@ -65,7 +65,7 @@ typedef void (*shmem_startup_hook_type) (void);
extern PGDLLIMPORT bool proc_exit_inprogress;
extern PGDLLIMPORT bool shmem_exit_inprogress;
extern void proc_exit(int code) pg_attribute_noreturn();
pg_noreturn extern void proc_exit(int code);
extern void shmem_exit(int code);
extern void on_proc_exit(pg_on_exit_callback function, Datum arg);
extern void on_shmem_exit(pg_on_exit_callback function, Datum arg);

View File

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

View File

@ -117,6 +117,6 @@ typedef struct ConnectionTiming
TimestampTz auth_end;
} ConnectionTiming;
extern void BackendMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn();
pg_noreturn extern void BackendMain(const void *startup_data, size_t startup_data_len);
#endif /* BACKEND_STARTUP_H */

View File

@ -69,19 +69,19 @@ extern List *pg_plan_queries(List *querytrees, const char *query_string,
ParamListInfo boundParams);
extern void die(SIGNAL_ARGS);
extern void quickdie(SIGNAL_ARGS) pg_attribute_noreturn();
pg_noreturn extern void quickdie(SIGNAL_ARGS);
extern void StatementCancelHandler(SIGNAL_ARGS);
extern void FloatExceptionHandler(SIGNAL_ARGS) pg_attribute_noreturn();
pg_noreturn extern void FloatExceptionHandler(SIGNAL_ARGS);
extern void HandleRecoveryConflictInterrupt(ProcSignalReason reason);
extern void ProcessClientReadInterrupt(bool blocked);
extern void ProcessClientWriteInterrupt(bool blocked);
extern void process_postgres_switches(int argc, char *argv[],
GucContext ctx, const char **dbname);
extern void PostgresSingleUserMain(int argc, char *argv[],
const char *username) pg_attribute_noreturn();
extern void PostgresMain(const char *dbname,
const char *username) pg_attribute_noreturn();
pg_noreturn extern void PostgresSingleUserMain(int argc, char *argv[],
const char *username);
pg_noreturn extern void PostgresMain(const char *dbname,
const char *username);
extern void ResetUsage(void);
extern void ShowUsage(const char *title);
extern int check_log_duration(char *msec_str, bool was_logged);

View File

@ -415,17 +415,8 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
error_context_stack = _save_context_stack##__VA_ARGS__; \
} while (0)
/*
* Some compilers understand pg_attribute_noreturn(); for other compilers,
* insert pg_unreachable() so that the compiler gets the point.
*/
#ifdef HAVE_PG_ATTRIBUTE_NORETURN
#define PG_RE_THROW() \
pg_re_throw()
#else
#define PG_RE_THROW() \
(pg_re_throw(), pg_unreachable())
#endif
extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
@ -476,9 +467,9 @@ extern void EmitErrorReport(void);
extern ErrorData *CopyErrorData(void);
extern void FreeErrorData(ErrorData *edata);
extern void FlushErrorState(void);
extern void ReThrowError(ErrorData *edata) pg_attribute_noreturn();
pg_noreturn extern void ReThrowError(ErrorData *edata);
extern void ThrowErrorData(ErrorData *edata);
extern void pg_re_throw(void) pg_attribute_noreturn();
pg_noreturn extern void pg_re_throw(void);
extern char *GetErrorContextStack(void);

View File

@ -37,9 +37,9 @@ extern PGDLLIMPORT int extra_float_digits;
/*
* Utility functions in float.c
*/
extern void float_overflow_error(void) pg_attribute_noreturn();
extern void float_underflow_error(void) pg_attribute_noreturn();
extern void float_zero_divide_error(void) pg_attribute_noreturn();
pg_noreturn extern void float_overflow_error(void);
pg_noreturn extern void float_underflow_error(void);
pg_noreturn extern void float_zero_divide_error(void);
extern int is_infinite(float8 val);
extern float8 float8in_internal(char *num, char **endptr_p,
const char *type_name, const char *orig_string,

View File

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

View File

@ -160,8 +160,8 @@ extern void MemoryContextCreate(MemoryContext node,
extern void *MemoryContextAllocationFailure(MemoryContext context, Size size,
int flags);
extern void MemoryContextSizeFailure(MemoryContext context, Size size,
int flags) pg_attribute_noreturn();
pg_noreturn extern void MemoryContextSizeFailure(MemoryContext context, Size size,
int flags);
static inline void
MemoryContextCheckSize(MemoryContext context, Size size, int flags)

View File

@ -89,7 +89,7 @@ extern char *cat_str(int count,...);
extern char *make2_str(const char *str1, const char *str2);
extern char *make3_str(const char *str1, const char *str2, const char *str3);
extern void mmerror(int error_code, enum errortype type, const char *error,...) pg_attribute_printf(3, 4);
extern void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn();
pg_noreturn extern void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2, 3);
extern void output_get_descr_header(const char *desc_name);
extern void output_get_descr(const char *desc_name, const char *index);
extern void output_set_descr_header(const char *desc_name);

View File

@ -1354,7 +1354,7 @@ extern int plpgsql_peek(yyscan_t yyscanner);
extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc,
int *tok2_loc, yyscan_t yyscanner);
extern int plpgsql_scanner_errposition(int location, yyscan_t yyscanner);
extern void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn();
pg_noreturn extern void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message);
extern int plpgsql_location_to_lineno(int location, yyscan_t yyscanner);
extern int plpgsql_latest_lineno(yyscan_t yyscanner);
extern yyscan_t plpgsql_scanner_init(const char *str);

View File

@ -24,7 +24,7 @@
static void exit_nicely(PGconn *conn);
static void pg_attribute_noreturn() pg_fatal_impl(int line, const char *fmt,...)
pg_noreturn static void pg_fatal_impl(int line, const char *fmt,...)
pg_attribute_printf(2, 3);
static bool process_result(PGconn *conn, PGresult *res, int results,
int numsent);
@ -71,8 +71,7 @@ exit_nicely(PGconn *conn)
* Print an error to stderr and terminate the program.
*/
#define pg_fatal(...) pg_fatal_impl(__LINE__, __VA_ARGS__)
static void
pg_attribute_noreturn()
pg_noreturn static void
pg_fatal_impl(int line, const char *fmt,...)
{
va_list args;

View File

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

View File

@ -44,7 +44,7 @@ PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(worker_spi_launch);
PGDLLEXPORT void worker_spi_main(Datum main_arg) pg_attribute_noreturn();
PGDLLEXPORT pg_noreturn void worker_spi_main(Datum main_arg);
/* GUC variables */
static int worker_spi_naptime = 10;

View File

@ -117,11 +117,11 @@ extern int link(const char *target, const char *linkname);
(itssymlink(target) ? (errno = ENOTSUP, -1) : link(target, linkname))
#endif
static void memory_exhausted(const char *msg) pg_attribute_noreturn();
pg_noreturn static void memory_exhausted(const char *msg);
static void verror(const char *string, va_list args) pg_attribute_printf(1, 0);
static void error(const char *string,...) pg_attribute_printf(1, 2);
static void warning(const char *string,...) pg_attribute_printf(1, 2);
static void usage(FILE *stream, int status) pg_attribute_noreturn();
pg_noreturn static void usage(FILE *stream, int status);
static void addtt(zic_t starttime, int type);
static int addtype(zic_t utoff, char const *abbr,
bool isdst, bool ttisstd, bool ttisut);

View File

@ -37,9 +37,9 @@
* This is cut down to just the minimum that we need to build indent.
*/
void err(int, const char *, ...)
pg_attribute_noreturn() pg_attribute_printf(2, 3);
void errx(int, const char *, ...)
pg_attribute_noreturn() pg_attribute_printf(2, 3);
pg_noreturn void err(int, const char *, ...)
pg_attribute_printf(2, 3);
pg_noreturn void errx(int, const char *, ...)
pg_attribute_printf(2, 3);
#endif /* !_ERR_H_ */