1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

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
This commit is contained in:
Michael Paquier
2023-07-31 16:14:47 +09:00
parent f1e9f6bbfa
commit 7395a90db8

View File

@@ -39,6 +39,8 @@ static const char *pgstat_get_wait_io(WaitEventIO w);
static uint32 local_my_wait_event_info; static uint32 local_my_wait_event_info;
uint32 *my_wait_event_info = &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. * 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) if (wait_event_info == 0)
return NULL; return NULL;
classId = wait_event_info & 0xFF000000; classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
switch (classId) switch (classId)
{ {
@@ -138,8 +140,8 @@ pgstat_get_wait_event(uint32 wait_event_info)
if (wait_event_info == 0) if (wait_event_info == 0)
return NULL; return NULL;
classId = wait_event_info & 0xFF000000; classId = wait_event_info & WAIT_EVENT_CLASS_MASK;
eventId = wait_event_info & 0x0000FFFF; eventId = wait_event_info & WAIT_EVENT_ID_MASK;
switch (classId) switch (classId)
{ {