Add WAIT_EVENT_{CLASS,ID}_MASK in wait_event.c
authorMichael Paquier <[email protected]>
Mon, 31 Jul 2023 07:14:47 +0000 (16:14 +0900)
committerMichael Paquier <[email protected]>
Mon, 31 Jul 2023 07:14:47 +0000 (16:14 +0900)
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  will extend their use.

Discussion: https://postgr.es/m/[email protected]

src/backend/utils/activity/wait_event.c

index 4aad11c111301de9b7e7a9c49c6a36914d07659c..59177de7a04c5cc55bf3789c4fdf28ec5b894a01 100644 (file)
@@ -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)
    {