PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

#define proclist_contains (   list,
  procno,
  link_member 
)    proclist_contains_offset((list), (procno), offsetof(PGPROC, link_member))
#define proclist_delete (   list,
  procno,
  link_member 
)    proclist_delete_offset((list), (procno), offsetof(PGPROC, link_member))
#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:786
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:76
Definition: proc.h:94
#define offsetof(type, field)
Definition: c.h:555

Definition at line 195 of file proclist.h.

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

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

Definition at line 182 of file proclist.h.

Referenced by ConditionVariableSignal().

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

Definition at line 178 of file proclist.h.

Referenced by LWLockQueueSelf().

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

Function Documentation

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

Definition at line 134 of file proclist.h.

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

136 {
137  proclist_node *node = proclist_node_get(procno, node_offset);
138 
139  /*
140  * If this is not a member of a proclist, then the next and prev pointers
141  * should be 0. Circular lists are not allowed so this condition is not
142  * confusable with a real pgprocno 0.
143  */
144  if (node->prev == 0 && node->next == 0)
145  return false;
146 
147  /* If there is a previous node, then this node must be in the list. */
148  if (node->prev != INVALID_PGPROCNO)
149  return true;
150 
151  /*
152  * There is no previous node, so the only way this node can be in the list
153  * is if it's the head node.
154  */
155  return list->head == procno;
156 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:76
static void proclist_delete_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 111 of file proclist.h.

References 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().

112 {
113  proclist_node *node = proclist_node_get(procno, node_offset);
114 
115  if (node->prev == INVALID_PGPROCNO)
116  list->head = node->next;
117  else
118  proclist_node_get(node->prev, node_offset)->next = node->next;
119 
120  if (node->next == INVALID_PGPROCNO)
121  list->tail = node->prev;
122  else
123  proclist_node_get(node->next, node_offset)->prev = node->prev;
124 
125  node->next = node->prev = INVALID_PGPROCNO;
126 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:76
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:76
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 ConditionVariableSignal(), LWLockDequeueSelf(), LWLockWakeup(), and proclist_pop_head_node_offset().

39 {
40  return list->head == INVALID_PGPROCNO;
41 }
#define INVALID_PGPROCNO
Definition: proc.h:76
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:263
static PGPROC* proclist_pop_head_node_offset ( proclist_head list,
size_t  node_offset 
)
inlinestatic

Definition at line 162 of file proclist.h.

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

163 {
164  PGPROC *proc;
165 
166  Assert(!proclist_is_empty(list));
167  proc = GetPGProcByNumber(list->head);
168  proclist_delete_offset(list, list->head, node_offset);
169  return proc;
170 }
#define GetPGProcByNumber(n)
Definition: proc.h:263
static void proclist_delete_offset(proclist_head *list, int procno, size_t node_offset)
Definition: proclist.h:111
#define Assert(condition)
Definition: c.h:675
static bool proclist_is_empty(proclist_head *list)
Definition: proclist.h:38
Definition: proc.h:94
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  if (list->head == INVALID_PGPROCNO)
64  {
65  Assert(list->tail == INVALID_PGPROCNO);
66  node->next = node->prev = INVALID_PGPROCNO;
67  list->head = list->tail = procno;
68  }
69  else
70  {
71  Assert(list->tail != INVALID_PGPROCNO);
72  Assert(list->head != procno);
73  Assert(list->tail != procno);
74  node->next = list->head;
75  proclist_node_get(node->next, node_offset)->prev = procno;
76  node->prev = INVALID_PGPROCNO;
77  list->head = procno;
78  }
79 }
static proclist_node * proclist_node_get(int procno, size_t node_offset)
Definition: proclist.h:48
#define INVALID_PGPROCNO
Definition: proc.h:76
#define Assert(condition)
Definition: c.h:675
static void proclist_push_tail_offset ( proclist_head list,
int  procno,
size_t  node_offset 
)
inlinestatic

Definition at line 85 of file proclist.h.

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

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