Lines Matching defs:sg
54 * Initialize the memory 'sg' points at.
62 static void sg_init(Segment* const sg,
69 tl_assert(sg);
76 sg->g_next = NULL;
77 sg->g_prev = NULL;
78 sg->thr_next = NULL;
79 sg->thr_prev = NULL;
80 sg->tid = created;
81 sg->refcnt = 1;
84 sg->stacktrace = VG_(record_ExeContext)(vg_created, 0);
86 sg->stacktrace = 0;
89 DRD_(vc_copy)(&sg->vc, &creator_sg->vc);
91 DRD_(vc_init)(&sg->vc, 0, 0);
92 DRD_(vc_increment)(&sg->vc, created);
93 DRD_(bm_init)(&sg->bm);
99 vc = DRD_(vc_aprint)(&sg->vc);
107 static void DRD_(sg_cleanup)(Segment* const sg)
109 tl_assert(sg);
110 tl_assert(sg->refcnt == 0);
112 DRD_(vc_cleanup)(&sg->vc);
113 DRD_(bm_cleanup)(&sg->bm);
119 Segment* sg;
126 sg = VG_(malloc)("drd.segment.sn.1", sizeof(*sg));
127 tl_assert(sg);
128 sg_init(sg, creator, created);
130 DRD_(g_sg_list)->g_prev = sg;
131 sg->g_next = DRD_(g_sg_list);
133 DRD_(g_sg_list) = sg;
134 return sg;
137 static void DRD_(sg_delete)(Segment* const sg)
143 vc = DRD_(vc_aprint)(&sg->vc);
151 tl_assert(sg);
152 if (sg->g_next)
153 sg->g_next->g_prev = sg->g_prev;
154 if (sg->g_prev)
155 sg->g_prev->g_next = sg->g_next;
157 DRD_(g_sg_list) = sg->g_next;
158 DRD_(sg_cleanup)(sg);
159 VG_(free)(sg);
163 Segment* DRD_(sg_get)(Segment* const sg)
165 tl_assert(sg);
167 sg->refcnt++;
168 return sg;
175 void DRD_(sg_put)(Segment* const sg)
177 if (sg == 0)
184 vc = DRD_(vc_aprint)(&sg->vc);
187 sg->refcnt, sg->refcnt - 1, vc);
191 tl_assert(sg->refcnt >= 1);
193 if (--sg->refcnt == 0)
195 DRD_(sg_delete)(sg);
229 void DRD_(sg_print)(Segment* const sg)
231 tl_assert(sg);
233 DRD_(vc_print)(&sg->vc);
235 DRD_(bm_print)(&sg->bm);