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

Commit4b74c6a

Browse files
committed
Make init_spin_delay() C89 compliant#2.
My previous attempt at doing so, in80abbeb, was not sufficient. While thatfixed the problem for bufmgr.c and lwlock.c , s_lock.c still has non-constantexpressions in the struct initializer, because the file/line/functioninformation 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
1 parent533cd23 commit4b74c6a

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,9 +4029,11 @@ rnode_comparator(const void *p1, const void *p2)
40294029
uint32
40304030
LockBufHdr(BufferDesc*desc)
40314031
{
4032-
SpinDelayStatusdelayStatus=init_local_spin_delay();
4032+
SpinDelayStatusdelayStatus;
40334033
uint32old_buf_state;
40344034

4035+
init_local_spin_delay(&delayStatus);
4036+
40354037
while (true)
40364038
{
40374039
/* set BM_LOCKED flag */
@@ -4055,9 +4057,11 @@ LockBufHdr(BufferDesc *desc)
40554057
staticuint32
40564058
WaitBufHdrUnlocked(BufferDesc*buf)
40574059
{
4058-
SpinDelayStatusdelayStatus=init_local_spin_delay();
4060+
SpinDelayStatusdelayStatus;
40594061
uint32buf_state;
40604062

4063+
init_local_spin_delay(&delayStatus);
4064+
40614065
buf_state=pg_atomic_read_u32(&buf->state);
40624066

40634067
while (buf_state&BM_LOCKED)

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,9 @@ LWLockWaitListLock(LWLock *lock)
870870

871871
/* and then spin without atomic operations until lock is released */
872872
{
873-
SpinDelayStatusdelayStatus=init_local_spin_delay();
873+
SpinDelayStatusdelayStatus;
874+
875+
init_local_spin_delay(&delayStatus);
874876

875877
while (old_state&LW_FLAG_LOCKED)
876878
{

‎src/backend/storage/lmgr/s_lock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ s_lock_stuck(const char *file, int line, const char *func)
9191
int
9292
s_lock(volatileslock_t*lock,constchar*file,intline,constchar*func)
9393
{
94-
SpinDelayStatusdelayStatus=init_spin_delay(file,line,func);
94+
SpinDelayStatusdelayStatus;
95+
96+
init_spin_delay(&delayStatus,file,line,func);
9597

9698
while (TAS_SPIN(lock))
9799
{

‎src/include/storage/s_lock.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,19 @@ typedef struct
10051005
constchar*func;
10061006
}SpinDelayStatus;
10071007

1008-
#defineinit_spin_delay(file,line,func) {0, 0, 0, file, line, func}
1009-
#defineinit_local_spin_delay() init_spin_delay(__FILE__, __LINE__, PG_FUNCNAME_MACRO)
1008+
staticinlinevoid
1009+
init_spin_delay(SpinDelayStatus*status,
1010+
constchar*file,intline,constchar*func)
1011+
{
1012+
status->spins=0;
1013+
status->delays=0;
1014+
status->cur_delay=0;
1015+
status->file=file;
1016+
status->line=line;
1017+
status->func=func;
1018+
}
1019+
1020+
#defineinit_local_spin_delay(status) init_spin_delay(status, __FILE__, __LINE__, PG_FUNCNAME_MACRO)
10101021
voidperform_spin_delay(SpinDelayStatus*status);
10111022
voidfinish_spin_delay(SpinDelayStatus*status);
10121023

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp