postgres.git / summary / log / commit / refs
commit 7395a90db87bcb2f617d3c486657813122d3f151
Author: Michael Paquier <michael@paquier.xyz>
Date: Mon Jul 31 07:14:47 2023 +0000
First released in: 17.0
Add WAIT_EVENT_{CLASS,ID}_MASK in wait_event.c
These are useful to extract the class ID and the event ID associated to
a single uint32 wait_event_info. Only two code paths use them now, but
an upcoming patch will extend their use.
Discussion: https://postgr.es/m/ZMcJ7F7nkGkIs8zP@paquier.xyz
src/backend/utils/activity/wait_event.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c
index 4aad11c1113..59177de7a04 100644
--- a/src/backend/utils/activity/wait_event.c
+++ b/src/backend/utils/activity/wait_event.c
@@ -39,6 +39,8 @@ static const char *pgstat_get_wait_io(WaitEventIO w);
static uint32 local_my_wait_event_info;
uint32 *my_wait_event_info = &local_my_wait_event_info;
+#define WAIT_EVENT_CLASS_MASK 0xFF000000
+#define WAIT_EVENT_ID_MASK 0x0000FFFF
/*
* Configure wait event reporting to report wait events to *wait_event_info.
@@ -82,7 +84,7 @@ pgstat_get_wait_event_type(uint32 wait_event_info)
if (wait_event_info == 0)
return NULL;
- classId = wait_event_info & 0xFF000000;
+ classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
switch (classId)
{
@@ -138,8 +140,8 @@ pgstat_get_wait_event(uint32 wait_event_info)
if (wait_event_info == 0)
return NULL;
- classId = wait_event_info & 0xFF000000;
- eventId = wait_event_info & 0x0000FFFF;
+ classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
+ eventId = wait_event_info & WAIT_EVENT_ID_MASK;
switch (classId)
{
[parent: f1e9f6bbfa53]