mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-23 23:07:15 +08:00
Make init_spin_delay() C89 compliant #2.
My previous attempt at doing so, in 80abbeba23, was not sufficient. While that fixed the problem for bufmgr.c and lwlock.c , s_lock.c still has non-constant expressions in the struct initializer, because the file/line/function information comes from the caller of s_lock(). Give up on using a macro, and use a static inline instead. Discussion: 4369.1460435533@sss.pgh.pa.us
This commit is contained in:
@ -1005,8 +1005,19 @@ typedef struct
|
||||
const char *func;
|
||||
} SpinDelayStatus;
|
||||
|
||||
#define init_spin_delay(file, line, func) {0, 0, 0, file, line, func}
|
||||
#define init_local_spin_delay() init_spin_delay(__FILE__, __LINE__, PG_FUNCNAME_MACRO)
|
||||
static inline void
|
||||
init_spin_delay(SpinDelayStatus *status,
|
||||
const char *file, int line, const char *func)
|
||||
{
|
||||
status->spins = 0;
|
||||
status->delays = 0;
|
||||
status->cur_delay = 0;
|
||||
status->file = file;
|
||||
status->line = line;
|
||||
status->func = func;
|
||||
}
|
||||
|
||||
#define init_local_spin_delay(status) init_spin_delay(status, __FILE__, __LINE__, PG_FUNCNAME_MACRO)
|
||||
void perform_spin_delay(SpinDelayStatus *status);
|
||||
void finish_spin_delay(SpinDelayStatus *status);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user