PostgreSQL Source Code  git master
proclist.h File Reference
Include dependency graph for proclist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define proclist_delete(list, procno, link_member)   proclist_delete_offset((list), (procno), offsetof(PGPROC, link_member))
 
#define proclist_push_head(list, procno, link_member)   proclist_push_head_offset((list), (procno), offsetof(PGPROC, link_member))
 
#define proclist_push_tail(list, procno, link_member)   proclist_push_tail_offset((list), (procno), offsetof(PGPROC, link_member))
 
#define proclist_pop_head_node(list, link_member)   proclist_pop_head_node_offset((list), offsetof(PGPROC, link_member))
 
#define proclist_contains(list, procno, link_member)   proclist_contains_offset((list), (procno), offsetof(PGPROC, link_member))
 
#define proclist_foreach_modify(iter, lhead, link_member)
 

Functions

static void proclist_init (proclist_head *list)
 
static bool proclist_is_empty (proclist_head *list)
 
static proclist_nodeproclist_node_get (int procno, size_t node_offset)
 
static void proclist_push_head_offset (proclist_head *list, int procno, size_t node_offset)
 
static void proclist_push_tail_offset (proclist_head *list, int procno, size_t node_offset)
 
static void proclist_delete_offset (proclist_head *list, int procno, size_t node_offset)
 
static bool proclist_contains_offset (proclist_head *list, int procno, size_t node_offset)
 
static PGPROCproclist_pop_head_node_offset (proclist_head *list, size_t node_offset)
 

Macro Definition Documentation

◆ proclist_contains

#define proclist_contains (   list,
  procno,
  link_member 
)    proclist_contains_offset((list), (procno), offsetof(PGPROC, link_member))

◆ proclist_delete

#define proclist_delete (   list,
  procno,
  link_member 
)    proclist_delete_offset((list), (procno), offsetof(PGPROC, link_member))

◆ proclist_foreach_modify

#define proclist_foreach_modify (   iter,
  lhead,
  link_member 
)
Value:
(iter).cur = (lhead)->head, \
(iter).next = (iter).cur == INVALID_PGPROCNO ? INVALID_PGPROCNO : \
offsetof(PGPROC, link_member))->next; \
(iter).cur != INVALID_PGPROCNO; \
(iter).cur = (iter).next, \
(iter).next = (iter).cur == INVALID_PGPROCNO ? INVALID_PGPROCNO : \
proclist_node_get((iter).cur, \
offsetof(PGPROC, link_member))->next)
static int32 next
Definition: blutils.c:210
struct cursor * cur
Definition: ecpg.c:28
#define AssertVariableIsOfTypeMacro(varname, typename)
Definition: c.h:826
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:77
Definition: proc.h:95
#define offsetof(type, field)
Definition: c.h:611

Definition at line 206 of file proclist.h.

Referenced by LWLockDequeueSelf(), LWLockUpdateVar(), and LWLockWakeup().

◆ proclist_pop_head_node

#define proclist_pop_head_node (   list,
  link_member 
)    proclist_pop_head_node_offset((list), offsetof(PGPROC, link_member))

Definition at line 193 of file proclist.h.

Referenced by ConditionVariableBroadcast(), and ConditionVariableSignal().

◆ proclist_push_head

#define proclist_push_head (   list,
  procno,
  link_member 
)    proclist_push_head_offset((list), (procno), offsetof(PGPROC, link_member))

Definition at line 189 of file proclist.h.

Referenced by LWLockQueueSelf().

◆ proclist_push_tail

#define proclist_push_tail (   list,
  procno,
  link_member 
)    proclist_push_tail_offset((list), (procno), offsetof(PGPROC, link_member))

Function Documentation

◆ proclist_contains_offset()

static bool proclist_contains_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 146 of file proclist.h.

References Assert, proclist_head::head, INVALID_PGPROCNO, proclist_node::next, proclist_node::prev, proclist_node_get(), and proclist_head::tail.

