Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbbfd7ed

Browse files
committed
Add macros wrapping all usage of gcc's __attribute__.
Until now __attribute__() was defined to be empty for all compilers butgcc. That's problematic because it prevents using it in other compilers;which is necessary e.g. for atomics portability. It's also justgenerally 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 thatunderstand 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 intowarnings or errors on those compilers. But there shouldn't be manyoccurances of that and it's hard to work around...Discussion: 54B58BA3.8040302@ohmu.fiAuthor: Oskari Saarenmaa, with some minor changes by me.
1 parent66ece31 commitbbfd7ed

File tree

68 files changed

+167
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+167
-132
lines changed

‎contrib/cube/cubescan.l‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ float ({integer}|{real})([eE]{integer})?
6060

6161
%%
6262

63-
void__attribute__((noreturn))
63+
voidpg_attribute_noreturn
6464
yyerror(NDBOX **result,constchar *message)
6565
{
6666
if (*yytext == YY_END_OF_BUFFER_CHAR)

‎contrib/pg_upgrade/pg_upgrade.h‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ voidoptionally_create_toast_tables(void);
359359
bool
360360
exec_prog(constchar*log_file,constchar*opt_log_file,
361361
boolthrow_error,constchar*fmt,...)
362-
__attribute__((format(PG_PRINTF_ATTRIBUTE,4,5)));
362+
pg_attribute_printf(4,5);
363363
voidverify_directories(void);
364364
boolpid_lock_file_exists(constchar*datadir);
365365

@@ -445,7 +445,7 @@ voidinit_tablespaces(void);
445445
PGconn*connectToServer(ClusterInfo*cluster,constchar*db_name);
446446
PGresult*
447447
executeQueryOrDie(PGconn*conn,constchar*fmt,...)
448-
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
448+
pg_attribute_printf(2,3);
449449

450450
char*cluster_conn_opts(ClusterInfo*cluster);
451451

@@ -462,17 +462,17 @@ intget_user_info(char **user_name_p);
462462
voidcheck_ok(void);
463463
void
464464
report_status(eLogTypetype,constchar*fmt,...)
465-
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
465+
pg_attribute_printf(2,3);
466466
void
467467
pg_log(eLogTypetype,constchar*fmt,...)
468-
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
468+
pg_attribute_printf(2,3);
469469
void
470470
pg_fatal(constchar*fmt,...)
471-
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2),noreturn));
471+
pg_attribute_printf(1,2)pg_attribute_noreturn;
472472
voidend_progress_output(void);
473473
void
474474
prep_status(constchar*fmt,...)
475-
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
475+
pg_attribute_printf(1,2);
476476
voidcheck_ok(void);
477477
constchar*getErrorText(interrNum);
478478
unsignedintstr2uint(constchar*str);
@@ -489,7 +489,7 @@ void old_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
489489
void
490490
parallel_exec_prog(constchar*log_file,constchar*opt_log_file,
491491
constchar*fmt,...)
492-
__attribute__((format(PG_PRINTF_ATTRIBUTE,3,4)));
492+
pg_attribute_printf(3,4);
493493
voidparallel_transfer_all_new_dbs(DbInfoArr*old_db_arr,DbInfoArr*new_db_arr,
494494
char*old_pgdata,char*new_pgdata,
495495
char*old_tablespace);

‎contrib/pg_upgrade/util.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ prep_status(const char *fmt,...)
8282

8383

8484
static
85-
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,0)))
85+
pg_attribute_printf(2,0)
8686
void
8787
pg_log_v(eLogTypetype,constchar*fmt,va_listap)
8888
{

‎contrib/pg_xlogdump/pg_xlogdump.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef struct XLogDumpStats
6969

7070
staticvoid
7171
fatal_error(constchar*fmt,...)
72-
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
72+
pg_attribute_printf(1,2);
7373

7474
/*
7575
* Big red button to push when things go horribly wrong.

‎contrib/pgcrypto/px.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ voidpx_memset(void *ptr, int c, size_t len);
208208
#ifdefPX_DEBUG
209209
void
210210
px_debug(constchar*fmt,...)
211-
__attribute__((format(PG_PRINTF_ATTRIBUTE,1,2)));
211+
pg_attribute_printf(1,2);
212212
#else
213213
#definepx_debug(...)
214214
#endif

‎contrib/seg/segscan.l‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ float ({integer}|{real})([eE]{integer})?
5959

6060
%%
6161

62-
void__attribute__((noreturn))
62+
voidpg_attribute_noreturn
6363
yyerror(SEG *result,constchar *message)
6464
{
6565
if (*yytext == YY_END_OF_BUFFER_CHAR)

‎src/backend/access/transam/xlogreader.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void
3636
report_invalid_record(XLogReaderState*state,constchar*fmt,...)
3737
/* This extension allows gcc to check the format string for consistency with
3838
the supplied arguments. */
39-
__attribute__((format(PG_PRINTF_ATTRIBUTE,2,3)));
39+
pg_attribute_printf(2,3);
4040

4141
staticvoidResetDecoder(XLogReaderState*state);
4242

‎src/backend/postmaster/autovacuum.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ intAutovacuumLauncherPid = 0;
286286
staticpid_tavlauncher_forkexec(void);
287287
staticpid_tavworker_forkexec(void);
288288
#endif
289-
NON_EXEC_STATICvoidAutoVacWorkerMain(intargc,char*argv[])__attribute__((noreturn));
290-
NON_EXEC_STATICvoidAutoVacLauncherMain(intargc,char*argv[])__attribute__((noreturn));
289+
NON_EXEC_STATICvoidAutoVacWorkerMain(intargc,char*argv[])pg_attribute_noreturn;
290+
NON_EXEC_STATICvoidAutoVacLauncherMain(intargc,char*argv[])pg_attribute_noreturn;
291291

292292
staticOiddo_start_worker(void);
293293
staticvoidlauncher_determine_sleep(boolcanlaunch,boolrecursing,

‎src/backend/postmaster/pgarch.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static volatile sig_atomic_t ready_to_stop = false;
8686
staticpid_tpgarch_forkexec(void);
8787
#endif
8888

89-
NON_EXEC_STATICvoidPgArchiverMain(intargc,char*argv[])__attribute__((noreturn));
89+
NON_EXEC_STATICvoidPgArchiverMain(intargc,char*argv[])pg_attribute_noreturn;
9090
staticvoidpgarch_exit(SIGNAL_ARGS);
9191
staticvoidArchSigHupHandler(SIGNAL_ARGS);
9292
staticvoidArchSigTermHandler(SIGNAL_ARGS);

‎src/backend/postmaster/pgstat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static instr_time total_func_time;
251251
staticpid_tpgstat_forkexec(void);
252252
#endif
253253

254-
NON_EXEC_STATICvoidPgstatCollectorMain(intargc,char*argv[])__attribute__((noreturn));
254+
NON_EXEC_STATICvoidPgstatCollectorMain(intargc,char*argv[])pg_attribute_noreturn;
255255
staticvoidpgstat_exit(SIGNAL_ARGS);
256256
staticvoidpgstat_beshutdown_hook(intcode,Datumarg);
257257
staticvoidpgstat_sighup_handler(SIGNAL_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp