mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Add macros wrapping all usage of gcc's __attribute__.
Until now __attribute__() was defined to be empty for all compilers but gcc. That's problematic because it prevents using it in other compilers; which is necessary e.g. for atomics portability. It's also just generally dubious to do so in a header as widely included as c.h. Instead add pg_attribute_format_arg, pg_attribute_printf, pg_attribute_noreturn macros which are implemented in the compilers that understand them. Also add pg_attribute_noreturn and pg_attribute_packed, but don't provide fallbacks, since they can affect functionality. This means that external code that, possibly unwittingly, relied on __attribute__ defined to be empty on !gcc compilers may now run into warnings or errors on those compilers. But there shouldn't be many occurances of that and it's hard to work around... Discussion: 54B58BA3.8040302@ohmu.fi Author: Oskari Saarenmaa, with some minor changes by me.
This commit is contained in:
@ -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 void test_shm_mq_main(Datum) __attribute__((noreturn));
|
||||
extern void test_shm_mq_main(Datum) pg_attribute_noreturn;
|
||||
|
||||
#endif
|
||||
|
@ -46,7 +46,7 @@ PG_MODULE_MAGIC;
|
||||
PG_FUNCTION_INFO_V1(worker_spi_launch);
|
||||
|
||||
void _PG_init(void);
|
||||
void worker_spi_main(Datum) __attribute__((noreturn));
|
||||
void worker_spi_main(Datum) pg_attribute_noreturn;
|
||||
|
||||
/* flags set by signal handlers */
|
||||
static volatile sig_atomic_t got_sighup = false;
|
||||
|
@ -135,17 +135,17 @@ static void
|
||||
header(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
pg_attribute_printf(1, 2);
|
||||
static void
|
||||
status(const char *fmt,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
pg_attribute_printf(1, 2);
|
||||
static void
|
||||
psql_command(const char *database, const char *query,...)
|
||||
/* This extension allows gcc to check the format string for consistency with
|
||||
the supplied arguments. */
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
pg_attribute_printf(2, 3);
|
||||
|
||||
#ifdef WIN32
|
||||
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
||||
|
Reference in New Issue
Block a user