148 {
149  proclist_node *node = proclist_node_get(procno, node_offset);
150 
151  /* If it's not in any list, it's definitely not in this one. */
152  if (node->prev == 0 && node->next == 0)
153  return false;
154 
155  /*
156  * It must, in fact, be in this list. Ideally, in assert-enabled builds,
157  * we'd verify that. But since this function is typically used while
158  * holding a spinlock, crawling the whole list is unacceptable. However,
159  * we can verify matters in O(1) time when the node is a list head or
160  * tail, and that seems worth doing, since in practice that should often
161  * be enough to catch mistakes.
162  */
163  Assert(node->prev != INVALID_PGPROCNO || list->head == procno);
164  Assert(node->next != INVALID_PGPROCNO || list->tail == procno);
165 
166  return true;
167 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:77
#define Assert(condition)
Definition: c.h:688

◆ proclist_delete_offset()

static void proclist_delete_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 115 of file proclist.h.

References Assert, proclist_head::head, INVALID_PGPROCNO, proclist_node::next, proclist_node::prev, proclist_node_get(), and proclist_head::tail.

Referenced by proclist_pop_head_node_offset().

116 {
117  proclist_node *node = proclist_node_get(procno, node_offset);
118 
119  Assert(node->next != 0 || node->prev != 0);
120 
121  if (node->prev == INVALID_PGPROCNO)
122  {
123  Assert(list->head == procno);
124  list->head = node->next;
125  }
126  else
127  proclist_node_get(node->prev, node_offset)->next = node->next;
128 
129  if (node->next == INVALID_PGPROCNO)
130  {
131  Assert(list->tail == procno);
132  list->tail = node->prev;
133  }
134  else
135  proclist_node_get(node->next, node_offset)->prev = node->prev;
136 
137  node->next = node->prev = 0;
138 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:77
#define Assert(condition)
Definition: c.h:688

◆ proclist_init()

static void proclist_init ( proclist_head list)
inlinestatic

Definition at line 29 of file proclist.h.

References proclist_head::head, INVALID_PGPROCNO, and proclist_head::tail.

Referenced by ConditionVariableInit(), LWLockInitialize(), LWLockUpdateVar(), and LWLockWakeup().

30 {
31  list->head = list->tail = INVALID_PGPROCNO;
32 }
#define INVALID_PGPROCNO
Definition: proc.h:77

◆ proclist_is_empty()

static bool proclist_is_empty ( proclist_head list)
inlinestatic

Definition at line 38 of file proclist.h.

References proclist_head::head, and INVALID_PGPROCNO.

Referenced by ConditionVariableBroadcast(), ConditionVariableSignal(), LWLockDequeueSelf(), LWLockWakeup(), and proclist_pop_head_node_offset().

39 {
40  return list->head == INVALID_PGPROCNO;
41 }
#define INVALID_PGPROCNO
Definition: proc.h:77

◆ proclist_node_get()

static proclist_node* proclist_node_get ( int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 48 of file proclist.h.

References GetPGProcByNumber.

Referenced by proclist_contains_offset(), proclist_delete_offset(), proclist_push_head_offset(), and proclist_push_tail_offset().

49 {
50  char *entry = (char *) GetPGProcByNumber(procno);
51 
52  return (proclist_node *) (entry + node_offset);
53 }
#define GetPGProcByNumber(n)
Definition: proc.h:277

◆ proclist_pop_head_node_offset()

static PGPROC* proclist_pop_head_node_offset ( proclist_head list,
size_t  node_offset 
)
inlinestatic

Definition at line 173 of file proclist.h.

References Assert, GetPGProcByNumber, proclist_head::head, proclist_delete_offset(), and proclist_is_empty().

174 {
175  PGPROC *proc;
176 
177  Assert(!proclist_is_empty(list));
178  proc = GetPGProcByNumber(list->head);
179  proclist_delete_offset(list, list->head, node_offset);
180  return proc;
181 }
#define GetPGProcByNumber(n)
Definition: proc.h:277
static void proclist_delete_offset(proclist_head *list, int procno, size_t node_offset)
Definition: proclist.h:115
#define Assert(condition)
Definition: c.h:688
static bool proclist_is_empty(proclist_head *list)
Definition: proclist.h:38
Definition: proc.h:95

◆ proclist_push_head_offset()

static void proclist_push_head_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 59 of file proclist.h.

References Assert, proclist_head::head, INVALID_PGPROCNO, proclist_node::next, proclist_node::prev, proclist_node_get(), and proclist_head::tail.

60 {
61  proclist_node *node = proclist_node_get(procno, node_offset);
62 
63  Assert(node->next == 0 && node->prev == 0);
64 
65  if (list->head == INVALID_PGPROCNO)
66  {
67  Assert(list->tail == INVALID_PGPROCNO);
68  node->next = node->prev = INVALID_PGPROCNO;
69  list->head = list->tail = procno;
70  }
71  else
72  {
73  Assert(list->tail != INVALID_PGPROCNO);
74  Assert(list->head != procno);
75  Assert(list->tail != procno);
76  node->next = list->head;
77  proclist_node_get(node->next, node_offset)->prev = procno;
78  node->prev = INVALID_PGPROCNO;
79  list->head = procno;
80  }
81 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:77
#define Assert(condition)
Definition: c.h:688

◆ proclist_push_tail_offset()

static void proclist_push_tail_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 87 of file proclist.h.

References Assert, proclist_head::head, INVALID_PGPROCNO, proclist_node::next, proclist_node::prev, proclist_node_get(), and proclist_head::tail.

88 {
89  proclist_node *node = proclist_node_get(procno, node_offset);
90 
91  Assert(node->next == 0 && node->prev == 0);
92 
93  if (list->tail == INVALID_PGPROCNO)
94  {
95  Assert(list->head == INVALID_PGPROCNO);
96  node->next = node->prev = INVALID_PGPROCNO;
97  list->head = list->tail = procno;
98  }
99  else
100  {
101  Assert(list->head != INVALID_PGPROCNO);
102  Assert(list->head != procno);
103  Assert(list->tail != procno);
104  node->prev = list->tail;
105  proclist_node_get(node->prev, node_offset)->next = procno;
106  node->next = INVALID_PGPROCNO;
107  list->tail = procno;
108  }
109 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:77
#define Assert(condition)
Definition: c.h:688