hexsha
stringlengths 40
40
| repo
stringlengths 5
105
| path
stringlengths 3
173
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
438
| return_type
stringlengths 1
106
⌀ | original_string
stringlengths 21
40.7k
| original_docstring
stringlengths 18
13.4k
| docstring
stringlengths 11
3.24k
| docstring_tokens
sequence | code
stringlengths 14
20.4k
| code_tokens
sequence | short_docstring
stringlengths 0
4.36k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_mp_output | int | static int
ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta)
{
const priv_p priv = node->private;
const int hdr_len = priv->conf.xmitShortSeq ? 2 : 4;
int distrib[NG_PPP_MAX_LINKS];
int firstFragment;
int activeLinkNum;
/* At least one link must be active */
if (priv->numActiveLinks == 0) {
NG_FREE_DATA(m, meta);
return (ENETDOWN);
}
/* Round-robin strategy */
if (priv->conf.enableRoundRobin || m->m_pkthdr.len < MP_MIN_FRAG_LEN) {
activeLinkNum = priv->lastLink++ % priv->numActiveLinks;
bzero(&distrib, priv->numActiveLinks * sizeof(distrib[0]));
distrib[activeLinkNum] = m->m_pkthdr.len;
goto deliver;
}
/* Strategy when all links are equivalent (optimize the common case) */
if (priv->allLinksEqual) {
const int fraction = m->m_pkthdr.len / priv->numActiveLinks;
int i, remain;
for (i = 0; i < priv->numActiveLinks; i++)
distrib[priv->lastLink++ % priv->numActiveLinks]
= fraction;
remain = m->m_pkthdr.len - (fraction * priv->numActiveLinks);
while (remain > 0) {
distrib[priv->lastLink++ % priv->numActiveLinks]++;
remain--;
}
goto deliver;
}
/* Strategy when all links are not equivalent */
ng_ppp_mp_strategy(node, m->m_pkthdr.len, distrib);
deliver:
/* Update stats */
priv->bundleStats.xmitFrames++;
priv->bundleStats.xmitOctets += m->m_pkthdr.len;
/* Send alloted portions of frame out on the link(s) */
for (firstFragment = 1, activeLinkNum = priv->numActiveLinks - 1;
activeLinkNum >= 0; activeLinkNum--) {
const int linkNum = priv->activeLinks[activeLinkNum];
struct ng_ppp_link *const link = &priv->links[linkNum];
/* Deliver fragment(s) out the next link */
for ( ; distrib[activeLinkNum] > 0; firstFragment = 0) {
int len, lastFragment, error;
struct mbuf *m2;
meta_p meta2;
/* Calculate fragment length; don't exceed link MTU */
len = distrib[activeLinkNum];
if (len > link->conf.mru - hdr_len)
len = link->conf.mru - hdr_len;
distrib[activeLinkNum] -= len;
lastFragment = (len == m->m_pkthdr.len);
/* Split off next fragment as "m2" */
m2 = m;
if (!lastFragment) {
struct mbuf *n = m_split(m, len, M_NOWAIT);
if (n == NULL) {
NG_FREE_DATA(m, meta);
return (ENOMEM);
}
m = n;
}
/* Prepend MP header */
if (priv->conf.xmitShortSeq) {
u_int16_t shdr;
shdr = priv->xseq;
priv->xseq =
(priv->xseq + 1) & MP_SHORT_SEQ_MASK;
if (firstFragment)
shdr |= MP_SHORT_FIRST_FLAG;
if (lastFragment)
shdr |= MP_SHORT_LAST_FLAG;
shdr = htons(shdr);
m2 = ng_ppp_prepend(m2, &shdr, 2);
} else {
u_int32_t lhdr;
lhdr = priv->xseq;
priv->xseq =
(priv->xseq + 1) & MP_LONG_SEQ_MASK;
if (firstFragment)
lhdr |= MP_LONG_FIRST_FLAG;
if (lastFragment)
lhdr |= MP_LONG_LAST_FLAG;
lhdr = htonl(lhdr);
m2 = ng_ppp_prepend(m2, &lhdr, 4);
}
if (m2 == NULL) {
if (!lastFragment)
m_freem(m);
NG_FREE_META(meta);
return (ENOBUFS);
}
/* Copy the meta information, if any */
meta2 = lastFragment ? meta : ng_copy_meta(meta);
/* Send fragment */
error = ng_ppp_output(node, 0,
PROT_MP, linkNum, m2, meta2);
if (error != 0) {
if (!lastFragment)
NG_FREE_DATA(m, meta);
return (error);
}
}
}
/* Done */
return (0);
} | /*
* Deliver a frame out on the bundle, i.e., figure out how to fragment
* the frame across the individual PPP links and do so.
*/ | Deliver a frame out on the bundle, i.e., figure out how to fragment
the frame across the individual PPP links and do so. | [
"Deliver",
"a",
"frame",
"out",
"on",
"the",
"bundle",
"i",
".",
"e",
".",
"figure",
"out",
"how",
"to",
"fragment",
"the",
"frame",
"across",
"the",
"individual",
"PPP",
"links",
"and",
"do",
"so",
"."
] | static int
ng_ppp_mp_output(node_p node, struct mbuf *m, meta_p meta)
{
const priv_p priv = node->private;
const int hdr_len = priv->conf.xmitShortSeq ? 2 : 4;
int distrib[NG_PPP_MAX_LINKS];
int firstFragment;
int activeLinkNum;
if (priv->numActiveLinks == 0) {
NG_FREE_DATA(m, meta);
return (ENETDOWN);
}
if (priv->conf.enableRoundRobin || m->m_pkthdr.len < MP_MIN_FRAG_LEN) {
activeLinkNum = priv->lastLink++ % priv->numActiveLinks;
bzero(&distrib, priv->numActiveLinks * sizeof(distrib[0]));
distrib[activeLinkNum] = m->m_pkthdr.len;
goto deliver;
}
if (priv->allLinksEqual) {
const int fraction = m->m_pkthdr.len / priv->numActiveLinks;
int i, remain;
for (i = 0; i < priv->numActiveLinks; i++)
distrib[priv->lastLink++ % priv->numActiveLinks]
= fraction;
remain = m->m_pkthdr.len - (fraction * priv->numActiveLinks);
while (remain > 0) {
distrib[priv->lastLink++ % priv->numActiveLinks]++;
remain--;
}
goto deliver;
}
ng_ppp_mp_strategy(node, m->m_pkthdr.len, distrib);
deliver:
priv->bundleStats.xmitFrames++;
priv->bundleStats.xmitOctets += m->m_pkthdr.len;
for (firstFragment = 1, activeLinkNum = priv->numActiveLinks - 1;
activeLinkNum >= 0; activeLinkNum--) {
const int linkNum = priv->activeLinks[activeLinkNum];
struct ng_ppp_link *const link = &priv->links[linkNum];
for ( ; distrib[activeLinkNum] > 0; firstFragment = 0) {
int len, lastFragment, error;
struct mbuf *m2;
meta_p meta2;
len = distrib[activeLinkNum];
if (len > link->conf.mru - hdr_len)
len = link->conf.mru - hdr_len;
distrib[activeLinkNum] -= len;
lastFragment = (len == m->m_pkthdr.len);
m2 = m;
if (!lastFragment) {
struct mbuf *n = m_split(m, len, M_NOWAIT);
if (n == NULL) {
NG_FREE_DATA(m, meta);
return (ENOMEM);
}
m = n;
}
if (priv->conf.xmitShortSeq) {
u_int16_t shdr;
shdr = priv->xseq;
priv->xseq =
(priv->xseq + 1) & MP_SHORT_SEQ_MASK;
if (firstFragment)
shdr |= MP_SHORT_FIRST_FLAG;
if (lastFragment)
shdr |= MP_SHORT_LAST_FLAG;
shdr = htons(shdr);
m2 = ng_ppp_prepend(m2, &shdr, 2);
} else {
u_int32_t lhdr;
lhdr = priv->xseq;
priv->xseq =
(priv->xseq + 1) & MP_LONG_SEQ_MASK;
if (firstFragment)
lhdr |= MP_LONG_FIRST_FLAG;
if (lastFragment)
lhdr |= MP_LONG_LAST_FLAG;
lhdr = htonl(lhdr);
m2 = ng_ppp_prepend(m2, &lhdr, 4);
}
if (m2 == NULL) {
if (!lastFragment)
m_freem(m);
NG_FREE_META(meta);
return (ENOBUFS);
}
meta2 = lastFragment ? meta : ng_copy_meta(meta);
error = ng_ppp_output(node, 0,
PROT_MP, linkNum, m2, meta2);
if (error != 0) {
if (!lastFragment)
NG_FREE_DATA(m, meta);
return (error);
}
}
}
return (0);
} | [
"static",
"int",
"ng_ppp_mp_output",
"(",
"node_p",
"node",
",",
"struct",
"mbuf",
"*",
"m",
",",
"meta_p",
"meta",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"const",
"int",
"hdr_len",
"=",
"priv",
"->",
"conf",
".",
"xmitShortSeq",
"?",
"2",
":",
"4",
";",
"int",
"distrib",
"[",
"NG_PPP_MAX_LINKS",
"]",
";",
"int",
"firstFragment",
";",
"int",
"activeLinkNum",
";",
"if",
"(",
"priv",
"->",
"numActiveLinks",
"==",
"0",
")",
"{",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"ENETDOWN",
")",
";",
"}",
"if",
"(",
"priv",
"->",
"conf",
".",
"enableRoundRobin",
"||",
"m",
"->",
"m_pkthdr",
".",
"len",
"<",
"MP_MIN_FRAG_LEN",
")",
"{",
"activeLinkNum",
"=",
"priv",
"->",
"lastLink",
"++",
"%",
"priv",
"->",
"numActiveLinks",
";",
"bzero",
"(",
"&",
"distrib",
",",
"priv",
"->",
"numActiveLinks",
"*",
"sizeof",
"(",
"distrib",
"[",
"0",
"]",
")",
")",
";",
"distrib",
"[",
"activeLinkNum",
"]",
"=",
"m",
"->",
"m_pkthdr",
".",
"len",
";",
"goto",
"deliver",
";",
"}",
"if",
"(",
"priv",
"->",
"allLinksEqual",
")",
"{",
"const",
"int",
"fraction",
"=",
"m",
"->",
"m_pkthdr",
".",
"len",
"/",
"priv",
"->",
"numActiveLinks",
";",
"int",
"i",
",",
"remain",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"priv",
"->",
"numActiveLinks",
";",
"i",
"++",
")",
"distrib",
"[",
"priv",
"->",
"lastLink",
"++",
"%",
"priv",
"->",
"numActiveLinks",
"]",
"=",
"fraction",
";",
"remain",
"=",
"m",
"->",
"m_pkthdr",
".",
"len",
"-",
"(",
"fraction",
"*",
"priv",
"->",
"numActiveLinks",
")",
";",
"while",
"(",
"remain",
">",
"0",
")",
"{",
"distrib",
"[",
"priv",
"->",
"lastLink",
"++",
"%",
"priv",
"->",
"numActiveLinks",
"]",
"++",
";",
"remain",
"--",
";",
"}",
"goto",
"deliver",
";",
"}",
"ng_ppp_mp_strategy",
"(",
"node",
",",
"m",
"->",
"m_pkthdr",
".",
"len",
",",
"distrib",
")",
";",
"deliver",
":",
"priv",
"->",
"bundleStats",
".",
"xmitFrames",
"++",
";",
"priv",
"->",
"bundleStats",
".",
"xmitOctets",
"+=",
"m",
"->",
"m_pkthdr",
".",
"len",
";",
"for",
"(",
"firstFragment",
"=",
"1",
",",
"activeLinkNum",
"=",
"priv",
"->",
"numActiveLinks",
"-",
"1",
";",
"activeLinkNum",
">=",
"0",
";",
"activeLinkNum",
"--",
")",
"{",
"const",
"int",
"linkNum",
"=",
"priv",
"->",
"activeLinks",
"[",
"activeLinkNum",
"]",
";",
"struct",
"ng_ppp_link",
"*",
"const",
"link",
"=",
"&",
"priv",
"->",
"links",
"[",
"linkNum",
"]",
";",
"for",
"(",
";",
"distrib",
"[",
"activeLinkNum",
"]",
">",
"0",
";",
"firstFragment",
"=",
"0",
")",
"{",
"int",
"len",
",",
"lastFragment",
",",
"error",
";",
"struct",
"mbuf",
"*",
"m2",
";",
"meta_p",
"meta2",
";",
"len",
"=",
"distrib",
"[",
"activeLinkNum",
"]",
";",
"if",
"(",
"len",
">",
"link",
"->",
"conf",
".",
"mru",
"-",
"hdr_len",
")",
"len",
"=",
"link",
"->",
"conf",
".",
"mru",
"-",
"hdr_len",
";",
"distrib",
"[",
"activeLinkNum",
"]",
"-=",
"len",
";",
"lastFragment",
"=",
"(",
"len",
"==",
"m",
"->",
"m_pkthdr",
".",
"len",
")",
";",
"m2",
"=",
"m",
";",
"if",
"(",
"!",
"lastFragment",
")",
"{",
"struct",
"mbuf",
"*",
"n",
"=",
"m_split",
"(",
"m",
",",
"len",
",",
"M_NOWAIT",
")",
";",
"if",
"(",
"n",
"==",
"NULL",
")",
"{",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"ENOMEM",
")",
";",
"}",
"m",
"=",
"n",
";",
"}",
"if",
"(",
"priv",
"->",
"conf",
".",
"xmitShortSeq",
")",
"{",
"u_int16_t",
"shdr",
";",
"shdr",
"=",
"priv",
"->",
"xseq",
";",
"priv",
"->",
"xseq",
"=",
"(",
"priv",
"->",
"xseq",
"+",
"1",
")",
"&",
"MP_SHORT_SEQ_MASK",
";",
"if",
"(",
"firstFragment",
")",
"shdr",
"|=",
"MP_SHORT_FIRST_FLAG",
";",
"if",
"(",
"lastFragment",
")",
"shdr",
"|=",
"MP_SHORT_LAST_FLAG",
";",
"shdr",
"=",
"htons",
"(",
"shdr",
")",
";",
"m2",
"=",
"ng_ppp_prepend",
"(",
"m2",
",",
"&",
"shdr",
",",
"2",
")",
";",
"}",
"else",
"{",
"u_int32_t",
"lhdr",
";",
"lhdr",
"=",
"priv",
"->",
"xseq",
";",
"priv",
"->",
"xseq",
"=",
"(",
"priv",
"->",
"xseq",
"+",
"1",
")",
"&",
"MP_LONG_SEQ_MASK",
";",
"if",
"(",
"firstFragment",
")",
"lhdr",
"|=",
"MP_LONG_FIRST_FLAG",
";",
"if",
"(",
"lastFragment",
")",
"lhdr",
"|=",
"MP_LONG_LAST_FLAG",
";",
"lhdr",
"=",
"htonl",
"(",
"lhdr",
")",
";",
"m2",
"=",
"ng_ppp_prepend",
"(",
"m2",
",",
"&",
"lhdr",
",",
"4",
")",
";",
"}",
"if",
"(",
"m2",
"==",
"NULL",
")",
"{",
"if",
"(",
"!",
"lastFragment",
")",
"m_freem",
"(",
"m",
")",
";",
"NG_FREE_META",
"(",
"meta",
")",
";",
"return",
"(",
"ENOBUFS",
")",
";",
"}",
"meta2",
"=",
"lastFragment",
"?",
"meta",
":",
"ng_copy_meta",
"(",
"meta",
")",
";",
"error",
"=",
"ng_ppp_output",
"(",
"node",
",",
"0",
",",
"PROT_MP",
",",
"linkNum",
",",
"m2",
",",
"meta2",
")",
";",
"if",
"(",
"error",
"!=",
"0",
")",
"{",
"if",
"(",
"!",
"lastFragment",
")",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"error",
")",
";",
"}",
"}",
"}",
"return",
"(",
"0",
")",
";",
"}"
] | Deliver a frame out on the bundle, i.e., figure out how to fragment
the frame across the individual PPP links and do so. | [
"Deliver",
"a",
"frame",
"out",
"on",
"the",
"bundle",
"i",
".",
"e",
".",
"figure",
"out",
"how",
"to",
"fragment",
"the",
"frame",
"across",
"the",
"individual",
"PPP",
"links",
"and",
"do",
"so",
"."
] | [
"/* At least one link must be active */",
"/* Round-robin strategy */",
"/* Strategy when all links are equivalent (optimize the common case) */",
"/* Strategy when all links are not equivalent */",
"/* Update stats */",
"/* Send alloted portions of frame out on the link(s) */",
"/* Deliver fragment(s) out the next link */",
"/* Calculate fragment length; don't exceed link MTU */",
"/* Split off next fragment as \"m2\" */",
"/* Prepend MP header */",
"/* Copy the meta information, if any */",
"/* Send fragment */",
"/* Done */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "m",
"type": "struct mbuf"
},
{
"param": "meta",
"type": "meta_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "m",
"type": "struct mbuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "meta",
"type": "meta_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_addproto | null | static struct mbuf *
ng_ppp_addproto(struct mbuf *m, int proto, int compOK)
{
if (compOK && PROT_COMPRESSABLE(proto)) {
u_char pbyte = (u_char)proto;
return ng_ppp_prepend(m, &pbyte, 1);
} else {
u_int16_t pword = htons((u_int16_t)proto);
return ng_ppp_prepend(m, &pword, 2);
}
} | /*
* Prepend a possibly compressed PPP protocol number in front of a frame
*/ | Prepend a possibly compressed PPP protocol number in front of a frame | [
"Prepend",
"a",
"possibly",
"compressed",
"PPP",
"protocol",
"number",
"in",
"front",
"of",
"a",
"frame"
] | static struct mbuf *
ng_ppp_addproto(struct mbuf *m, int proto, int compOK)
{
if (compOK && PROT_COMPRESSABLE(proto)) {
u_char pbyte = (u_char)proto;
return ng_ppp_prepend(m, &pbyte, 1);
} else {
u_int16_t pword = htons((u_int16_t)proto);
return ng_ppp_prepend(m, &pword, 2);
}
} | [
"static",
"struct",
"mbuf",
"*",
"ng_ppp_addproto",
"(",
"struct",
"mbuf",
"*",
"m",
",",
"int",
"proto",
",",
"int",
"compOK",
")",
"{",
"if",
"(",
"compOK",
"&&",
"PROT_COMPRESSABLE",
"(",
"proto",
")",
")",
"{",
"u_char",
"pbyte",
"=",
"(",
"u_char",
")",
"proto",
";",
"return",
"ng_ppp_prepend",
"(",
"m",
",",
"&",
"pbyte",
",",
"1",
")",
";",
"}",
"else",
"{",
"u_int16_t",
"pword",
"=",
"htons",
"(",
"(",
"u_int16_t",
")",
"proto",
")",
";",
"return",
"ng_ppp_prepend",
"(",
"m",
",",
"&",
"pword",
",",
"2",
")",
";",
"}",
"}"
] | Prepend a possibly compressed PPP protocol number in front of a frame | [
"Prepend",
"a",
"possibly",
"compressed",
"PPP",
"protocol",
"number",
"in",
"front",
"of",
"a",
"frame"
] | [] | [
{
"param": "m",
"type": "struct mbuf"
},
{
"param": "proto",
"type": "int"
},
{
"param": "compOK",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "m",
"type": "struct mbuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "proto",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compOK",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_update | void | static void
ng_ppp_update(node_p node, int newConf)
{
const priv_p priv = node->private;
int i;
/* Update active status for VJ Compression */
priv->vjCompHooked = priv->hooks[HOOK_INDEX_VJC_IP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_COMP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_UNCOMP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_VJIP] != NULL;
/* Increase latency for each link an amount equal to one MP header */
if (newConf) {
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
int hdrBytes;
hdrBytes = (priv->links[i].conf.enableACFComp ? 0 : 2)
+ (priv->links[i].conf.enableProtoComp ? 1 : 2)
+ (priv->conf.xmitShortSeq ? 2 : 4);
priv->links[i].conf.latency +=
((hdrBytes * priv->links[i].conf.bandwidth) + 50)
/ 100;
}
}
/* Update list of active links */
bzero(&priv->activeLinks, sizeof(priv->activeLinks));
priv->numActiveLinks = 0;
priv->allLinksEqual = 1;
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
struct ng_ppp_link *const link = &priv->links[i];
/* Is link active? */
if (link->conf.enableLink && link->hook != NULL) {
struct ng_ppp_link *link0;
/* Add link to list of active links */
priv->activeLinks[priv->numActiveLinks++] = i;
link0 = &priv->links[priv->activeLinks[0]];
/* Determine if all links are still equal */
if (link->conf.latency != link0->conf.latency
|| link->conf.bandwidth != link0->conf.bandwidth)
priv->allLinksEqual = 0;
/* Initialize rec'd sequence number */
if (link->seq == MP_NOSEQ) {
link->seq = (link == link0) ?
MP_INITIAL_SEQ : link0->seq;
}
} else
link->seq = MP_NOSEQ;
}
/* Update MP state as multi-link is active or not */
if (priv->conf.enableMultilink && priv->numActiveLinks > 0)
ng_ppp_start_frag_timer(node);
else {
ng_ppp_stop_frag_timer(node);
ng_ppp_frag_reset(node);
priv->xseq = MP_INITIAL_SEQ;
priv->mseq = MP_INITIAL_SEQ;
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
struct ng_ppp_link *const link = &priv->links[i];
bzero(&link->lastWrite, sizeof(link->lastWrite));
link->bytesInQueue = 0;
link->seq = MP_NOSEQ;
}
}
} | /*
* Update private information that is derived from other private information
*/ | Update private information that is derived from other private information | [
"Update",
"private",
"information",
"that",
"is",
"derived",
"from",
"other",
"private",
"information"
] | static void
ng_ppp_update(node_p node, int newConf)
{
const priv_p priv = node->private;
int i;
priv->vjCompHooked = priv->hooks[HOOK_INDEX_VJC_IP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_COMP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_UNCOMP] != NULL
&& priv->hooks[HOOK_INDEX_VJC_VJIP] != NULL;
if (newConf) {
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
int hdrBytes;
hdrBytes = (priv->links[i].conf.enableACFComp ? 0 : 2)
+ (priv->links[i].conf.enableProtoComp ? 1 : 2)
+ (priv->conf.xmitShortSeq ? 2 : 4);
priv->links[i].conf.latency +=
((hdrBytes * priv->links[i].conf.bandwidth) + 50)
/ 100;
}
}
bzero(&priv->activeLinks, sizeof(priv->activeLinks));
priv->numActiveLinks = 0;
priv->allLinksEqual = 1;
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
struct ng_ppp_link *const link = &priv->links[i];
if (link->conf.enableLink && link->hook != NULL) {
struct ng_ppp_link *link0;
priv->activeLinks[priv->numActiveLinks++] = i;
link0 = &priv->links[priv->activeLinks[0]];
if (link->conf.latency != link0->conf.latency
|| link->conf.bandwidth != link0->conf.bandwidth)
priv->allLinksEqual = 0;
if (link->seq == MP_NOSEQ) {
link->seq = (link == link0) ?
MP_INITIAL_SEQ : link0->seq;
}
} else
link->seq = MP_NOSEQ;
}
if (priv->conf.enableMultilink && priv->numActiveLinks > 0)
ng_ppp_start_frag_timer(node);
else {
ng_ppp_stop_frag_timer(node);
ng_ppp_frag_reset(node);
priv->xseq = MP_INITIAL_SEQ;
priv->mseq = MP_INITIAL_SEQ;
for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
struct ng_ppp_link *const link = &priv->links[i];
bzero(&link->lastWrite, sizeof(link->lastWrite));
link->bytesInQueue = 0;
link->seq = MP_NOSEQ;
}
}
} | [
"static",
"void",
"ng_ppp_update",
"(",
"node_p",
"node",
",",
"int",
"newConf",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"int",
"i",
";",
"priv",
"->",
"vjCompHooked",
"=",
"priv",
"->",
"hooks",
"[",
"HOOK_INDEX_VJC_IP",
"]",
"!=",
"NULL",
"&&",
"priv",
"->",
"hooks",
"[",
"HOOK_INDEX_VJC_COMP",
"]",
"!=",
"NULL",
"&&",
"priv",
"->",
"hooks",
"[",
"HOOK_INDEX_VJC_UNCOMP",
"]",
"!=",
"NULL",
"&&",
"priv",
"->",
"hooks",
"[",
"HOOK_INDEX_VJC_VJIP",
"]",
"!=",
"NULL",
";",
"if",
"(",
"newConf",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"NG_PPP_MAX_LINKS",
";",
"i",
"++",
")",
"{",
"int",
"hdrBytes",
";",
"hdrBytes",
"=",
"(",
"priv",
"->",
"links",
"[",
"i",
"]",
".",
"conf",
".",
"enableACFComp",
"?",
"0",
":",
"2",
")",
"+",
"(",
"priv",
"->",
"links",
"[",
"i",
"]",
".",
"conf",
".",
"enableProtoComp",
"?",
"1",
":",
"2",
")",
"+",
"(",
"priv",
"->",
"conf",
".",
"xmitShortSeq",
"?",
"2",
":",
"4",
")",
";",
"priv",
"->",
"links",
"[",
"i",
"]",
".",
"conf",
".",
"latency",
"+=",
"(",
"(",
"hdrBytes",
"*",
"priv",
"->",
"links",
"[",
"i",
"]",
".",
"conf",
".",
"bandwidth",
")",
"+",
"50",
")",
"/",
"100",
";",
"}",
"}",
"bzero",
"(",
"&",
"priv",
"->",
"activeLinks",
",",
"sizeof",
"(",
"priv",
"->",
"activeLinks",
")",
")",
";",
"priv",
"->",
"numActiveLinks",
"=",
"0",
";",
"priv",
"->",
"allLinksEqual",
"=",
"1",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"NG_PPP_MAX_LINKS",
";",
"i",
"++",
")",
"{",
"struct",
"ng_ppp_link",
"*",
"const",
"link",
"=",
"&",
"priv",
"->",
"links",
"[",
"i",
"]",
";",
"if",
"(",
"link",
"->",
"conf",
".",
"enableLink",
"&&",
"link",
"->",
"hook",
"!=",
"NULL",
")",
"{",
"struct",
"ng_ppp_link",
"*",
"link0",
";",
"priv",
"->",
"activeLinks",
"[",
"priv",
"->",
"numActiveLinks",
"++",
"]",
"=",
"i",
";",
"link0",
"=",
"&",
"priv",
"->",
"links",
"[",
"priv",
"->",
"activeLinks",
"[",
"0",
"]",
"]",
";",
"if",
"(",
"link",
"->",
"conf",
".",
"latency",
"!=",
"link0",
"->",
"conf",
".",
"latency",
"||",
"link",
"->",
"conf",
".",
"bandwidth",
"!=",
"link0",
"->",
"conf",
".",
"bandwidth",
")",
"priv",
"->",
"allLinksEqual",
"=",
"0",
";",
"if",
"(",
"link",
"->",
"seq",
"==",
"MP_NOSEQ",
")",
"{",
"link",
"->",
"seq",
"=",
"(",
"link",
"==",
"link0",
")",
"?",
"MP_INITIAL_SEQ",
":",
"link0",
"->",
"seq",
";",
"}",
"}",
"else",
"link",
"->",
"seq",
"=",
"MP_NOSEQ",
";",
"}",
"if",
"(",
"priv",
"->",
"conf",
".",
"enableMultilink",
"&&",
"priv",
"->",
"numActiveLinks",
">",
"0",
")",
"ng_ppp_start_frag_timer",
"(",
"node",
")",
";",
"else",
"{",
"ng_ppp_stop_frag_timer",
"(",
"node",
")",
";",
"ng_ppp_frag_reset",
"(",
"node",
")",
";",
"priv",
"->",
"xseq",
"=",
"MP_INITIAL_SEQ",
";",
"priv",
"->",
"mseq",
"=",
"MP_INITIAL_SEQ",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"NG_PPP_MAX_LINKS",
";",
"i",
"++",
")",
"{",
"struct",
"ng_ppp_link",
"*",
"const",
"link",
"=",
"&",
"priv",
"->",
"links",
"[",
"i",
"]",
";",
"bzero",
"(",
"&",
"link",
"->",
"lastWrite",
",",
"sizeof",
"(",
"link",
"->",
"lastWrite",
")",
")",
";",
"link",
"->",
"bytesInQueue",
"=",
"0",
";",
"link",
"->",
"seq",
"=",
"MP_NOSEQ",
";",
"}",
"}",
"}"
] | Update private information that is derived from other private information | [
"Update",
"private",
"information",
"that",
"is",
"derived",
"from",
"other",
"private",
"information"
] | [
"/* Update active status for VJ Compression */",
"/* Increase latency for each link an amount equal to one MP header */",
"/* Update list of active links */",
"/* Is link active? */",
"/* Add link to list of active links */",
"/* Determine if all links are still equal */",
"/* Initialize rec'd sequence number */",
"/* Update MP state as multi-link is active or not */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "newConf",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "newConf",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_config_valid | int | static int
ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf)
{
const priv_p priv = node->private;
int i, newNumLinksActive;
/* Check per-link config and count how many links would be active */
for (newNumLinksActive = i = 0; i < NG_PPP_MAX_LINKS; i++) {
if (newConf->links[i].enableLink && priv->links[i].hook != NULL)
newNumLinksActive++;
if (!newConf->links[i].enableLink)
continue;
if (newConf->links[i].mru < MP_MIN_LINK_MRU)
return (0);
if (newConf->links[i].bandwidth == 0)
return (0);
if (newConf->links[i].bandwidth > NG_PPP_MAX_BANDWIDTH)
return (0);
if (newConf->links[i].latency > NG_PPP_MAX_LATENCY)
return (0);
}
/* Check bundle parameters */
if (newConf->bund.enableMultilink && newConf->bund.mrru < MP_MIN_MRRU)
return (0);
/* Disallow changes to multi-link configuration while MP is active */
if (priv->numActiveLinks > 0 && newNumLinksActive > 0) {
if (!priv->conf.enableMultilink
!= !newConf->bund.enableMultilink
|| !priv->conf.xmitShortSeq != !newConf->bund.xmitShortSeq
|| !priv->conf.recvShortSeq != !newConf->bund.recvShortSeq)
return (0);
}
/* At most one link can be active unless multi-link is enabled */
if (!newConf->bund.enableMultilink && newNumLinksActive > 1)
return (0);
/* Configuration change would be valid */
return (1);
} | /*
* Determine if a new configuration would represent a valid change
* from the current configuration and link activity status.
*/ | Determine if a new configuration would represent a valid change
from the current configuration and link activity status. | [
"Determine",
"if",
"a",
"new",
"configuration",
"would",
"represent",
"a",
"valid",
"change",
"from",
"the",
"current",
"configuration",
"and",
"link",
"activity",
"status",
"."
] | static int
ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf)
{
const priv_p priv = node->private;
int i, newNumLinksActive;
for (newNumLinksActive = i = 0; i < NG_PPP_MAX_LINKS; i++) {
if (newConf->links[i].enableLink && priv->links[i].hook != NULL)
newNumLinksActive++;
if (!newConf->links[i].enableLink)
continue;
if (newConf->links[i].mru < MP_MIN_LINK_MRU)
return (0);
if (newConf->links[i].bandwidth == 0)
return (0);
if (newConf->links[i].bandwidth > NG_PPP_MAX_BANDWIDTH)
return (0);
if (newConf->links[i].latency > NG_PPP_MAX_LATENCY)
return (0);
}
if (newConf->bund.enableMultilink && newConf->bund.mrru < MP_MIN_MRRU)
return (0);
if (priv->numActiveLinks > 0 && newNumLinksActive > 0) {
if (!priv->conf.enableMultilink
!= !newConf->bund.enableMultilink
|| !priv->conf.xmitShortSeq != !newConf->bund.xmitShortSeq
|| !priv->conf.recvShortSeq != !newConf->bund.recvShortSeq)
return (0);
}
if (!newConf->bund.enableMultilink && newNumLinksActive > 1)
return (0);
return (1);
} | [
"static",
"int",
"ng_ppp_config_valid",
"(",
"node_p",
"node",
",",
"const",
"struct",
"ng_ppp_node_conf",
"*",
"newConf",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"int",
"i",
",",
"newNumLinksActive",
";",
"for",
"(",
"newNumLinksActive",
"=",
"i",
"=",
"0",
";",
"i",
"<",
"NG_PPP_MAX_LINKS",
";",
"i",
"++",
")",
"{",
"if",
"(",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"enableLink",
"&&",
"priv",
"->",
"links",
"[",
"i",
"]",
".",
"hook",
"!=",
"NULL",
")",
"newNumLinksActive",
"++",
";",
"if",
"(",
"!",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"enableLink",
")",
"continue",
";",
"if",
"(",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"mru",
"<",
"MP_MIN_LINK_MRU",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"bandwidth",
"==",
"0",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"bandwidth",
">",
"NG_PPP_MAX_BANDWIDTH",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"newConf",
"->",
"links",
"[",
"i",
"]",
".",
"latency",
">",
"NG_PPP_MAX_LATENCY",
")",
"return",
"(",
"0",
")",
";",
"}",
"if",
"(",
"newConf",
"->",
"bund",
".",
"enableMultilink",
"&&",
"newConf",
"->",
"bund",
".",
"mrru",
"<",
"MP_MIN_MRRU",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"priv",
"->",
"numActiveLinks",
">",
"0",
"&&",
"newNumLinksActive",
">",
"0",
")",
"{",
"if",
"(",
"!",
"priv",
"->",
"conf",
".",
"enableMultilink",
"!=",
"!",
"newConf",
"->",
"bund",
".",
"enableMultilink",
"||",
"!",
"priv",
"->",
"conf",
".",
"xmitShortSeq",
"!=",
"!",
"newConf",
"->",
"bund",
".",
"xmitShortSeq",
"||",
"!",
"priv",
"->",
"conf",
".",
"recvShortSeq",
"!=",
"!",
"newConf",
"->",
"bund",
".",
"recvShortSeq",
")",
"return",
"(",
"0",
")",
";",
"}",
"if",
"(",
"!",
"newConf",
"->",
"bund",
".",
"enableMultilink",
"&&",
"newNumLinksActive",
">",
"1",
")",
"return",
"(",
"0",
")",
";",
"return",
"(",
"1",
")",
";",
"}"
] | Determine if a new configuration would represent a valid change
from the current configuration and link activity status. | [
"Determine",
"if",
"a",
"new",
"configuration",
"would",
"represent",
"a",
"valid",
"change",
"from",
"the",
"current",
"configuration",
"and",
"link",
"activity",
"status",
"."
] | [
"/* Check per-link config and count how many links would be active */",
"/* Check bundle parameters */",
"/* Disallow changes to multi-link configuration while MP is active */",
"/* At most one link can be active unless multi-link is enabled */",
"/* Configuration change would be valid */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "newConf",
"type": "struct ng_ppp_node_conf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "newConf",
"type": "struct ng_ppp_node_conf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_frag_reset | void | static void
ng_ppp_frag_reset(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
for (qent = TAILQ_FIRST(&priv->frags); qent; qent = qnext) {
qnext = TAILQ_NEXT(qent, f_qent);
NG_FREE_DATA(qent->data, qent->meta);
kfree(qent, M_NETGRAPH);
}
TAILQ_INIT(&priv->frags);
priv->qlen = 0;
} | /*
* Free all entries in the fragment queue
*/ | Free all entries in the fragment queue | [
"Free",
"all",
"entries",
"in",
"the",
"fragment",
"queue"
] | static void
ng_ppp_frag_reset(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
for (qent = TAILQ_FIRST(&priv->frags); qent; qent = qnext) {
qnext = TAILQ_NEXT(qent, f_qent);
NG_FREE_DATA(qent->data, qent->meta);
kfree(qent, M_NETGRAPH);
}
TAILQ_INIT(&priv->frags);
priv->qlen = 0;
} | [
"static",
"void",
"ng_ppp_frag_reset",
"(",
"node_p",
"node",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"struct",
"ng_ppp_frag",
"*",
"qent",
",",
"*",
"qnext",
";",
"for",
"(",
"qent",
"=",
"TAILQ_FIRST",
"(",
"&",
"priv",
"->",
"frags",
")",
";",
"qent",
";",
"qent",
"=",
"qnext",
")",
"{",
"qnext",
"=",
"TAILQ_NEXT",
"(",
"qent",
",",
"f_qent",
")",
";",
"NG_FREE_DATA",
"(",
"qent",
"->",
"data",
",",
"qent",
"->",
"meta",
")",
";",
"kfree",
"(",
"qent",
",",
"M_NETGRAPH",
")",
";",
"}",
"TAILQ_INIT",
"(",
"&",
"priv",
"->",
"frags",
")",
";",
"priv",
"->",
"qlen",
"=",
"0",
";",
"}"
] | Free all entries in the fragment queue | [
"Free",
"all",
"entries",
"in",
"the",
"fragment",
"queue"
] | [] | [
{
"param": "node",
"type": "node_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb480180c0b908a74ef77a0926370dc12439d614 | atrens/DragonFlyBSD-src | lib/libc/stdlib/twalk.c | [
"BSD-3-Clause"
] | C | trecurse | void | static void
trecurse(const node_t *root, void (*action)(const void *, VISIT, int),
int level)
{
if (root->llink == NULL && root->rlink == NULL)
(*action)(root, leaf, level);
else {
(*action)(root, preorder, level);
if (root->llink != NULL)
trecurse(root->llink, action, level + 1);
(*action)(root, postorder, level);
if (root->rlink != NULL)
trecurse(root->rlink, action, level + 1);
(*action)(root, endorder, level);
}
} | /*
* Walk the nodes of a tree
*
* Parameters:
* root: Root of the tree to be walked
*/ | Walk the nodes of a tree
Parameters:
root: Root of the tree to be walked | [
"Walk",
"the",
"nodes",
"of",
"a",
"tree",
"Parameters",
":",
"root",
":",
"Root",
"of",
"the",
"tree",
"to",
"be",
"walked"
] | static void
trecurse(const node_t *root, void (*action)(const void *, VISIT, int),
int level)
{
if (root->llink == NULL && root->rlink == NULL)
(*action)(root, leaf, level);
else {
(*action)(root, preorder, level);
if (root->llink != NULL)
trecurse(root->llink, action, level + 1);
(*action)(root, postorder, level);
if (root->rlink != NULL)
trecurse(root->rlink, action, level + 1);
(*action)(root, endorder, level);
}
} | [
"static",
"void",
"trecurse",
"(",
"const",
"node_t",
"*",
"root",
",",
"void",
"(",
"*",
"action",
")",
"(",
"const",
"void",
"*",
",",
"VISIT",
",",
"int",
")",
",",
"int",
"level",
")",
"{",
"if",
"(",
"root",
"->",
"llink",
"==",
"NULL",
"&&",
"root",
"->",
"rlink",
"==",
"NULL",
")",
"(",
"*",
"action",
")",
"(",
"root",
",",
"leaf",
",",
"level",
")",
";",
"else",
"{",
"(",
"*",
"action",
")",
"(",
"root",
",",
"preorder",
",",
"level",
")",
";",
"if",
"(",
"root",
"->",
"llink",
"!=",
"NULL",
")",
"trecurse",
"(",
"root",
"->",
"llink",
",",
"action",
",",
"level",
"+",
"1",
")",
";",
"(",
"*",
"action",
")",
"(",
"root",
",",
"postorder",
",",
"level",
")",
";",
"if",
"(",
"root",
"->",
"rlink",
"!=",
"NULL",
")",
"trecurse",
"(",
"root",
"->",
"rlink",
",",
"action",
",",
"level",
"+",
"1",
")",
";",
"(",
"*",
"action",
")",
"(",
"root",
",",
"endorder",
",",
"level",
")",
";",
"}",
"}"
] | Walk the nodes of a tree
Parameters:
root: Root of the tree to be walked | [
"Walk",
"the",
"nodes",
"of",
"a",
"tree",
"Parameters",
":",
"root",
":",
"Root",
"of",
"the",
"tree",
"to",
"be",
"walked"
] | [] | [
{
"param": "root",
"type": "node_t"
},
{
"param": "action",
"type": "void"
},
{
"param": "level",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "root",
"type": "node_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "action",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "level",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb480180c0b908a74ef77a0926370dc12439d614 | atrens/DragonFlyBSD-src | lib/libc/stdlib/twalk.c | [
"BSD-3-Clause"
] | C | twalk | void | void
twalk(const void *vroot,
void (*action)(const void *, VISIT, int))
{
if (vroot != NULL && action != NULL)
trecurse(vroot, action, 0);
} | /*
* Walk the nodes of a tree
*
* Parameters:
* vroot: Root of the tree to be walked
*/ | Walk the nodes of a tree
Parameters:
vroot: Root of the tree to be walked | [
"Walk",
"the",
"nodes",
"of",
"a",
"tree",
"Parameters",
":",
"vroot",
":",
"Root",
"of",
"the",
"tree",
"to",
"be",
"walked"
] | void
twalk(const void *vroot,
void (*action)(const void *, VISIT, int))
{
if (vroot != NULL && action != NULL)
trecurse(vroot, action, 0);
} | [
"void",
"twalk",
"(",
"const",
"void",
"*",
"vroot",
",",
"void",
"(",
"*",
"action",
")",
"(",
"const",
"void",
"*",
",",
"VISIT",
",",
"int",
")",
")",
"{",
"if",
"(",
"vroot",
"!=",
"NULL",
"&&",
"action",
"!=",
"NULL",
")",
"trecurse",
"(",
"vroot",
",",
"action",
",",
"0",
")",
";",
"}"
] | Walk the nodes of a tree
Parameters:
vroot: Root of the tree to be walked | [
"Walk",
"the",
"nodes",
"of",
"a",
"tree",
"Parameters",
":",
"vroot",
":",
"Root",
"of",
"the",
"tree",
"to",
"be",
"walked"
] | [] | [
{
"param": "vroot",
"type": "void"
},
{
"param": "action",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vroot",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "action",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f63a6fdaae653b2bd822dbb58141cc157fa82d72 | atrens/DragonFlyBSD-src | sys/vfs/hammer/hammer_volume.c | [
"BSD-3-Clause"
] | C | hammer_format_freemap | int | static int
hammer_format_freemap(hammer_transaction_t trans, hammer_volume_t volume)
{
hammer_mount_t hmp = trans->hmp;
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t alloc_offset;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int64_t layer1_count = 0;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
alloc_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
hmkprintf(hmp, "Initialize freemap volume %d\n", volume->vol_no);
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
if (layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL) {
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
bzero(layer1, sizeof(*layer1));
layer1->phys_offset = alloc_offset;
layer1->blocks_free = 0;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
alloc_offset += HAMMER_BIGBLOCK_SIZE;
}
}
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_count = 0;
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
hammer_modify_buffer(trans, buffer2, layer2, sizeof(*layer2));
bzero(layer2, sizeof(*layer2));
if (phys_offset + block_offset < alloc_offset) {
layer2->zone = HAMMER_ZONE_FREEMAP_INDEX;
layer2->append_off = HAMMER_BIGBLOCK_SIZE;
layer2->bytes_free = 0;
} else if (phys_offset + block_offset < vol_free_end) {
layer2->zone = 0;
layer2->append_off = 0;
layer2->bytes_free = HAMMER_BIGBLOCK_SIZE;
++layer1_count;
} else {
layer2->zone = HAMMER_ZONE_UNAVAIL_INDEX;
layer2->append_off = HAMMER_BIGBLOCK_SIZE;
layer2->bytes_free = 0;
}
hammer_crc_set_layer2(hmp->version, layer2);
hammer_modify_buffer_done(buffer2);
}
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
layer1->blocks_free += layer1_count;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
}
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | /*
* XXX This somehow needs to stop doing hammer_modify_buffer() for
* layer2 entries. In theory adding a large block device could
* blow away UNDO fifo. The best way is to format layer2 entries
* in userspace without UNDO getting involved before the device is
* safely added to the filesystem. HAMMER has no interest in what
* has happened to the device before it safely joins the filesystem.
*/ | XXX This somehow needs to stop doing hammer_modify_buffer() for
layer2 entries. In theory adding a large block device could
blow away UNDO fifo. The best way is to format layer2 entries
in userspace without UNDO getting involved before the device is
safely added to the filesystem. HAMMER has no interest in what
has happened to the device before it safely joins the filesystem. | [
"XXX",
"This",
"somehow",
"needs",
"to",
"stop",
"doing",
"hammer_modify_buffer",
"()",
"for",
"layer2",
"entries",
".",
"In",
"theory",
"adding",
"a",
"large",
"block",
"device",
"could",
"blow",
"away",
"UNDO",
"fifo",
".",
"The",
"best",
"way",
"is",
"to",
"format",
"layer2",
"entries",
"in",
"userspace",
"without",
"UNDO",
"getting",
"involved",
"before",
"the",
"device",
"is",
"safely",
"added",
"to",
"the",
"filesystem",
".",
"HAMMER",
"has",
"no",
"interest",
"in",
"what",
"has",
"happened",
"to",
"the",
"device",
"before",
"it",
"safely",
"joins",
"the",
"filesystem",
"."
] | static int
hammer_format_freemap(hammer_transaction_t trans, hammer_volume_t volume)
{
hammer_mount_t hmp = trans->hmp;
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t alloc_offset;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int64_t layer1_count = 0;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
alloc_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
hmkprintf(hmp, "Initialize freemap volume %d\n", volume->vol_no);
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
if (layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL) {
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
bzero(layer1, sizeof(*layer1));
layer1->phys_offset = alloc_offset;
layer1->blocks_free = 0;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
alloc_offset += HAMMER_BIGBLOCK_SIZE;
}
}
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_count = 0;
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
hammer_modify_buffer(trans, buffer2, layer2, sizeof(*layer2));
bzero(layer2, sizeof(*layer2));
if (phys_offset + block_offset < alloc_offset) {
layer2->zone = HAMMER_ZONE_FREEMAP_INDEX;
layer2->append_off = HAMMER_BIGBLOCK_SIZE;
layer2->bytes_free = 0;
} else if (phys_offset + block_offset < vol_free_end) {
layer2->zone = 0;
layer2->append_off = 0;
layer2->bytes_free = HAMMER_BIGBLOCK_SIZE;
++layer1_count;
} else {
layer2->zone = HAMMER_ZONE_UNAVAIL_INDEX;
layer2->append_off = HAMMER_BIGBLOCK_SIZE;
layer2->bytes_free = 0;
}
hammer_crc_set_layer2(hmp->version, layer2);
hammer_modify_buffer_done(buffer2);
}
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
layer1->blocks_free += layer1_count;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
}
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | [
"static",
"int",
"hammer_format_freemap",
"(",
"hammer_transaction_t",
"trans",
",",
"hammer_volume_t",
"volume",
")",
"{",
"hammer_mount_t",
"hmp",
"=",
"trans",
"->",
"hmp",
";",
"hammer_volume_ondisk_t",
"ondisk",
";",
"hammer_blockmap_t",
"freemap",
";",
"hammer_off_t",
"alloc_offset",
";",
"hammer_off_t",
"phys_offset",
";",
"hammer_off_t",
"block_offset",
";",
"hammer_off_t",
"layer1_offset",
";",
"hammer_off_t",
"layer2_offset",
";",
"hammer_off_t",
"vol_free_end",
";",
"hammer_off_t",
"aligned_vol_free_end",
";",
"hammer_blockmap_layer1_t",
"layer1",
";",
"hammer_blockmap_layer2_t",
"layer2",
";",
"hammer_buffer_t",
"buffer1",
"=",
"NULL",
";",
"hammer_buffer_t",
"buffer2",
"=",
"NULL",
";",
"int64_t",
"vol_buf_size",
";",
"int64_t",
"layer1_count",
"=",
"0",
";",
"int",
"error",
"=",
"0",
";",
"KKASSERT",
"(",
"volume",
"->",
"vol_no",
"!=",
"HAMMER_ROOT_VOLNO",
")",
";",
"ondisk",
"=",
"volume",
"->",
"ondisk",
";",
"vol_buf_size",
"=",
"HAMMER_VOL_BUF_SIZE",
"(",
"ondisk",
")",
";",
"KKASSERT",
"(",
"(",
"vol_buf_size",
"&",
"~",
"HAMMER_OFF_SHORT_MASK",
")",
"==",
"0",
")",
";",
"vol_free_end",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"ondisk",
"->",
"vol_no",
",",
"vol_buf_size",
"&",
"~",
"HAMMER_BIGBLOCK_MASK64",
")",
";",
"aligned_vol_free_end",
"=",
"HAMMER_BLOCKMAP_LAYER2_DOALIGN",
"(",
"vol_free_end",
")",
";",
"freemap",
"=",
"&",
"hmp",
"->",
"blockmap",
"[",
"HAMMER_ZONE_FREEMAP_INDEX",
"]",
";",
"alloc_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"vol_no",
",",
"0",
")",
";",
"hmkprintf",
"(",
"hmp",
",",
"\"",
"\\n",
"\"",
",",
"volume",
"->",
"vol_no",
")",
";",
"for",
"(",
"phys_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"vol_no",
",",
"0",
")",
";",
"phys_offset",
"<",
"aligned_vol_free_end",
";",
"phys_offset",
"+=",
"HAMMER_BLOCKMAP_LAYER2",
")",
"{",
"layer1_offset",
"=",
"freemap",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER1_OFFSET",
"(",
"phys_offset",
")",
";",
"layer1",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer1_offset",
",",
"&",
"error",
",",
"&",
"buffer1",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"if",
"(",
"layer1",
"->",
"phys_offset",
"==",
"HAMMER_BLOCKMAP_UNAVAIL",
")",
"{",
"hammer_modify_buffer",
"(",
"trans",
",",
"buffer1",
",",
"layer1",
",",
"sizeof",
"(",
"*",
"layer1",
")",
")",
";",
"bzero",
"(",
"layer1",
",",
"sizeof",
"(",
"*",
"layer1",
")",
")",
";",
"layer1",
"->",
"phys_offset",
"=",
"alloc_offset",
";",
"layer1",
"->",
"blocks_free",
"=",
"0",
";",
"hammer_crc_set_layer1",
"(",
"hmp",
"->",
"version",
",",
"layer1",
")",
";",
"hammer_modify_buffer_done",
"(",
"buffer1",
")",
";",
"alloc_offset",
"+=",
"HAMMER_BIGBLOCK_SIZE",
";",
"}",
"}",
"for",
"(",
"phys_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"vol_no",
",",
"0",
")",
";",
"phys_offset",
"<",
"aligned_vol_free_end",
";",
"phys_offset",
"+=",
"HAMMER_BLOCKMAP_LAYER2",
")",
"{",
"layer1_count",
"=",
"0",
";",
"layer1_offset",
"=",
"freemap",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER1_OFFSET",
"(",
"phys_offset",
")",
";",
"layer1",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer1_offset",
",",
"&",
"error",
",",
"&",
"buffer1",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"KKASSERT",
"(",
"layer1",
"->",
"phys_offset",
"!=",
"HAMMER_BLOCKMAP_UNAVAIL",
")",
";",
"for",
"(",
"block_offset",
"=",
"0",
";",
"block_offset",
"<",
"HAMMER_BLOCKMAP_LAYER2",
";",
"block_offset",
"+=",
"HAMMER_BIGBLOCK_SIZE",
")",
"{",
"layer2_offset",
"=",
"layer1",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER2_OFFSET",
"(",
"block_offset",
")",
";",
"layer2",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer2_offset",
",",
"&",
"error",
",",
"&",
"buffer2",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"hammer_modify_buffer",
"(",
"trans",
",",
"buffer2",
",",
"layer2",
",",
"sizeof",
"(",
"*",
"layer2",
")",
")",
";",
"bzero",
"(",
"layer2",
",",
"sizeof",
"(",
"*",
"layer2",
")",
")",
";",
"if",
"(",
"phys_offset",
"+",
"block_offset",
"<",
"alloc_offset",
")",
"{",
"layer2",
"->",
"zone",
"=",
"HAMMER_ZONE_FREEMAP_INDEX",
";",
"layer2",
"->",
"append_off",
"=",
"HAMMER_BIGBLOCK_SIZE",
";",
"layer2",
"->",
"bytes_free",
"=",
"0",
";",
"}",
"else",
"if",
"(",
"phys_offset",
"+",
"block_offset",
"<",
"vol_free_end",
")",
"{",
"layer2",
"->",
"zone",
"=",
"0",
";",
"layer2",
"->",
"append_off",
"=",
"0",
";",
"layer2",
"->",
"bytes_free",
"=",
"HAMMER_BIGBLOCK_SIZE",
";",
"++",
"layer1_count",
";",
"}",
"else",
"{",
"layer2",
"->",
"zone",
"=",
"HAMMER_ZONE_UNAVAIL_INDEX",
";",
"layer2",
"->",
"append_off",
"=",
"HAMMER_BIGBLOCK_SIZE",
";",
"layer2",
"->",
"bytes_free",
"=",
"0",
";",
"}",
"hammer_crc_set_layer2",
"(",
"hmp",
"->",
"version",
",",
"layer2",
")",
";",
"hammer_modify_buffer_done",
"(",
"buffer2",
")",
";",
"}",
"hammer_modify_buffer",
"(",
"trans",
",",
"buffer1",
",",
"layer1",
",",
"sizeof",
"(",
"*",
"layer1",
")",
")",
";",
"layer1",
"->",
"blocks_free",
"+=",
"layer1_count",
";",
"hammer_crc_set_layer1",
"(",
"hmp",
"->",
"version",
",",
"layer1",
")",
";",
"hammer_modify_buffer_done",
"(",
"buffer1",
")",
";",
"}",
"end",
":",
"if",
"(",
"buffer1",
")",
"hammer_rel_buffer",
"(",
"buffer1",
",",
"0",
")",
";",
"if",
"(",
"buffer2",
")",
"hammer_rel_buffer",
"(",
"buffer2",
",",
"0",
")",
";",
"return",
"error",
";",
"}"
] | XXX This somehow needs to stop doing hammer_modify_buffer() for
layer2 entries. | [
"XXX",
"This",
"somehow",
"needs",
"to",
"stop",
"doing",
"hammer_modify_buffer",
"()",
"for",
"layer2",
"entries",
"."
] | [] | [
{
"param": "trans",
"type": "hammer_transaction_t"
},
{
"param": "volume",
"type": "hammer_volume_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "trans",
"type": "hammer_transaction_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "volume",
"type": "hammer_volume_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f63a6fdaae653b2bd822dbb58141cc157fa82d72 | atrens/DragonFlyBSD-src | sys/vfs/hammer/hammer_volume.c | [
"BSD-3-Clause"
] | C | hammer_free_freemap | int | static int
hammer_free_freemap(hammer_transaction_t trans, hammer_volume_t volume)
{
hammer_mount_t hmp = trans->hmp;
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
hmkprintf(hmp, "Free freemap volume %d\n", volume->vol_no);
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
case HAMMER_ZONE_FREEMAP_INDEX:
case HAMMER_ZONE_UNAVAIL_INDEX:
continue;
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
if (layer2->append_off == 0 &&
layer2->bytes_free == HAMMER_BIGBLOCK_SIZE)
continue;
break;
}
return EBUSY; /* Not empty */
}
}
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
hammer_modify_buffer(trans, buffer2, layer2, sizeof(*layer2));
bzero(layer2, sizeof(*layer2));
hammer_modify_buffer_done(buffer2);
break;
}
}
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
bzero(layer1, sizeof(*layer1));
layer1->phys_offset = HAMMER_BLOCKMAP_UNAVAIL;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
}
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | /*
* XXX This somehow needs to stop doing hammer_modify_buffer() for
* layer2 entries. In theory removing a large block device could
* blow away UNDO fifo. The best way is to erase layer2 entries
* in userspace without UNDO getting involved after the device has
* been safely removed from the filesystem. HAMMER has no interest
* in what happens to the device once it's safely removed.
*/ | XXX This somehow needs to stop doing hammer_modify_buffer() for
layer2 entries. In theory removing a large block device could
blow away UNDO fifo. The best way is to erase layer2 entries
in userspace without UNDO getting involved after the device has
been safely removed from the filesystem. HAMMER has no interest
in what happens to the device once it's safely removed. | [
"XXX",
"This",
"somehow",
"needs",
"to",
"stop",
"doing",
"hammer_modify_buffer",
"()",
"for",
"layer2",
"entries",
".",
"In",
"theory",
"removing",
"a",
"large",
"block",
"device",
"could",
"blow",
"away",
"UNDO",
"fifo",
".",
"The",
"best",
"way",
"is",
"to",
"erase",
"layer2",
"entries",
"in",
"userspace",
"without",
"UNDO",
"getting",
"involved",
"after",
"the",
"device",
"has",
"been",
"safely",
"removed",
"from",
"the",
"filesystem",
".",
"HAMMER",
"has",
"no",
"interest",
"in",
"what",
"happens",
"to",
"the",
"device",
"once",
"it",
"'",
"s",
"safely",
"removed",
"."
] | static int
hammer_free_freemap(hammer_transaction_t trans, hammer_volume_t volume)
{
hammer_mount_t hmp = trans->hmp;
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
hmkprintf(hmp, "Free freemap volume %d\n", volume->vol_no);
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
case HAMMER_ZONE_FREEMAP_INDEX:
case HAMMER_ZONE_UNAVAIL_INDEX:
continue;
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
if (layer2->append_off == 0 &&
layer2->bytes_free == HAMMER_BIGBLOCK_SIZE)
continue;
break;
}
return EBUSY;
}
}
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
KKASSERT(layer1->phys_offset != HAMMER_BLOCKMAP_UNAVAIL);
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
hammer_modify_buffer(trans, buffer2, layer2, sizeof(*layer2));
bzero(layer2, sizeof(*layer2));
hammer_modify_buffer_done(buffer2);
break;
}
}
hammer_modify_buffer(trans, buffer1, layer1, sizeof(*layer1));
bzero(layer1, sizeof(*layer1));
layer1->phys_offset = HAMMER_BLOCKMAP_UNAVAIL;
hammer_crc_set_layer1(hmp->version, layer1);
hammer_modify_buffer_done(buffer1);
}
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | [
"static",
"int",
"hammer_free_freemap",
"(",
"hammer_transaction_t",
"trans",
",",
"hammer_volume_t",
"volume",
")",
"{",
"hammer_mount_t",
"hmp",
"=",
"trans",
"->",
"hmp",
";",
"hammer_volume_ondisk_t",
"ondisk",
";",
"hammer_blockmap_t",
"freemap",
";",
"hammer_off_t",
"phys_offset",
";",
"hammer_off_t",
"block_offset",
";",
"hammer_off_t",
"layer1_offset",
";",
"hammer_off_t",
"layer2_offset",
";",
"hammer_off_t",
"vol_free_end",
";",
"hammer_off_t",
"aligned_vol_free_end",
";",
"hammer_blockmap_layer1_t",
"layer1",
";",
"hammer_blockmap_layer2_t",
"layer2",
";",
"hammer_buffer_t",
"buffer1",
"=",
"NULL",
";",
"hammer_buffer_t",
"buffer2",
"=",
"NULL",
";",
"int64_t",
"vol_buf_size",
";",
"int",
"error",
"=",
"0",
";",
"KKASSERT",
"(",
"volume",
"->",
"vol_no",
"!=",
"HAMMER_ROOT_VOLNO",
")",
";",
"ondisk",
"=",
"volume",
"->",
"ondisk",
";",
"vol_buf_size",
"=",
"HAMMER_VOL_BUF_SIZE",
"(",
"ondisk",
")",
";",
"KKASSERT",
"(",
"(",
"vol_buf_size",
"&",
"~",
"HAMMER_OFF_SHORT_MASK",
")",
"==",
"0",
")",
";",
"vol_free_end",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"ondisk",
"->",
"vol_no",
",",
"vol_buf_size",
"&",
"~",
"HAMMER_BIGBLOCK_MASK64",
")",
";",
"aligned_vol_free_end",
"=",
"HAMMER_BLOCKMAP_LAYER2_DOALIGN",
"(",
"vol_free_end",
")",
";",
"freemap",
"=",
"&",
"hmp",
"->",
"blockmap",
"[",
"HAMMER_ZONE_FREEMAP_INDEX",
"]",
";",
"hmkprintf",
"(",
"hmp",
",",
"\"",
"\\n",
"\"",
",",
"volume",
"->",
"vol_no",
")",
";",
"for",
"(",
"phys_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"vol_no",
",",
"0",
")",
";",
"phys_offset",
"<",
"aligned_vol_free_end",
";",
"phys_offset",
"+=",
"HAMMER_BLOCKMAP_LAYER2",
")",
"{",
"layer1_offset",
"=",
"freemap",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER1_OFFSET",
"(",
"phys_offset",
")",
";",
"layer1",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer1_offset",
",",
"&",
"error",
",",
"&",
"buffer1",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"KKASSERT",
"(",
"layer1",
"->",
"phys_offset",
"!=",
"HAMMER_BLOCKMAP_UNAVAIL",
")",
";",
"for",
"(",
"block_offset",
"=",
"0",
";",
"block_offset",
"<",
"HAMMER_BLOCKMAP_LAYER2",
";",
"block_offset",
"+=",
"HAMMER_BIGBLOCK_SIZE",
")",
"{",
"layer2_offset",
"=",
"layer1",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER2_OFFSET",
"(",
"block_offset",
")",
";",
"layer2",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer2_offset",
",",
"&",
"error",
",",
"&",
"buffer2",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"switch",
"(",
"layer2",
"->",
"zone",
")",
"{",
"case",
"HAMMER_ZONE_UNDO_INDEX",
":",
"KKASSERT",
"(",
"0",
")",
";",
"case",
"HAMMER_ZONE_FREEMAP_INDEX",
":",
"case",
"HAMMER_ZONE_UNAVAIL_INDEX",
":",
"continue",
";",
"default",
":",
"KKASSERT",
"(",
"phys_offset",
"+",
"block_offset",
"<",
"aligned_vol_free_end",
")",
";",
"if",
"(",
"layer2",
"->",
"append_off",
"==",
"0",
"&&",
"layer2",
"->",
"bytes_free",
"==",
"HAMMER_BIGBLOCK_SIZE",
")",
"continue",
";",
"break",
";",
"}",
"return",
"EBUSY",
";",
"}",
"}",
"for",
"(",
"phys_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"vol_no",
",",
"0",
")",
";",
"phys_offset",
"<",
"aligned_vol_free_end",
";",
"phys_offset",
"+=",
"HAMMER_BLOCKMAP_LAYER2",
")",
"{",
"layer1_offset",
"=",
"freemap",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER1_OFFSET",
"(",
"phys_offset",
")",
";",
"layer1",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer1_offset",
",",
"&",
"error",
",",
"&",
"buffer1",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"KKASSERT",
"(",
"layer1",
"->",
"phys_offset",
"!=",
"HAMMER_BLOCKMAP_UNAVAIL",
")",
";",
"for",
"(",
"block_offset",
"=",
"0",
";",
"block_offset",
"<",
"HAMMER_BLOCKMAP_LAYER2",
";",
"block_offset",
"+=",
"HAMMER_BIGBLOCK_SIZE",
")",
"{",
"layer2_offset",
"=",
"layer1",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER2_OFFSET",
"(",
"block_offset",
")",
";",
"layer2",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer2_offset",
",",
"&",
"error",
",",
"&",
"buffer2",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"switch",
"(",
"layer2",
"->",
"zone",
")",
"{",
"case",
"HAMMER_ZONE_UNDO_INDEX",
":",
"KKASSERT",
"(",
"0",
")",
";",
"default",
":",
"KKASSERT",
"(",
"phys_offset",
"+",
"block_offset",
"<",
"aligned_vol_free_end",
")",
";",
"hammer_modify_buffer",
"(",
"trans",
",",
"buffer2",
",",
"layer2",
",",
"sizeof",
"(",
"*",
"layer2",
")",
")",
";",
"bzero",
"(",
"layer2",
",",
"sizeof",
"(",
"*",
"layer2",
")",
")",
";",
"hammer_modify_buffer_done",
"(",
"buffer2",
")",
";",
"break",
";",
"}",
"}",
"hammer_modify_buffer",
"(",
"trans",
",",
"buffer1",
",",
"layer1",
",",
"sizeof",
"(",
"*",
"layer1",
")",
")",
";",
"bzero",
"(",
"layer1",
",",
"sizeof",
"(",
"*",
"layer1",
")",
")",
";",
"layer1",
"->",
"phys_offset",
"=",
"HAMMER_BLOCKMAP_UNAVAIL",
";",
"hammer_crc_set_layer1",
"(",
"hmp",
"->",
"version",
",",
"layer1",
")",
";",
"hammer_modify_buffer_done",
"(",
"buffer1",
")",
";",
"}",
"end",
":",
"if",
"(",
"buffer1",
")",
"hammer_rel_buffer",
"(",
"buffer1",
",",
"0",
")",
";",
"if",
"(",
"buffer2",
")",
"hammer_rel_buffer",
"(",
"buffer2",
",",
"0",
")",
";",
"return",
"error",
";",
"}"
] | XXX This somehow needs to stop doing hammer_modify_buffer() for
layer2 entries. | [
"XXX",
"This",
"somehow",
"needs",
"to",
"stop",
"doing",
"hammer_modify_buffer",
"()",
"for",
"layer2",
"entries",
"."
] | [
"/* Not empty */"
] | [
{
"param": "trans",
"type": "hammer_transaction_t"
},
{
"param": "volume",
"type": "hammer_volume_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "trans",
"type": "hammer_transaction_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "volume",
"type": "hammer_volume_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f63a6fdaae653b2bd822dbb58141cc157fa82d72 | atrens/DragonFlyBSD-src | sys/vfs/hammer/hammer_volume.c | [
"BSD-3-Clause"
] | C | hammer_count_bigblocks | int | static int
hammer_count_bigblocks(hammer_mount_t hmp, hammer_volume_t volume,
int64_t *total_bigblocks, int64_t *empty_bigblocks)
{
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int64_t total = 0;
int64_t empty = 0;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
*total_bigblocks = 0; /* avoid gcc warnings */
*empty_bigblocks = 0; /* avoid gcc warnings */
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->ondisk->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
case HAMMER_ZONE_FREEMAP_INDEX:
case HAMMER_ZONE_UNAVAIL_INDEX:
continue;
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
total++;
if (layer2->append_off == 0 &&
layer2->bytes_free == HAMMER_BIGBLOCK_SIZE)
empty++;
break;
}
}
}
hmkprintf(hmp, "big-blocks total=%jd empty=%jd\n", total, empty);
*total_bigblocks = total;
*empty_bigblocks = empty;
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | /*
* Count total big-blocks and empty big-blocks within the volume.
* The volume must be a non-root volume.
*
* Note that total big-blocks doesn't include big-blocks for layer2
* (and obviously layer1 and undomap). This is requirement of the
* volume header and this function is to retrieve that information.
*/ | Count total big-blocks and empty big-blocks within the volume.
The volume must be a non-root volume.
Note that total big-blocks doesn't include big-blocks for layer2
(and obviously layer1 and undomap). This is requirement of the
volume header and this function is to retrieve that information. | [
"Count",
"total",
"big",
"-",
"blocks",
"and",
"empty",
"big",
"-",
"blocks",
"within",
"the",
"volume",
".",
"The",
"volume",
"must",
"be",
"a",
"non",
"-",
"root",
"volume",
".",
"Note",
"that",
"total",
"big",
"-",
"blocks",
"doesn",
"'",
"t",
"include",
"big",
"-",
"blocks",
"for",
"layer2",
"(",
"and",
"obviously",
"layer1",
"and",
"undomap",
")",
".",
"This",
"is",
"requirement",
"of",
"the",
"volume",
"header",
"and",
"this",
"function",
"is",
"to",
"retrieve",
"that",
"information",
"."
] | static int
hammer_count_bigblocks(hammer_mount_t hmp, hammer_volume_t volume,
int64_t *total_bigblocks, int64_t *empty_bigblocks)
{
hammer_volume_ondisk_t ondisk;
hammer_blockmap_t freemap;
hammer_off_t phys_offset;
hammer_off_t block_offset;
hammer_off_t layer1_offset;
hammer_off_t layer2_offset;
hammer_off_t vol_free_end;
hammer_off_t aligned_vol_free_end;
hammer_blockmap_layer1_t layer1;
hammer_blockmap_layer2_t layer2;
hammer_buffer_t buffer1 = NULL;
hammer_buffer_t buffer2 = NULL;
int64_t vol_buf_size;
int64_t total = 0;
int64_t empty = 0;
int error = 0;
KKASSERT(volume->vol_no != HAMMER_ROOT_VOLNO);
*total_bigblocks = 0;
*empty_bigblocks = 0;
ondisk = volume->ondisk;
vol_buf_size = HAMMER_VOL_BUF_SIZE(ondisk);
KKASSERT((vol_buf_size & ~HAMMER_OFF_SHORT_MASK) == 0);
vol_free_end = HAMMER_ENCODE_RAW_BUFFER(ondisk->vol_no,
vol_buf_size & ~HAMMER_BIGBLOCK_MASK64);
aligned_vol_free_end = HAMMER_BLOCKMAP_LAYER2_DOALIGN(vol_free_end);
freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
for (phys_offset = HAMMER_ENCODE_RAW_BUFFER(volume->ondisk->vol_no, 0);
phys_offset < aligned_vol_free_end;
phys_offset += HAMMER_BLOCKMAP_LAYER2) {
layer1_offset = freemap->phys_offset +
HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_offset);
layer1 = hammer_bread(hmp, layer1_offset, &error, &buffer1);
if (error)
goto end;
for (block_offset = 0;
block_offset < HAMMER_BLOCKMAP_LAYER2;
block_offset += HAMMER_BIGBLOCK_SIZE) {
layer2_offset = layer1->phys_offset +
HAMMER_BLOCKMAP_LAYER2_OFFSET(block_offset);
layer2 = hammer_bread(hmp, layer2_offset, &error, &buffer2);
if (error)
goto end;
switch (layer2->zone) {
case HAMMER_ZONE_UNDO_INDEX:
KKASSERT(0);
case HAMMER_ZONE_FREEMAP_INDEX:
case HAMMER_ZONE_UNAVAIL_INDEX:
continue;
default:
KKASSERT(phys_offset + block_offset < aligned_vol_free_end);
total++;
if (layer2->append_off == 0 &&
layer2->bytes_free == HAMMER_BIGBLOCK_SIZE)
empty++;
break;
}
}
}
hmkprintf(hmp, "big-blocks total=%jd empty=%jd\n", total, empty);
*total_bigblocks = total;
*empty_bigblocks = empty;
end:
if (buffer1)
hammer_rel_buffer(buffer1, 0);
if (buffer2)
hammer_rel_buffer(buffer2, 0);
return error;
} | [
"static",
"int",
"hammer_count_bigblocks",
"(",
"hammer_mount_t",
"hmp",
",",
"hammer_volume_t",
"volume",
",",
"int64_t",
"*",
"total_bigblocks",
",",
"int64_t",
"*",
"empty_bigblocks",
")",
"{",
"hammer_volume_ondisk_t",
"ondisk",
";",
"hammer_blockmap_t",
"freemap",
";",
"hammer_off_t",
"phys_offset",
";",
"hammer_off_t",
"block_offset",
";",
"hammer_off_t",
"layer1_offset",
";",
"hammer_off_t",
"layer2_offset",
";",
"hammer_off_t",
"vol_free_end",
";",
"hammer_off_t",
"aligned_vol_free_end",
";",
"hammer_blockmap_layer1_t",
"layer1",
";",
"hammer_blockmap_layer2_t",
"layer2",
";",
"hammer_buffer_t",
"buffer1",
"=",
"NULL",
";",
"hammer_buffer_t",
"buffer2",
"=",
"NULL",
";",
"int64_t",
"vol_buf_size",
";",
"int64_t",
"total",
"=",
"0",
";",
"int64_t",
"empty",
"=",
"0",
";",
"int",
"error",
"=",
"0",
";",
"KKASSERT",
"(",
"volume",
"->",
"vol_no",
"!=",
"HAMMER_ROOT_VOLNO",
")",
";",
"*",
"total_bigblocks",
"=",
"0",
";",
"*",
"empty_bigblocks",
"=",
"0",
";",
"ondisk",
"=",
"volume",
"->",
"ondisk",
";",
"vol_buf_size",
"=",
"HAMMER_VOL_BUF_SIZE",
"(",
"ondisk",
")",
";",
"KKASSERT",
"(",
"(",
"vol_buf_size",
"&",
"~",
"HAMMER_OFF_SHORT_MASK",
")",
"==",
"0",
")",
";",
"vol_free_end",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"ondisk",
"->",
"vol_no",
",",
"vol_buf_size",
"&",
"~",
"HAMMER_BIGBLOCK_MASK64",
")",
";",
"aligned_vol_free_end",
"=",
"HAMMER_BLOCKMAP_LAYER2_DOALIGN",
"(",
"vol_free_end",
")",
";",
"freemap",
"=",
"&",
"hmp",
"->",
"blockmap",
"[",
"HAMMER_ZONE_FREEMAP_INDEX",
"]",
";",
"for",
"(",
"phys_offset",
"=",
"HAMMER_ENCODE_RAW_BUFFER",
"(",
"volume",
"->",
"ondisk",
"->",
"vol_no",
",",
"0",
")",
";",
"phys_offset",
"<",
"aligned_vol_free_end",
";",
"phys_offset",
"+=",
"HAMMER_BLOCKMAP_LAYER2",
")",
"{",
"layer1_offset",
"=",
"freemap",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER1_OFFSET",
"(",
"phys_offset",
")",
";",
"layer1",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer1_offset",
",",
"&",
"error",
",",
"&",
"buffer1",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"for",
"(",
"block_offset",
"=",
"0",
";",
"block_offset",
"<",
"HAMMER_BLOCKMAP_LAYER2",
";",
"block_offset",
"+=",
"HAMMER_BIGBLOCK_SIZE",
")",
"{",
"layer2_offset",
"=",
"layer1",
"->",
"phys_offset",
"+",
"HAMMER_BLOCKMAP_LAYER2_OFFSET",
"(",
"block_offset",
")",
";",
"layer2",
"=",
"hammer_bread",
"(",
"hmp",
",",
"layer2_offset",
",",
"&",
"error",
",",
"&",
"buffer2",
")",
";",
"if",
"(",
"error",
")",
"goto",
"end",
";",
"switch",
"(",
"layer2",
"->",
"zone",
")",
"{",
"case",
"HAMMER_ZONE_UNDO_INDEX",
":",
"KKASSERT",
"(",
"0",
")",
";",
"case",
"HAMMER_ZONE_FREEMAP_INDEX",
":",
"case",
"HAMMER_ZONE_UNAVAIL_INDEX",
":",
"continue",
";",
"default",
":",
"KKASSERT",
"(",
"phys_offset",
"+",
"block_offset",
"<",
"aligned_vol_free_end",
")",
";",
"total",
"++",
";",
"if",
"(",
"layer2",
"->",
"append_off",
"==",
"0",
"&&",
"layer2",
"->",
"bytes_free",
"==",
"HAMMER_BIGBLOCK_SIZE",
")",
"empty",
"++",
";",
"break",
";",
"}",
"}",
"}",
"hmkprintf",
"(",
"hmp",
",",
"\"",
"\\n",
"\"",
",",
"total",
",",
"empty",
")",
";",
"*",
"total_bigblocks",
"=",
"total",
";",
"*",
"empty_bigblocks",
"=",
"empty",
";",
"end",
":",
"if",
"(",
"buffer1",
")",
"hammer_rel_buffer",
"(",
"buffer1",
",",
"0",
")",
";",
"if",
"(",
"buffer2",
")",
"hammer_rel_buffer",
"(",
"buffer2",
",",
"0",
")",
";",
"return",
"error",
";",
"}"
] | Count total big-blocks and empty big-blocks within the volume. | [
"Count",
"total",
"big",
"-",
"blocks",
"and",
"empty",
"big",
"-",
"blocks",
"within",
"the",
"volume",
"."
] | [
"/* avoid gcc warnings */",
"/* avoid gcc warnings */"
] | [
{
"param": "hmp",
"type": "hammer_mount_t"
},
{
"param": "volume",
"type": "hammer_volume_t"
},
{
"param": "total_bigblocks",
"type": "int64_t"
},
{
"param": "empty_bigblocks",
"type": "int64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hmp",
"type": "hammer_mount_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "volume",
"type": "hammer_volume_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "total_bigblocks",
"type": "int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "empty_bigblocks",
"type": "int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_stash_add | void | static void
frame_stash_add (struct frame_info *frame)
{
frame_stash = frame;
} | /* Add the following FRAME to the frame stash. */ | Add the following FRAME to the frame stash. | [
"Add",
"the",
"following",
"FRAME",
"to",
"the",
"frame",
"stash",
"."
] | static void
frame_stash_add (struct frame_info *frame)
{
frame_stash = frame;
} | [
"static",
"void",
"frame_stash_add",
"(",
"struct",
"frame_info",
"*",
"frame",
")",
"{",
"frame_stash",
"=",
"frame",
";",
"}"
] | Add the following FRAME to the frame stash. | [
"Add",
"the",
"following",
"FRAME",
"to",
"the",
"frame",
"stash",
"."
] | [] | [
{
"param": "frame",
"type": "struct frame_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_stash_find | null | static struct frame_info *
frame_stash_find (struct frame_id id)
{
if (frame_stash && frame_id_eq (frame_stash->this_id.value, id))
return frame_stash;
return NULL;
} | /* Search the frame stash for an entry with the given frame ID.
If found, return that frame. Otherwise return NULL. */ | Search the frame stash for an entry with the given frame ID.
If found, return that frame. Otherwise return NULL. | [
"Search",
"the",
"frame",
"stash",
"for",
"an",
"entry",
"with",
"the",
"given",
"frame",
"ID",
".",
"If",
"found",
"return",
"that",
"frame",
".",
"Otherwise",
"return",
"NULL",
"."
] | static struct frame_info *
frame_stash_find (struct frame_id id)
{
if (frame_stash && frame_id_eq (frame_stash->this_id.value, id))
return frame_stash;
return NULL;
} | [
"static",
"struct",
"frame_info",
"*",
"frame_stash_find",
"(",
"struct",
"frame_id",
"id",
")",
"{",
"if",
"(",
"frame_stash",
"&&",
"frame_id_eq",
"(",
"frame_stash",
"->",
"this_id",
".",
"value",
",",
"id",
")",
")",
"return",
"frame_stash",
";",
"return",
"NULL",
";",
"}"
] | Search the frame stash for an entry with the given frame ID. | [
"Search",
"the",
"frame",
"stash",
"for",
"an",
"entry",
"with",
"the",
"given",
"frame",
"ID",
"."
] | [] | [
{
"param": "id",
"type": "struct frame_id"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": "struct frame_id",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_stash_invalidate | void | static void
frame_stash_invalidate (void)
{
frame_stash = NULL;
} | /* Invalidate the frame stash by removing all entries in it. */ | Invalidate the frame stash by removing all entries in it. | [
"Invalidate",
"the",
"frame",
"stash",
"by",
"removing",
"all",
"entries",
"in",
"it",
"."
] | static void
frame_stash_invalidate (void)
{
frame_stash = NULL;
} | [
"static",
"void",
"frame_stash_invalidate",
"(",
"void",
")",
"{",
"frame_stash",
"=",
"NULL",
";",
"}"
] | Invalidate the frame stash by removing all entries in it. | [
"Invalidate",
"the",
"frame",
"stash",
"by",
"removing",
"all",
"entries",
"in",
"it",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | skip_artificial_frames | null | static struct frame_info *
skip_artificial_frames (struct frame_info *frame)
{
while (get_frame_type (frame) == INLINE_FRAME
|| get_frame_type (frame) == TAILCALL_FRAME)
frame = get_prev_frame (frame);
return frame;
} | /* Given FRAME, return the enclosing frame as found in real frames read-in from
inferior memory. Skip any previous frames which were made up by GDB.
Return the original frame if no immediate previous frames exist. */ | Given FRAME, return the enclosing frame as found in real frames read-in from
inferior memory. Skip any previous frames which were made up by GDB.
Return the original frame if no immediate previous frames exist. | [
"Given",
"FRAME",
"return",
"the",
"enclosing",
"frame",
"as",
"found",
"in",
"real",
"frames",
"read",
"-",
"in",
"from",
"inferior",
"memory",
".",
"Skip",
"any",
"previous",
"frames",
"which",
"were",
"made",
"up",
"by",
"GDB",
".",
"Return",
"the",
"original",
"frame",
"if",
"no",
"immediate",
"previous",
"frames",
"exist",
"."
] | static struct frame_info *
skip_artificial_frames (struct frame_info *frame)
{
while (get_frame_type (frame) == INLINE_FRAME
|| get_frame_type (frame) == TAILCALL_FRAME)
frame = get_prev_frame (frame);
return frame;
} | [
"static",
"struct",
"frame_info",
"*",
"skip_artificial_frames",
"(",
"struct",
"frame_info",
"*",
"frame",
")",
"{",
"while",
"(",
"get_frame_type",
"(",
"frame",
")",
"==",
"INLINE_FRAME",
"||",
"get_frame_type",
"(",
"frame",
")",
"==",
"TAILCALL_FRAME",
")",
"frame",
"=",
"get_prev_frame",
"(",
"frame",
")",
";",
"return",
"frame",
";",
"}"
] | Given FRAME, return the enclosing frame as found in real frames read-in from
inferior memory. | [
"Given",
"FRAME",
"return",
"the",
"enclosing",
"frame",
"as",
"found",
"in",
"real",
"frames",
"read",
"-",
"in",
"from",
"inferior",
"memory",
"."
] | [] | [
{
"param": "frame",
"type": "struct frame_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_id_inner | int | static int
frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
{
int inner;
if (!l.stack_addr_p || !r.stack_addr_p)
/* Like NaN, any operation involving an invalid ID always fails. */
inner = 0;
else if (l.artificial_depth > r.artificial_depth
&& l.stack_addr == r.stack_addr
&& l.code_addr_p == r.code_addr_p
&& l.special_addr_p == r.special_addr_p
&& l.special_addr == r.special_addr)
{
/* Same function, different inlined functions. */
struct block *lb, *rb;
gdb_assert (l.code_addr_p && r.code_addr_p);
lb = block_for_pc (l.code_addr);
rb = block_for_pc (r.code_addr);
if (lb == NULL || rb == NULL)
/* Something's gone wrong. */
inner = 0;
else
/* This will return true if LB and RB are the same block, or
if the block with the smaller depth lexically encloses the
block with the greater depth. */
inner = contained_in (lb, rb);
}
else
/* Only return non-zero when strictly inner than. Note that, per
comment in "frame.h", there is some fuzz here. Frameless
functions are not strictly inner than (same .stack but
different .code and/or .special address). */
inner = gdbarch_inner_than (gdbarch, l.stack_addr, r.stack_addr);
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=");
fprint_frame_id (gdb_stdlog, l);
fprintf_unfiltered (gdb_stdlog, ",r=");
fprint_frame_id (gdb_stdlog, r);
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
}
return inner;
} | /* Safety net to check whether frame ID L should be inner to
frame ID R, according to their stack addresses.
This method cannot be used to compare arbitrary frames, as the
ranges of valid stack addresses may be discontiguous (e.g. due
to sigaltstack).
However, it can be used as safety net to discover invalid frame
IDs in certain circumstances. Assuming that NEXT is the immediate
inner frame to THIS and that NEXT and THIS are both NORMAL frames:
* The stack address of NEXT must be inner-than-or-equal to the stack
address of THIS.
Therefore, if frame_id_inner (THIS, NEXT) holds, some unwind
error has occurred.
* If NEXT and THIS have different stack addresses, no other frame
in the frame chain may have a stack address in between.
Therefore, if frame_id_inner (TEST, THIS) holds, but
frame_id_inner (TEST, NEXT) does not hold, TEST cannot refer
to a valid frame in the frame chain.
The sanity checks above cannot be performed when a SIGTRAMP frame
is involved, because signal handlers might be executed on a different
stack than the stack used by the routine that caused the signal
to be raised. This can happen for instance when a thread exceeds
its maximum stack size. In this case, certain compilers implement
a stack overflow strategy that cause the handler to be run on a
different stack. */ | Safety net to check whether frame ID L should be inner to
frame ID R, according to their stack addresses.
This method cannot be used to compare arbitrary frames, as the
ranges of valid stack addresses may be discontiguous .
However, it can be used as safety net to discover invalid frame
IDs in certain circumstances. Assuming that NEXT is the immediate
inner frame to THIS and that NEXT and THIS are both NORMAL frames.
The stack address of NEXT must be inner-than-or-equal to the stack
address of THIS.
Therefore, if frame_id_inner (THIS, NEXT) holds, some unwind
error has occurred.
If NEXT and THIS have different stack addresses, no other frame
in the frame chain may have a stack address in between.
Therefore, if frame_id_inner (TEST, THIS) holds, but
frame_id_inner (TEST, NEXT) does not hold, TEST cannot refer
to a valid frame in the frame chain.
The sanity checks above cannot be performed when a SIGTRAMP frame
is involved, because signal handlers might be executed on a different
stack than the stack used by the routine that caused the signal
to be raised. This can happen for instance when a thread exceeds
its maximum stack size. In this case, certain compilers implement
a stack overflow strategy that cause the handler to be run on a
different stack. | [
"Safety",
"net",
"to",
"check",
"whether",
"frame",
"ID",
"L",
"should",
"be",
"inner",
"to",
"frame",
"ID",
"R",
"according",
"to",
"their",
"stack",
"addresses",
".",
"This",
"method",
"cannot",
"be",
"used",
"to",
"compare",
"arbitrary",
"frames",
"as",
"the",
"ranges",
"of",
"valid",
"stack",
"addresses",
"may",
"be",
"discontiguous",
".",
"However",
"it",
"can",
"be",
"used",
"as",
"safety",
"net",
"to",
"discover",
"invalid",
"frame",
"IDs",
"in",
"certain",
"circumstances",
".",
"Assuming",
"that",
"NEXT",
"is",
"the",
"immediate",
"inner",
"frame",
"to",
"THIS",
"and",
"that",
"NEXT",
"and",
"THIS",
"are",
"both",
"NORMAL",
"frames",
".",
"The",
"stack",
"address",
"of",
"NEXT",
"must",
"be",
"inner",
"-",
"than",
"-",
"or",
"-",
"equal",
"to",
"the",
"stack",
"address",
"of",
"THIS",
".",
"Therefore",
"if",
"frame_id_inner",
"(",
"THIS",
"NEXT",
")",
"holds",
"some",
"unwind",
"error",
"has",
"occurred",
".",
"If",
"NEXT",
"and",
"THIS",
"have",
"different",
"stack",
"addresses",
"no",
"other",
"frame",
"in",
"the",
"frame",
"chain",
"may",
"have",
"a",
"stack",
"address",
"in",
"between",
".",
"Therefore",
"if",
"frame_id_inner",
"(",
"TEST",
"THIS",
")",
"holds",
"but",
"frame_id_inner",
"(",
"TEST",
"NEXT",
")",
"does",
"not",
"hold",
"TEST",
"cannot",
"refer",
"to",
"a",
"valid",
"frame",
"in",
"the",
"frame",
"chain",
".",
"The",
"sanity",
"checks",
"above",
"cannot",
"be",
"performed",
"when",
"a",
"SIGTRAMP",
"frame",
"is",
"involved",
"because",
"signal",
"handlers",
"might",
"be",
"executed",
"on",
"a",
"different",
"stack",
"than",
"the",
"stack",
"used",
"by",
"the",
"routine",
"that",
"caused",
"the",
"signal",
"to",
"be",
"raised",
".",
"This",
"can",
"happen",
"for",
"instance",
"when",
"a",
"thread",
"exceeds",
"its",
"maximum",
"stack",
"size",
".",
"In",
"this",
"case",
"certain",
"compilers",
"implement",
"a",
"stack",
"overflow",
"strategy",
"that",
"cause",
"the",
"handler",
"to",
"be",
"run",
"on",
"a",
"different",
"stack",
"."
] | static int
frame_id_inner (struct gdbarch *gdbarch, struct frame_id l, struct frame_id r)
{
int inner;
if (!l.stack_addr_p || !r.stack_addr_p)
inner = 0;
else if (l.artificial_depth > r.artificial_depth
&& l.stack_addr == r.stack_addr
&& l.code_addr_p == r.code_addr_p
&& l.special_addr_p == r.special_addr_p
&& l.special_addr == r.special_addr)
{
struct block *lb, *rb;
gdb_assert (l.code_addr_p && r.code_addr_p);
lb = block_for_pc (l.code_addr);
rb = block_for_pc (r.code_addr);
if (lb == NULL || rb == NULL)
inner = 0;
else
inner = contained_in (lb, rb);
}
else
inner = gdbarch_inner_than (gdbarch, l.stack_addr, r.stack_addr);
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=");
fprint_frame_id (gdb_stdlog, l);
fprintf_unfiltered (gdb_stdlog, ",r=");
fprint_frame_id (gdb_stdlog, r);
fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
}
return inner;
} | [
"static",
"int",
"frame_id_inner",
"(",
"struct",
"gdbarch",
"*",
"gdbarch",
",",
"struct",
"frame_id",
"l",
",",
"struct",
"frame_id",
"r",
")",
"{",
"int",
"inner",
";",
"if",
"(",
"!",
"l",
".",
"stack_addr_p",
"||",
"!",
"r",
".",
"stack_addr_p",
")",
"inner",
"=",
"0",
";",
"else",
"if",
"(",
"l",
".",
"artificial_depth",
">",
"r",
".",
"artificial_depth",
"&&",
"l",
".",
"stack_addr",
"==",
"r",
".",
"stack_addr",
"&&",
"l",
".",
"code_addr_p",
"==",
"r",
".",
"code_addr_p",
"&&",
"l",
".",
"special_addr_p",
"==",
"r",
".",
"special_addr_p",
"&&",
"l",
".",
"special_addr",
"==",
"r",
".",
"special_addr",
")",
"{",
"struct",
"block",
"*",
"lb",
",",
"*",
"rb",
";",
"gdb_assert",
"(",
"l",
".",
"code_addr_p",
"&&",
"r",
".",
"code_addr_p",
")",
";",
"lb",
"=",
"block_for_pc",
"(",
"l",
".",
"code_addr",
")",
";",
"rb",
"=",
"block_for_pc",
"(",
"r",
".",
"code_addr",
")",
";",
"if",
"(",
"lb",
"==",
"NULL",
"||",
"rb",
"==",
"NULL",
")",
"inner",
"=",
"0",
";",
"else",
"inner",
"=",
"contained_in",
"(",
"lb",
",",
"rb",
")",
";",
"}",
"else",
"inner",
"=",
"gdbarch_inner_than",
"(",
"gdbarch",
",",
"l",
".",
"stack_addr",
",",
"r",
".",
"stack_addr",
")",
";",
"if",
"(",
"frame_debug",
")",
"{",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\"",
")",
";",
"fprint_frame_id",
"(",
"gdb_stdlog",
",",
"l",
")",
";",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\"",
")",
";",
"fprint_frame_id",
"(",
"gdb_stdlog",
",",
"r",
")",
";",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\\n",
"\"",
",",
"inner",
")",
";",
"}",
"return",
"inner",
";",
"}"
] | Safety net to check whether frame ID L should be inner to
frame ID R, according to their stack addresses. | [
"Safety",
"net",
"to",
"check",
"whether",
"frame",
"ID",
"L",
"should",
"be",
"inner",
"to",
"frame",
"ID",
"R",
"according",
"to",
"their",
"stack",
"addresses",
"."
] | [
"/* Like NaN, any operation involving an invalid ID always fails. */",
"/* Same function, different inlined functions. */",
"/* Something's gone wrong. */",
"/* This will return true if LB and RB are the same block, or\n\t if the block with the smaller depth lexically encloses the\n\t block with the greater depth. */",
"/* Only return non-zero when strictly inner than. Note that, per\n comment in \"frame.h\", there is some fuzz here. Frameless\n functions are not strictly inner than (same .stack but\n different .code and/or .special address). */"
] | [
{
"param": "gdbarch",
"type": "struct gdbarch"
},
{
"param": "l",
"type": "struct frame_id"
},
{
"param": "r",
"type": "struct frame_id"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gdbarch",
"type": "struct gdbarch",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "l",
"type": "struct frame_id",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "r",
"type": "struct frame_id",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | deprecated_frame_register_read | int | int
deprecated_frame_register_read (struct frame_info *frame, int regnum,
gdb_byte *myaddr)
{
int optimized;
int unavailable;
enum lval_type lval;
CORE_ADDR addr;
int realnum;
frame_register (frame, regnum, &optimized, &unavailable,
&lval, &addr, &realnum, myaddr);
return !optimized && !unavailable;
} | /* This function is deprecated. Use get_frame_register_value instead,
which provides more accurate information.
Find and return the value of REGNUM for the specified stack frame.
The number of bytes copied is REGISTER_SIZE (REGNUM).
Returns 0 if the register value could not be found. */ | This function is deprecated. Use get_frame_register_value instead,
which provides more accurate information.
Find and return the value of REGNUM for the specified stack frame.
The number of bytes copied is REGISTER_SIZE (REGNUM).
Returns 0 if the register value could not be found. | [
"This",
"function",
"is",
"deprecated",
".",
"Use",
"get_frame_register_value",
"instead",
"which",
"provides",
"more",
"accurate",
"information",
".",
"Find",
"and",
"return",
"the",
"value",
"of",
"REGNUM",
"for",
"the",
"specified",
"stack",
"frame",
".",
"The",
"number",
"of",
"bytes",
"copied",
"is",
"REGISTER_SIZE",
"(",
"REGNUM",
")",
".",
"Returns",
"0",
"if",
"the",
"register",
"value",
"could",
"not",
"be",
"found",
"."
] | int
deprecated_frame_register_read (struct frame_info *frame, int regnum,
gdb_byte *myaddr)
{
int optimized;
int unavailable;
enum lval_type lval;
CORE_ADDR addr;
int realnum;
frame_register (frame, regnum, &optimized, &unavailable,
&lval, &addr, &realnum, myaddr);
return !optimized && !unavailable;
} | [
"int",
"deprecated_frame_register_read",
"(",
"struct",
"frame_info",
"*",
"frame",
",",
"int",
"regnum",
",",
"gdb_byte",
"*",
"myaddr",
")",
"{",
"int",
"optimized",
";",
"int",
"unavailable",
";",
"enum",
"lval_type",
"lval",
";",
"CORE_ADDR",
"addr",
";",
"int",
"realnum",
";",
"frame_register",
"(",
"frame",
",",
"regnum",
",",
"&",
"optimized",
",",
"&",
"unavailable",
",",
"&",
"lval",
",",
"&",
"addr",
",",
"&",
"realnum",
",",
"myaddr",
")",
";",
"return",
"!",
"optimized",
"&&",
"!",
"unavailable",
";",
"}"
] | This function is deprecated. | [
"This",
"function",
"is",
"deprecated",
"."
] | [] | [
{
"param": "frame",
"type": "struct frame_info"
},
{
"param": "regnum",
"type": "int"
},
{
"param": "myaddr",
"type": "gdb_byte"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "regnum",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "myaddr",
"type": "gdb_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | unwind_to_current_frame | int | static int
unwind_to_current_frame (struct ui_out *ui_out, void *args)
{
struct frame_info *frame = get_prev_frame (args);
/* A sentinel frame can fail to unwind, e.g., because its PC value
lands in somewhere like start. */
if (frame == NULL)
return 1;
current_frame = frame;
return 0;
} | /* Return the innermost (currently executing) stack frame. This is
split into two functions. The function unwind_to_current_frame()
is wrapped in catch exceptions so that, even when the unwind of the
sentinel frame fails, the function still returns a stack frame. */ | Return the innermost (currently executing) stack frame. This is
split into two functions. The function unwind_to_current_frame()
is wrapped in catch exceptions so that, even when the unwind of the
sentinel frame fails, the function still returns a stack frame. | [
"Return",
"the",
"innermost",
"(",
"currently",
"executing",
")",
"stack",
"frame",
".",
"This",
"is",
"split",
"into",
"two",
"functions",
".",
"The",
"function",
"unwind_to_current_frame",
"()",
"is",
"wrapped",
"in",
"catch",
"exceptions",
"so",
"that",
"even",
"when",
"the",
"unwind",
"of",
"the",
"sentinel",
"frame",
"fails",
"the",
"function",
"still",
"returns",
"a",
"stack",
"frame",
"."
] | static int
unwind_to_current_frame (struct ui_out *ui_out, void *args)
{
struct frame_info *frame = get_prev_frame (args);
if (frame == NULL)
return 1;
current_frame = frame;
return 0;
} | [
"static",
"int",
"unwind_to_current_frame",
"(",
"struct",
"ui_out",
"*",
"ui_out",
",",
"void",
"*",
"args",
")",
"{",
"struct",
"frame_info",
"*",
"frame",
"=",
"get_prev_frame",
"(",
"args",
")",
";",
"if",
"(",
"frame",
"==",
"NULL",
")",
"return",
"1",
";",
"current_frame",
"=",
"frame",
";",
"return",
"0",
";",
"}"
] | Return the innermost (currently executing) stack frame. | [
"Return",
"the",
"innermost",
"(",
"currently",
"executing",
")",
"stack",
"frame",
"."
] | [
"/* A sentinel frame can fail to unwind, e.g., because its PC value\n lands in somewhere like start. */"
] | [
{
"param": "ui_out",
"type": "struct ui_out"
},
{
"param": "args",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ui_out",
"type": "struct ui_out",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "args",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | deprecated_safe_get_selected_frame | null | struct frame_info *
deprecated_safe_get_selected_frame (void)
{
if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
} | /* This is a variant of get_selected_frame() which can be called when
the inferior does not have a frame; in that case it will return
NULL instead of calling error(). */ | This is a variant of get_selected_frame() which can be called when
the inferior does not have a frame; in that case it will return
NULL instead of calling error(). | [
"This",
"is",
"a",
"variant",
"of",
"get_selected_frame",
"()",
"which",
"can",
"be",
"called",
"when",
"the",
"inferior",
"does",
"not",
"have",
"a",
"frame",
";",
"in",
"that",
"case",
"it",
"will",
"return",
"NULL",
"instead",
"of",
"calling",
"error",
"()",
"."
] | struct frame_info *
deprecated_safe_get_selected_frame (void)
{
if (!has_stack_frames ())
return NULL;
return get_selected_frame (NULL);
} | [
"struct",
"frame_info",
"*",
"deprecated_safe_get_selected_frame",
"(",
"void",
")",
"{",
"if",
"(",
"!",
"has_stack_frames",
"(",
")",
")",
"return",
"NULL",
";",
"return",
"get_selected_frame",
"(",
"NULL",
")",
";",
"}"
] | This is a variant of get_selected_frame() which can be called when
the inferior does not have a frame; in that case it will return
NULL instead of calling error(). | [
"This",
"is",
"a",
"variant",
"of",
"get_selected_frame",
"()",
"which",
"can",
"be",
"called",
"when",
"the",
"inferior",
"does",
"not",
"have",
"a",
"frame",
";",
"in",
"that",
"case",
"it",
"will",
"return",
"NULL",
"instead",
"of",
"calling",
"error",
"()",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | select_frame | void | void
select_frame (struct frame_info *fi)
{
selected_frame = fi;
/* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
frame is being invalidated. */
if (deprecated_selected_frame_level_changed_hook)
deprecated_selected_frame_level_changed_hook (frame_relative_level (fi));
/* FIXME: kseitz/2002-08-28: It would be nice to call
selected_frame_level_changed_event() right here, but due to limitations
in the current interfaces, we would end up flooding UIs with events
because select_frame() is used extensively internally.
Once we have frame-parameterized frame (and frame-related) commands,
the event notification can be moved here, since this function will only
be called when the user's selected frame is being changed. */
/* Ensure that symbols for this frame are read in. Also, determine the
source language of this frame, and switch to it if desired. */
if (fi)
{
CORE_ADDR pc;
/* We retrieve the frame's symtab by using the frame PC.
However we cannot use the frame PC as-is, because it usually
points to the instruction following the "call", which is
sometimes the first instruction of another function. So we
rely on get_frame_address_in_block() which provides us with a
PC which is guaranteed to be inside the frame's code
block. */
if (get_frame_address_in_block_if_available (fi, &pc))
{
struct symtab *s = find_pc_symtab (pc);
if (s
&& s->language != current_language->la_language
&& s->language != language_unknown
&& language_mode == language_mode_auto)
set_language (s->language);
}
}
} | /* Select frame FI (or NULL - to invalidate the current frame). */ | Select frame FI (or NULL - to invalidate the current frame). | [
"Select",
"frame",
"FI",
"(",
"or",
"NULL",
"-",
"to",
"invalidate",
"the",
"current",
"frame",
")",
"."
] | void
select_frame (struct frame_info *fi)
{
selected_frame = fi;
if (deprecated_selected_frame_level_changed_hook)
deprecated_selected_frame_level_changed_hook (frame_relative_level (fi));
if (fi)
{
CORE_ADDR pc;
if (get_frame_address_in_block_if_available (fi, &pc))
{
struct symtab *s = find_pc_symtab (pc);
if (s
&& s->language != current_language->la_language
&& s->language != language_unknown
&& language_mode == language_mode_auto)
set_language (s->language);
}
}
} | [
"void",
"select_frame",
"(",
"struct",
"frame_info",
"*",
"fi",
")",
"{",
"selected_frame",
"=",
"fi",
";",
"if",
"(",
"deprecated_selected_frame_level_changed_hook",
")",
"deprecated_selected_frame_level_changed_hook",
"(",
"frame_relative_level",
"(",
"fi",
")",
")",
";",
"if",
"(",
"fi",
")",
"{",
"CORE_ADDR",
"pc",
";",
"if",
"(",
"get_frame_address_in_block_if_available",
"(",
"fi",
",",
"&",
"pc",
")",
")",
"{",
"struct",
"symtab",
"*",
"s",
"=",
"find_pc_symtab",
"(",
"pc",
")",
";",
"if",
"(",
"s",
"&&",
"s",
"->",
"language",
"!=",
"current_language",
"->",
"la_language",
"&&",
"s",
"->",
"language",
"!=",
"language_unknown",
"&&",
"language_mode",
"==",
"language_mode_auto",
")",
"set_language",
"(",
"s",
"->",
"language",
")",
";",
"}",
"}",
"}"
] | Select frame FI (or NULL - to invalidate the current frame). | [
"Select",
"frame",
"FI",
"(",
"or",
"NULL",
"-",
"to",
"invalidate",
"the",
"current",
"frame",
")",
"."
] | [
"/* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the\n frame is being invalidated. */",
"/* FIXME: kseitz/2002-08-28: It would be nice to call\n selected_frame_level_changed_event() right here, but due to limitations\n in the current interfaces, we would end up flooding UIs with events\n because select_frame() is used extensively internally.\n\n Once we have frame-parameterized frame (and frame-related) commands,\n the event notification can be moved here, since this function will only\n be called when the user's selected frame is being changed. */",
"/* Ensure that symbols for this frame are read in. Also, determine the\n source language of this frame, and switch to it if desired. */",
"/* We retrieve the frame's symtab by using the frame PC.\n\t However we cannot use the frame PC as-is, because it usually\n\t points to the instruction following the \"call\", which is\n\t sometimes the first instruction of another function. So we\n\t rely on get_frame_address_in_block() which provides us with a\n\t PC which is guaranteed to be inside the frame's code\n\t block. */"
] | [
{
"param": "fi",
"type": "struct frame_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fi",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_observer_target_changed | void | static void
frame_observer_target_changed (struct target_ops *target)
{
reinit_frame_cache ();
} | /* Observer for the target_changed event. */ | Observer for the target_changed event. | [
"Observer",
"for",
"the",
"target_changed",
"event",
"."
] | static void
frame_observer_target_changed (struct target_ops *target)
{
reinit_frame_cache ();
} | [
"static",
"void",
"frame_observer_target_changed",
"(",
"struct",
"target_ops",
"*",
"target",
")",
"{",
"reinit_frame_cache",
"(",
")",
";",
"}"
] | Observer for the target_changed event. | [
"Observer",
"for",
"the",
"target_changed",
"event",
"."
] | [] | [
{
"param": "target",
"type": "struct target_ops"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "target",
"type": "struct target_ops",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | reinit_frame_cache | void | void
reinit_frame_cache (void)
{
struct frame_info *fi;
/* Tear down all frame caches. */
for (fi = current_frame; fi != NULL; fi = fi->prev)
{
if (fi->prologue_cache && fi->unwind->dealloc_cache)
fi->unwind->dealloc_cache (fi, fi->prologue_cache);
if (fi->base_cache && fi->base->unwind->dealloc_cache)
fi->base->unwind->dealloc_cache (fi, fi->base_cache);
}
/* Since we can't really be sure what the first object allocated was. */
obstack_free (&frame_cache_obstack, 0);
obstack_init (&frame_cache_obstack);
if (current_frame != NULL)
annotate_frames_invalid ();
current_frame = NULL; /* Invalidate cache */
select_frame (NULL);
frame_stash_invalidate ();
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, "{ reinit_frame_cache () }\n");
} | /* Flush the entire frame cache. */ | Flush the entire frame cache. | [
"Flush",
"the",
"entire",
"frame",
"cache",
"."
] | void
reinit_frame_cache (void)
{
struct frame_info *fi;
for (fi = current_frame; fi != NULL; fi = fi->prev)
{
if (fi->prologue_cache && fi->unwind->dealloc_cache)
fi->unwind->dealloc_cache (fi, fi->prologue_cache);
if (fi->base_cache && fi->base->unwind->dealloc_cache)
fi->base->unwind->dealloc_cache (fi, fi->base_cache);
}
obstack_free (&frame_cache_obstack, 0);
obstack_init (&frame_cache_obstack);
if (current_frame != NULL)
annotate_frames_invalid ();
current_frame = NULL;
select_frame (NULL);
frame_stash_invalidate ();
if (frame_debug)
fprintf_unfiltered (gdb_stdlog, "{ reinit_frame_cache () }\n");
} | [
"void",
"reinit_frame_cache",
"(",
"void",
")",
"{",
"struct",
"frame_info",
"*",
"fi",
";",
"for",
"(",
"fi",
"=",
"current_frame",
";",
"fi",
"!=",
"NULL",
";",
"fi",
"=",
"fi",
"->",
"prev",
")",
"{",
"if",
"(",
"fi",
"->",
"prologue_cache",
"&&",
"fi",
"->",
"unwind",
"->",
"dealloc_cache",
")",
"fi",
"->",
"unwind",
"->",
"dealloc_cache",
"(",
"fi",
",",
"fi",
"->",
"prologue_cache",
")",
";",
"if",
"(",
"fi",
"->",
"base_cache",
"&&",
"fi",
"->",
"base",
"->",
"unwind",
"->",
"dealloc_cache",
")",
"fi",
"->",
"base",
"->",
"unwind",
"->",
"dealloc_cache",
"(",
"fi",
",",
"fi",
"->",
"base_cache",
")",
";",
"}",
"obstack_free",
"(",
"&",
"frame_cache_obstack",
",",
"0",
")",
";",
"obstack_init",
"(",
"&",
"frame_cache_obstack",
")",
";",
"if",
"(",
"current_frame",
"!=",
"NULL",
")",
"annotate_frames_invalid",
"(",
")",
";",
"current_frame",
"=",
"NULL",
";",
"select_frame",
"(",
"NULL",
")",
";",
"frame_stash_invalidate",
"(",
")",
";",
"if",
"(",
"frame_debug",
")",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\\n",
"\"",
")",
";",
"}"
] | Flush the entire frame cache. | [
"Flush",
"the",
"entire",
"frame",
"cache",
"."
] | [
"/* Tear down all frame caches. */",
"/* Since we can't really be sure what the first object allocated was. */",
"/* Invalidate cache */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_register_unwind_location | void | static void
frame_register_unwind_location (struct frame_info *this_frame, int regnum,
int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump)
{
gdb_assert (this_frame == NULL || this_frame->level >= 0);
while (this_frame != NULL)
{
int unavailable;
frame_register_unwind (this_frame, regnum, optimizedp, &unavailable,
lvalp, addrp, realnump, NULL);
if (*optimizedp)
break;
if (*lvalp != lval_register)
break;
regnum = *realnump;
this_frame = get_next_frame (this_frame);
}
} | /* Find where a register is saved (in memory or another register).
The result of frame_register_unwind is just where it is saved
relative to this particular frame. */ | Find where a register is saved (in memory or another register).
The result of frame_register_unwind is just where it is saved
relative to this particular frame. | [
"Find",
"where",
"a",
"register",
"is",
"saved",
"(",
"in",
"memory",
"or",
"another",
"register",
")",
".",
"The",
"result",
"of",
"frame_register_unwind",
"is",
"just",
"where",
"it",
"is",
"saved",
"relative",
"to",
"this",
"particular",
"frame",
"."
] | static void
frame_register_unwind_location (struct frame_info *this_frame, int regnum,
int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump)
{
gdb_assert (this_frame == NULL || this_frame->level >= 0);
while (this_frame != NULL)
{
int unavailable;
frame_register_unwind (this_frame, regnum, optimizedp, &unavailable,
lvalp, addrp, realnump, NULL);
if (*optimizedp)
break;
if (*lvalp != lval_register)
break;
regnum = *realnump;
this_frame = get_next_frame (this_frame);
}
} | [
"static",
"void",
"frame_register_unwind_location",
"(",
"struct",
"frame_info",
"*",
"this_frame",
",",
"int",
"regnum",
",",
"int",
"*",
"optimizedp",
",",
"enum",
"lval_type",
"*",
"lvalp",
",",
"CORE_ADDR",
"*",
"addrp",
",",
"int",
"*",
"realnump",
")",
"{",
"gdb_assert",
"(",
"this_frame",
"==",
"NULL",
"||",
"this_frame",
"->",
"level",
">=",
"0",
")",
";",
"while",
"(",
"this_frame",
"!=",
"NULL",
")",
"{",
"int",
"unavailable",
";",
"frame_register_unwind",
"(",
"this_frame",
",",
"regnum",
",",
"optimizedp",
",",
"&",
"unavailable",
",",
"lvalp",
",",
"addrp",
",",
"realnump",
",",
"NULL",
")",
";",
"if",
"(",
"*",
"optimizedp",
")",
"break",
";",
"if",
"(",
"*",
"lvalp",
"!=",
"lval_register",
")",
"break",
";",
"regnum",
"=",
"*",
"realnump",
";",
"this_frame",
"=",
"get_next_frame",
"(",
"this_frame",
")",
";",
"}",
"}"
] | Find where a register is saved (in memory or another register). | [
"Find",
"where",
"a",
"register",
"is",
"saved",
"(",
"in",
"memory",
"or",
"another",
"register",
")",
"."
] | [] | [
{
"param": "this_frame",
"type": "struct frame_info"
},
{
"param": "regnum",
"type": "int"
},
{
"param": "optimizedp",
"type": "int"
},
{
"param": "lvalp",
"type": "enum lval_type"
},
{
"param": "addrp",
"type": "CORE_ADDR"
},
{
"param": "realnump",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "this_frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "regnum",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "optimizedp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lvalp",
"type": "enum lval_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addrp",
"type": "CORE_ADDR",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "realnump",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_debug_got_null_frame | void | static void
frame_debug_got_null_frame (struct frame_info *this_frame,
const char *reason)
{
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame (this_frame=");
if (this_frame != NULL)
fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level);
else
fprintf_unfiltered (gdb_stdlog, "<NULL>");
fprintf_unfiltered (gdb_stdlog, ") -> // %s}\n", reason);
}
} | /* Debug routine to print a NULL frame being returned. */ | Debug routine to print a NULL frame being returned. | [
"Debug",
"routine",
"to",
"print",
"a",
"NULL",
"frame",
"being",
"returned",
"."
] | static void
frame_debug_got_null_frame (struct frame_info *this_frame,
const char *reason)
{
if (frame_debug)
{
fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame (this_frame=");
if (this_frame != NULL)
fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level);
else
fprintf_unfiltered (gdb_stdlog, "<NULL>");
fprintf_unfiltered (gdb_stdlog, ") -> // %s}\n", reason);
}
} | [
"static",
"void",
"frame_debug_got_null_frame",
"(",
"struct",
"frame_info",
"*",
"this_frame",
",",
"const",
"char",
"*",
"reason",
")",
"{",
"if",
"(",
"frame_debug",
")",
"{",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\"",
")",
";",
"if",
"(",
"this_frame",
"!=",
"NULL",
")",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\"",
",",
"this_frame",
"->",
"level",
")",
";",
"else",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\"",
")",
";",
"fprintf_unfiltered",
"(",
"gdb_stdlog",
",",
"\"",
"\\n",
"\"",
",",
"reason",
")",
";",
"}",
"}"
] | Debug routine to print a NULL frame being returned. | [
"Debug",
"routine",
"to",
"print",
"a",
"NULL",
"frame",
"being",
"returned",
"."
] | [] | [
{
"param": "this_frame",
"type": "struct frame_info"
},
{
"param": "reason",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "this_frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reason",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | inside_entry_func | int | static int
inside_entry_func (struct frame_info *this_frame)
{
CORE_ADDR entry_point;
if (!entry_point_address_query (&entry_point))
return 0;
return get_frame_func (this_frame) == entry_point;
} | /* Test whether THIS_FRAME is inside the process entry point function. */ | Test whether THIS_FRAME is inside the process entry point function. | [
"Test",
"whether",
"THIS_FRAME",
"is",
"inside",
"the",
"process",
"entry",
"point",
"function",
"."
] | static int
inside_entry_func (struct frame_info *this_frame)
{
CORE_ADDR entry_point;
if (!entry_point_address_query (&entry_point))
return 0;
return get_frame_func (this_frame) == entry_point;
} | [
"static",
"int",
"inside_entry_func",
"(",
"struct",
"frame_info",
"*",
"this_frame",
")",
"{",
"CORE_ADDR",
"entry_point",
";",
"if",
"(",
"!",
"entry_point_address_query",
"(",
"&",
"entry_point",
")",
")",
"return",
"0",
";",
"return",
"get_frame_func",
"(",
"this_frame",
")",
"==",
"entry_point",
";",
"}"
] | Test whether THIS_FRAME is inside the process entry point function. | [
"Test",
"whether",
"THIS_FRAME",
"is",
"inside",
"the",
"process",
"entry",
"point",
"function",
"."
] | [] | [
{
"param": "this_frame",
"type": "struct frame_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "this_frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_unwinder_is | int | int
frame_unwinder_is (struct frame_info *fi, const struct frame_unwind *unwinder)
{
if (fi->unwind == NULL)
frame_unwind_find_by_frame (fi, &fi->prologue_cache);
return fi->unwind == unwinder;
} | /* Return true if the frame unwinder for frame FI is UNWINDER; false
otherwise. */ | Return true if the frame unwinder for frame FI is UNWINDER; false
otherwise. | [
"Return",
"true",
"if",
"the",
"frame",
"unwinder",
"for",
"frame",
"FI",
"is",
"UNWINDER",
";",
"false",
"otherwise",
"."
] | int
frame_unwinder_is (struct frame_info *fi, const struct frame_unwind *unwinder)
{
if (fi->unwind == NULL)
frame_unwind_find_by_frame (fi, &fi->prologue_cache);
return fi->unwind == unwinder;
} | [
"int",
"frame_unwinder_is",
"(",
"struct",
"frame_info",
"*",
"fi",
",",
"const",
"struct",
"frame_unwind",
"*",
"unwinder",
")",
"{",
"if",
"(",
"fi",
"->",
"unwind",
"==",
"NULL",
")",
"frame_unwind_find_by_frame",
"(",
"fi",
",",
"&",
"fi",
"->",
"prologue_cache",
")",
";",
"return",
"fi",
"->",
"unwind",
"==",
"unwinder",
";",
"}"
] | Return true if the frame unwinder for frame FI is UNWINDER; false
otherwise. | [
"Return",
"true",
"if",
"the",
"frame",
"unwinder",
"for",
"frame",
"FI",
"is",
"UNWINDER",
";",
"false",
"otherwise",
"."
] | [] | [
{
"param": "fi",
"type": "struct frame_info"
},
{
"param": "unwinder",
"type": "struct frame_unwind"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fi",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unwinder",
"type": "struct frame_unwind",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_relative_level | int | int
frame_relative_level (struct frame_info *fi)
{
if (fi == NULL)
return -1;
else
return fi->level;
} | /* Level of the selected frame: 0 for innermost, 1 for its caller, ...
or -1 for a NULL frame. */ | Level of the selected frame: 0 for innermost, 1 for its caller,
or -1 for a NULL frame. | [
"Level",
"of",
"the",
"selected",
"frame",
":",
"0",
"for",
"innermost",
"1",
"for",
"its",
"caller",
"or",
"-",
"1",
"for",
"a",
"NULL",
"frame",
"."
] | int
frame_relative_level (struct frame_info *fi)
{
if (fi == NULL)
return -1;
else
return fi->level;
} | [
"int",
"frame_relative_level",
"(",
"struct",
"frame_info",
"*",
"fi",
")",
"{",
"if",
"(",
"fi",
"==",
"NULL",
")",
"return",
"-1",
";",
"else",
"return",
"fi",
"->",
"level",
";",
"}"
] | Level of the selected frame: 0 for innermost, 1 for its caller, ...
or -1 for a NULL frame. | [
"Level",
"of",
"the",
"selected",
"frame",
":",
"0",
"for",
"innermost",
"1",
"for",
"its",
"caller",
"...",
"or",
"-",
"1",
"for",
"a",
"NULL",
"frame",
"."
] | [] | [
{
"param": "fi",
"type": "struct frame_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fi",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_stop_reason_string | char | const char *
frame_stop_reason_string (enum unwind_stop_reason reason)
{
switch (reason)
{
#define SET(name, description) \
case name: return _(description);
#include "unwind_stop_reasons.def"
#undef SET
default:
internal_error (__FILE__, __LINE__,
"Invalid frame stop reason");
}
} | /* Return a string explaining REASON. */ | Return a string explaining REASON. | [
"Return",
"a",
"string",
"explaining",
"REASON",
"."
] | const char *
frame_stop_reason_string (enum unwind_stop_reason reason)
{
switch (reason)
{
#define SET(name, description) \
case name: return _(description);
#include "unwind_stop_reasons.def"
#undef SET
default:
internal_error (__FILE__, __LINE__,
"Invalid frame stop reason");
}
} | [
"const",
"char",
"*",
"frame_stop_reason_string",
"(",
"enum",
"unwind_stop_reason",
"reason",
")",
"{",
"switch",
"(",
"reason",
")",
"{",
"#define",
"SET",
"(",
"name",
",",
"description",
")",
" \\\n case name: return _(description);",
"\n",
"#include",
"\"",
"\"",
"\n",
"#undef",
" SET",
"\n\n",
"default",
":",
"internal_error",
"(",
"__FILE__",
",",
"__LINE__",
",",
"\"",
"\"",
")",
";",
"}",
"}"
] | Return a string explaining REASON. | [
"Return",
"a",
"string",
"explaining",
"REASON",
"."
] | [] | [
{
"param": "reason",
"type": "enum unwind_stop_reason"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reason",
"type": "enum unwind_stop_reason",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_cleanup_after_sniffer | void | static void
frame_cleanup_after_sniffer (void *arg)
{
struct frame_info *frame = arg;
/* The sniffer should not allocate a prologue cache if it did not
match this frame. */
gdb_assert (frame->prologue_cache == NULL);
/* No sniffer should extend the frame chain; sniff based on what is
already certain. */
gdb_assert (!frame->prev_p);
/* The sniffer should not check the frame's ID; that's circular. */
gdb_assert (!frame->this_id.p);
/* Clear cached fields dependent on the unwinder.
The previous PC is independent of the unwinder, but the previous
function is not (see get_frame_address_in_block). */
frame->prev_func.p = 0;
frame->prev_func.addr = 0;
/* Discard the unwinder last, so that we can easily find it if an assertion
in this function triggers. */
frame->unwind = NULL;
} | /* Clean up after a failed (wrong unwinder) attempt to unwind past
FRAME. */ | Clean up after a failed (wrong unwinder) attempt to unwind past
FRAME. | [
"Clean",
"up",
"after",
"a",
"failed",
"(",
"wrong",
"unwinder",
")",
"attempt",
"to",
"unwind",
"past",
"FRAME",
"."
] | static void
frame_cleanup_after_sniffer (void *arg)
{
struct frame_info *frame = arg;
gdb_assert (frame->prologue_cache == NULL);
gdb_assert (!frame->prev_p);
gdb_assert (!frame->this_id.p);
frame->prev_func.p = 0;
frame->prev_func.addr = 0;
frame->unwind = NULL;
} | [
"static",
"void",
"frame_cleanup_after_sniffer",
"(",
"void",
"*",
"arg",
")",
"{",
"struct",
"frame_info",
"*",
"frame",
"=",
"arg",
";",
"gdb_assert",
"(",
"frame",
"->",
"prologue_cache",
"==",
"NULL",
")",
";",
"gdb_assert",
"(",
"!",
"frame",
"->",
"prev_p",
")",
";",
"gdb_assert",
"(",
"!",
"frame",
"->",
"this_id",
".",
"p",
")",
";",
"frame",
"->",
"prev_func",
".",
"p",
"=",
"0",
";",
"frame",
"->",
"prev_func",
".",
"addr",
"=",
"0",
";",
"frame",
"->",
"unwind",
"=",
"NULL",
";",
"}"
] | Clean up after a failed (wrong unwinder) attempt to unwind past
FRAME. | [
"Clean",
"up",
"after",
"a",
"failed",
"(",
"wrong",
"unwinder",
")",
"attempt",
"to",
"unwind",
"past",
"FRAME",
"."
] | [
"/* The sniffer should not allocate a prologue cache if it did not\n match this frame. */",
"/* No sniffer should extend the frame chain; sniff based on what is\n already certain. */",
"/* The sniffer should not check the frame's ID; that's circular. */",
"/* Clear cached fields dependent on the unwinder.\n\n The previous PC is independent of the unwinder, but the previous\n function is not (see get_frame_address_in_block). */",
"/* Discard the unwinder last, so that we can easily find it if an assertion\n in this function triggers. */"
] | [
{
"param": "arg",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4b8ab60b7cf68e3075ac2172c935d4a66821a612 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/frame.c | [
"BSD-3-Clause"
] | C | frame_prepare_for_sniffer | null | struct cleanup *
frame_prepare_for_sniffer (struct frame_info *frame,
const struct frame_unwind *unwind)
{
gdb_assert (frame->unwind == NULL);
frame->unwind = unwind;
return make_cleanup (frame_cleanup_after_sniffer, frame);
} | /* Set FRAME's unwinder temporarily, so that we can call a sniffer.
Return a cleanup which should be called if unwinding fails, and
discarded if it succeeds. */ | Set FRAME's unwinder temporarily, so that we can call a sniffer.
Return a cleanup which should be called if unwinding fails, and
discarded if it succeeds. | [
"Set",
"FRAME",
"'",
"s",
"unwinder",
"temporarily",
"so",
"that",
"we",
"can",
"call",
"a",
"sniffer",
".",
"Return",
"a",
"cleanup",
"which",
"should",
"be",
"called",
"if",
"unwinding",
"fails",
"and",
"discarded",
"if",
"it",
"succeeds",
"."
] | struct cleanup *
frame_prepare_for_sniffer (struct frame_info *frame,
const struct frame_unwind *unwind)
{
gdb_assert (frame->unwind == NULL);
frame->unwind = unwind;
return make_cleanup (frame_cleanup_after_sniffer, frame);
} | [
"struct",
"cleanup",
"*",
"frame_prepare_for_sniffer",
"(",
"struct",
"frame_info",
"*",
"frame",
",",
"const",
"struct",
"frame_unwind",
"*",
"unwind",
")",
"{",
"gdb_assert",
"(",
"frame",
"->",
"unwind",
"==",
"NULL",
")",
";",
"frame",
"->",
"unwind",
"=",
"unwind",
";",
"return",
"make_cleanup",
"(",
"frame_cleanup_after_sniffer",
",",
"frame",
")",
";",
"}"
] | Set FRAME's unwinder temporarily, so that we can call a sniffer. | [
"Set",
"FRAME",
"'",
"s",
"unwinder",
"temporarily",
"so",
"that",
"we",
"can",
"call",
"a",
"sniffer",
"."
] | [] | [
{
"param": "frame",
"type": "struct frame_info"
},
{
"param": "unwind",
"type": "struct frame_unwind"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "frame",
"type": "struct frame_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unwind",
"type": "struct frame_unwind",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5de2350abfe15ecd19b2d6345df07c1b136fe755 | atrens/DragonFlyBSD-src | sys/netgraph7/ng_ip_input.c | [
"BSD-3-Clause"
] | C | ngipi_cons | int | static int
ngipi_cons(node_p node)
{
return(0);
} | /*
* Be obliging. but no work to do.
*/ | Be obliging. but no work to do. | [
"Be",
"obliging",
".",
"but",
"no",
"work",
"to",
"do",
"."
] | static int
ngipi_cons(node_p node)
{
return(0);
} | [
"static",
"int",
"ngipi_cons",
"(",
"node_p",
"node",
")",
"{",
"return",
"(",
"0",
")",
";",
"}"
] | Be obliging. | [
"Be",
"obliging",
"."
] | [] | [
{
"param": "node",
"type": "node_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a42284db122cd850aef89d977fbf9918c0f753e0 | atrens/DragonFlyBSD-src | contrib/tcsh-6/tc.who.c | [
"BSD-3-Clause"
] | C | initwatch | void | void
initwatch(void)
{
whohead.who_next = &whotail;
whotail.who_prev = &whohead;
stlast = 1;
#ifdef WHODEBUG
debugwholist(NULL, NULL);
#endif /* WHODEBUG */
} | /*
* Karl Kleinpaste, 26 Jan 1984.
* Initialize the dummy tty list for login watch.
* This dummy list eliminates boundary conditions
* when doing pointer-chase searches.
*/ | Karl Kleinpaste, 26 Jan 1984.
Initialize the dummy tty list for login watch.
This dummy list eliminates boundary conditions
when doing pointer-chase searches. | [
"Karl",
"Kleinpaste",
"26",
"Jan",
"1984",
".",
"Initialize",
"the",
"dummy",
"tty",
"list",
"for",
"login",
"watch",
".",
"This",
"dummy",
"list",
"eliminates",
"boundary",
"conditions",
"when",
"doing",
"pointer",
"-",
"chase",
"searches",
"."
] | void
initwatch(void)
{
whohead.who_next = &whotail;
whotail.who_prev = &whohead;
stlast = 1;
#ifdef WHODEBUG
debugwholist(NULL, NULL);
#endif
} | [
"void",
"initwatch",
"(",
"void",
")",
"{",
"whohead",
".",
"who_next",
"=",
"&",
"whotail",
";",
"whotail",
".",
"who_prev",
"=",
"&",
"whohead",
";",
"stlast",
"=",
"1",
";",
"#ifdef",
"WHODEBUG",
"debugwholist",
"(",
"NULL",
",",
"NULL",
")",
";",
"#endif",
"}"
] | Karl Kleinpaste, 26 Jan 1984. | [
"Karl",
"Kleinpaste",
"26",
"Jan",
"1984",
"."
] | [
"/* WHODEBUG */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_open_alternate_stream | FILE | static FILE *
dump_open_alternate_stream (struct dump_file_info *dfi)
{
FILE *stream ;
if (!dfi->alt_filename)
return NULL;
if (dfi->alt_stream)
return dfi->alt_stream;
stream = strcmp ("stderr", dfi->alt_filename) == 0
? stderr
: strcmp ("stdout", dfi->alt_filename) == 0
? stdout
: fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
if (!stream)
error ("could not open dump file %qs: %m", dfi->alt_filename);
else
dfi->alt_state = 1;
return stream;
} | /* For a given DFI, open an alternate dump filename (which could also
be a standard stream such as stdout/stderr). If the alternate dump
file cannot be opened, return NULL. */ | For a given DFI, open an alternate dump filename (which could also
be a standard stream such as stdout/stderr). If the alternate dump
file cannot be opened, return NULL. | [
"For",
"a",
"given",
"DFI",
"open",
"an",
"alternate",
"dump",
"filename",
"(",
"which",
"could",
"also",
"be",
"a",
"standard",
"stream",
"such",
"as",
"stdout",
"/",
"stderr",
")",
".",
"If",
"the",
"alternate",
"dump",
"file",
"cannot",
"be",
"opened",
"return",
"NULL",
"."
] | static FILE *
dump_open_alternate_stream (struct dump_file_info *dfi)
{
FILE *stream ;
if (!dfi->alt_filename)
return NULL;
if (dfi->alt_stream)
return dfi->alt_stream;
stream = strcmp ("stderr", dfi->alt_filename) == 0
? stderr
: strcmp ("stdout", dfi->alt_filename) == 0
? stdout
: fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
if (!stream)
error ("could not open dump file %qs: %m", dfi->alt_filename);
else
dfi->alt_state = 1;
return stream;
} | [
"static",
"FILE",
"*",
"dump_open_alternate_stream",
"(",
"struct",
"dump_file_info",
"*",
"dfi",
")",
"{",
"FILE",
"*",
"stream",
";",
"if",
"(",
"!",
"dfi",
"->",
"alt_filename",
")",
"return",
"NULL",
";",
"if",
"(",
"dfi",
"->",
"alt_stream",
")",
"return",
"dfi",
"->",
"alt_stream",
";",
"stream",
"=",
"strcmp",
"(",
"\"",
"\"",
",",
"dfi",
"->",
"alt_filename",
")",
"==",
"0",
"?",
"stderr",
":",
"strcmp",
"(",
"\"",
"\"",
",",
"dfi",
"->",
"alt_filename",
")",
"==",
"0",
"?",
"stdout",
":",
"fopen",
"(",
"dfi",
"->",
"alt_filename",
",",
"dfi",
"->",
"alt_state",
"<",
"0",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"!",
"stream",
")",
"error",
"(",
"\"",
"\"",
",",
"dfi",
"->",
"alt_filename",
")",
";",
"else",
"dfi",
"->",
"alt_state",
"=",
"1",
";",
"return",
"stream",
";",
"}"
] | For a given DFI, open an alternate dump filename (which could also
be a standard stream such as stdout/stderr). | [
"For",
"a",
"given",
"DFI",
"open",
"an",
"alternate",
"dump",
"filename",
"(",
"which",
"could",
"also",
"be",
"a",
"standard",
"stream",
"such",
"as",
"stdout",
"/",
"stderr",
")",
"."
] | [] | [
{
"param": "dfi",
"type": "struct dump_file_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dfi",
"type": "struct dump_file_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_loc | void | void
dump_loc (dump_flags_t dump_kind, FILE *dfile, source_location loc)
{
if (dump_kind)
{
if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION)
fprintf (dfile, "%s:%d:%d: note: ", LOCATION_FILE (loc),
LOCATION_LINE (loc), LOCATION_COLUMN (loc));
else if (current_function_decl)
fprintf (dfile, "%s:%d:%d: note: ",
DECL_SOURCE_FILE (current_function_decl),
DECL_SOURCE_LINE (current_function_decl),
DECL_SOURCE_COLUMN (current_function_decl));
}
} | /* Print source location on DFILE if enabled. */ | Print source location on DFILE if enabled. | [
"Print",
"source",
"location",
"on",
"DFILE",
"if",
"enabled",
"."
] | void
dump_loc (dump_flags_t dump_kind, FILE *dfile, source_location loc)
{
if (dump_kind)
{
if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION)
fprintf (dfile, "%s:%d:%d: note: ", LOCATION_FILE (loc),
LOCATION_LINE (loc), LOCATION_COLUMN (loc));
else if (current_function_decl)
fprintf (dfile, "%s:%d:%d: note: ",
DECL_SOURCE_FILE (current_function_decl),
DECL_SOURCE_LINE (current_function_decl),
DECL_SOURCE_COLUMN (current_function_decl));
}
} | [
"void",
"dump_loc",
"(",
"dump_flags_t",
"dump_kind",
",",
"FILE",
"*",
"dfile",
",",
"source_location",
"loc",
")",
"{",
"if",
"(",
"dump_kind",
")",
"{",
"if",
"(",
"LOCATION_LOCUS",
"(",
"loc",
")",
">",
"BUILTINS_LOCATION",
")",
"fprintf",
"(",
"dfile",
",",
"\"",
"\"",
",",
"LOCATION_FILE",
"(",
"loc",
")",
",",
"LOCATION_LINE",
"(",
"loc",
")",
",",
"LOCATION_COLUMN",
"(",
"loc",
")",
")",
";",
"else",
"if",
"(",
"current_function_decl",
")",
"fprintf",
"(",
"dfile",
",",
"\"",
"\"",
",",
"DECL_SOURCE_FILE",
"(",
"current_function_decl",
")",
",",
"DECL_SOURCE_LINE",
"(",
"current_function_decl",
")",
",",
"DECL_SOURCE_COLUMN",
"(",
"current_function_decl",
")",
")",
";",
"}",
"}"
] | Print source location on DFILE if enabled. | [
"Print",
"source",
"location",
"on",
"DFILE",
"if",
"enabled",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "dfile",
"type": "FILE"
},
{
"param": "loc",
"type": "source_location"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dfile",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loc",
"type": "source_location",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_gimple_stmt | void | void
dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
if (dump_file && (dump_kind & pflags))
print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
if (alt_dump_file && (dump_kind & alt_flags))
print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
} | /* Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */ | Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. | [
"Dump",
"gimple",
"statement",
"GS",
"with",
"SPC",
"indentation",
"spaces",
"and",
"EXTRA_DUMP_FLAGS",
"on",
"the",
"dump",
"streams",
"if",
"DUMP_KIND",
"is",
"enabled",
"."
] | void
dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
if (dump_file && (dump_kind & pflags))
print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
if (alt_dump_file && (dump_kind & alt_flags))
print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
} | [
"void",
"dump_gimple_stmt",
"(",
"dump_flags_t",
"dump_kind",
",",
"dump_flags_t",
"extra_dump_flags",
",",
"gimple",
"*",
"gs",
",",
"int",
"spc",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"print_gimple_stmt",
"(",
"dump_file",
",",
"gs",
",",
"spc",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"print_gimple_stmt",
"(",
"alt_dump_file",
",",
"gs",
",",
"spc",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}"
] | Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. | [
"Dump",
"gimple",
"statement",
"GS",
"with",
"SPC",
"indentation",
"spaces",
"and",
"EXTRA_DUMP_FLAGS",
"on",
"the",
"dump",
"streams",
"if",
"DUMP_KIND",
"is",
"enabled",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "extra_dump_flags",
"type": "dump_flags_t"
},
{
"param": "gs",
"type": "gimple"
},
{
"param": "spc",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extra_dump_flags",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gs",
"type": "gimple",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "spc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_gimple_stmt_loc | void | void
dump_gimple_stmt_loc (dump_flags_t dump_kind, source_location loc,
dump_flags_t extra_dump_flags, gimple *gs, int spc)
{
if (dump_file && (dump_kind & pflags))
{
dump_loc (dump_kind, dump_file, loc);
print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
dump_loc (dump_kind, alt_dump_file, loc);
print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
}
} | /* Similar to dump_gimple_stmt, except additionally print source location. */ | Similar to dump_gimple_stmt, except additionally print source location. | [
"Similar",
"to",
"dump_gimple_stmt",
"except",
"additionally",
"print",
"source",
"location",
"."
] | void
dump_gimple_stmt_loc (dump_flags_t dump_kind, source_location loc,
dump_flags_t extra_dump_flags, gimple *gs, int spc)
{
if (dump_file && (dump_kind & pflags))
{
dump_loc (dump_kind, dump_file, loc);
print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
dump_loc (dump_kind, alt_dump_file, loc);
print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
}
} | [
"void",
"dump_gimple_stmt_loc",
"(",
"dump_flags_t",
"dump_kind",
",",
"source_location",
"loc",
",",
"dump_flags_t",
"extra_dump_flags",
",",
"gimple",
"*",
"gs",
",",
"int",
"spc",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"{",
"dump_loc",
"(",
"dump_kind",
",",
"dump_file",
",",
"loc",
")",
";",
"print_gimple_stmt",
"(",
"dump_file",
",",
"gs",
",",
"spc",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"{",
"dump_loc",
"(",
"dump_kind",
",",
"alt_dump_file",
",",
"loc",
")",
";",
"print_gimple_stmt",
"(",
"alt_dump_file",
",",
"gs",
",",
"spc",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}",
"}"
] | Similar to dump_gimple_stmt, except additionally print source location. | [
"Similar",
"to",
"dump_gimple_stmt",
"except",
"additionally",
"print",
"source",
"location",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "loc",
"type": "source_location"
},
{
"param": "extra_dump_flags",
"type": "dump_flags_t"
},
{
"param": "gs",
"type": "gimple"
},
{
"param": "spc",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loc",
"type": "source_location",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extra_dump_flags",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gs",
"type": "gimple",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "spc",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_generic_expr | void | void
dump_generic_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
tree t)
{
if (dump_file && (dump_kind & pflags))
print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
if (alt_dump_file && (dump_kind & alt_flags))
print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
} | /* Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
DUMP_KIND is enabled. */ | Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
DUMP_KIND is enabled. | [
"Dump",
"expression",
"tree",
"T",
"using",
"EXTRA_DUMP_FLAGS",
"on",
"dump",
"streams",
"if",
"DUMP_KIND",
"is",
"enabled",
"."
] | void
dump_generic_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
tree t)
{
if (dump_file && (dump_kind & pflags))
print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
if (alt_dump_file && (dump_kind & alt_flags))
print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
} | [
"void",
"dump_generic_expr",
"(",
"dump_flags_t",
"dump_kind",
",",
"dump_flags_t",
"extra_dump_flags",
",",
"tree",
"t",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"print_generic_expr",
"(",
"dump_file",
",",
"t",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"print_generic_expr",
"(",
"alt_dump_file",
",",
"t",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}"
] | Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
DUMP_KIND is enabled. | [
"Dump",
"expression",
"tree",
"T",
"using",
"EXTRA_DUMP_FLAGS",
"on",
"dump",
"streams",
"if",
"DUMP_KIND",
"is",
"enabled",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "extra_dump_flags",
"type": "dump_flags_t"
},
{
"param": "t",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extra_dump_flags",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "t",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_generic_expr_loc | void | void
dump_generic_expr_loc (int dump_kind, source_location loc,
dump_flags_t extra_dump_flags, tree t)
{
if (dump_file && (dump_kind & pflags))
{
dump_loc (dump_kind, dump_file, loc);
print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
dump_loc (dump_kind, alt_dump_file, loc);
print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
}
} | /* Similar to dump_generic_expr, except additionally print the source
location. */ | Similar to dump_generic_expr, except additionally print the source
location. | [
"Similar",
"to",
"dump_generic_expr",
"except",
"additionally",
"print",
"the",
"source",
"location",
"."
] | void
dump_generic_expr_loc (int dump_kind, source_location loc,
dump_flags_t extra_dump_flags, tree t)
{
if (dump_file && (dump_kind & pflags))
{
dump_loc (dump_kind, dump_file, loc);
print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
dump_loc (dump_kind, alt_dump_file, loc);
print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
}
} | [
"void",
"dump_generic_expr_loc",
"(",
"int",
"dump_kind",
",",
"source_location",
"loc",
",",
"dump_flags_t",
"extra_dump_flags",
",",
"tree",
"t",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"{",
"dump_loc",
"(",
"dump_kind",
",",
"dump_file",
",",
"loc",
")",
";",
"print_generic_expr",
"(",
"dump_file",
",",
"t",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"{",
"dump_loc",
"(",
"dump_kind",
",",
"alt_dump_file",
",",
"loc",
")",
";",
"print_generic_expr",
"(",
"alt_dump_file",
",",
"t",
",",
"dump_flags",
"|",
"extra_dump_flags",
")",
";",
"}",
"}"
] | Similar to dump_generic_expr, except additionally print the source
location. | [
"Similar",
"to",
"dump_generic_expr",
"except",
"additionally",
"print",
"the",
"source",
"location",
"."
] | [] | [
{
"param": "dump_kind",
"type": "int"
},
{
"param": "loc",
"type": "source_location"
},
{
"param": "extra_dump_flags",
"type": "dump_flags_t"
},
{
"param": "t",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loc",
"type": "source_location",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extra_dump_flags",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "t",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_printf | void | void
dump_printf (dump_flags_t dump_kind, const char *format, ...)
{
if (dump_file && (dump_kind & pflags))
{
va_list ap;
va_start (ap, format);
vfprintf (dump_file, format, ap);
va_end (ap);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
va_list ap;
va_start (ap, format);
vfprintf (alt_dump_file, format, ap);
va_end (ap);
}
} | /* Output a formatted message using FORMAT on appropriate dump streams. */ | Output a formatted message using FORMAT on appropriate dump streams. | [
"Output",
"a",
"formatted",
"message",
"using",
"FORMAT",
"on",
"appropriate",
"dump",
"streams",
"."
] | void
dump_printf (dump_flags_t dump_kind, const char *format, ...)
{
if (dump_file && (dump_kind & pflags))
{
va_list ap;
va_start (ap, format);
vfprintf (dump_file, format, ap);
va_end (ap);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
va_list ap;
va_start (ap, format);
vfprintf (alt_dump_file, format, ap);
va_end (ap);
}
} | [
"void",
"dump_printf",
"(",
"dump_flags_t",
"dump_kind",
",",
"const",
"char",
"*",
"format",
",",
"...",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"{",
"va_list",
"ap",
";",
"va_start",
"(",
"ap",
",",
"format",
")",
";",
"vfprintf",
"(",
"dump_file",
",",
"format",
",",
"ap",
")",
";",
"va_end",
"(",
"ap",
")",
";",
"}",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"{",
"va_list",
"ap",
";",
"va_start",
"(",
"ap",
",",
"format",
")",
";",
"vfprintf",
"(",
"alt_dump_file",
",",
"format",
",",
"ap",
")",
";",
"va_end",
"(",
"ap",
")",
";",
"}",
"}"
] | Output a formatted message using FORMAT on appropriate dump streams. | [
"Output",
"a",
"formatted",
"message",
"using",
"FORMAT",
"on",
"appropriate",
"dump",
"streams",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "format",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "format",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_printf_loc | void | void
dump_printf_loc (dump_flags_t dump_kind, source_location loc,
const char *format, ...)
{
if (dump_file && (dump_kind & pflags))
{
va_list ap;
dump_loc (dump_kind, dump_file, loc);
va_start (ap, format);
vfprintf (dump_file, format, ap);
va_end (ap);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
va_list ap;
dump_loc (dump_kind, alt_dump_file, loc);
va_start (ap, format);
vfprintf (alt_dump_file, format, ap);
va_end (ap);
}
} | /* Similar to dump_printf, except source location is also printed. */ | Similar to dump_printf, except source location is also printed. | [
"Similar",
"to",
"dump_printf",
"except",
"source",
"location",
"is",
"also",
"printed",
"."
] | void
dump_printf_loc (dump_flags_t dump_kind, source_location loc,
const char *format, ...)
{
if (dump_file && (dump_kind & pflags))
{
va_list ap;
dump_loc (dump_kind, dump_file, loc);
va_start (ap, format);
vfprintf (dump_file, format, ap);
va_end (ap);
}
if (alt_dump_file && (dump_kind & alt_flags))
{
va_list ap;
dump_loc (dump_kind, alt_dump_file, loc);
va_start (ap, format);
vfprintf (alt_dump_file, format, ap);
va_end (ap);
}
} | [
"void",
"dump_printf_loc",
"(",
"dump_flags_t",
"dump_kind",
",",
"source_location",
"loc",
",",
"const",
"char",
"*",
"format",
",",
"...",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"{",
"va_list",
"ap",
";",
"dump_loc",
"(",
"dump_kind",
",",
"dump_file",
",",
"loc",
")",
";",
"va_start",
"(",
"ap",
",",
"format",
")",
";",
"vfprintf",
"(",
"dump_file",
",",
"format",
",",
"ap",
")",
";",
"va_end",
"(",
"ap",
")",
";",
"}",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"{",
"va_list",
"ap",
";",
"dump_loc",
"(",
"dump_kind",
",",
"alt_dump_file",
",",
"loc",
")",
";",
"va_start",
"(",
"ap",
",",
"format",
")",
";",
"vfprintf",
"(",
"alt_dump_file",
",",
"format",
",",
"ap",
")",
";",
"va_end",
"(",
"ap",
")",
";",
"}",
"}"
] | Similar to dump_printf, except source location is also printed. | [
"Similar",
"to",
"dump_printf",
"except",
"source",
"location",
"is",
"also",
"printed",
"."
] | [] | [
{
"param": "dump_kind",
"type": "dump_flags_t"
},
{
"param": "loc",
"type": "source_location"
},
{
"param": "format",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loc",
"type": "source_location",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "format",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_begin | FILE | FILE *
dump_begin (int phase, dump_flags_t *flag_ptr)
{
return g->get_dumps ()->dump_begin (phase, flag_ptr);
} | /* Begin a tree dump for PHASE. Stores any user supplied flag in
*FLAG_PTR and returns a stream to write to. If the dump is not
enabled, returns NULL.
Multiple calls will reopen and append to the dump file. */ | Begin a tree dump for PHASE. Stores any user supplied flag in
FLAG_PTR and returns a stream to write to. If the dump is not
enabled, returns NULL.
Multiple calls will reopen and append to the dump file. | [
"Begin",
"a",
"tree",
"dump",
"for",
"PHASE",
".",
"Stores",
"any",
"user",
"supplied",
"flag",
"in",
"FLAG_PTR",
"and",
"returns",
"a",
"stream",
"to",
"write",
"to",
".",
"If",
"the",
"dump",
"is",
"not",
"enabled",
"returns",
"NULL",
".",
"Multiple",
"calls",
"will",
"reopen",
"and",
"append",
"to",
"the",
"dump",
"file",
"."
] | FILE *
dump_begin (int phase, dump_flags_t *flag_ptr)
{
return g->get_dumps ()->dump_begin (phase, flag_ptr);
} | [
"FILE",
"*",
"dump_begin",
"(",
"int",
"phase",
",",
"dump_flags_t",
"*",
"flag_ptr",
")",
"{",
"return",
"g",
"->",
"get_dumps",
"(",
")",
"->",
"dump_begin",
"(",
"phase",
",",
"flag_ptr",
")",
";",
"}"
] | Begin a tree dump for PHASE. | [
"Begin",
"a",
"tree",
"dump",
"for",
"PHASE",
"."
] | [] | [
{
"param": "phase",
"type": "int"
},
{
"param": "flag_ptr",
"type": "dump_flags_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "phase",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flag_ptr",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_flag_name | char | const char *
dump_flag_name (int phase)
{
return g->get_dumps ()->dump_flag_name (phase);
} | /* Returns the switch name of PHASE. */ | Returns the switch name of PHASE. | [
"Returns",
"the",
"switch",
"name",
"of",
"PHASE",
"."
] | const char *
dump_flag_name (int phase)
{
return g->get_dumps ()->dump_flag_name (phase);
} | [
"const",
"char",
"*",
"dump_flag_name",
"(",
"int",
"phase",
")",
"{",
"return",
"g",
"->",
"get_dumps",
"(",
")",
"->",
"dump_flag_name",
"(",
"phase",
")",
";",
"}"
] | Returns the switch name of PHASE. | [
"Returns",
"the",
"switch",
"name",
"of",
"PHASE",
"."
] | [] | [
{
"param": "phase",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "phase",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | opt_info_switch_p_1 | int | static int
opt_info_switch_p_1 (const char *arg, dump_flags_t *flags, int *optgroup_flags,
char **filename)
{
const char *option_value;
const char *ptr;
option_value = arg;
ptr = option_value;
*filename = NULL;
*flags = 0;
*optgroup_flags = 0;
if (!ptr)
return 1; /* Handle '-fopt-info' without any additional options. */
while (*ptr)
{
const struct dump_option_value_info *option_ptr;
const char *end_ptr;
const char *eq_ptr;
unsigned length;
while (*ptr == '-')
ptr++;
end_ptr = strchr (ptr, '-');
eq_ptr = strchr (ptr, '=');
if (eq_ptr && !end_ptr)
end_ptr = eq_ptr;
if (!end_ptr)
end_ptr = ptr + strlen (ptr);
length = end_ptr - ptr;
for (option_ptr = optinfo_verbosity_options; option_ptr->name;
option_ptr++)
if (strlen (option_ptr->name) == length
&& !memcmp (option_ptr->name, ptr, length))
{
*flags |= option_ptr->value;
goto found;
}
for (option_ptr = optgroup_options; option_ptr->name; option_ptr++)
if (strlen (option_ptr->name) == length
&& !memcmp (option_ptr->name, ptr, length))
{
*optgroup_flags |= option_ptr->value;
goto found;
}
if (*ptr == '=')
{
/* Interpret rest of the argument as a dump filename. This
filename overrides other command line filenames. */
*filename = xstrdup (ptr + 1);
break;
}
else
{
warning (0, "unknown option %q.*s in %<-fopt-info-%s%>",
length, ptr, arg);
return 0;
}
found:;
ptr = end_ptr;
}
return 1;
} | /* Parse ARG as a -fopt-info switch and store flags, optgroup_flags
and filename. Return non-zero if it is a recognized switch. */ | Parse ARG as a -fopt-info switch and store flags, optgroup_flags
and filename. Return non-zero if it is a recognized switch. | [
"Parse",
"ARG",
"as",
"a",
"-",
"fopt",
"-",
"info",
"switch",
"and",
"store",
"flags",
"optgroup_flags",
"and",
"filename",
".",
"Return",
"non",
"-",
"zero",
"if",
"it",
"is",
"a",
"recognized",
"switch",
"."
] | static int
opt_info_switch_p_1 (const char *arg, dump_flags_t *flags, int *optgroup_flags,
char **filename)
{
const char *option_value;
const char *ptr;
option_value = arg;
ptr = option_value;
*filename = NULL;
*flags = 0;
*optgroup_flags = 0;
if (!ptr)
return 1;
while (*ptr)
{
const struct dump_option_value_info *option_ptr;
const char *end_ptr;
const char *eq_ptr;
unsigned length;
while (*ptr == '-')
ptr++;
end_ptr = strchr (ptr, '-');
eq_ptr = strchr (ptr, '=');
if (eq_ptr && !end_ptr)
end_ptr = eq_ptr;
if (!end_ptr)
end_ptr = ptr + strlen (ptr);
length = end_ptr - ptr;
for (option_ptr = optinfo_verbosity_options; option_ptr->name;
option_ptr++)
if (strlen (option_ptr->name) == length
&& !memcmp (option_ptr->name, ptr, length))
{
*flags |= option_ptr->value;
goto found;
}
for (option_ptr = optgroup_options; option_ptr->name; option_ptr++)
if (strlen (option_ptr->name) == length
&& !memcmp (option_ptr->name, ptr, length))
{
*optgroup_flags |= option_ptr->value;
goto found;
}
if (*ptr == '=')
{
*filename = xstrdup (ptr + 1);
break;
}
else
{
warning (0, "unknown option %q.*s in %<-fopt-info-%s%>",
length, ptr, arg);
return 0;
}
found:;
ptr = end_ptr;
}
return 1;
} | [
"static",
"int",
"opt_info_switch_p_1",
"(",
"const",
"char",
"*",
"arg",
",",
"dump_flags_t",
"*",
"flags",
",",
"int",
"*",
"optgroup_flags",
",",
"char",
"*",
"*",
"filename",
")",
"{",
"const",
"char",
"*",
"option_value",
";",
"const",
"char",
"*",
"ptr",
";",
"option_value",
"=",
"arg",
";",
"ptr",
"=",
"option_value",
";",
"*",
"filename",
"=",
"NULL",
";",
"*",
"flags",
"=",
"0",
";",
"*",
"optgroup_flags",
"=",
"0",
";",
"if",
"(",
"!",
"ptr",
")",
"return",
"1",
";",
"while",
"(",
"*",
"ptr",
")",
"{",
"const",
"struct",
"dump_option_value_info",
"*",
"option_ptr",
";",
"const",
"char",
"*",
"end_ptr",
";",
"const",
"char",
"*",
"eq_ptr",
";",
"unsigned",
"length",
";",
"while",
"(",
"*",
"ptr",
"==",
"'",
"'",
")",
"ptr",
"++",
";",
"end_ptr",
"=",
"strchr",
"(",
"ptr",
",",
"'",
"'",
")",
";",
"eq_ptr",
"=",
"strchr",
"(",
"ptr",
",",
"'",
"'",
")",
";",
"if",
"(",
"eq_ptr",
"&&",
"!",
"end_ptr",
")",
"end_ptr",
"=",
"eq_ptr",
";",
"if",
"(",
"!",
"end_ptr",
")",
"end_ptr",
"=",
"ptr",
"+",
"strlen",
"(",
"ptr",
")",
";",
"length",
"=",
"end_ptr",
"-",
"ptr",
";",
"for",
"(",
"option_ptr",
"=",
"optinfo_verbosity_options",
";",
"option_ptr",
"->",
"name",
";",
"option_ptr",
"++",
")",
"if",
"(",
"strlen",
"(",
"option_ptr",
"->",
"name",
")",
"==",
"length",
"&&",
"!",
"memcmp",
"(",
"option_ptr",
"->",
"name",
",",
"ptr",
",",
"length",
")",
")",
"{",
"*",
"flags",
"|=",
"option_ptr",
"->",
"value",
";",
"goto",
"found",
";",
"}",
"for",
"(",
"option_ptr",
"=",
"optgroup_options",
";",
"option_ptr",
"->",
"name",
";",
"option_ptr",
"++",
")",
"if",
"(",
"strlen",
"(",
"option_ptr",
"->",
"name",
")",
"==",
"length",
"&&",
"!",
"memcmp",
"(",
"option_ptr",
"->",
"name",
",",
"ptr",
",",
"length",
")",
")",
"{",
"*",
"optgroup_flags",
"|=",
"option_ptr",
"->",
"value",
";",
"goto",
"found",
";",
"}",
"if",
"(",
"*",
"ptr",
"==",
"'",
"'",
")",
"{",
"*",
"filename",
"=",
"xstrdup",
"(",
"ptr",
"+",
"1",
")",
";",
"break",
";",
"}",
"else",
"{",
"warning",
"(",
"0",
",",
"\"",
"\"",
",",
"length",
",",
"ptr",
",",
"arg",
")",
";",
"return",
"0",
";",
"}",
"found",
":",
";",
"ptr",
"=",
"end_ptr",
";",
"}",
"return",
"1",
";",
"}"
] | Parse ARG as a -fopt-info switch and store flags, optgroup_flags
and filename. | [
"Parse",
"ARG",
"as",
"a",
"-",
"fopt",
"-",
"info",
"switch",
"and",
"store",
"flags",
"optgroup_flags",
"and",
"filename",
"."
] | [
"/* Handle '-fopt-info' without any additional options. */",
"/* Interpret rest of the argument as a dump filename. This\n filename overrides other command line filenames. */"
] | [
{
"param": "arg",
"type": "char"
},
{
"param": "flags",
"type": "dump_flags_t"
},
{
"param": "optgroup_flags",
"type": "int"
},
{
"param": "filename",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "dump_flags_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "optgroup_flags",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_basic_block | void | void
dump_basic_block (int dump_kind, basic_block bb, int indent)
{
if (dump_file && (dump_kind & pflags))
dump_bb (dump_file, bb, indent, TDF_DETAILS);
if (alt_dump_file && (dump_kind & alt_flags))
dump_bb (alt_dump_file, bb, indent, TDF_DETAILS);
} | /* Print basic block on the dump streams. */ | Print basic block on the dump streams. | [
"Print",
"basic",
"block",
"on",
"the",
"dump",
"streams",
"."
] | void
dump_basic_block (int dump_kind, basic_block bb, int indent)
{
if (dump_file && (dump_kind & pflags))
dump_bb (dump_file, bb, indent, TDF_DETAILS);
if (alt_dump_file && (dump_kind & alt_flags))
dump_bb (alt_dump_file, bb, indent, TDF_DETAILS);
} | [
"void",
"dump_basic_block",
"(",
"int",
"dump_kind",
",",
"basic_block",
"bb",
",",
"int",
"indent",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_kind",
"&",
"pflags",
")",
")",
"dump_bb",
"(",
"dump_file",
",",
"bb",
",",
"indent",
",",
"TDF_DETAILS",
")",
";",
"if",
"(",
"alt_dump_file",
"&&",
"(",
"dump_kind",
"&",
"alt_flags",
")",
")",
"dump_bb",
"(",
"alt_dump_file",
",",
"bb",
",",
"indent",
",",
"TDF_DETAILS",
")",
";",
"}"
] | Print basic block on the dump streams. | [
"Print",
"basic",
"block",
"on",
"the",
"dump",
"streams",
"."
] | [] | [
{
"param": "dump_kind",
"type": "int"
},
{
"param": "bb",
"type": "basic_block"
},
{
"param": "indent",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_kind",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "indent",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | dump_function | void | void
dump_function (int phase, tree fn)
{
FILE *stream;
dump_flags_t flags;
stream = dump_begin (phase, &flags);
if (stream)
{
dump_function_to_file (fn, stream, flags);
dump_end (phase, stream);
}
} | /* Dump FUNCTION_DECL FN as tree dump PHASE. */ | Dump FUNCTION_DECL FN as tree dump PHASE. | [
"Dump",
"FUNCTION_DECL",
"FN",
"as",
"tree",
"dump",
"PHASE",
"."
] | void
dump_function (int phase, tree fn)
{
FILE *stream;
dump_flags_t flags;
stream = dump_begin (phase, &flags);
if (stream)
{
dump_function_to_file (fn, stream, flags);
dump_end (phase, stream);
}
} | [
"void",
"dump_function",
"(",
"int",
"phase",
",",
"tree",
"fn",
")",
"{",
"FILE",
"*",
"stream",
";",
"dump_flags_t",
"flags",
";",
"stream",
"=",
"dump_begin",
"(",
"phase",
",",
"&",
"flags",
")",
";",
"if",
"(",
"stream",
")",
"{",
"dump_function_to_file",
"(",
"fn",
",",
"stream",
",",
"flags",
")",
";",
"dump_end",
"(",
"phase",
",",
"stream",
")",
";",
"}",
"}"
] | Dump FUNCTION_DECL FN as tree dump PHASE. | [
"Dump",
"FUNCTION_DECL",
"FN",
"as",
"tree",
"dump",
"PHASE",
"."
] | [] | [
{
"param": "phase",
"type": "int"
},
{
"param": "fn",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "phase",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fn",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0acc7a98db5596ee229b8a42eadb99817be42c14 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/dumpfile.c | [
"BSD-3-Clause"
] | C | print_combine_total_stats | void | void
print_combine_total_stats (void)
{
if (dump_file)
dump_combine_total_stats (dump_file);
} | /* Print information from the combine pass on dump_file. */ | Print information from the combine pass on dump_file. | [
"Print",
"information",
"from",
"the",
"combine",
"pass",
"on",
"dump_file",
"."
] | void
print_combine_total_stats (void)
{
if (dump_file)
dump_combine_total_stats (dump_file);
} | [
"void",
"print_combine_total_stats",
"(",
"void",
")",
"{",
"if",
"(",
"dump_file",
")",
"dump_combine_total_stats",
"(",
"dump_file",
")",
";",
"}"
] | Print information from the combine pass on dump_file. | [
"Print",
"information",
"from",
"the",
"combine",
"pass",
"on",
"dump_file",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5ddf923b19327e6afdef476c54e1b66eb4ddd73e | atrens/DragonFlyBSD-src | libexec/bootpd/readfile.c | [
"BSD-3-Clause"
] | C | rdtab_init | void | void
rdtab_init(void)
{
hwhashtable = hash_Init(HASHTABLESIZE);
iphashtable = hash_Init(HASHTABLESIZE);
nmhashtable = hash_Init(HASHTABLESIZE);
if (!(hwhashtable && iphashtable && nmhashtable)) {
report(LOG_ERR, "Unable to allocate hash tables.");
exit(1);
}
} | /*
* Allocate hash tables for hardware address, ip address, and hostname
* (shared by bootpd and bootpef)
*/ | Allocate hash tables for hardware address, ip address, and hostname
(shared by bootpd and bootpef) | [
"Allocate",
"hash",
"tables",
"for",
"hardware",
"address",
"ip",
"address",
"and",
"hostname",
"(",
"shared",
"by",
"bootpd",
"and",
"bootpef",
")"
] | void
rdtab_init(void)
{
hwhashtable = hash_Init(HASHTABLESIZE);
iphashtable = hash_Init(HASHTABLESIZE);
nmhashtable = hash_Init(HASHTABLESIZE);
if (!(hwhashtable && iphashtable && nmhashtable)) {
report(LOG_ERR, "Unable to allocate hash tables.");
exit(1);
}
} | [
"void",
"rdtab_init",
"(",
"void",
")",
"{",
"hwhashtable",
"=",
"hash_Init",
"(",
"HASHTABLESIZE",
")",
";",
"iphashtable",
"=",
"hash_Init",
"(",
"HASHTABLESIZE",
")",
";",
"nmhashtable",
"=",
"hash_Init",
"(",
"HASHTABLESIZE",
")",
";",
"if",
"(",
"!",
"(",
"hwhashtable",
"&&",
"iphashtable",
"&&",
"nmhashtable",
")",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] | Allocate hash tables for hardware address, ip address, and hostname
(shared by bootpd and bootpef) | [
"Allocate",
"hash",
"tables",
"for",
"hardware",
"address",
"ip",
"address",
"and",
"hostname",
"(",
"shared",
"by",
"bootpd",
"and",
"bootpef",
")"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5ddf923b19327e6afdef476c54e1b66eb4ddd73e | atrens/DragonFlyBSD-src | libexec/bootpd/readfile.c | [
"BSD-3-Clause"
] | C | readtab | void | void
readtab(int force)
{
struct host *hp;
FILE *fp;
struct stat st;
unsigned hashcode, buflen;
static char buffer[MAXENTRYLEN];
/*
* Check the last modification time.
*/
if (stat(bootptab, &st) < 0) {
report(LOG_ERR, "stat on \"%s\": %s",
bootptab, get_errmsg());
return;
}
#ifdef DEBUG
if (debug > 3) {
char timestr[28];
strcpy(timestr, ctime(&(st.st_mtime)));
/* zap the newline */
timestr[24] = '\0';
report(LOG_INFO, "bootptab mtime: %s",
timestr);
}
#endif
if ((force == 0) &&
(st.st_mtime == modtime) &&
st.st_nlink) {
/*
* hasn't been modified or deleted yet.
*/
return;
}
if (debug)
report(LOG_INFO, "reading %s\"%s\"",
(modtime != 0L) ? "new " : "",
bootptab);
/*
* Open bootptab file.
*/
if ((fp = fopen(bootptab, "r")) == NULL) {
report(LOG_ERR, "error opening \"%s\": %s", bootptab, get_errmsg());
return;
}
/*
* Record file modification time.
*/
if (fstat(fileno(fp), &st) < 0) {
report(LOG_ERR, "fstat: %s", get_errmsg());
fclose(fp);
return;
}
modtime = st.st_mtime;
/*
* Entirely erase all hash tables.
*/
hash_Reset(hwhashtable, free_host);
hash_Reset(iphashtable, free_host);
hash_Reset(nmhashtable, free_host);
nhosts = 0;
nentries = 0;
while (TRUE) {
buflen = sizeof(buffer);
read_entry(fp, buffer, &buflen);
if (buflen == 0) { /* More entries? */
break;
}
hp = (struct host *) smalloc(sizeof(struct host));
bzero((char *) hp, sizeof(*hp));
/* the link count it zero */
/*
* Get individual info
*/
if (process_entry(hp, buffer) < 0) {
hp->linkcount = 1;
free_host((hash_datum *) hp);
continue;
}
/*
* If this is not a dummy entry, and the IP or HW
* address is not yet set, try to get them here.
* Dummy entries have . as first char of name.
*/
if (goodname(hp->hostname->string)) {
char *hn = hp->hostname->string;
u_int32 value;
if (hp->flags.iaddr == 0) {
if (lookup_ipa(hn, &value)) {
report(LOG_ERR, "can not get IP addr for %s", hn);
report(LOG_ERR, "(dummy names should start with '.')");
} else {
hp->iaddr.s_addr = value;
hp->flags.iaddr = TRUE;
}
}
/* Set default subnet mask. */
if (hp->flags.subnet_mask == 0) {
if (lookup_netmask(hp->iaddr.s_addr, &value)) {
report(LOG_ERR, "can not get netmask for %s", hn);
} else {
hp->subnet_mask.s_addr = value;
hp->flags.subnet_mask = TRUE;
}
}
}
if (hp->flags.iaddr) {
nhosts++;
}
/* Register by HW addr if known. */
if (hp->flags.htype && hp->flags.haddr) {
/* We will either insert it or free it. */
hp->linkcount++;
hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype));
if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) {
report(LOG_NOTICE, "duplicate %s address: %s",
netname(hp->htype),
haddrtoa(hp->haddr, haddrlength(hp->htype)));
free_host((hash_datum *) hp);
continue;
}
}
/* Register by IP addr if known. */
if (hp->flags.iaddr) {
hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4);
if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) {
report(LOG_ERR,
"hash_Insert() failed on IP address insertion");
} else {
/* Just inserted the host struct in a new hash list. */
hp->linkcount++;
}
}
/* Register by Name (always known) */
hashcode = hash_HashFunction((u_char *) hp->hostname->string,
strlen(hp->hostname->string));
if (hash_Insert(nmhashtable, hashcode, nullcmp,
hp->hostname->string, hp) < 0) {
report(LOG_ERR,
"hash_Insert() failed on insertion of hostname: \"%s\"",
hp->hostname->string);
} else {
/* Just inserted the host struct in a new hash list. */
hp->linkcount++;
}
nentries++;
}
fclose(fp);
if (debug)
report(LOG_INFO, "read %d entries (%d hosts) from \"%s\"",
nentries, nhosts, bootptab);
return;
} | /*
* Read bootptab database file. Avoid rereading the file if the
* write date hasn't changed since the last time we read it.
*/ | Read bootptab database file. Avoid rereading the file if the
write date hasn't changed since the last time we read it. | [
"Read",
"bootptab",
"database",
"file",
".",
"Avoid",
"rereading",
"the",
"file",
"if",
"the",
"write",
"date",
"hasn",
"'",
"t",
"changed",
"since",
"the",
"last",
"time",
"we",
"read",
"it",
"."
] | void
readtab(int force)
{
struct host *hp;
FILE *fp;
struct stat st;
unsigned hashcode, buflen;
static char buffer[MAXENTRYLEN];
if (stat(bootptab, &st) < 0) {
report(LOG_ERR, "stat on \"%s\": %s",
bootptab, get_errmsg());
return;
}
#ifdef DEBUG
if (debug > 3) {
char timestr[28];
strcpy(timestr, ctime(&(st.st_mtime)));
timestr[24] = '\0';
report(LOG_INFO, "bootptab mtime: %s",
timestr);
}
#endif
if ((force == 0) &&
(st.st_mtime == modtime) &&
st.st_nlink) {
return;
}
if (debug)
report(LOG_INFO, "reading %s\"%s\"",
(modtime != 0L) ? "new " : "",
bootptab);
if ((fp = fopen(bootptab, "r")) == NULL) {
report(LOG_ERR, "error opening \"%s\": %s", bootptab, get_errmsg());
return;
}
if (fstat(fileno(fp), &st) < 0) {
report(LOG_ERR, "fstat: %s", get_errmsg());
fclose(fp);
return;
}
modtime = st.st_mtime;
hash_Reset(hwhashtable, free_host);
hash_Reset(iphashtable, free_host);
hash_Reset(nmhashtable, free_host);
nhosts = 0;
nentries = 0;
while (TRUE) {
buflen = sizeof(buffer);
read_entry(fp, buffer, &buflen);
if (buflen == 0) {
break;
}
hp = (struct host *) smalloc(sizeof(struct host));
bzero((char *) hp, sizeof(*hp));
if (process_entry(hp, buffer) < 0) {
hp->linkcount = 1;
free_host((hash_datum *) hp);
continue;
}
if (goodname(hp->hostname->string)) {
char *hn = hp->hostname->string;
u_int32 value;
if (hp->flags.iaddr == 0) {
if (lookup_ipa(hn, &value)) {
report(LOG_ERR, "can not get IP addr for %s", hn);
report(LOG_ERR, "(dummy names should start with '.')");
} else {
hp->iaddr.s_addr = value;
hp->flags.iaddr = TRUE;
}
}
if (hp->flags.subnet_mask == 0) {
if (lookup_netmask(hp->iaddr.s_addr, &value)) {
report(LOG_ERR, "can not get netmask for %s", hn);
} else {
hp->subnet_mask.s_addr = value;
hp->flags.subnet_mask = TRUE;
}
}
}
if (hp->flags.iaddr) {
nhosts++;
}
if (hp->flags.htype && hp->flags.haddr) {
hp->linkcount++;
hashcode = hash_HashFunction(hp->haddr, haddrlength(hp->htype));
if (hash_Insert(hwhashtable, hashcode, hwinscmp, hp, hp) < 0) {
report(LOG_NOTICE, "duplicate %s address: %s",
netname(hp->htype),
haddrtoa(hp->haddr, haddrlength(hp->htype)));
free_host((hash_datum *) hp);
continue;
}
}
if (hp->flags.iaddr) {
hashcode = hash_HashFunction((u_char *) & (hp->iaddr.s_addr), 4);
if (hash_Insert(iphashtable, hashcode, nullcmp, hp, hp) < 0) {
report(LOG_ERR,
"hash_Insert() failed on IP address insertion");
} else {
hp->linkcount++;
}
}
hashcode = hash_HashFunction((u_char *) hp->hostname->string,
strlen(hp->hostname->string));
if (hash_Insert(nmhashtable, hashcode, nullcmp,
hp->hostname->string, hp) < 0) {
report(LOG_ERR,
"hash_Insert() failed on insertion of hostname: \"%s\"",
hp->hostname->string);
} else {
hp->linkcount++;
}
nentries++;
}
fclose(fp);
if (debug)
report(LOG_INFO, "read %d entries (%d hosts) from \"%s\"",
nentries, nhosts, bootptab);
return;
} | [
"void",
"readtab",
"(",
"int",
"force",
")",
"{",
"struct",
"host",
"*",
"hp",
";",
"FILE",
"*",
"fp",
";",
"struct",
"stat",
"st",
";",
"unsigned",
"hashcode",
",",
"buflen",
";",
"static",
"char",
"buffer",
"[",
"MAXENTRYLEN",
"]",
";",
"if",
"(",
"stat",
"(",
"bootptab",
",",
"&",
"st",
")",
"<",
"0",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"bootptab",
",",
"get_errmsg",
"(",
")",
")",
";",
"return",
";",
"}",
"#ifdef",
"DEBUG",
"if",
"(",
"debug",
">",
"3",
")",
"{",
"char",
"timestr",
"[",
"28",
"]",
";",
"strcpy",
"(",
"timestr",
",",
"ctime",
"(",
"&",
"(",
"st",
".",
"st_mtime",
")",
")",
")",
";",
"timestr",
"[",
"24",
"]",
"=",
"'",
"\\0",
"'",
";",
"report",
"(",
"LOG_INFO",
",",
"\"",
"\"",
",",
"timestr",
")",
";",
"}",
"#endif",
"if",
"(",
"(",
"force",
"==",
"0",
")",
"&&",
"(",
"st",
".",
"st_mtime",
"==",
"modtime",
")",
"&&",
"st",
".",
"st_nlink",
")",
"{",
"return",
";",
"}",
"if",
"(",
"debug",
")",
"report",
"(",
"LOG_INFO",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"(",
"modtime",
"!=",
"0L",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
",",
"bootptab",
")",
";",
"if",
"(",
"(",
"fp",
"=",
"fopen",
"(",
"bootptab",
",",
"\"",
"\"",
")",
")",
"==",
"NULL",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"bootptab",
",",
"get_errmsg",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"fstat",
"(",
"fileno",
"(",
"fp",
")",
",",
"&",
"st",
")",
"<",
"0",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
",",
"get_errmsg",
"(",
")",
")",
";",
"fclose",
"(",
"fp",
")",
";",
"return",
";",
"}",
"modtime",
"=",
"st",
".",
"st_mtime",
";",
"hash_Reset",
"(",
"hwhashtable",
",",
"free_host",
")",
";",
"hash_Reset",
"(",
"iphashtable",
",",
"free_host",
")",
";",
"hash_Reset",
"(",
"nmhashtable",
",",
"free_host",
")",
";",
"nhosts",
"=",
"0",
";",
"nentries",
"=",
"0",
";",
"while",
"(",
"TRUE",
")",
"{",
"buflen",
"=",
"sizeof",
"(",
"buffer",
")",
";",
"read_entry",
"(",
"fp",
",",
"buffer",
",",
"&",
"buflen",
")",
";",
"if",
"(",
"buflen",
"==",
"0",
")",
"{",
"break",
";",
"}",
"hp",
"=",
"(",
"struct",
"host",
"*",
")",
"smalloc",
"(",
"sizeof",
"(",
"struct",
"host",
")",
")",
";",
"bzero",
"(",
"(",
"char",
"*",
")",
"hp",
",",
"sizeof",
"(",
"*",
"hp",
")",
")",
";",
"if",
"(",
"process_entry",
"(",
"hp",
",",
"buffer",
")",
"<",
"0",
")",
"{",
"hp",
"->",
"linkcount",
"=",
"1",
";",
"free_host",
"(",
"(",
"hash_datum",
"*",
")",
"hp",
")",
";",
"continue",
";",
"}",
"if",
"(",
"goodname",
"(",
"hp",
"->",
"hostname",
"->",
"string",
")",
")",
"{",
"char",
"*",
"hn",
"=",
"hp",
"->",
"hostname",
"->",
"string",
";",
"u_int32",
"value",
";",
"if",
"(",
"hp",
"->",
"flags",
".",
"iaddr",
"==",
"0",
")",
"{",
"if",
"(",
"lookup_ipa",
"(",
"hn",
",",
"&",
"value",
")",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
",",
"hn",
")",
";",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
")",
";",
"}",
"else",
"{",
"hp",
"->",
"iaddr",
".",
"s_addr",
"=",
"value",
";",
"hp",
"->",
"flags",
".",
"iaddr",
"=",
"TRUE",
";",
"}",
"}",
"if",
"(",
"hp",
"->",
"flags",
".",
"subnet_mask",
"==",
"0",
")",
"{",
"if",
"(",
"lookup_netmask",
"(",
"hp",
"->",
"iaddr",
".",
"s_addr",
",",
"&",
"value",
")",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
",",
"hn",
")",
";",
"}",
"else",
"{",
"hp",
"->",
"subnet_mask",
".",
"s_addr",
"=",
"value",
";",
"hp",
"->",
"flags",
".",
"subnet_mask",
"=",
"TRUE",
";",
"}",
"}",
"}",
"if",
"(",
"hp",
"->",
"flags",
".",
"iaddr",
")",
"{",
"nhosts",
"++",
";",
"}",
"if",
"(",
"hp",
"->",
"flags",
".",
"htype",
"&&",
"hp",
"->",
"flags",
".",
"haddr",
")",
"{",
"hp",
"->",
"linkcount",
"++",
";",
"hashcode",
"=",
"hash_HashFunction",
"(",
"hp",
"->",
"haddr",
",",
"haddrlength",
"(",
"hp",
"->",
"htype",
")",
")",
";",
"if",
"(",
"hash_Insert",
"(",
"hwhashtable",
",",
"hashcode",
",",
"hwinscmp",
",",
"hp",
",",
"hp",
")",
"<",
"0",
")",
"{",
"report",
"(",
"LOG_NOTICE",
",",
"\"",
"\"",
",",
"netname",
"(",
"hp",
"->",
"htype",
")",
",",
"haddrtoa",
"(",
"hp",
"->",
"haddr",
",",
"haddrlength",
"(",
"hp",
"->",
"htype",
")",
")",
")",
";",
"free_host",
"(",
"(",
"hash_datum",
"*",
")",
"hp",
")",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"hp",
"->",
"flags",
".",
"iaddr",
")",
"{",
"hashcode",
"=",
"hash_HashFunction",
"(",
"(",
"u_char",
"*",
")",
"&",
"(",
"hp",
"->",
"iaddr",
".",
"s_addr",
")",
",",
"4",
")",
";",
"if",
"(",
"hash_Insert",
"(",
"iphashtable",
",",
"hashcode",
",",
"nullcmp",
",",
"hp",
",",
"hp",
")",
"<",
"0",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\"",
")",
";",
"}",
"else",
"{",
"hp",
"->",
"linkcount",
"++",
";",
"}",
"}",
"hashcode",
"=",
"hash_HashFunction",
"(",
"(",
"u_char",
"*",
")",
"hp",
"->",
"hostname",
"->",
"string",
",",
"strlen",
"(",
"hp",
"->",
"hostname",
"->",
"string",
")",
")",
";",
"if",
"(",
"hash_Insert",
"(",
"nmhashtable",
",",
"hashcode",
",",
"nullcmp",
",",
"hp",
"->",
"hostname",
"->",
"string",
",",
"hp",
")",
"<",
"0",
")",
"{",
"report",
"(",
"LOG_ERR",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"hp",
"->",
"hostname",
"->",
"string",
")",
";",
"}",
"else",
"{",
"hp",
"->",
"linkcount",
"++",
";",
"}",
"nentries",
"++",
";",
"}",
"fclose",
"(",
"fp",
")",
";",
"if",
"(",
"debug",
")",
"report",
"(",
"LOG_INFO",
",",
"\"",
"\\\"",
"\\\"",
"\"",
",",
"nentries",
",",
"nhosts",
",",
"bootptab",
")",
";",
"return",
";",
"}"
] | Read bootptab database file. | [
"Read",
"bootptab",
"database",
"file",
"."
] | [
"/*\n\t * Check the last modification time.\n\t */",
"/* zap the newline */",
"/*\n\t\t * hasn't been modified or deleted yet.\n\t\t */",
"/*\n\t * Open bootptab file.\n\t */",
"/*\n\t * Record file modification time.\n\t */",
"/*\n\t * Entirely erase all hash tables.\n\t */",
"/* More entries? */",
"/* the link count it zero */",
"/*\n\t\t * Get individual info\n\t\t */",
"/*\n\t\t * If this is not a dummy entry, and the IP or HW\n\t\t * address is not yet set, try to get them here.\n\t\t * Dummy entries have . as first char of name.\n\t\t */",
"/* Set default subnet mask. */",
"/* Register by HW addr if known. */",
"/* We will either insert it or free it. */",
"/* Register by IP addr if known. */",
"/* Just inserted the host struct in a new hash list. */",
"/* Register by Name (always known) */",
"/* Just inserted the host struct in a new hash list. */"
] | [
{
"param": "force",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "force",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5ddf923b19327e6afdef476c54e1b66eb4ddd73e | atrens/DragonFlyBSD-src | libexec/bootpd/readfile.c | [
"BSD-3-Clause"
] | C | nmcmp | boolean | boolean
nmcmp(hash_datum *d1, hash_datum *d2)
{
char *name = (char *) d1; /* XXX - OK? */
struct host *hp = (struct host *) d2;
return !strcmp(name, hp->hostname->string);
} | /*
* Function for comparing a string with the hostname field of a host
* structure.
*/ | Function for comparing a string with the hostname field of a host
structure. | [
"Function",
"for",
"comparing",
"a",
"string",
"with",
"the",
"hostname",
"field",
"of",
"a",
"host",
"structure",
"."
] | boolean
nmcmp(hash_datum *d1, hash_datum *d2)
{
char *name = (char *) d1;
struct host *hp = (struct host *) d2;
return !strcmp(name, hp->hostname->string);
} | [
"boolean",
"nmcmp",
"(",
"hash_datum",
"*",
"d1",
",",
"hash_datum",
"*",
"d2",
")",
"{",
"char",
"*",
"name",
"=",
"(",
"char",
"*",
")",
"d1",
";",
"struct",
"host",
"*",
"hp",
"=",
"(",
"struct",
"host",
"*",
")",
"d2",
";",
"return",
"!",
"strcmp",
"(",
"name",
",",
"hp",
"->",
"hostname",
"->",
"string",
")",
";",
"}"
] | Function for comparing a string with the hostname field of a host
structure. | [
"Function",
"for",
"comparing",
"a",
"string",
"with",
"the",
"hostname",
"field",
"of",
"a",
"host",
"structure",
"."
] | [
"/* XXX - OK? */"
] | [
{
"param": "d1",
"type": "hash_datum"
},
{
"param": "d2",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d1",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d2",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5ddf923b19327e6afdef476c54e1b66eb4ddd73e | atrens/DragonFlyBSD-src | libexec/bootpd/readfile.c | [
"BSD-3-Clause"
] | C | hwlookcmp | boolean | boolean
hwlookcmp(hash_datum *d1, hash_datum *d2)
{
struct host *host1 = (struct host *) d1;
struct host *host2 = (struct host *) d2;
if (host1->htype != host2->htype) {
return FALSE;
}
if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) {
return FALSE;
}
return TRUE;
} | /*
* Compare function to determine whether two hardware addresses are
* equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE
* otherwise.
*
* This function is used when retrieving elements from the hardware address
* hash table.
*/ | Compare function to determine whether two hardware addresses are
equivalent. Returns TRUE if "host1" and "host2" are equivalent, FALSE
otherwise.
This function is used when retrieving elements from the hardware address
hash table. | [
"Compare",
"function",
"to",
"determine",
"whether",
"two",
"hardware",
"addresses",
"are",
"equivalent",
".",
"Returns",
"TRUE",
"if",
"\"",
"host1",
"\"",
"and",
"\"",
"host2",
"\"",
"are",
"equivalent",
"FALSE",
"otherwise",
".",
"This",
"function",
"is",
"used",
"when",
"retrieving",
"elements",
"from",
"the",
"hardware",
"address",
"hash",
"table",
"."
] | boolean
hwlookcmp(hash_datum *d1, hash_datum *d2)
{
struct host *host1 = (struct host *) d1;
struct host *host2 = (struct host *) d2;
if (host1->htype != host2->htype) {
return FALSE;
}
if (bcmp(host1->haddr, host2->haddr, haddrlength(host1->htype))) {
return FALSE;
}
return TRUE;
} | [
"boolean",
"hwlookcmp",
"(",
"hash_datum",
"*",
"d1",
",",
"hash_datum",
"*",
"d2",
")",
"{",
"struct",
"host",
"*",
"host1",
"=",
"(",
"struct",
"host",
"*",
")",
"d1",
";",
"struct",
"host",
"*",
"host2",
"=",
"(",
"struct",
"host",
"*",
")",
"d2",
";",
"if",
"(",
"host1",
"->",
"htype",
"!=",
"host2",
"->",
"htype",
")",
"{",
"return",
"FALSE",
";",
"}",
"if",
"(",
"bcmp",
"(",
"host1",
"->",
"haddr",
",",
"host2",
"->",
"haddr",
",",
"haddrlength",
"(",
"host1",
"->",
"htype",
")",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Compare function to determine whether two hardware addresses are
equivalent. | [
"Compare",
"function",
"to",
"determine",
"whether",
"two",
"hardware",
"addresses",
"are",
"equivalent",
"."
] | [] | [
{
"param": "d1",
"type": "hash_datum"
},
{
"param": "d2",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d1",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d2",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5ddf923b19327e6afdef476c54e1b66eb4ddd73e | atrens/DragonFlyBSD-src | libexec/bootpd/readfile.c | [
"BSD-3-Clause"
] | C | iplookcmp | boolean | boolean
iplookcmp(hash_datum *d1, hash_datum *d2)
{
struct host *host1 = (struct host *) d1;
struct host *host2 = (struct host *) d2;
return (host1->iaddr.s_addr == host2->iaddr.s_addr);
} | /*
* Compare function for doing IP address hash table lookup.
*/ | Compare function for doing IP address hash table lookup. | [
"Compare",
"function",
"for",
"doing",
"IP",
"address",
"hash",
"table",
"lookup",
"."
] | boolean
iplookcmp(hash_datum *d1, hash_datum *d2)
{
struct host *host1 = (struct host *) d1;
struct host *host2 = (struct host *) d2;
return (host1->iaddr.s_addr == host2->iaddr.s_addr);
} | [
"boolean",
"iplookcmp",
"(",
"hash_datum",
"*",
"d1",
",",
"hash_datum",
"*",
"d2",
")",
"{",
"struct",
"host",
"*",
"host1",
"=",
"(",
"struct",
"host",
"*",
")",
"d1",
";",
"struct",
"host",
"*",
"host2",
"=",
"(",
"struct",
"host",
"*",
")",
"d2",
";",
"return",
"(",
"host1",
"->",
"iaddr",
".",
"s_addr",
"==",
"host2",
"->",
"iaddr",
".",
"s_addr",
")",
";",
"}"
] | Compare function for doing IP address hash table lookup. | [
"Compare",
"function",
"for",
"doing",
"IP",
"address",
"hash",
"table",
"lookup",
"."
] | [] | [
{
"param": "d1",
"type": "hash_datum"
},
{
"param": "d2",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "d1",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "d2",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Init | hash_tbl | hash_tbl *
hash_Init(unsigned tablesize)
{
hash_tbl *hashtblptr;
unsigned totalsize;
if (tablesize > 0) {
totalsize = sizeof(hash_tbl)
+ sizeof(hash_member *) * (tablesize - 1);
hashtblptr = (hash_tbl *) malloc(totalsize);
if (hashtblptr) {
bzero((char *) hashtblptr, totalsize);
hashtblptr->size = tablesize; /* Success! */
hashtblptr->bucketnum = 0;
hashtblptr->member = (hashtblptr->table)[0];
}
} else {
hashtblptr = NULL; /* Disallow zero-length tables */
}
return hashtblptr; /* NULL if failure */
} | /*
* Hash table initialization routine.
*
* This routine creates and intializes a hash table of size "tablesize"
* entries. Successful calls return a pointer to the hash table (which must
* be passed to other hash routines to identify the hash table). Failed
* calls return NULL.
*/ | Hash table initialization routine.
This routine creates and intializes a hash table of size "tablesize"
entries. Successful calls return a pointer to the hash table (which must
be passed to other hash routines to identify the hash table). Failed
calls return NULL. | [
"Hash",
"table",
"initialization",
"routine",
".",
"This",
"routine",
"creates",
"and",
"intializes",
"a",
"hash",
"table",
"of",
"size",
"\"",
"tablesize",
"\"",
"entries",
".",
"Successful",
"calls",
"return",
"a",
"pointer",
"to",
"the",
"hash",
"table",
"(",
"which",
"must",
"be",
"passed",
"to",
"other",
"hash",
"routines",
"to",
"identify",
"the",
"hash",
"table",
")",
".",
"Failed",
"calls",
"return",
"NULL",
"."
] | hash_tbl *
hash_Init(unsigned tablesize)
{
hash_tbl *hashtblptr;
unsigned totalsize;
if (tablesize > 0) {
totalsize = sizeof(hash_tbl)
+ sizeof(hash_member *) * (tablesize - 1);
hashtblptr = (hash_tbl *) malloc(totalsize);
if (hashtblptr) {
bzero((char *) hashtblptr, totalsize);
hashtblptr->size = tablesize;
hashtblptr->bucketnum = 0;
hashtblptr->member = (hashtblptr->table)[0];
}
} else {
hashtblptr = NULL;
}
return hashtblptr;
} | [
"hash_tbl",
"*",
"hash_Init",
"(",
"unsigned",
"tablesize",
")",
"{",
"hash_tbl",
"*",
"hashtblptr",
";",
"unsigned",
"totalsize",
";",
"if",
"(",
"tablesize",
">",
"0",
")",
"{",
"totalsize",
"=",
"sizeof",
"(",
"hash_tbl",
")",
"+",
"sizeof",
"(",
"hash_member",
"*",
")",
"*",
"(",
"tablesize",
"-",
"1",
")",
";",
"hashtblptr",
"=",
"(",
"hash_tbl",
"*",
")",
"malloc",
"(",
"totalsize",
")",
";",
"if",
"(",
"hashtblptr",
")",
"{",
"bzero",
"(",
"(",
"char",
"*",
")",
"hashtblptr",
",",
"totalsize",
")",
";",
"hashtblptr",
"->",
"size",
"=",
"tablesize",
";",
"hashtblptr",
"->",
"bucketnum",
"=",
"0",
";",
"hashtblptr",
"->",
"member",
"=",
"(",
"hashtblptr",
"->",
"table",
")",
"[",
"0",
"]",
";",
"}",
"}",
"else",
"{",
"hashtblptr",
"=",
"NULL",
";",
"}",
"return",
"hashtblptr",
";",
"}"
] | Hash table initialization routine. | [
"Hash",
"table",
"initialization",
"routine",
"."
] | [
"/* Success! */",
"/* Disallow zero-length tables */",
"/* NULL if failure */"
] | [
{
"param": "tablesize",
"type": "unsigned"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tablesize",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Reset | void | void
hash_Reset(hash_tbl *hashtable, hash_freefp free_data)
{
hash_member **bucketptr;
unsigned i;
bucketptr = hashtable->table;
for (i = 0; i < hashtable->size; i++) {
hashi_FreeMembers(*bucketptr, free_data);
*bucketptr++ = NULL;
}
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
} | /*
* This routine re-initializes the hash table. It frees all the allocated
* memory and resets all bucket pointers to NULL.
*/ | This routine re-initializes the hash table. It frees all the allocated
memory and resets all bucket pointers to NULL. | [
"This",
"routine",
"re",
"-",
"initializes",
"the",
"hash",
"table",
".",
"It",
"frees",
"all",
"the",
"allocated",
"memory",
"and",
"resets",
"all",
"bucket",
"pointers",
"to",
"NULL",
"."
] | void
hash_Reset(hash_tbl *hashtable, hash_freefp free_data)
{
hash_member **bucketptr;
unsigned i;
bucketptr = hashtable->table;
for (i = 0; i < hashtable->size; i++) {
hashi_FreeMembers(*bucketptr, free_data);
*bucketptr++ = NULL;
}
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
} | [
"void",
"hash_Reset",
"(",
"hash_tbl",
"*",
"hashtable",
",",
"hash_freefp",
"free_data",
")",
"{",
"hash_member",
"*",
"*",
"bucketptr",
";",
"unsigned",
"i",
";",
"bucketptr",
"=",
"hashtable",
"->",
"table",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"hashtable",
"->",
"size",
";",
"i",
"++",
")",
"{",
"hashi_FreeMembers",
"(",
"*",
"bucketptr",
",",
"free_data",
")",
";",
"*",
"bucketptr",
"++",
"=",
"NULL",
";",
"}",
"hashtable",
"->",
"bucketnum",
"=",
"0",
";",
"hashtable",
"->",
"member",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"0",
"]",
";",
"}"
] | This routine re-initializes the hash table. | [
"This",
"routine",
"re",
"-",
"initializes",
"the",
"hash",
"table",
"."
] | [] | [
{
"param": "hashtable",
"type": "hash_tbl"
},
{
"param": "free_data",
"type": "hash_freefp"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "free_data",
"type": "hash_freefp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_HashFunction | null | unsigned
hash_HashFunction(unsigned char *string, unsigned len)
{
unsigned accum;
accum = 0;
for (; len > 0; len--) {
accum <<= 1;
accum += (unsigned) (*string++ & 0xFF);
}
return accum;
} | /*
* Generic hash function to calculate a hash code from the given string.
*
* For each byte of the string, this function left-shifts the value in an
* accumulator and then adds the byte into the accumulator. The contents of
* the accumulator is returned after the entire string has been processed.
* It is assumed that this result will be used as the "hashcode" parameter in
* calls to other functions in this package. These functions automatically
* adjust the hashcode for the size of each hashtable.
*
* This algorithm probably works best when the hash table size is a prime
* number.
*
* Hopefully, this function is better than the previous one which returned
* the sum of the squares of all the bytes. I'm still open to other
* suggestions for a default hash function. The programmer is more than
* welcome to supply his/her own hash function as that is one of the design
* features of this package.
*/ | Generic hash function to calculate a hash code from the given string.
For each byte of the string, this function left-shifts the value in an
accumulator and then adds the byte into the accumulator. The contents of
the accumulator is returned after the entire string has been processed.
It is assumed that this result will be used as the "hashcode" parameter in
calls to other functions in this package. These functions automatically
adjust the hashcode for the size of each hashtable.
This algorithm probably works best when the hash table size is a prime
number.
Hopefully, this function is better than the previous one which returned
the sum of the squares of all the bytes. I'm still open to other
suggestions for a default hash function. The programmer is more than
welcome to supply his/her own hash function as that is one of the design
features of this package. | [
"Generic",
"hash",
"function",
"to",
"calculate",
"a",
"hash",
"code",
"from",
"the",
"given",
"string",
".",
"For",
"each",
"byte",
"of",
"the",
"string",
"this",
"function",
"left",
"-",
"shifts",
"the",
"value",
"in",
"an",
"accumulator",
"and",
"then",
"adds",
"the",
"byte",
"into",
"the",
"accumulator",
".",
"The",
"contents",
"of",
"the",
"accumulator",
"is",
"returned",
"after",
"the",
"entire",
"string",
"has",
"been",
"processed",
".",
"It",
"is",
"assumed",
"that",
"this",
"result",
"will",
"be",
"used",
"as",
"the",
"\"",
"hashcode",
"\"",
"parameter",
"in",
"calls",
"to",
"other",
"functions",
"in",
"this",
"package",
".",
"These",
"functions",
"automatically",
"adjust",
"the",
"hashcode",
"for",
"the",
"size",
"of",
"each",
"hashtable",
".",
"This",
"algorithm",
"probably",
"works",
"best",
"when",
"the",
"hash",
"table",
"size",
"is",
"a",
"prime",
"number",
".",
"Hopefully",
"this",
"function",
"is",
"better",
"than",
"the",
"previous",
"one",
"which",
"returned",
"the",
"sum",
"of",
"the",
"squares",
"of",
"all",
"the",
"bytes",
".",
"I",
"'",
"m",
"still",
"open",
"to",
"other",
"suggestions",
"for",
"a",
"default",
"hash",
"function",
".",
"The",
"programmer",
"is",
"more",
"than",
"welcome",
"to",
"supply",
"his",
"/",
"her",
"own",
"hash",
"function",
"as",
"that",
"is",
"one",
"of",
"the",
"design",
"features",
"of",
"this",
"package",
"."
] | unsigned
hash_HashFunction(unsigned char *string, unsigned len)
{
unsigned accum;
accum = 0;
for (; len > 0; len--) {
accum <<= 1;
accum += (unsigned) (*string++ & 0xFF);
}
return accum;
} | [
"unsigned",
"hash_HashFunction",
"(",
"unsigned",
"char",
"*",
"string",
",",
"unsigned",
"len",
")",
"{",
"unsigned",
"accum",
";",
"accum",
"=",
"0",
";",
"for",
"(",
";",
"len",
">",
"0",
";",
"len",
"--",
")",
"{",
"accum",
"<<=",
"1",
";",
"accum",
"+=",
"(",
"unsigned",
")",
"(",
"*",
"string",
"++",
"&",
"0xFF",
")",
";",
"}",
"return",
"accum",
";",
"}"
] | Generic hash function to calculate a hash code from the given string. | [
"Generic",
"hash",
"function",
"to",
"calculate",
"a",
"hash",
"code",
"from",
"the",
"given",
"string",
"."
] | [] | [
{
"param": "string",
"type": "unsigned char"
},
{
"param": "len",
"type": "unsigned"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "unsigned char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "len",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Exists | int | int
hash_Exists(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key)
{
hash_member *memberptr;
memberptr = (hashtable->table)[hashcode % (hashtable->size)];
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
return TRUE; /* Entry does exist */
}
memberptr = memberptr->next;
}
return FALSE; /* Entry does not exist */
} | /*
* Returns TRUE if at least one entry for the given key exists; FALSE
* otherwise.
*/ | Returns TRUE if at least one entry for the given key exists; FALSE
otherwise. | [
"Returns",
"TRUE",
"if",
"at",
"least",
"one",
"entry",
"for",
"the",
"given",
"key",
"exists",
";",
"FALSE",
"otherwise",
"."
] | int
hash_Exists(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key)
{
hash_member *memberptr;
memberptr = (hashtable->table)[hashcode % (hashtable->size)];
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
return TRUE;
}
memberptr = memberptr->next;
}
return FALSE;
} | [
"int",
"hash_Exists",
"(",
"hash_tbl",
"*",
"hashtable",
",",
"unsigned",
"hashcode",
",",
"hash_cmpfp",
"compare",
",",
"hash_datum",
"*",
"key",
")",
"{",
"hash_member",
"*",
"memberptr",
";",
"memberptr",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"%",
"(",
"hashtable",
"->",
"size",
")",
"]",
";",
"while",
"(",
"memberptr",
")",
"{",
"if",
"(",
"(",
"*",
"compare",
")",
"(",
"key",
",",
"memberptr",
"->",
"data",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"memberptr",
"=",
"memberptr",
"->",
"next",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Returns TRUE if at least one entry for the given key exists; FALSE
otherwise. | [
"Returns",
"TRUE",
"if",
"at",
"least",
"one",
"entry",
"for",
"the",
"given",
"key",
"exists",
";",
"FALSE",
"otherwise",
"."
] | [
"/* Entry does exist */",
"/* Entry does not exist */"
] | [
{
"param": "hashtable",
"type": "hash_tbl"
},
{
"param": "hashcode",
"type": "unsigned"
},
{
"param": "compare",
"type": "hash_cmpfp"
},
{
"param": "key",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hashcode",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compare",
"type": "hash_cmpfp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Insert | int | int
hash_Insert(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key, hash_datum *element)
{
hash_member *temp;
hashcode %= hashtable->size;
if (hash_Exists(hashtable, hashcode, compare, key)) {
return -1; /* At least one entry already exists */
}
temp = (hash_member *) malloc(sizeof(hash_member));
if (!temp)
return -1; /* malloc failed! */
temp->data = element;
temp->next = (hashtable->table)[hashcode];
(hashtable->table)[hashcode] = temp;
return 0; /* Success */
} | /*
* Insert the data item "element" into the hash table using "hashcode"
* to determine the bucket number, and "compare" and "key" to determine
* its uniqueness.
*
* If the insertion is successful 0 is returned. If a matching entry
* already exists in the given bucket of the hash table, or some other error
* occurs, -1 is returned and the insertion is not done.
*/ |
If the insertion is successful 0 is returned. If a matching entry
already exists in the given bucket of the hash table, or some other error
occurs, -1 is returned and the insertion is not done. | [
"If",
"the",
"insertion",
"is",
"successful",
"0",
"is",
"returned",
".",
"If",
"a",
"matching",
"entry",
"already",
"exists",
"in",
"the",
"given",
"bucket",
"of",
"the",
"hash",
"table",
"or",
"some",
"other",
"error",
"occurs",
"-",
"1",
"is",
"returned",
"and",
"the",
"insertion",
"is",
"not",
"done",
"."
] | int
hash_Insert(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key, hash_datum *element)
{
hash_member *temp;
hashcode %= hashtable->size;
if (hash_Exists(hashtable, hashcode, compare, key)) {
return -1;
}
temp = (hash_member *) malloc(sizeof(hash_member));
if (!temp)
return -1;
temp->data = element;
temp->next = (hashtable->table)[hashcode];
(hashtable->table)[hashcode] = temp;
return 0;
} | [
"int",
"hash_Insert",
"(",
"hash_tbl",
"*",
"hashtable",
",",
"unsigned",
"hashcode",
",",
"hash_cmpfp",
"compare",
",",
"hash_datum",
"*",
"key",
",",
"hash_datum",
"*",
"element",
")",
"{",
"hash_member",
"*",
"temp",
";",
"hashcode",
"%=",
"hashtable",
"->",
"size",
";",
"if",
"(",
"hash_Exists",
"(",
"hashtable",
",",
"hashcode",
",",
"compare",
",",
"key",
")",
")",
"{",
"return",
"-1",
";",
"}",
"temp",
"=",
"(",
"hash_member",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"hash_member",
")",
")",
";",
"if",
"(",
"!",
"temp",
")",
"return",
"-1",
";",
"temp",
"->",
"data",
"=",
"element",
";",
"temp",
"->",
"next",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"]",
";",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"]",
"=",
"temp",
";",
"return",
"0",
";",
"}"
] | Insert the data item "element" into the hash table using "hashcode"
to determine the bucket number, and "compare" and "key" to determine
its uniqueness. | [
"Insert",
"the",
"data",
"item",
"\"",
"element",
"\"",
"into",
"the",
"hash",
"table",
"using",
"\"",
"hashcode",
"\"",
"to",
"determine",
"the",
"bucket",
"number",
"and",
"\"",
"compare",
"\"",
"and",
"\"",
"key",
"\"",
"to",
"determine",
"its",
"uniqueness",
"."
] | [
"/* At least one entry already exists */",
"/* malloc failed! */",
"/* Success */"
] | [
{
"param": "hashtable",
"type": "hash_tbl"
},
{
"param": "hashcode",
"type": "unsigned"
},
{
"param": "compare",
"type": "hash_cmpfp"
},
{
"param": "key",
"type": "hash_datum"
},
{
"param": "element",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hashcode",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compare",
"type": "hash_cmpfp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "element",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Delete | int | int
hash_Delete(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key, hash_freefp free_data)
{
hash_member *memberptr, *tempptr;
hash_member *previous = NULL;
int retval;
retval = -1;
hashcode %= hashtable->size;
/*
* Delete the first member of the list if it matches. Since this moves
* the second member into the first position we have to keep doing this
* over and over until it no longer matches.
*/
memberptr = (hashtable->table)[hashcode];
while (memberptr && (*compare) (key, memberptr->data)) {
(hashtable->table)[hashcode] = memberptr->next;
/*
* Stop hashi_FreeMembers() from deleting the whole list!
*/
memberptr->next = NULL;
hashi_FreeMembers(memberptr, free_data);
memberptr = (hashtable->table)[hashcode];
retval = 0;
}
/*
* Now traverse the rest of the list
*/
if (memberptr) {
previous = memberptr;
memberptr = memberptr->next;
}
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
tempptr = memberptr;
previous->next = memberptr = memberptr->next;
/*
* Put the brakes on hashi_FreeMembers(). . . .
*/
tempptr->next = NULL;
hashi_FreeMembers(tempptr, free_data);
retval = 0;
} else {
previous = memberptr;
memberptr = memberptr->next;
}
}
return retval;
} | /*
* Delete all data elements which match the given key. If at least one
* element is found and the deletion is successful, 0 is returned.
* If no matching elements can be found in the hash table, -1 is returned.
*/ | Delete all data elements which match the given key. If at least one
element is found and the deletion is successful, 0 is returned.
If no matching elements can be found in the hash table, -1 is returned. | [
"Delete",
"all",
"data",
"elements",
"which",
"match",
"the",
"given",
"key",
".",
"If",
"at",
"least",
"one",
"element",
"is",
"found",
"and",
"the",
"deletion",
"is",
"successful",
"0",
"is",
"returned",
".",
"If",
"no",
"matching",
"elements",
"can",
"be",
"found",
"in",
"the",
"hash",
"table",
"-",
"1",
"is",
"returned",
"."
] | int
hash_Delete(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key, hash_freefp free_data)
{
hash_member *memberptr, *tempptr;
hash_member *previous = NULL;
int retval;
retval = -1;
hashcode %= hashtable->size;
memberptr = (hashtable->table)[hashcode];
while (memberptr && (*compare) (key, memberptr->data)) {
(hashtable->table)[hashcode] = memberptr->next;
memberptr->next = NULL;
hashi_FreeMembers(memberptr, free_data);
memberptr = (hashtable->table)[hashcode];
retval = 0;
}
if (memberptr) {
previous = memberptr;
memberptr = memberptr->next;
}
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
tempptr = memberptr;
previous->next = memberptr = memberptr->next;
tempptr->next = NULL;
hashi_FreeMembers(tempptr, free_data);
retval = 0;
} else {
previous = memberptr;
memberptr = memberptr->next;
}
}
return retval;
} | [
"int",
"hash_Delete",
"(",
"hash_tbl",
"*",
"hashtable",
",",
"unsigned",
"hashcode",
",",
"hash_cmpfp",
"compare",
",",
"hash_datum",
"*",
"key",
",",
"hash_freefp",
"free_data",
")",
"{",
"hash_member",
"*",
"memberptr",
",",
"*",
"tempptr",
";",
"hash_member",
"*",
"previous",
"=",
"NULL",
";",
"int",
"retval",
";",
"retval",
"=",
"-1",
";",
"hashcode",
"%=",
"hashtable",
"->",
"size",
";",
"memberptr",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"]",
";",
"while",
"(",
"memberptr",
"&&",
"(",
"*",
"compare",
")",
"(",
"key",
",",
"memberptr",
"->",
"data",
")",
")",
"{",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"]",
"=",
"memberptr",
"->",
"next",
";",
"memberptr",
"->",
"next",
"=",
"NULL",
";",
"hashi_FreeMembers",
"(",
"memberptr",
",",
"free_data",
")",
";",
"memberptr",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"]",
";",
"retval",
"=",
"0",
";",
"}",
"if",
"(",
"memberptr",
")",
"{",
"previous",
"=",
"memberptr",
";",
"memberptr",
"=",
"memberptr",
"->",
"next",
";",
"}",
"while",
"(",
"memberptr",
")",
"{",
"if",
"(",
"(",
"*",
"compare",
")",
"(",
"key",
",",
"memberptr",
"->",
"data",
")",
")",
"{",
"tempptr",
"=",
"memberptr",
";",
"previous",
"->",
"next",
"=",
"memberptr",
"=",
"memberptr",
"->",
"next",
";",
"tempptr",
"->",
"next",
"=",
"NULL",
";",
"hashi_FreeMembers",
"(",
"tempptr",
",",
"free_data",
")",
";",
"retval",
"=",
"0",
";",
"}",
"else",
"{",
"previous",
"=",
"memberptr",
";",
"memberptr",
"=",
"memberptr",
"->",
"next",
";",
"}",
"}",
"return",
"retval",
";",
"}"
] | Delete all data elements which match the given key. | [
"Delete",
"all",
"data",
"elements",
"which",
"match",
"the",
"given",
"key",
"."
] | [
"/*\n\t * Delete the first member of the list if it matches. Since this moves\n\t * the second member into the first position we have to keep doing this\n\t * over and over until it no longer matches.\n\t */",
"/*\n\t\t * Stop hashi_FreeMembers() from deleting the whole list!\n\t\t */",
"/*\n\t * Now traverse the rest of the list\n\t */",
"/*\n\t\t\t * Put the brakes on hashi_FreeMembers(). . . .\n\t\t\t */"
] | [
{
"param": "hashtable",
"type": "hash_tbl"
},
{
"param": "hashcode",
"type": "unsigned"
},
{
"param": "compare",
"type": "hash_cmpfp"
},
{
"param": "key",
"type": "hash_datum"
},
{
"param": "free_data",
"type": "hash_freefp"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hashcode",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compare",
"type": "hash_cmpfp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "free_data",
"type": "hash_freefp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_Lookup | hash_datum | hash_datum *
hash_Lookup(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key)
{
hash_member *memberptr;
memberptr = (hashtable->table)[hashcode % (hashtable->size)];
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
return (memberptr->data);
}
memberptr = memberptr->next;
}
return NULL;
} | /*
* Locate and return the data entry associated with the given key.
*
* If the data entry is found, a pointer to it is returned. Otherwise,
* NULL is returned.
*/ | Locate and return the data entry associated with the given key.
If the data entry is found, a pointer to it is returned. Otherwise,
NULL is returned. | [
"Locate",
"and",
"return",
"the",
"data",
"entry",
"associated",
"with",
"the",
"given",
"key",
".",
"If",
"the",
"data",
"entry",
"is",
"found",
"a",
"pointer",
"to",
"it",
"is",
"returned",
".",
"Otherwise",
"NULL",
"is",
"returned",
"."
] | hash_datum *
hash_Lookup(hash_tbl *hashtable, unsigned hashcode, hash_cmpfp compare,
hash_datum *key)
{
hash_member *memberptr;
memberptr = (hashtable->table)[hashcode % (hashtable->size)];
while (memberptr) {
if ((*compare) (key, memberptr->data)) {
return (memberptr->data);
}
memberptr = memberptr->next;
}
return NULL;
} | [
"hash_datum",
"*",
"hash_Lookup",
"(",
"hash_tbl",
"*",
"hashtable",
",",
"unsigned",
"hashcode",
",",
"hash_cmpfp",
"compare",
",",
"hash_datum",
"*",
"key",
")",
"{",
"hash_member",
"*",
"memberptr",
";",
"memberptr",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"hashcode",
"%",
"(",
"hashtable",
"->",
"size",
")",
"]",
";",
"while",
"(",
"memberptr",
")",
"{",
"if",
"(",
"(",
"*",
"compare",
")",
"(",
"key",
",",
"memberptr",
"->",
"data",
")",
")",
"{",
"return",
"(",
"memberptr",
"->",
"data",
")",
";",
"}",
"memberptr",
"=",
"memberptr",
"->",
"next",
";",
"}",
"return",
"NULL",
";",
"}"
] | Locate and return the data entry associated with the given key. | [
"Locate",
"and",
"return",
"the",
"data",
"entry",
"associated",
"with",
"the",
"given",
"key",
"."
] | [] | [
{
"param": "hashtable",
"type": "hash_tbl"
},
{
"param": "hashcode",
"type": "unsigned"
},
{
"param": "compare",
"type": "hash_cmpfp"
},
{
"param": "key",
"type": "hash_datum"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hashcode",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "compare",
"type": "hash_cmpfp",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "hash_datum",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_NextEntry | hash_datum | hash_datum *
hash_NextEntry(hash_tbl *hashtable)
{
unsigned bucket;
hash_member *memberptr;
/*
* First try to pick up where we left off.
*/
memberptr = hashtable->member;
if (memberptr) {
hashtable->member = memberptr->next; /* Set up for next call */
return memberptr->data; /* Return the data */
}
/*
* We hit the end of a chain, so look through the array of buckets
* until we find a new chain (non-empty bucket) or run out of buckets.
*/
bucket = hashtable->bucketnum + 1;
while ((bucket < hashtable->size) &&
!(memberptr = (hashtable->table)[bucket])) {
bucket++;
}
/*
* Check to see if we ran out of buckets.
*/
if (bucket >= hashtable->size) {
/*
* Reset to top of table for next call.
*/
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
/*
* But return end-of-table indication to the caller this time.
*/
return NULL;
}
/*
* Must have found a non-empty bucket.
*/
hashtable->bucketnum = bucket;
hashtable->member = memberptr->next; /* Set up for next call */
return memberptr->data; /* Return the data */
} | /*
* Return the next available entry in the hashtable for a linear search
*/ | Return the next available entry in the hashtable for a linear search | [
"Return",
"the",
"next",
"available",
"entry",
"in",
"the",
"hashtable",
"for",
"a",
"linear",
"search"
] | hash_datum *
hash_NextEntry(hash_tbl *hashtable)
{
unsigned bucket;
hash_member *memberptr;
memberptr = hashtable->member;
if (memberptr) {
hashtable->member = memberptr->next;
return memberptr->data;
}
bucket = hashtable->bucketnum + 1;
while ((bucket < hashtable->size) &&
!(memberptr = (hashtable->table)[bucket])) {
bucket++;
}
if (bucket >= hashtable->size) {
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
return NULL;
}
hashtable->bucketnum = bucket;
hashtable->member = memberptr->next;
return memberptr->data;
} | [
"hash_datum",
"*",
"hash_NextEntry",
"(",
"hash_tbl",
"*",
"hashtable",
")",
"{",
"unsigned",
"bucket",
";",
"hash_member",
"*",
"memberptr",
";",
"memberptr",
"=",
"hashtable",
"->",
"member",
";",
"if",
"(",
"memberptr",
")",
"{",
"hashtable",
"->",
"member",
"=",
"memberptr",
"->",
"next",
";",
"return",
"memberptr",
"->",
"data",
";",
"}",
"bucket",
"=",
"hashtable",
"->",
"bucketnum",
"+",
"1",
";",
"while",
"(",
"(",
"bucket",
"<",
"hashtable",
"->",
"size",
")",
"&&",
"!",
"(",
"memberptr",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"bucket",
"]",
")",
")",
"{",
"bucket",
"++",
";",
"}",
"if",
"(",
"bucket",
">=",
"hashtable",
"->",
"size",
")",
"{",
"hashtable",
"->",
"bucketnum",
"=",
"0",
";",
"hashtable",
"->",
"member",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"0",
"]",
";",
"return",
"NULL",
";",
"}",
"hashtable",
"->",
"bucketnum",
"=",
"bucket",
";",
"hashtable",
"->",
"member",
"=",
"memberptr",
"->",
"next",
";",
"return",
"memberptr",
"->",
"data",
";",
"}"
] | Return the next available entry in the hashtable for a linear search | [
"Return",
"the",
"next",
"available",
"entry",
"in",
"the",
"hashtable",
"for",
"a",
"linear",
"search"
] | [
"/*\n\t * First try to pick up where we left off.\n\t */",
"/* Set up for next call */",
"/* Return the data */",
"/*\n\t * We hit the end of a chain, so look through the array of buckets\n\t * until we find a new chain (non-empty bucket) or run out of buckets.\n\t */",
"/*\n\t * Check to see if we ran out of buckets.\n\t */",
"/*\n\t\t * Reset to top of table for next call.\n\t\t */",
"/*\n\t\t * But return end-of-table indication to the caller this time.\n\t\t */",
"/*\n\t * Must have found a non-empty bucket.\n\t */",
"/* Set up for next call */",
"/* Return the data */"
] | [
{
"param": "hashtable",
"type": "hash_tbl"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f6495d12d3e97b733afff2cd0735945ef1d5680e | atrens/DragonFlyBSD-src | libexec/bootpd/hash.c | [
"BSD-3-Clause"
] | C | hash_FirstEntry | hash_datum | hash_datum *
hash_FirstEntry(hash_tbl *hashtable)
{
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
return hash_NextEntry(hashtable);
} | /*
* Return the first entry in a hash table for a linear search
*/ | Return the first entry in a hash table for a linear search | [
"Return",
"the",
"first",
"entry",
"in",
"a",
"hash",
"table",
"for",
"a",
"linear",
"search"
] | hash_datum *
hash_FirstEntry(hash_tbl *hashtable)
{
hashtable->bucketnum = 0;
hashtable->member = (hashtable->table)[0];
return hash_NextEntry(hashtable);
} | [
"hash_datum",
"*",
"hash_FirstEntry",
"(",
"hash_tbl",
"*",
"hashtable",
")",
"{",
"hashtable",
"->",
"bucketnum",
"=",
"0",
";",
"hashtable",
"->",
"member",
"=",
"(",
"hashtable",
"->",
"table",
")",
"[",
"0",
"]",
";",
"return",
"hash_NextEntry",
"(",
"hashtable",
")",
";",
"}"
] | Return the first entry in a hash table for a linear search | [
"Return",
"the",
"first",
"entry",
"in",
"a",
"hash",
"table",
"for",
"a",
"linear",
"search"
] | [] | [
{
"param": "hashtable",
"type": "hash_tbl"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hashtable",
"type": "hash_tbl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | new_agent_expr | null | struct agent_expr *
new_agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
{
struct agent_expr *x = xmalloc (sizeof (*x));
x->len = 0;
x->size = 1; /* Change this to a larger value once
reallocation code is tested. */
x->buf = xmalloc (x->size);
x->gdbarch = gdbarch;
x->scope = scope;
/* Bit vector for registers used. */
x->reg_mask_len = 1;
x->reg_mask = xmalloc (x->reg_mask_len * sizeof (x->reg_mask[0]));
memset (x->reg_mask, 0, x->reg_mask_len * sizeof (x->reg_mask[0]));
return x;
} | /* Allocate a new, empty agent expression. */ | Allocate a new, empty agent expression. | [
"Allocate",
"a",
"new",
"empty",
"agent",
"expression",
"."
] | struct agent_expr *
new_agent_expr (struct gdbarch *gdbarch, CORE_ADDR scope)
{
struct agent_expr *x = xmalloc (sizeof (*x));
x->len = 0;
x->size = 1;
x->buf = xmalloc (x->size);
x->gdbarch = gdbarch;
x->scope = scope;
x->reg_mask_len = 1;
x->reg_mask = xmalloc (x->reg_mask_len * sizeof (x->reg_mask[0]));
memset (x->reg_mask, 0, x->reg_mask_len * sizeof (x->reg_mask[0]));
return x;
} | [
"struct",
"agent_expr",
"*",
"new_agent_expr",
"(",
"struct",
"gdbarch",
"*",
"gdbarch",
",",
"CORE_ADDR",
"scope",
")",
"{",
"struct",
"agent_expr",
"*",
"x",
"=",
"xmalloc",
"(",
"sizeof",
"(",
"*",
"x",
")",
")",
";",
"x",
"->",
"len",
"=",
"0",
";",
"x",
"->",
"size",
"=",
"1",
";",
"x",
"->",
"buf",
"=",
"xmalloc",
"(",
"x",
"->",
"size",
")",
";",
"x",
"->",
"gdbarch",
"=",
"gdbarch",
";",
"x",
"->",
"scope",
"=",
"scope",
";",
"x",
"->",
"reg_mask_len",
"=",
"1",
";",
"x",
"->",
"reg_mask",
"=",
"xmalloc",
"(",
"x",
"->",
"reg_mask_len",
"*",
"sizeof",
"(",
"x",
"->",
"reg_mask",
"[",
"0",
"]",
")",
")",
";",
"memset",
"(",
"x",
"->",
"reg_mask",
",",
"0",
",",
"x",
"->",
"reg_mask_len",
"*",
"sizeof",
"(",
"x",
"->",
"reg_mask",
"[",
"0",
"]",
")",
")",
";",
"return",
"x",
";",
"}"
] | Allocate a new, empty agent expression. | [
"Allocate",
"a",
"new",
"empty",
"agent",
"expression",
"."
] | [
"/* Change this to a larger value once\n\t\t\t\t reallocation code is tested. */",
"/* Bit vector for registers used. */"
] | [
{
"param": "gdbarch",
"type": "struct gdbarch"
},
{
"param": "scope",
"type": "CORE_ADDR"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "gdbarch",
"type": "struct gdbarch",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scope",
"type": "CORE_ADDR",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | grow_expr | void | static void
grow_expr (struct agent_expr *x, int n)
{
if (x->len + n > x->size)
{
x->size *= 2;
if (x->size < x->len + n)
x->size = x->len + n + 10;
x->buf = xrealloc (x->buf, x->size);
}
} | /* Make sure that X has room for at least N more bytes. This doesn't
affect the length, just the allocated size. */ | Make sure that X has room for at least N more bytes. This doesn't
affect the length, just the allocated size. | [
"Make",
"sure",
"that",
"X",
"has",
"room",
"for",
"at",
"least",
"N",
"more",
"bytes",
".",
"This",
"doesn",
"'",
"t",
"affect",
"the",
"length",
"just",
"the",
"allocated",
"size",
"."
] | static void
grow_expr (struct agent_expr *x, int n)
{
if (x->len + n > x->size)
{
x->size *= 2;
if (x->size < x->len + n)
x->size = x->len + n + 10;
x->buf = xrealloc (x->buf, x->size);
}
} | [
"static",
"void",
"grow_expr",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"n",
")",
"{",
"if",
"(",
"x",
"->",
"len",
"+",
"n",
">",
"x",
"->",
"size",
")",
"{",
"x",
"->",
"size",
"*=",
"2",
";",
"if",
"(",
"x",
"->",
"size",
"<",
"x",
"->",
"len",
"+",
"n",
")",
"x",
"->",
"size",
"=",
"x",
"->",
"len",
"+",
"n",
"+",
"10",
";",
"x",
"->",
"buf",
"=",
"xrealloc",
"(",
"x",
"->",
"buf",
",",
"x",
"->",
"size",
")",
";",
"}",
"}"
] | Make sure that X has room for at least N more bytes. | [
"Make",
"sure",
"that",
"X",
"has",
"room",
"for",
"at",
"least",
"N",
"more",
"bytes",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | append_const | void | static void
append_const (struct agent_expr *x, LONGEST val, int n)
{
int i;
grow_expr (x, n);
for (i = n - 1; i >= 0; i--)
{
x->buf[x->len + i] = val & 0xff;
val >>= 8;
}
x->len += n;
} | /* Append the low N bytes of VAL as an N-byte integer to the
expression X, in big-endian order. */ | Append the low N bytes of VAL as an N-byte integer to the
expression X, in big-endian order. | [
"Append",
"the",
"low",
"N",
"bytes",
"of",
"VAL",
"as",
"an",
"N",
"-",
"byte",
"integer",
"to",
"the",
"expression",
"X",
"in",
"big",
"-",
"endian",
"order",
"."
] | static void
append_const (struct agent_expr *x, LONGEST val, int n)
{
int i;
grow_expr (x, n);
for (i = n - 1; i >= 0; i--)
{
x->buf[x->len + i] = val & 0xff;
val >>= 8;
}
x->len += n;
} | [
"static",
"void",
"append_const",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"LONGEST",
"val",
",",
"int",
"n",
")",
"{",
"int",
"i",
";",
"grow_expr",
"(",
"x",
",",
"n",
")",
";",
"for",
"(",
"i",
"=",
"n",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"i",
"]",
"=",
"val",
"&",
"0xff",
";",
"val",
">>=",
"8",
";",
"}",
"x",
"->",
"len",
"+=",
"n",
";",
"}"
] | Append the low N bytes of VAL as an N-byte integer to the
expression X, in big-endian order. | [
"Append",
"the",
"low",
"N",
"bytes",
"of",
"VAL",
"as",
"an",
"N",
"-",
"byte",
"integer",
"to",
"the",
"expression",
"X",
"in",
"big",
"-",
"endian",
"order",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "val",
"type": "LONGEST"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "val",
"type": "LONGEST",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | read_const | LONGEST | static LONGEST
read_const (struct agent_expr *x, int o, int n)
{
int i;
LONGEST accum = 0;
/* Make sure we're not reading off the end of the expression. */
if (o + n > x->len)
error (_("GDB bug: ax-general.c (read_const): incomplete constant"));
for (i = 0; i < n; i++)
accum = (accum << 8) | x->buf[o + i];
return accum;
} | /* Extract an N-byte big-endian unsigned integer from expression X at
offset O. */ | Extract an N-byte big-endian unsigned integer from expression X at
offset O. | [
"Extract",
"an",
"N",
"-",
"byte",
"big",
"-",
"endian",
"unsigned",
"integer",
"from",
"expression",
"X",
"at",
"offset",
"O",
"."
] | static LONGEST
read_const (struct agent_expr *x, int o, int n)
{
int i;
LONGEST accum = 0;
if (o + n > x->len)
error (_("GDB bug: ax-general.c (read_const): incomplete constant"));
for (i = 0; i < n; i++)
accum = (accum << 8) | x->buf[o + i];
return accum;
} | [
"static",
"LONGEST",
"read_const",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"o",
",",
"int",
"n",
")",
"{",
"int",
"i",
";",
"LONGEST",
"accum",
"=",
"0",
";",
"if",
"(",
"o",
"+",
"n",
">",
"x",
"->",
"len",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"accum",
"=",
"(",
"accum",
"<<",
"8",
")",
"|",
"x",
"->",
"buf",
"[",
"o",
"+",
"i",
"]",
";",
"return",
"accum",
";",
"}"
] | Extract an N-byte big-endian unsigned integer from expression X at
offset O. | [
"Extract",
"an",
"N",
"-",
"byte",
"big",
"-",
"endian",
"unsigned",
"integer",
"from",
"expression",
"X",
"at",
"offset",
"O",
"."
] | [
"/* Make sure we're not reading off the end of the expression. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "o",
"type": "int"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "o",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_simple | void | void
ax_simple (struct agent_expr *x, enum agent_op op)
{
grow_expr (x, 1);
x->buf[x->len++] = op;
} | /* Append a simple operator OP to EXPR. */ | Append a simple operator OP to EXPR. | [
"Append",
"a",
"simple",
"operator",
"OP",
"to",
"EXPR",
"."
] | void
ax_simple (struct agent_expr *x, enum agent_op op)
{
grow_expr (x, 1);
x->buf[x->len++] = op;
} | [
"void",
"ax_simple",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"enum",
"agent_op",
"op",
")",
"{",
"grow_expr",
"(",
"x",
",",
"1",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"op",
";",
"}"
] | Append a simple operator OP to EXPR. | [
"Append",
"a",
"simple",
"operator",
"OP",
"to",
"EXPR",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "op",
"type": "enum agent_op"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "enum agent_op",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_pick | void | void
ax_pick (struct agent_expr *x, int depth)
{
if (depth < 0 || depth > 255)
error (_("GDB bug: ax-general.c (ax_pick): stack depth out of range"));
ax_simple (x, aop_pick);
append_const (x, 1, depth);
} | /* Append a pick operator to EXPR. DEPTH is the stack item to pick,
with 0 being top of stack. */ | Append a pick operator to EXPR. DEPTH is the stack item to pick,
with 0 being top of stack. | [
"Append",
"a",
"pick",
"operator",
"to",
"EXPR",
".",
"DEPTH",
"is",
"the",
"stack",
"item",
"to",
"pick",
"with",
"0",
"being",
"top",
"of",
"stack",
"."
] | void
ax_pick (struct agent_expr *x, int depth)
{
if (depth < 0 || depth > 255)
error (_("GDB bug: ax-general.c (ax_pick): stack depth out of range"));
ax_simple (x, aop_pick);
append_const (x, 1, depth);
} | [
"void",
"ax_pick",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"depth",
"<",
"0",
"||",
"depth",
">",
"255",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"ax_simple",
"(",
"x",
",",
"aop_pick",
")",
";",
"append_const",
"(",
"x",
",",
"1",
",",
"depth",
")",
";",
"}"
] | Append a pick operator to EXPR. | [
"Append",
"a",
"pick",
"operator",
"to",
"EXPR",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "depth",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "depth",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | generic_ext | void | static void
generic_ext (struct agent_expr *x, enum agent_op op, int n)
{
/* N must fit in a byte. */
if (n < 0 || n > 255)
error (_("GDB bug: ax-general.c (generic_ext): bit count out of range"));
/* That had better be enough range. */
if (sizeof (LONGEST) * 8 > 255)
error (_("GDB bug: ax-general.c (generic_ext): "
"opcode has inadequate range"));
grow_expr (x, 2);
x->buf[x->len++] = op;
x->buf[x->len++] = n;
} | /* Append a sign-extension or zero-extension instruction to EXPR, to
extend an N-bit value. */ | Append a sign-extension or zero-extension instruction to EXPR, to
extend an N-bit value. | [
"Append",
"a",
"sign",
"-",
"extension",
"or",
"zero",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | static void
generic_ext (struct agent_expr *x, enum agent_op op, int n)
{
if (n < 0 || n > 255)
error (_("GDB bug: ax-general.c (generic_ext): bit count out of range"));
if (sizeof (LONGEST) * 8 > 255)
error (_("GDB bug: ax-general.c (generic_ext): "
"opcode has inadequate range"));
grow_expr (x, 2);
x->buf[x->len++] = op;
x->buf[x->len++] = n;
} | [
"static",
"void",
"generic_ext",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"enum",
"agent_op",
"op",
",",
"int",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
"||",
"n",
">",
"255",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"if",
"(",
"sizeof",
"(",
"LONGEST",
")",
"*",
"8",
">",
"255",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
")",
";",
"grow_expr",
"(",
"x",
",",
"2",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"op",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"n",
";",
"}"
] | Append a sign-extension or zero-extension instruction to EXPR, to
extend an N-bit value. | [
"Append",
"a",
"sign",
"-",
"extension",
"or",
"zero",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | [
"/* N must fit in a byte. */",
"/* That had better be enough range. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "op",
"type": "enum agent_op"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "enum agent_op",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_ext | void | void
ax_ext (struct agent_expr *x, int n)
{
generic_ext (x, aop_ext, n);
} | /* Append a sign-extension instruction to EXPR, to extend an N-bit value. */ | Append a sign-extension instruction to EXPR, to extend an N-bit value. | [
"Append",
"a",
"sign",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | void
ax_ext (struct agent_expr *x, int n)
{
generic_ext (x, aop_ext, n);
} | [
"void",
"ax_ext",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"n",
")",
"{",
"generic_ext",
"(",
"x",
",",
"aop_ext",
",",
"n",
")",
";",
"}"
] | Append a sign-extension instruction to EXPR, to extend an N-bit value. | [
"Append",
"a",
"sign",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_zero_ext | void | void
ax_zero_ext (struct agent_expr *x, int n)
{
generic_ext (x, aop_zero_ext, n);
} | /* Append a zero-extension instruction to EXPR, to extend an N-bit value. */ | Append a zero-extension instruction to EXPR, to extend an N-bit value. | [
"Append",
"a",
"zero",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | void
ax_zero_ext (struct agent_expr *x, int n)
{
generic_ext (x, aop_zero_ext, n);
} | [
"void",
"ax_zero_ext",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"n",
")",
"{",
"generic_ext",
"(",
"x",
",",
"aop_zero_ext",
",",
"n",
")",
";",
"}"
] | Append a zero-extension instruction to EXPR, to extend an N-bit value. | [
"Append",
"a",
"zero",
"-",
"extension",
"instruction",
"to",
"EXPR",
"to",
"extend",
"an",
"N",
"-",
"bit",
"value",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_trace_quick | void | void
ax_trace_quick (struct agent_expr *x, int n)
{
/* N must fit in a byte. */
if (n < 0 || n > 255)
error (_("GDB bug: ax-general.c (ax_trace_quick): "
"size out of range for trace_quick"));
grow_expr (x, 2);
x->buf[x->len++] = aop_trace_quick;
x->buf[x->len++] = n;
} | /* Append a trace_quick instruction to EXPR, to record N bytes. */ | Append a trace_quick instruction to EXPR, to record N bytes. | [
"Append",
"a",
"trace_quick",
"instruction",
"to",
"EXPR",
"to",
"record",
"N",
"bytes",
"."
] | void
ax_trace_quick (struct agent_expr *x, int n)
{
if (n < 0 || n > 255)
error (_("GDB bug: ax-general.c (ax_trace_quick): "
"size out of range for trace_quick"));
grow_expr (x, 2);
x->buf[x->len++] = aop_trace_quick;
x->buf[x->len++] = n;
} | [
"void",
"ax_trace_quick",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
"||",
"n",
">",
"255",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
")",
";",
"grow_expr",
"(",
"x",
",",
"2",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"aop_trace_quick",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"n",
";",
"}"
] | Append a trace_quick instruction to EXPR, to record N bytes. | [
"Append",
"a",
"trace_quick",
"instruction",
"to",
"EXPR",
"to",
"record",
"N",
"bytes",
"."
] | [
"/* N must fit in a byte. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "n",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_goto | int | int
ax_goto (struct agent_expr *x, enum agent_op op)
{
grow_expr (x, 3);
x->buf[x->len + 0] = op;
x->buf[x->len + 1] = 0xff;
x->buf[x->len + 2] = 0xff;
x->len += 3;
return x->len - 2;
} | /* Append a goto op to EXPR. OP is the actual op (must be aop_goto or
aop_if_goto). We assume we don't know the target offset yet,
because it's probably a forward branch, so we leave space in EXPR
for the target, and return the offset in EXPR of that space, so we
can backpatch it once we do know the target offset. Use ax_label
to do the backpatching. */ | Append a goto op to EXPR. OP is the actual op (must be aop_goto or
aop_if_goto). We assume we don't know the target offset yet,
because it's probably a forward branch, so we leave space in EXPR
for the target, and return the offset in EXPR of that space, so we
can backpatch it once we do know the target offset. Use ax_label
to do the backpatching. | [
"Append",
"a",
"goto",
"op",
"to",
"EXPR",
".",
"OP",
"is",
"the",
"actual",
"op",
"(",
"must",
"be",
"aop_goto",
"or",
"aop_if_goto",
")",
".",
"We",
"assume",
"we",
"don",
"'",
"t",
"know",
"the",
"target",
"offset",
"yet",
"because",
"it",
"'",
"s",
"probably",
"a",
"forward",
"branch",
"so",
"we",
"leave",
"space",
"in",
"EXPR",
"for",
"the",
"target",
"and",
"return",
"the",
"offset",
"in",
"EXPR",
"of",
"that",
"space",
"so",
"we",
"can",
"backpatch",
"it",
"once",
"we",
"do",
"know",
"the",
"target",
"offset",
".",
"Use",
"ax_label",
"to",
"do",
"the",
"backpatching",
"."
] | int
ax_goto (struct agent_expr *x, enum agent_op op)
{
grow_expr (x, 3);
x->buf[x->len + 0] = op;
x->buf[x->len + 1] = 0xff;
x->buf[x->len + 2] = 0xff;
x->len += 3;
return x->len - 2;
} | [
"int",
"ax_goto",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"enum",
"agent_op",
"op",
")",
"{",
"grow_expr",
"(",
"x",
",",
"3",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"0",
"]",
"=",
"op",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"1",
"]",
"=",
"0xff",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"2",
"]",
"=",
"0xff",
";",
"x",
"->",
"len",
"+=",
"3",
";",
"return",
"x",
"->",
"len",
"-",
"2",
";",
"}"
] | Append a goto op to EXPR. | [
"Append",
"a",
"goto",
"op",
"to",
"EXPR",
"."
] | [] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "op",
"type": "enum agent_op"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "enum agent_op",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_label | void | void
ax_label (struct agent_expr *x, int patch, int target)
{
/* Make sure the value is in range. Don't accept 0xffff as an
offset; that's our magic sentinel value for unpatched branches. */
if (target < 0 || target >= 0xffff)
error (_("GDB bug: ax-general.c (ax_label): label target out of range"));
x->buf[patch] = (target >> 8) & 0xff;
x->buf[patch + 1] = target & 0xff;
} | /* Suppose a given call to ax_goto returns some value PATCH. When you
know the offset TARGET that goto should jump to, call
ax_label (EXPR, PATCH, TARGET)
to patch TARGET into the ax_goto instruction. */ | Suppose a given call to ax_goto returns some value PATCH. When you
know the offset TARGET that goto should jump to, call
ax_label (EXPR, PATCH, TARGET)
to patch TARGET into the ax_goto instruction. | [
"Suppose",
"a",
"given",
"call",
"to",
"ax_goto",
"returns",
"some",
"value",
"PATCH",
".",
"When",
"you",
"know",
"the",
"offset",
"TARGET",
"that",
"goto",
"should",
"jump",
"to",
"call",
"ax_label",
"(",
"EXPR",
"PATCH",
"TARGET",
")",
"to",
"patch",
"TARGET",
"into",
"the",
"ax_goto",
"instruction",
"."
] | void
ax_label (struct agent_expr *x, int patch, int target)
{
if (target < 0 || target >= 0xffff)
error (_("GDB bug: ax-general.c (ax_label): label target out of range"));
x->buf[patch] = (target >> 8) & 0xff;
x->buf[patch + 1] = target & 0xff;
} | [
"void",
"ax_label",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"patch",
",",
"int",
"target",
")",
"{",
"if",
"(",
"target",
"<",
"0",
"||",
"target",
">=",
"0xffff",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"x",
"->",
"buf",
"[",
"patch",
"]",
"=",
"(",
"target",
">>",
"8",
")",
"&",
"0xff",
";",
"x",
"->",
"buf",
"[",
"patch",
"+",
"1",
"]",
"=",
"target",
"&",
"0xff",
";",
"}"
] | Suppose a given call to ax_goto returns some value PATCH. | [
"Suppose",
"a",
"given",
"call",
"to",
"ax_goto",
"returns",
"some",
"value",
"PATCH",
"."
] | [
"/* Make sure the value is in range. Don't accept 0xffff as an\n offset; that's our magic sentinel value for unpatched branches. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "patch",
"type": "int"
},
{
"param": "target",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "patch",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_const_l | void | void
ax_const_l (struct agent_expr *x, LONGEST l)
{
static enum agent_op ops[]
=
{aop_const8, aop_const16, aop_const32, aop_const64};
int size;
int op;
/* How big is the number? 'op' keeps track of which opcode to use.
Notice that we don't really care whether the original number was
signed or unsigned; we always reproduce the value exactly, and
use the shortest representation. */
for (op = 0, size = 8; size < 64; size *= 2, op++)
{
LONGEST lim = ((LONGEST) 1) << (size - 1);
if (-lim <= l && l <= lim - 1)
break;
}
/* Emit the right opcode... */
ax_simple (x, ops[op]);
/* Emit the low SIZE bytes as an unsigned number. We know that
sign-extending this will yield l. */
append_const (x, l, size / 8);
/* Now, if it was negative, and not full-sized, sign-extend it. */
if (l < 0 && size < 64)
ax_ext (x, size);
} | /* Assemble code to push a constant on the stack. */ | Assemble code to push a constant on the stack. | [
"Assemble",
"code",
"to",
"push",
"a",
"constant",
"on",
"the",
"stack",
"."
] | void
ax_const_l (struct agent_expr *x, LONGEST l)
{
static enum agent_op ops[]
=
{aop_const8, aop_const16, aop_const32, aop_const64};
int size;
int op;
for (op = 0, size = 8; size < 64; size *= 2, op++)
{
LONGEST lim = ((LONGEST) 1) << (size - 1);
if (-lim <= l && l <= lim - 1)
break;
}
ax_simple (x, ops[op]);
append_const (x, l, size / 8);
if (l < 0 && size < 64)
ax_ext (x, size);
} | [
"void",
"ax_const_l",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"LONGEST",
"l",
")",
"{",
"static",
"enum",
"agent_op",
"ops",
"[",
"]",
"=",
"{",
"aop_const8",
",",
"aop_const16",
",",
"aop_const32",
",",
"aop_const64",
"}",
";",
"int",
"size",
";",
"int",
"op",
";",
"for",
"(",
"op",
"=",
"0",
",",
"size",
"=",
"8",
";",
"size",
"<",
"64",
";",
"size",
"*=",
"2",
",",
"op",
"++",
")",
"{",
"LONGEST",
"lim",
"=",
"(",
"(",
"LONGEST",
")",
"1",
")",
"<<",
"(",
"size",
"-",
"1",
")",
";",
"if",
"(",
"-",
"lim",
"<=",
"l",
"&&",
"l",
"<=",
"lim",
"-",
"1",
")",
"break",
";",
"}",
"ax_simple",
"(",
"x",
",",
"ops",
"[",
"op",
"]",
")",
";",
"append_const",
"(",
"x",
",",
"l",
",",
"size",
"/",
"8",
")",
";",
"if",
"(",
"l",
"<",
"0",
"&&",
"size",
"<",
"64",
")",
"ax_ext",
"(",
"x",
",",
"size",
")",
";",
"}"
] | Assemble code to push a constant on the stack. | [
"Assemble",
"code",
"to",
"push",
"a",
"constant",
"on",
"the",
"stack",
"."
] | [
"/* How big is the number? 'op' keeps track of which opcode to use.\n Notice that we don't really care whether the original number was\n signed or unsigned; we always reproduce the value exactly, and\n use the shortest representation. */",
"/* Emit the right opcode... */",
"/* Emit the low SIZE bytes as an unsigned number. We know that\n sign-extending this will yield l. */",
"/* Now, if it was negative, and not full-sized, sign-extend it. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "l",
"type": "LONGEST"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "l",
"type": "LONGEST",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_reg | void | void
ax_reg (struct agent_expr *x, int reg)
{
if (reg >= gdbarch_num_regs (x->gdbarch))
{
/* This is a pseudo-register. */
if (!gdbarch_ax_pseudo_register_push_stack_p (x->gdbarch))
error (_("'%s' is a pseudo-register; "
"GDB cannot yet trace its contents."),
user_reg_map_regnum_to_name (x->gdbarch, reg));
if (gdbarch_ax_pseudo_register_push_stack (x->gdbarch, x, reg))
error (_("Trace '%s' failed."),
user_reg_map_regnum_to_name (x->gdbarch, reg));
}
else
{
/* Make sure the register number is in range. */
if (reg < 0 || reg > 0xffff)
error (_("GDB bug: ax-general.c (ax_reg): "
"register number out of range"));
grow_expr (x, 3);
x->buf[x->len] = aop_reg;
x->buf[x->len + 1] = (reg >> 8) & 0xff;
x->buf[x->len + 2] = (reg) & 0xff;
x->len += 3;
}
} | /* Assemble code to push the value of register number REG on the
stack. */ | Assemble code to push the value of register number REG on the
stack. | [
"Assemble",
"code",
"to",
"push",
"the",
"value",
"of",
"register",
"number",
"REG",
"on",
"the",
"stack",
"."
] | void
ax_reg (struct agent_expr *x, int reg)
{
if (reg >= gdbarch_num_regs (x->gdbarch))
{
if (!gdbarch_ax_pseudo_register_push_stack_p (x->gdbarch))
error (_("'%s' is a pseudo-register; "
"GDB cannot yet trace its contents."),
user_reg_map_regnum_to_name (x->gdbarch, reg));
if (gdbarch_ax_pseudo_register_push_stack (x->gdbarch, x, reg))
error (_("Trace '%s' failed."),
user_reg_map_regnum_to_name (x->gdbarch, reg));
}
else
{
if (reg < 0 || reg > 0xffff)
error (_("GDB bug: ax-general.c (ax_reg): "
"register number out of range"));
grow_expr (x, 3);
x->buf[x->len] = aop_reg;
x->buf[x->len + 1] = (reg >> 8) & 0xff;
x->buf[x->len + 2] = (reg) & 0xff;
x->len += 3;
}
} | [
"void",
"ax_reg",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"int",
"reg",
")",
"{",
"if",
"(",
"reg",
">=",
"gdbarch_num_regs",
"(",
"x",
"->",
"gdbarch",
")",
")",
"{",
"if",
"(",
"!",
"gdbarch_ax_pseudo_register_push_stack_p",
"(",
"x",
"->",
"gdbarch",
")",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"user_reg_map_regnum_to_name",
"(",
"x",
"->",
"gdbarch",
",",
"reg",
")",
")",
";",
"if",
"(",
"gdbarch_ax_pseudo_register_push_stack",
"(",
"x",
"->",
"gdbarch",
",",
"x",
",",
"reg",
")",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
",",
"user_reg_map_regnum_to_name",
"(",
"x",
"->",
"gdbarch",
",",
"reg",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"reg",
"<",
"0",
"||",
"reg",
">",
"0xffff",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
")",
";",
"grow_expr",
"(",
"x",
",",
"3",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"]",
"=",
"aop_reg",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"1",
"]",
"=",
"(",
"reg",
">>",
"8",
")",
"&",
"0xff",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"2",
"]",
"=",
"(",
"reg",
")",
"&",
"0xff",
";",
"x",
"->",
"len",
"+=",
"3",
";",
"}",
"}"
] | Assemble code to push the value of register number REG on the
stack. | [
"Assemble",
"code",
"to",
"push",
"the",
"value",
"of",
"register",
"number",
"REG",
"on",
"the",
"stack",
"."
] | [
"/* This is a pseudo-register. */",
"/* Make sure the register number is in range. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "reg",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_tsv | void | void
ax_tsv (struct agent_expr *x, enum agent_op op, int num)
{
/* Make sure the tsv number is in range. */
if (num < 0 || num > 0xffff)
internal_error (__FILE__, __LINE__,
_("ax-general.c (ax_tsv): variable "
"number is %d, out of range"), num);
grow_expr (x, 3);
x->buf[x->len] = op;
x->buf[x->len + 1] = (num >> 8) & 0xff;
x->buf[x->len + 2] = (num) & 0xff;
x->len += 3;
} | /* Assemble code to operate on a trace state variable. */ | Assemble code to operate on a trace state variable. | [
"Assemble",
"code",
"to",
"operate",
"on",
"a",
"trace",
"state",
"variable",
"."
] | void
ax_tsv (struct agent_expr *x, enum agent_op op, int num)
{
if (num < 0 || num > 0xffff)
internal_error (__FILE__, __LINE__,
_("ax-general.c (ax_tsv): variable "
"number is %d, out of range"), num);
grow_expr (x, 3);
x->buf[x->len] = op;
x->buf[x->len + 1] = (num >> 8) & 0xff;
x->buf[x->len + 2] = (num) & 0xff;
x->len += 3;
} | [
"void",
"ax_tsv",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"enum",
"agent_op",
"op",
",",
"int",
"num",
")",
"{",
"if",
"(",
"num",
"<",
"0",
"||",
"num",
">",
"0xffff",
")",
"internal_error",
"(",
"__FILE__",
",",
"__LINE__",
",",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"num",
")",
";",
"grow_expr",
"(",
"x",
",",
"3",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"]",
"=",
"op",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"1",
"]",
"=",
"(",
"num",
">>",
"8",
")",
"&",
"0xff",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"+",
"2",
"]",
"=",
"(",
"num",
")",
"&",
"0xff",
";",
"x",
"->",
"len",
"+=",
"3",
";",
"}"
] | Assemble code to operate on a trace state variable. | [
"Assemble",
"code",
"to",
"operate",
"on",
"a",
"trace",
"state",
"variable",
"."
] | [
"/* Make sure the tsv number is in range. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "op",
"type": "enum agent_op"
},
{
"param": "num",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op",
"type": "enum agent_op",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_string | void | void
ax_string (struct agent_expr *x, const char *str, int slen)
{
int i;
/* Make sure the string length is reasonable. */
if (slen < 0 || slen > 0xffff)
internal_error (__FILE__, __LINE__,
_("ax-general.c (ax_string): string "
"length is %d, out of allowed range"), slen);
grow_expr (x, 2 + slen + 1);
x->buf[x->len++] = ((slen + 1) >> 8) & 0xff;
x->buf[x->len++] = (slen + 1) & 0xff;
for (i = 0; i < slen; ++i)
x->buf[x->len++] = str[i];
x->buf[x->len++] = '\0';
} | /* Append a string to the expression. Note that the string is going
into the bytecodes directly, not on the stack. As a precaution,
include both length as prefix, and terminate with a NUL. (The NUL
is counted in the length.) */ | Append a string to the expression. Note that the string is going
into the bytecodes directly, not on the stack. As a precaution,
include both length as prefix, and terminate with a NUL. (The NUL
is counted in the length.) | [
"Append",
"a",
"string",
"to",
"the",
"expression",
".",
"Note",
"that",
"the",
"string",
"is",
"going",
"into",
"the",
"bytecodes",
"directly",
"not",
"on",
"the",
"stack",
".",
"As",
"a",
"precaution",
"include",
"both",
"length",
"as",
"prefix",
"and",
"terminate",
"with",
"a",
"NUL",
".",
"(",
"The",
"NUL",
"is",
"counted",
"in",
"the",
"length",
".",
")"
] | void
ax_string (struct agent_expr *x, const char *str, int slen)
{
int i;
if (slen < 0 || slen > 0xffff)
internal_error (__FILE__, __LINE__,
_("ax-general.c (ax_string): string "
"length is %d, out of allowed range"), slen);
grow_expr (x, 2 + slen + 1);
x->buf[x->len++] = ((slen + 1) >> 8) & 0xff;
x->buf[x->len++] = (slen + 1) & 0xff;
for (i = 0; i < slen; ++i)
x->buf[x->len++] = str[i];
x->buf[x->len++] = '\0';
} | [
"void",
"ax_string",
"(",
"struct",
"agent_expr",
"*",
"x",
",",
"const",
"char",
"*",
"str",
",",
"int",
"slen",
")",
"{",
"int",
"i",
";",
"if",
"(",
"slen",
"<",
"0",
"||",
"slen",
">",
"0xffff",
")",
"internal_error",
"(",
"__FILE__",
",",
"__LINE__",
",",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"slen",
")",
";",
"grow_expr",
"(",
"x",
",",
"2",
"+",
"slen",
"+",
"1",
")",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"(",
"(",
"slen",
"+",
"1",
")",
">>",
"8",
")",
"&",
"0xff",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"(",
"slen",
"+",
"1",
")",
"&",
"0xff",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"slen",
";",
"++",
"i",
")",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"str",
"[",
"i",
"]",
";",
"x",
"->",
"buf",
"[",
"x",
"->",
"len",
"++",
"]",
"=",
"'",
"\\0",
"'",
";",
"}"
] | Append a string to the expression. | [
"Append",
"a",
"string",
"to",
"the",
"expression",
"."
] | [
"/* Make sure the string length is reasonable. */"
] | [
{
"param": "x",
"type": "struct agent_expr"
},
{
"param": "str",
"type": "char"
},
{
"param": "slen",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "str",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slen",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_print | void | void
ax_print (struct ui_file *f, struct agent_expr *x)
{
int i;
fprintf_filtered (f, _("Scope: %s\n"), paddress (x->gdbarch, x->scope));
fprintf_filtered (f, _("Reg mask:"));
for (i = 0; i < x->reg_mask_len; ++i)
fprintf_filtered (f, _(" %02x"), x->reg_mask[i]);
fprintf_filtered (f, _("\n"));
/* Check the size of the name array against the number of entries in
the enum, to catch additions that people didn't sync. */
if ((sizeof (aop_map) / sizeof (aop_map[0]))
!= aop_last)
error (_("GDB bug: ax-general.c (ax_print): opcode map out of sync"));
for (i = 0; i < x->len;)
{
enum agent_op op = x->buf[i];
if (op >= (sizeof (aop_map) / sizeof (aop_map[0]))
|| !aop_map[op].name)
{
fprintf_filtered (f, _("%3d <bad opcode %02x>\n"), i, op);
i++;
continue;
}
if (i + 1 + aop_map[op].op_size > x->len)
{
fprintf_filtered (f, _("%3d <incomplete opcode %s>\n"),
i, aop_map[op].name);
break;
}
fprintf_filtered (f, "%3d %s", i, aop_map[op].name);
if (aop_map[op].op_size > 0)
{
fputs_filtered (" ", f);
print_longest (f, 'd', 0,
read_const (x, i + 1, aop_map[op].op_size));
}
/* Handle the complicated printf arguments specially. */
else if (op == aop_printf)
{
int slen, nargs;
i++;
nargs = x->buf[i++];
slen = x->buf[i++];
slen = slen * 256 + x->buf[i++];
fprintf_filtered (f, _(" \"%s\", %d args"),
&(x->buf[i]), nargs);
i += slen - 1;
}
fprintf_filtered (f, "\n");
i += 1 + aop_map[op].op_size;
}
} | /* Disassemble the expression EXPR, writing to F. */ | Disassemble the expression EXPR, writing to F. | [
"Disassemble",
"the",
"expression",
"EXPR",
"writing",
"to",
"F",
"."
] | void
ax_print (struct ui_file *f, struct agent_expr *x)
{
int i;
fprintf_filtered (f, _("Scope: %s\n"), paddress (x->gdbarch, x->scope));
fprintf_filtered (f, _("Reg mask:"));
for (i = 0; i < x->reg_mask_len; ++i)
fprintf_filtered (f, _(" %02x"), x->reg_mask[i]);
fprintf_filtered (f, _("\n"));
if ((sizeof (aop_map) / sizeof (aop_map[0]))
!= aop_last)
error (_("GDB bug: ax-general.c (ax_print): opcode map out of sync"));
for (i = 0; i < x->len;)
{
enum agent_op op = x->buf[i];
if (op >= (sizeof (aop_map) / sizeof (aop_map[0]))
|| !aop_map[op].name)
{
fprintf_filtered (f, _("%3d <bad opcode %02x>\n"), i, op);
i++;
continue;
}
if (i + 1 + aop_map[op].op_size > x->len)
{
fprintf_filtered (f, _("%3d <incomplete opcode %s>\n"),
i, aop_map[op].name);
break;
}
fprintf_filtered (f, "%3d %s", i, aop_map[op].name);
if (aop_map[op].op_size > 0)
{
fputs_filtered (" ", f);
print_longest (f, 'd', 0,
read_const (x, i + 1, aop_map[op].op_size));
}
else if (op == aop_printf)
{
int slen, nargs;
i++;
nargs = x->buf[i++];
slen = x->buf[i++];
slen = slen * 256 + x->buf[i++];
fprintf_filtered (f, _(" \"%s\", %d args"),
&(x->buf[i]), nargs);
i += slen - 1;
}
fprintf_filtered (f, "\n");
i += 1 + aop_map[op].op_size;
}
} | [
"void",
"ax_print",
"(",
"struct",
"ui_file",
"*",
"f",
",",
"struct",
"agent_expr",
"*",
"x",
")",
"{",
"int",
"i",
";",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"paddress",
"(",
"x",
"->",
"gdbarch",
",",
"x",
"->",
"scope",
")",
")",
";",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"x",
"->",
"reg_mask_len",
";",
"++",
"i",
")",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\"",
")",
",",
"x",
"->",
"reg_mask",
"[",
"i",
"]",
")",
";",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"if",
"(",
"(",
"sizeof",
"(",
"aop_map",
")",
"/",
"sizeof",
"(",
"aop_map",
"[",
"0",
"]",
")",
")",
"!=",
"aop_last",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"x",
"->",
"len",
";",
")",
"{",
"enum",
"agent_op",
"op",
"=",
"x",
"->",
"buf",
"[",
"i",
"]",
";",
"if",
"(",
"op",
">=",
"(",
"sizeof",
"(",
"aop_map",
")",
"/",
"sizeof",
"(",
"aop_map",
"[",
"0",
"]",
")",
")",
"||",
"!",
"aop_map",
"[",
"op",
"]",
".",
"name",
")",
"{",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"i",
",",
"op",
")",
";",
"i",
"++",
";",
"continue",
";",
"}",
"if",
"(",
"i",
"+",
"1",
"+",
"aop_map",
"[",
"op",
"]",
".",
"op_size",
">",
"x",
"->",
"len",
")",
"{",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"i",
",",
"aop_map",
"[",
"op",
"]",
".",
"name",
")",
";",
"break",
";",
"}",
"fprintf_filtered",
"(",
"f",
",",
"\"",
"\"",
",",
"i",
",",
"aop_map",
"[",
"op",
"]",
".",
"name",
")",
";",
"if",
"(",
"aop_map",
"[",
"op",
"]",
".",
"op_size",
">",
"0",
")",
"{",
"fputs_filtered",
"(",
"\"",
"\"",
",",
"f",
")",
";",
"print_longest",
"(",
"f",
",",
"'",
"'",
",",
"0",
",",
"read_const",
"(",
"x",
",",
"i",
"+",
"1",
",",
"aop_map",
"[",
"op",
"]",
".",
"op_size",
")",
")",
";",
"}",
"else",
"if",
"(",
"op",
"==",
"aop_printf",
")",
"{",
"int",
"slen",
",",
"nargs",
";",
"i",
"++",
";",
"nargs",
"=",
"x",
"->",
"buf",
"[",
"i",
"++",
"]",
";",
"slen",
"=",
"x",
"->",
"buf",
"[",
"i",
"++",
"]",
";",
"slen",
"=",
"slen",
"*",
"256",
"+",
"x",
"->",
"buf",
"[",
"i",
"++",
"]",
";",
"fprintf_filtered",
"(",
"f",
",",
"_",
"(",
"\"",
"\\\"",
"\\\"",
"\"",
")",
",",
"&",
"(",
"x",
"->",
"buf",
"[",
"i",
"]",
")",
",",
"nargs",
")",
";",
"i",
"+=",
"slen",
"-",
"1",
";",
"}",
"fprintf_filtered",
"(",
"f",
",",
"\"",
"\\n",
"\"",
")",
";",
"i",
"+=",
"1",
"+",
"aop_map",
"[",
"op",
"]",
".",
"op_size",
";",
"}",
"}"
] | Disassemble the expression EXPR, writing to F. | [
"Disassemble",
"the",
"expression",
"EXPR",
"writing",
"to",
"F",
"."
] | [
"/* Check the size of the name array against the number of entries in\n the enum, to catch additions that people didn't sync. */",
"/* Handle the complicated printf arguments specially. */"
] | [
{
"param": "f",
"type": "struct ui_file"
},
{
"param": "x",
"type": "struct agent_expr"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": "struct ui_file",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_reg_mask | void | void
ax_reg_mask (struct agent_expr *ax, int reg)
{
if (reg >= gdbarch_num_regs (ax->gdbarch))
{
/* This is a pseudo-register. */
if (!gdbarch_ax_pseudo_register_collect_p (ax->gdbarch))
error (_("'%s' is a pseudo-register; "
"GDB cannot yet trace its contents."),
user_reg_map_regnum_to_name (ax->gdbarch, reg));
if (gdbarch_ax_pseudo_register_collect (ax->gdbarch, ax, reg))
error (_("Trace '%s' failed."),
user_reg_map_regnum_to_name (ax->gdbarch, reg));
}
else
{
int byte = reg / 8;
/* Grow the bit mask if necessary. */
if (byte >= ax->reg_mask_len)
{
/* It's not appropriate to double here. This isn't a
string buffer. */
int new_len = byte + 1;
unsigned char *new_reg_mask = xrealloc (ax->reg_mask,
new_len
* sizeof (ax->reg_mask[0]));
memset (new_reg_mask + ax->reg_mask_len, 0,
(new_len - ax->reg_mask_len) * sizeof (ax->reg_mask[0]));
ax->reg_mask_len = new_len;
ax->reg_mask = new_reg_mask;
}
ax->reg_mask[byte] |= 1 << (reg % 8);
}
} | /* Add register REG to the register mask for expression AX. */ | Add register REG to the register mask for expression AX. | [
"Add",
"register",
"REG",
"to",
"the",
"register",
"mask",
"for",
"expression",
"AX",
"."
] | void
ax_reg_mask (struct agent_expr *ax, int reg)
{
if (reg >= gdbarch_num_regs (ax->gdbarch))
{
if (!gdbarch_ax_pseudo_register_collect_p (ax->gdbarch))
error (_("'%s' is a pseudo-register; "
"GDB cannot yet trace its contents."),
user_reg_map_regnum_to_name (ax->gdbarch, reg));
if (gdbarch_ax_pseudo_register_collect (ax->gdbarch, ax, reg))
error (_("Trace '%s' failed."),
user_reg_map_regnum_to_name (ax->gdbarch, reg));
}
else
{
int byte = reg / 8;
if (byte >= ax->reg_mask_len)
{
int new_len = byte + 1;
unsigned char *new_reg_mask = xrealloc (ax->reg_mask,
new_len
* sizeof (ax->reg_mask[0]));
memset (new_reg_mask + ax->reg_mask_len, 0,
(new_len - ax->reg_mask_len) * sizeof (ax->reg_mask[0]));
ax->reg_mask_len = new_len;
ax->reg_mask = new_reg_mask;
}
ax->reg_mask[byte] |= 1 << (reg % 8);
}
} | [
"void",
"ax_reg_mask",
"(",
"struct",
"agent_expr",
"*",
"ax",
",",
"int",
"reg",
")",
"{",
"if",
"(",
"reg",
">=",
"gdbarch_num_regs",
"(",
"ax",
"->",
"gdbarch",
")",
")",
"{",
"if",
"(",
"!",
"gdbarch_ax_pseudo_register_collect_p",
"(",
"ax",
"->",
"gdbarch",
")",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"user_reg_map_regnum_to_name",
"(",
"ax",
"->",
"gdbarch",
",",
"reg",
")",
")",
";",
"if",
"(",
"gdbarch_ax_pseudo_register_collect",
"(",
"ax",
"->",
"gdbarch",
",",
"ax",
",",
"reg",
")",
")",
"error",
"(",
"_",
"(",
"\"",
"\"",
")",
",",
"user_reg_map_regnum_to_name",
"(",
"ax",
"->",
"gdbarch",
",",
"reg",
")",
")",
";",
"}",
"else",
"{",
"int",
"byte",
"=",
"reg",
"/",
"8",
";",
"if",
"(",
"byte",
">=",
"ax",
"->",
"reg_mask_len",
")",
"{",
"int",
"new_len",
"=",
"byte",
"+",
"1",
";",
"unsigned",
"char",
"*",
"new_reg_mask",
"=",
"xrealloc",
"(",
"ax",
"->",
"reg_mask",
",",
"new_len",
"*",
"sizeof",
"(",
"ax",
"->",
"reg_mask",
"[",
"0",
"]",
")",
")",
";",
"memset",
"(",
"new_reg_mask",
"+",
"ax",
"->",
"reg_mask_len",
",",
"0",
",",
"(",
"new_len",
"-",
"ax",
"->",
"reg_mask_len",
")",
"*",
"sizeof",
"(",
"ax",
"->",
"reg_mask",
"[",
"0",
"]",
")",
")",
";",
"ax",
"->",
"reg_mask_len",
"=",
"new_len",
";",
"ax",
"->",
"reg_mask",
"=",
"new_reg_mask",
";",
"}",
"ax",
"->",
"reg_mask",
"[",
"byte",
"]",
"|=",
"1",
"<<",
"(",
"reg",
"%",
"8",
")",
";",
"}",
"}"
] | Add register REG to the register mask for expression AX. | [
"Add",
"register",
"REG",
"to",
"the",
"register",
"mask",
"for",
"expression",
"AX",
"."
] | [
"/* This is a pseudo-register. */",
"/* Grow the bit mask if necessary. */",
"/* It's not appropriate to double here. This isn't a\n\t string buffer. */"
] | [
{
"param": "ax",
"type": "struct agent_expr"
},
{
"param": "reg",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ax",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8bd4df6acfa0d1b19a84af83b023e712a739ba1b | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/ax-general.c | [
"BSD-3-Clause"
] | C | ax_reqs | void | void
ax_reqs (struct agent_expr *ax)
{
int i;
int height;
/* Jump target table. targets[i] is non-zero iff we have found a
jump to offset i. */
char *targets = (char *) alloca (ax->len * sizeof (targets[0]));
/* Instruction boundary table. boundary[i] is non-zero iff our scan
has reached an instruction starting at offset i. */
char *boundary = (char *) alloca (ax->len * sizeof (boundary[0]));
/* Stack height record. If either targets[i] or boundary[i] is
non-zero, heights[i] is the height the stack should have before
executing the bytecode at that point. */
int *heights = (int *) alloca (ax->len * sizeof (heights[0]));
/* Pointer to a description of the present op. */
struct aop_map *op;
memset (targets, 0, ax->len * sizeof (targets[0]));
memset (boundary, 0, ax->len * sizeof (boundary[0]));
ax->max_height = ax->min_height = height = 0;
ax->flaw = agent_flaw_none;
ax->max_data_size = 0;
for (i = 0; i < ax->len; i += 1 + op->op_size)
{
if (ax->buf[i] > (sizeof (aop_map) / sizeof (aop_map[0])))
{
ax->flaw = agent_flaw_bad_instruction;
return;
}
op = &aop_map[ax->buf[i]];
if (!op->name)
{
ax->flaw = agent_flaw_bad_instruction;
return;
}
if (i + 1 + op->op_size > ax->len)
{
ax->flaw = agent_flaw_incomplete_instruction;
return;
}
/* If this instruction is a forward jump target, does the
current stack height match the stack height at the jump
source? */
if (targets[i] && (heights[i] != height))
{
ax->flaw = agent_flaw_height_mismatch;
return;
}
boundary[i] = 1;
heights[i] = height;
height -= op->consumed;
if (height < ax->min_height)
ax->min_height = height;
height += op->produced;
if (height > ax->max_height)
ax->max_height = height;
if (op->data_size > ax->max_data_size)
ax->max_data_size = op->data_size;
/* For jump instructions, check that the target is a valid
offset. If it is, record the fact that that location is a
jump target, and record the height we expect there. */
if (aop_goto == op - aop_map
|| aop_if_goto == op - aop_map)
{
int target = read_const (ax, i + 1, 2);
if (target < 0 || target >= ax->len)
{
ax->flaw = agent_flaw_bad_jump;
return;
}
/* Do we have any information about what the stack height
should be at the target? */
if (targets[target] || boundary[target])
{
if (heights[target] != height)
{
ax->flaw = agent_flaw_height_mismatch;
return;
}
}
/* Record the target, along with the stack height we expect. */
targets[target] = 1;
heights[target] = height;
}
/* For unconditional jumps with a successor, check that the
successor is a target, and pick up its stack height. */
if (aop_goto == op - aop_map
&& i + 3 < ax->len)
{
if (!targets[i + 3])
{
ax->flaw = agent_flaw_hole;
return;
}
height = heights[i + 3];
}
/* For reg instructions, record the register in the bit mask. */
if (aop_reg == op - aop_map)
{
int reg = read_const (ax, i + 1, 2);
ax_reg_mask (ax, reg);
}
}
/* Check that all the targets are on boundaries. */
for (i = 0; i < ax->len; i++)
if (targets[i] && !boundary[i])
{
ax->flaw = agent_flaw_bad_jump;
return;
}
ax->final_height = height;
} | /* Given an agent expression AX, fill in requirements and other descriptive
bits. */ | Given an agent expression AX, fill in requirements and other descriptive
bits. | [
"Given",
"an",
"agent",
"expression",
"AX",
"fill",
"in",
"requirements",
"and",
"other",
"descriptive",
"bits",
"."
] | void
ax_reqs (struct agent_expr *ax)
{
int i;
int height;
char *targets = (char *) alloca (ax->len * sizeof (targets[0]));
char *boundary = (char *) alloca (ax->len * sizeof (boundary[0]));
int *heights = (int *) alloca (ax->len * sizeof (heights[0]));
struct aop_map *op;
memset (targets, 0, ax->len * sizeof (targets[0]));
memset (boundary, 0, ax->len * sizeof (boundary[0]));
ax->max_height = ax->min_height = height = 0;
ax->flaw = agent_flaw_none;
ax->max_data_size = 0;
for (i = 0; i < ax->len; i += 1 + op->op_size)
{
if (ax->buf[i] > (sizeof (aop_map) / sizeof (aop_map[0])))
{
ax->flaw = agent_flaw_bad_instruction;
return;
}
op = &aop_map[ax->buf[i]];
if (!op->name)
{
ax->flaw = agent_flaw_bad_instruction;
return;
}
if (i + 1 + op->op_size > ax->len)
{
ax->flaw = agent_flaw_incomplete_instruction;
return;
}
if (targets[i] && (heights[i] != height))
{
ax->flaw = agent_flaw_height_mismatch;
return;
}
boundary[i] = 1;
heights[i] = height;
height -= op->consumed;
if (height < ax->min_height)
ax->min_height = height;
height += op->produced;
if (height > ax->max_height)
ax->max_height = height;
if (op->data_size > ax->max_data_size)
ax->max_data_size = op->data_size;
if (aop_goto == op - aop_map
|| aop_if_goto == op - aop_map)
{
int target = read_const (ax, i + 1, 2);
if (target < 0 || target >= ax->len)
{
ax->flaw = agent_flaw_bad_jump;
return;
}
if (targets[target] || boundary[target])
{
if (heights[target] != height)
{
ax->flaw = agent_flaw_height_mismatch;
return;
}
}
targets[target] = 1;
heights[target] = height;
}
if (aop_goto == op - aop_map
&& i + 3 < ax->len)
{
if (!targets[i + 3])
{
ax->flaw = agent_flaw_hole;
return;
}
height = heights[i + 3];
}
if (aop_reg == op - aop_map)
{
int reg = read_const (ax, i + 1, 2);
ax_reg_mask (ax, reg);
}
}
for (i = 0; i < ax->len; i++)
if (targets[i] && !boundary[i])
{
ax->flaw = agent_flaw_bad_jump;
return;
}
ax->final_height = height;
} | [
"void",
"ax_reqs",
"(",
"struct",
"agent_expr",
"*",
"ax",
")",
"{",
"int",
"i",
";",
"int",
"height",
";",
"char",
"*",
"targets",
"=",
"(",
"char",
"*",
")",
"alloca",
"(",
"ax",
"->",
"len",
"*",
"sizeof",
"(",
"targets",
"[",
"0",
"]",
")",
")",
";",
"char",
"*",
"boundary",
"=",
"(",
"char",
"*",
")",
"alloca",
"(",
"ax",
"->",
"len",
"*",
"sizeof",
"(",
"boundary",
"[",
"0",
"]",
")",
")",
";",
"int",
"*",
"heights",
"=",
"(",
"int",
"*",
")",
"alloca",
"(",
"ax",
"->",
"len",
"*",
"sizeof",
"(",
"heights",
"[",
"0",
"]",
")",
")",
";",
"struct",
"aop_map",
"*",
"op",
";",
"memset",
"(",
"targets",
",",
"0",
",",
"ax",
"->",
"len",
"*",
"sizeof",
"(",
"targets",
"[",
"0",
"]",
")",
")",
";",
"memset",
"(",
"boundary",
",",
"0",
",",
"ax",
"->",
"len",
"*",
"sizeof",
"(",
"boundary",
"[",
"0",
"]",
")",
")",
";",
"ax",
"->",
"max_height",
"=",
"ax",
"->",
"min_height",
"=",
"height",
"=",
"0",
";",
"ax",
"->",
"flaw",
"=",
"agent_flaw_none",
";",
"ax",
"->",
"max_data_size",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ax",
"->",
"len",
";",
"i",
"+=",
"1",
"+",
"op",
"->",
"op_size",
")",
"{",
"if",
"(",
"ax",
"->",
"buf",
"[",
"i",
"]",
">",
"(",
"sizeof",
"(",
"aop_map",
")",
"/",
"sizeof",
"(",
"aop_map",
"[",
"0",
"]",
")",
")",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_bad_instruction",
";",
"return",
";",
"}",
"op",
"=",
"&",
"aop_map",
"[",
"ax",
"->",
"buf",
"[",
"i",
"]",
"]",
";",
"if",
"(",
"!",
"op",
"->",
"name",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_bad_instruction",
";",
"return",
";",
"}",
"if",
"(",
"i",
"+",
"1",
"+",
"op",
"->",
"op_size",
">",
"ax",
"->",
"len",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_incomplete_instruction",
";",
"return",
";",
"}",
"if",
"(",
"targets",
"[",
"i",
"]",
"&&",
"(",
"heights",
"[",
"i",
"]",
"!=",
"height",
")",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_height_mismatch",
";",
"return",
";",
"}",
"boundary",
"[",
"i",
"]",
"=",
"1",
";",
"heights",
"[",
"i",
"]",
"=",
"height",
";",
"height",
"-=",
"op",
"->",
"consumed",
";",
"if",
"(",
"height",
"<",
"ax",
"->",
"min_height",
")",
"ax",
"->",
"min_height",
"=",
"height",
";",
"height",
"+=",
"op",
"->",
"produced",
";",
"if",
"(",
"height",
">",
"ax",
"->",
"max_height",
")",
"ax",
"->",
"max_height",
"=",
"height",
";",
"if",
"(",
"op",
"->",
"data_size",
">",
"ax",
"->",
"max_data_size",
")",
"ax",
"->",
"max_data_size",
"=",
"op",
"->",
"data_size",
";",
"if",
"(",
"aop_goto",
"==",
"op",
"-",
"aop_map",
"||",
"aop_if_goto",
"==",
"op",
"-",
"aop_map",
")",
"{",
"int",
"target",
"=",
"read_const",
"(",
"ax",
",",
"i",
"+",
"1",
",",
"2",
")",
";",
"if",
"(",
"target",
"<",
"0",
"||",
"target",
">=",
"ax",
"->",
"len",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_bad_jump",
";",
"return",
";",
"}",
"if",
"(",
"targets",
"[",
"target",
"]",
"||",
"boundary",
"[",
"target",
"]",
")",
"{",
"if",
"(",
"heights",
"[",
"target",
"]",
"!=",
"height",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_height_mismatch",
";",
"return",
";",
"}",
"}",
"targets",
"[",
"target",
"]",
"=",
"1",
";",
"heights",
"[",
"target",
"]",
"=",
"height",
";",
"}",
"if",
"(",
"aop_goto",
"==",
"op",
"-",
"aop_map",
"&&",
"i",
"+",
"3",
"<",
"ax",
"->",
"len",
")",
"{",
"if",
"(",
"!",
"targets",
"[",
"i",
"+",
"3",
"]",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_hole",
";",
"return",
";",
"}",
"height",
"=",
"heights",
"[",
"i",
"+",
"3",
"]",
";",
"}",
"if",
"(",
"aop_reg",
"==",
"op",
"-",
"aop_map",
")",
"{",
"int",
"reg",
"=",
"read_const",
"(",
"ax",
",",
"i",
"+",
"1",
",",
"2",
")",
";",
"ax_reg_mask",
"(",
"ax",
",",
"reg",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ax",
"->",
"len",
";",
"i",
"++",
")",
"if",
"(",
"targets",
"[",
"i",
"]",
"&&",
"!",
"boundary",
"[",
"i",
"]",
")",
"{",
"ax",
"->",
"flaw",
"=",
"agent_flaw_bad_jump",
";",
"return",
";",
"}",
"ax",
"->",
"final_height",
"=",
"height",
";",
"}"
] | Given an agent expression AX, fill in requirements and other descriptive
bits. | [
"Given",
"an",
"agent",
"expression",
"AX",
"fill",
"in",
"requirements",
"and",
"other",
"descriptive",
"bits",
"."
] | [
"/* Jump target table. targets[i] is non-zero iff we have found a\n jump to offset i. */",
"/* Instruction boundary table. boundary[i] is non-zero iff our scan\n has reached an instruction starting at offset i. */",
"/* Stack height record. If either targets[i] or boundary[i] is\n non-zero, heights[i] is the height the stack should have before\n executing the bytecode at that point. */",
"/* Pointer to a description of the present op. */",
"/* If this instruction is a forward jump target, does the\n current stack height match the stack height at the jump\n source? */",
"/* For jump instructions, check that the target is a valid\n offset. If it is, record the fact that that location is a\n jump target, and record the height we expect there. */",
"/* Do we have any information about what the stack height\n should be at the target? */",
"/* Record the target, along with the stack height we expect. */",
"/* For unconditional jumps with a successor, check that the\n successor is a target, and pick up its stack height. */",
"/* For reg instructions, record the register in the bit mask. */",
"/* Check that all the targets are on boundaries. */"
] | [
{
"param": "ax",
"type": "struct agent_expr"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ax",
"type": "struct agent_expr",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e10a8de80df5778e1fd4736f7835abb319acc22 | atrens/DragonFlyBSD-src | sys/netgraph7/bluetooth/common/ng_bluetooth.c | [
"BSD-3-Clause"
] | C | bluetooth_modevent | int | static int
bluetooth_modevent(module_t mod, int event, void *data)
{
int error = 0;
switch (event) {
case MOD_LOAD:
break;
case MOD_UNLOAD:
break;
default:
error = EOPNOTSUPP;
break;
}
return (error);
} | /*
* Handle loading and unloading for this code.
*/ | Handle loading and unloading for this code. | [
"Handle",
"loading",
"and",
"unloading",
"for",
"this",
"code",
"."
] | static int
bluetooth_modevent(module_t mod, int event, void *data)
{
int error = 0;
switch (event) {
case MOD_LOAD:
break;
case MOD_UNLOAD:
break;
default:
error = EOPNOTSUPP;
break;
}
return (error);
} | [
"static",
"int",
"bluetooth_modevent",
"(",
"module_t",
"mod",
",",
"int",
"event",
",",
"void",
"*",
"data",
")",
"{",
"int",
"error",
"=",
"0",
";",
"switch",
"(",
"event",
")",
"{",
"case",
"MOD_LOAD",
":",
"break",
";",
"case",
"MOD_UNLOAD",
":",
"break",
";",
"default",
":",
"error",
"=",
"EOPNOTSUPP",
";",
"break",
";",
"}",
"return",
"(",
"error",
")",
";",
"}"
] | Handle loading and unloading for this code. | [
"Handle",
"loading",
"and",
"unloading",
"for",
"this",
"code",
"."
] | [] | [
{
"param": "mod",
"type": "module_t"
},
{
"param": "event",
"type": "int"
},
{
"param": "data",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mod",
"type": "module_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "event",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | reduction_info_eq | int | static int
reduction_info_eq (const void *aa, const void *bb)
{
const struct reduction_info *a = (const struct reduction_info *) aa;
const struct reduction_info *b = (const struct reduction_info *) bb;
return (a->reduc_phi == b->reduc_phi);
} | /* Equality and hash functions for hashtab code. */ | Equality and hash functions for hashtab code. | [
"Equality",
"and",
"hash",
"functions",
"for",
"hashtab",
"code",
"."
] | static int
reduction_info_eq (const void *aa, const void *bb)
{
const struct reduction_info *a = (const struct reduction_info *) aa;
const struct reduction_info *b = (const struct reduction_info *) bb;
return (a->reduc_phi == b->reduc_phi);
} | [
"static",
"int",
"reduction_info_eq",
"(",
"const",
"void",
"*",
"aa",
",",
"const",
"void",
"*",
"bb",
")",
"{",
"const",
"struct",
"reduction_info",
"*",
"a",
"=",
"(",
"const",
"struct",
"reduction_info",
"*",
")",
"aa",
";",
"const",
"struct",
"reduction_info",
"*",
"b",
"=",
"(",
"const",
"struct",
"reduction_info",
"*",
")",
"bb",
";",
"return",
"(",
"a",
"->",
"reduc_phi",
"==",
"b",
"->",
"reduc_phi",
")",
";",
"}"
] | Equality and hash functions for hashtab code. | [
"Equality",
"and",
"hash",
"functions",
"for",
"hashtab",
"code",
"."
] | [] | [
{
"param": "aa",
"type": "void"
},
{
"param": "bb",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "aa",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bb",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | name_to_copy_elt_eq | int | static int
name_to_copy_elt_eq (const void *aa, const void *bb)
{
const struct name_to_copy_elt *a = (const struct name_to_copy_elt *) aa;
const struct name_to_copy_elt *b = (const struct name_to_copy_elt *) bb;
return a->version == b->version;
} | /* Equality and hash functions for hashtab code. */ | Equality and hash functions for hashtab code. | [
"Equality",
"and",
"hash",
"functions",
"for",
"hashtab",
"code",
"."
] | static int
name_to_copy_elt_eq (const void *aa, const void *bb)
{
const struct name_to_copy_elt *a = (const struct name_to_copy_elt *) aa;
const struct name_to_copy_elt *b = (const struct name_to_copy_elt *) bb;
return a->version == b->version;
} | [
"static",
"int",
"name_to_copy_elt_eq",
"(",
"const",
"void",
"*",
"aa",
",",
"const",
"void",
"*",
"bb",
")",
"{",
"const",
"struct",
"name_to_copy_elt",
"*",
"a",
"=",
"(",
"const",
"struct",
"name_to_copy_elt",
"*",
")",
"aa",
";",
"const",
"struct",
"name_to_copy_elt",
"*",
"b",
"=",
"(",
"const",
"struct",
"name_to_copy_elt",
"*",
")",
"bb",
";",
"return",
"a",
"->",
"version",
"==",
"b",
"->",
"version",
";",
"}"
] | Equality and hash functions for hashtab code. | [
"Equality",
"and",
"hash",
"functions",
"for",
"hashtab",
"code",
"."
] | [] | [
{
"param": "aa",
"type": "void"
},
{
"param": "bb",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "aa",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bb",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | lambda_trans_matrix_new | lambda_trans_matrix | static lambda_trans_matrix
lambda_trans_matrix_new (int colsize, int rowsize,
struct obstack * lambda_obstack)
{
lambda_trans_matrix ret;
ret = (lambda_trans_matrix)
obstack_alloc (lambda_obstack, sizeof (struct lambda_trans_matrix_s));
LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize, lambda_obstack);
LTM_ROWSIZE (ret) = rowsize;
LTM_COLSIZE (ret) = colsize;
LTM_DENOMINATOR (ret) = 1;
return ret;
} | /* Allocate a new transformation matrix. */ | Allocate a new transformation matrix. | [
"Allocate",
"a",
"new",
"transformation",
"matrix",
"."
] | static lambda_trans_matrix
lambda_trans_matrix_new (int colsize, int rowsize,
struct obstack * lambda_obstack)
{
lambda_trans_matrix ret;
ret = (lambda_trans_matrix)
obstack_alloc (lambda_obstack, sizeof (struct lambda_trans_matrix_s));
LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize, lambda_obstack);
LTM_ROWSIZE (ret) = rowsize;
LTM_COLSIZE (ret) = colsize;
LTM_DENOMINATOR (ret) = 1;
return ret;
} | [
"static",
"lambda_trans_matrix",
"lambda_trans_matrix_new",
"(",
"int",
"colsize",
",",
"int",
"rowsize",
",",
"struct",
"obstack",
"*",
"lambda_obstack",
")",
"{",
"lambda_trans_matrix",
"ret",
";",
"ret",
"=",
"(",
"lambda_trans_matrix",
")",
"obstack_alloc",
"(",
"lambda_obstack",
",",
"sizeof",
"(",
"struct",
"lambda_trans_matrix_s",
")",
")",
";",
"LTM_MATRIX",
"(",
"ret",
")",
"=",
"lambda_matrix_new",
"(",
"rowsize",
",",
"colsize",
",",
"lambda_obstack",
")",
";",
"LTM_ROWSIZE",
"(",
"ret",
")",
"=",
"rowsize",
";",
"LTM_COLSIZE",
"(",
"ret",
")",
"=",
"colsize",
";",
"LTM_DENOMINATOR",
"(",
"ret",
")",
"=",
"1",
";",
"return",
"ret",
";",
"}"
] | Allocate a new transformation matrix. | [
"Allocate",
"a",
"new",
"transformation",
"matrix",
"."
] | [] | [
{
"param": "colsize",
"type": "int"
},
{
"param": "rowsize",
"type": "int"
},
{
"param": "lambda_obstack",
"type": "struct obstack"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "colsize",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rowsize",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lambda_obstack",
"type": "struct obstack",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | lambda_matrix_vector_mult | void | static void
lambda_matrix_vector_mult (lambda_matrix matrix, int m, int n,
lambda_vector vec, lambda_vector dest)
{
int i, j;
lambda_vector_clear (dest, m);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
dest[i] += matrix[i][j] * vec[j];
} | /* Multiply a vector VEC by a matrix MAT.
MAT is an M*N matrix, and VEC is a vector with length N. The result
is stored in DEST which must be a vector of length M. */ | Multiply a vector VEC by a matrix MAT.
MAT is an M*N matrix, and VEC is a vector with length N. The result
is stored in DEST which must be a vector of length M. | [
"Multiply",
"a",
"vector",
"VEC",
"by",
"a",
"matrix",
"MAT",
".",
"MAT",
"is",
"an",
"M",
"*",
"N",
"matrix",
"and",
"VEC",
"is",
"a",
"vector",
"with",
"length",
"N",
".",
"The",
"result",
"is",
"stored",
"in",
"DEST",
"which",
"must",
"be",
"a",
"vector",
"of",
"length",
"M",
"."
] | static void
lambda_matrix_vector_mult (lambda_matrix matrix, int m, int n,
lambda_vector vec, lambda_vector dest)
{
int i, j;
lambda_vector_clear (dest, m);
for (i = 0; i < m; i++)
for (j = 0; j < n; j++)
dest[i] += matrix[i][j] * vec[j];
} | [
"static",
"void",
"lambda_matrix_vector_mult",
"(",
"lambda_matrix",
"matrix",
",",
"int",
"m",
",",
"int",
"n",
",",
"lambda_vector",
"vec",
",",
"lambda_vector",
"dest",
")",
"{",
"int",
"i",
",",
"j",
";",
"lambda_vector_clear",
"(",
"dest",
",",
"m",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"m",
";",
"i",
"++",
")",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"dest",
"[",
"i",
"]",
"+=",
"matrix",
"[",
"i",
"]",
"[",
"j",
"]",
"*",
"vec",
"[",
"j",
"]",
";",
"}"
] | Multiply a vector VEC by a matrix MAT. | [
"Multiply",
"a",
"vector",
"VEC",
"by",
"a",
"matrix",
"MAT",
"."
] | [] | [
{
"param": "matrix",
"type": "lambda_matrix"
},
{
"param": "m",
"type": "int"
},
{
"param": "n",
"type": "int"
},
{
"param": "vec",
"type": "lambda_vector"
},
{
"param": "dest",
"type": "lambda_vector"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "matrix",
"type": "lambda_matrix",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "m",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vec",
"type": "lambda_vector",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "lambda_vector",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | loop_parallel_p | bool | static bool
loop_parallel_p (struct loop *loop, struct obstack * parloop_obstack)
{
VEC (loop_p, heap) *loop_nest;
VEC (ddr_p, heap) *dependence_relations;
VEC (data_reference_p, heap) *datarefs;
lambda_trans_matrix trans;
bool ret = false;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Considering loop %d\n", loop->num);
if (!loop->inner)
fprintf (dump_file, "loop is innermost\n");
else
fprintf (dump_file, "loop NOT innermost\n");
}
/* Check for problems with dependences. If the loop can be reversed,
the iterations are independent. */
datarefs = VEC_alloc (data_reference_p, heap, 10);
dependence_relations = VEC_alloc (ddr_p, heap, 10 * 10);
loop_nest = VEC_alloc (loop_p, heap, 3);
if (! compute_data_dependences_for_loop (loop, true, &loop_nest, &datarefs,
&dependence_relations))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " FAILED: cannot analyze data dependencies\n");
ret = false;
goto end;
}
if (dump_file && (dump_flags & TDF_DETAILS))
dump_data_dependence_relations (dump_file, dependence_relations);
trans = lambda_trans_matrix_new (1, 1, parloop_obstack);
LTM_MATRIX (trans)[0][0] = -1;
if (lambda_transform_legal_p (trans, 1, dependence_relations))
{
ret = true;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " SUCCESS: may be parallelized\n");
}
else if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
" FAILED: data dependencies exist across iterations\n");
end:
VEC_free (loop_p, heap, loop_nest);
free_dependence_relations (dependence_relations);
free_data_refs (datarefs);
return ret;
} | /* Data dependency analysis. Returns true if the iterations of LOOP
are independent on each other (that is, if we can execute them
in parallel). */ | Data dependency analysis. Returns true if the iterations of LOOP
are independent on each other (that is, if we can execute them
in parallel). | [
"Data",
"dependency",
"analysis",
".",
"Returns",
"true",
"if",
"the",
"iterations",
"of",
"LOOP",
"are",
"independent",
"on",
"each",
"other",
"(",
"that",
"is",
"if",
"we",
"can",
"execute",
"them",
"in",
"parallel",
")",
"."
] | static bool
loop_parallel_p (struct loop *loop, struct obstack * parloop_obstack)
{
VEC (loop_p, heap) *loop_nest;
VEC (ddr_p, heap) *dependence_relations;
VEC (data_reference_p, heap) *datarefs;
lambda_trans_matrix trans;
bool ret = false;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Considering loop %d\n", loop->num);
if (!loop->inner)
fprintf (dump_file, "loop is innermost\n");
else
fprintf (dump_file, "loop NOT innermost\n");
}
datarefs = VEC_alloc (data_reference_p, heap, 10);
dependence_relations = VEC_alloc (ddr_p, heap, 10 * 10);
loop_nest = VEC_alloc (loop_p, heap, 3);
if (! compute_data_dependences_for_loop (loop, true, &loop_nest, &datarefs,
&dependence_relations))
{
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " FAILED: cannot analyze data dependencies\n");
ret = false;
goto end;
}
if (dump_file && (dump_flags & TDF_DETAILS))
dump_data_dependence_relations (dump_file, dependence_relations);
trans = lambda_trans_matrix_new (1, 1, parloop_obstack);
LTM_MATRIX (trans)[0][0] = -1;
if (lambda_transform_legal_p (trans, 1, dependence_relations))
{
ret = true;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, " SUCCESS: may be parallelized\n");
}
else if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
" FAILED: data dependencies exist across iterations\n");
end:
VEC_free (loop_p, heap, loop_nest);
free_dependence_relations (dependence_relations);
free_data_refs (datarefs);
return ret;
} | [
"static",
"bool",
"loop_parallel_p",
"(",
"struct",
"loop",
"*",
"loop",
",",
"struct",
"obstack",
"*",
"parloop_obstack",
")",
"{",
"VEC",
"(",
"loop_p",
",",
"heap",
")",
"*",
"loop_nest",
";",
"VEC",
"(",
"ddr_p",
",",
"heap",
")",
"*",
"dependence_relations",
";",
"VEC",
"(",
"data_reference_p",
",",
"heap",
")",
"*",
"datarefs",
";",
"lambda_trans_matrix",
"trans",
";",
"bool",
"ret",
"=",
"false",
";",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_flags",
"&",
"TDF_DETAILS",
")",
")",
"{",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
",",
"loop",
"->",
"num",
")",
";",
"if",
"(",
"!",
"loop",
"->",
"inner",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"datarefs",
"=",
"VEC_alloc",
"(",
"data_reference_p",
",",
"heap",
",",
"10",
")",
";",
"dependence_relations",
"=",
"VEC_alloc",
"(",
"ddr_p",
",",
"heap",
",",
"10",
"*",
"10",
")",
";",
"loop_nest",
"=",
"VEC_alloc",
"(",
"loop_p",
",",
"heap",
",",
"3",
")",
";",
"if",
"(",
"!",
"compute_data_dependences_for_loop",
"(",
"loop",
",",
"true",
",",
"&",
"loop_nest",
",",
"&",
"datarefs",
",",
"&",
"dependence_relations",
")",
")",
"{",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_flags",
"&",
"TDF_DETAILS",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"ret",
"=",
"false",
";",
"goto",
"end",
";",
"}",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_flags",
"&",
"TDF_DETAILS",
")",
")",
"dump_data_dependence_relations",
"(",
"dump_file",
",",
"dependence_relations",
")",
";",
"trans",
"=",
"lambda_trans_matrix_new",
"(",
"1",
",",
"1",
",",
"parloop_obstack",
")",
";",
"LTM_MATRIX",
"(",
"trans",
")",
"[",
"0",
"]",
"[",
"0",
"]",
"=",
"-1",
";",
"if",
"(",
"lambda_transform_legal_p",
"(",
"trans",
",",
"1",
",",
"dependence_relations",
")",
")",
"{",
"ret",
"=",
"true",
";",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_flags",
"&",
"TDF_DETAILS",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"dump_file",
"&&",
"(",
"dump_flags",
"&",
"TDF_DETAILS",
")",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
")",
";",
"end",
":",
"VEC_free",
"(",
"loop_p",
",",
"heap",
",",
"loop_nest",
")",
";",
"free_dependence_relations",
"(",
"dependence_relations",
")",
";",
"free_data_refs",
"(",
"datarefs",
")",
";",
"return",
"ret",
";",
"}"
] | Data dependency analysis. | [
"Data",
"dependency",
"analysis",
"."
] | [
"/* Check for problems with dependences. If the loop can be reversed,\n the iterations are independent. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "parloop_obstack",
"type": "struct obstack"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "parloop_obstack",
"type": "struct obstack",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | loop_has_blocks_with_irreducible_flag | bool | static inline bool
loop_has_blocks_with_irreducible_flag (struct loop *loop)
{
unsigned i;
basic_block *bbs = get_loop_body_in_dom_order (loop);
bool res = true;
for (i = 0; i < loop->num_nodes; i++)
if (bbs[i]->flags & BB_IRREDUCIBLE_LOOP)
goto end;
res = false;
end:
free (bbs);
return res;
} | /* Return true when LOOP contains basic blocks marked with the
BB_IRREDUCIBLE_LOOP flag. */ | Return true when LOOP contains basic blocks marked with the
BB_IRREDUCIBLE_LOOP flag. | [
"Return",
"true",
"when",
"LOOP",
"contains",
"basic",
"blocks",
"marked",
"with",
"the",
"BB_IRREDUCIBLE_LOOP",
"flag",
"."
] | static inline bool
loop_has_blocks_with_irreducible_flag (struct loop *loop)
{
unsigned i;
basic_block *bbs = get_loop_body_in_dom_order (loop);
bool res = true;
for (i = 0; i < loop->num_nodes; i++)
if (bbs[i]->flags & BB_IRREDUCIBLE_LOOP)
goto end;
res = false;
end:
free (bbs);
return res;
} | [
"static",
"inline",
"bool",
"loop_has_blocks_with_irreducible_flag",
"(",
"struct",
"loop",
"*",
"loop",
")",
"{",
"unsigned",
"i",
";",
"basic_block",
"*",
"bbs",
"=",
"get_loop_body_in_dom_order",
"(",
"loop",
")",
";",
"bool",
"res",
"=",
"true",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"loop",
"->",
"num_nodes",
";",
"i",
"++",
")",
"if",
"(",
"bbs",
"[",
"i",
"]",
"->",
"flags",
"&",
"BB_IRREDUCIBLE_LOOP",
")",
"goto",
"end",
";",
"res",
"=",
"false",
";",
"end",
":",
"free",
"(",
"bbs",
")",
";",
"return",
"res",
";",
"}"
] | Return true when LOOP contains basic blocks marked with the
BB_IRREDUCIBLE_LOOP flag. | [
"Return",
"true",
"when",
"LOOP",
"contains",
"basic",
"blocks",
"marked",
"with",
"the",
"BB_IRREDUCIBLE_LOOP",
"flag",
"."
] | [] | [
{
"param": "loop",
"type": "struct loop"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | eliminate_local_variables_1 | tree | static tree
eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data)
{
struct elv_data *const dta = (struct elv_data *) data;
tree t = *tp, var, addr, addr_type, type, obj;
if (DECL_P (t))
{
*walk_subtrees = 0;
if (!SSA_VAR_P (t) || DECL_EXTERNAL (t))
return NULL_TREE;
type = TREE_TYPE (t);
addr_type = build_pointer_type (type);
addr = take_address_of (t, addr_type, dta->entry, dta->decl_address,
dta->gsi);
if (dta->gsi == NULL && addr == NULL_TREE)
{
dta->reset = true;
return NULL_TREE;
}
*tp = build_simple_mem_ref (addr);
dta->changed = true;
return NULL_TREE;
}
if (TREE_CODE (t) == ADDR_EXPR)
{
/* ADDR_EXPR may appear in two contexts:
-- as a gimple operand, when the address taken is a function invariant
-- as gimple rhs, when the resulting address in not a function
invariant
We do not need to do anything special in the latter case (the base of
the memory reference whose address is taken may be replaced in the
DECL_P case). The former case is more complicated, as we need to
ensure that the new address is still a gimple operand. Thus, it
is not sufficient to replace just the base of the memory reference --
we need to move the whole computation of the address out of the
loop. */
if (!is_gimple_val (t))
return NULL_TREE;
*walk_subtrees = 0;
obj = TREE_OPERAND (t, 0);
var = get_base_address (obj);
if (!var || !SSA_VAR_P (var) || DECL_EXTERNAL (var))
return NULL_TREE;
addr_type = TREE_TYPE (t);
addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address,
dta->gsi);
if (dta->gsi == NULL && addr == NULL_TREE)
{
dta->reset = true;
return NULL_TREE;
}
*tp = addr;
dta->changed = true;
return NULL_TREE;
}
if (!EXPR_P (t))
*walk_subtrees = 0;
return NULL_TREE;
} | /* Eliminates references to local variables in *TP out of the single
entry single exit region starting at DTA->ENTRY.
DECL_ADDRESS contains addresses of the references that had their
address taken already. If the expression is changed, CHANGED is
set to true. Callback for walk_tree. */ | Eliminates references to local variables in *TP out of the single
entry single exit region starting at DTA->ENTRY.
DECL_ADDRESS contains addresses of the references that had their
address taken already. If the expression is changed, CHANGED is
set to true. | [
"Eliminates",
"references",
"to",
"local",
"variables",
"in",
"*",
"TP",
"out",
"of",
"the",
"single",
"entry",
"single",
"exit",
"region",
"starting",
"at",
"DTA",
"-",
">",
"ENTRY",
".",
"DECL_ADDRESS",
"contains",
"addresses",
"of",
"the",
"references",
"that",
"had",
"their",
"address",
"taken",
"already",
".",
"If",
"the",
"expression",
"is",
"changed",
"CHANGED",
"is",
"set",
"to",
"true",
"."
] | static tree
eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data)
{
struct elv_data *const dta = (struct elv_data *) data;
tree t = *tp, var, addr, addr_type, type, obj;
if (DECL_P (t))
{
*walk_subtrees = 0;
if (!SSA_VAR_P (t) || DECL_EXTERNAL (t))
return NULL_TREE;
type = TREE_TYPE (t);
addr_type = build_pointer_type (type);
addr = take_address_of (t, addr_type, dta->entry, dta->decl_address,
dta->gsi);
if (dta->gsi == NULL && addr == NULL_TREE)
{
dta->reset = true;
return NULL_TREE;
}
*tp = build_simple_mem_ref (addr);
dta->changed = true;
return NULL_TREE;
}
if (TREE_CODE (t) == ADDR_EXPR)
{
if (!is_gimple_val (t))
return NULL_TREE;
*walk_subtrees = 0;
obj = TREE_OPERAND (t, 0);
var = get_base_address (obj);
if (!var || !SSA_VAR_P (var) || DECL_EXTERNAL (var))
return NULL_TREE;
addr_type = TREE_TYPE (t);
addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address,
dta->gsi);
if (dta->gsi == NULL && addr == NULL_TREE)
{
dta->reset = true;
return NULL_TREE;
}
*tp = addr;
dta->changed = true;
return NULL_TREE;
}
if (!EXPR_P (t))
*walk_subtrees = 0;
return NULL_TREE;
} | [
"static",
"tree",
"eliminate_local_variables_1",
"(",
"tree",
"*",
"tp",
",",
"int",
"*",
"walk_subtrees",
",",
"void",
"*",
"data",
")",
"{",
"struct",
"elv_data",
"*",
"const",
"dta",
"=",
"(",
"struct",
"elv_data",
"*",
")",
"data",
";",
"tree",
"t",
"=",
"*",
"tp",
",",
"var",
",",
"addr",
",",
"addr_type",
",",
"type",
",",
"obj",
";",
"if",
"(",
"DECL_P",
"(",
"t",
")",
")",
"{",
"*",
"walk_subtrees",
"=",
"0",
";",
"if",
"(",
"!",
"SSA_VAR_P",
"(",
"t",
")",
"||",
"DECL_EXTERNAL",
"(",
"t",
")",
")",
"return",
"NULL_TREE",
";",
"type",
"=",
"TREE_TYPE",
"(",
"t",
")",
";",
"addr_type",
"=",
"build_pointer_type",
"(",
"type",
")",
";",
"addr",
"=",
"take_address_of",
"(",
"t",
",",
"addr_type",
",",
"dta",
"->",
"entry",
",",
"dta",
"->",
"decl_address",
",",
"dta",
"->",
"gsi",
")",
";",
"if",
"(",
"dta",
"->",
"gsi",
"==",
"NULL",
"&&",
"addr",
"==",
"NULL_TREE",
")",
"{",
"dta",
"->",
"reset",
"=",
"true",
";",
"return",
"NULL_TREE",
";",
"}",
"*",
"tp",
"=",
"build_simple_mem_ref",
"(",
"addr",
")",
";",
"dta",
"->",
"changed",
"=",
"true",
";",
"return",
"NULL_TREE",
";",
"}",
"if",
"(",
"TREE_CODE",
"(",
"t",
")",
"==",
"ADDR_EXPR",
")",
"{",
"if",
"(",
"!",
"is_gimple_val",
"(",
"t",
")",
")",
"return",
"NULL_TREE",
";",
"*",
"walk_subtrees",
"=",
"0",
";",
"obj",
"=",
"TREE_OPERAND",
"(",
"t",
",",
"0",
")",
";",
"var",
"=",
"get_base_address",
"(",
"obj",
")",
";",
"if",
"(",
"!",
"var",
"||",
"!",
"SSA_VAR_P",
"(",
"var",
")",
"||",
"DECL_EXTERNAL",
"(",
"var",
")",
")",
"return",
"NULL_TREE",
";",
"addr_type",
"=",
"TREE_TYPE",
"(",
"t",
")",
";",
"addr",
"=",
"take_address_of",
"(",
"obj",
",",
"addr_type",
",",
"dta",
"->",
"entry",
",",
"dta",
"->",
"decl_address",
",",
"dta",
"->",
"gsi",
")",
";",
"if",
"(",
"dta",
"->",
"gsi",
"==",
"NULL",
"&&",
"addr",
"==",
"NULL_TREE",
")",
"{",
"dta",
"->",
"reset",
"=",
"true",
";",
"return",
"NULL_TREE",
";",
"}",
"*",
"tp",
"=",
"addr",
";",
"dta",
"->",
"changed",
"=",
"true",
";",
"return",
"NULL_TREE",
";",
"}",
"if",
"(",
"!",
"EXPR_P",
"(",
"t",
")",
")",
"*",
"walk_subtrees",
"=",
"0",
";",
"return",
"NULL_TREE",
";",
"}"
] | Eliminates references to local variables in *TP out of the single
entry single exit region starting at DTA->ENTRY. | [
"Eliminates",
"references",
"to",
"local",
"variables",
"in",
"*",
"TP",
"out",
"of",
"the",
"single",
"entry",
"single",
"exit",
"region",
"starting",
"at",
"DTA",
"-",
">",
"ENTRY",
"."
] | [
"/* ADDR_EXPR may appear in two contexts:\n\t -- as a gimple operand, when the address taken is a function invariant\n\t -- as gimple rhs, when the resulting address in not a function\n\t invariant\n\t We do not need to do anything special in the latter case (the base of\n\t the memory reference whose address is taken may be replaced in the\n\t DECL_P case). The former case is more complicated, as we need to\n\t ensure that the new address is still a gimple operand. Thus, it\n\t is not sufficient to replace just the base of the memory reference --\n\t we need to move the whole computation of the address out of the\n\t loop. */"
] | [
{
"param": "tp",
"type": "tree"
},
{
"param": "walk_subtrees",
"type": "int"
},
{
"param": "data",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "walk_subtrees",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | eliminate_local_variables_stmt | void | static void
eliminate_local_variables_stmt (edge entry, gimple_stmt_iterator *gsi,
htab_t decl_address)
{
struct elv_data dta;
gimple stmt = gsi_stmt (*gsi);
memset (&dta.info, '\0', sizeof (dta.info));
dta.entry = entry;
dta.decl_address = decl_address;
dta.changed = false;
dta.reset = false;
if (gimple_debug_bind_p (stmt))
{
dta.gsi = NULL;
walk_tree (gimple_debug_bind_get_value_ptr (stmt),
eliminate_local_variables_1, &dta.info, NULL);
if (dta.reset)
{
gimple_debug_bind_reset_value (stmt);
dta.changed = true;
}
}
else
{
dta.gsi = gsi;
walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info);
}
if (dta.changed)
update_stmt (stmt);
} | /* Moves the references to local variables in STMT at *GSI out of the single
entry single exit region starting at ENTRY. DECL_ADDRESS contains
addresses of the references that had their address taken
already. */ | Moves the references to local variables in STMT at *GSI out of the single
entry single exit region starting at ENTRY. DECL_ADDRESS contains
addresses of the references that had their address taken
already. | [
"Moves",
"the",
"references",
"to",
"local",
"variables",
"in",
"STMT",
"at",
"*",
"GSI",
"out",
"of",
"the",
"single",
"entry",
"single",
"exit",
"region",
"starting",
"at",
"ENTRY",
".",
"DECL_ADDRESS",
"contains",
"addresses",
"of",
"the",
"references",
"that",
"had",
"their",
"address",
"taken",
"already",
"."
] | static void
eliminate_local_variables_stmt (edge entry, gimple_stmt_iterator *gsi,
htab_t decl_address)
{
struct elv_data dta;
gimple stmt = gsi_stmt (*gsi);
memset (&dta.info, '\0', sizeof (dta.info));
dta.entry = entry;
dta.decl_address = decl_address;
dta.changed = false;
dta.reset = false;
if (gimple_debug_bind_p (stmt))
{
dta.gsi = NULL;
walk_tree (gimple_debug_bind_get_value_ptr (stmt),
eliminate_local_variables_1, &dta.info, NULL);
if (dta.reset)
{
gimple_debug_bind_reset_value (stmt);
dta.changed = true;
}
}
else
{
dta.gsi = gsi;
walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info);
}
if (dta.changed)
update_stmt (stmt);
} | [
"static",
"void",
"eliminate_local_variables_stmt",
"(",
"edge",
"entry",
",",
"gimple_stmt_iterator",
"*",
"gsi",
",",
"htab_t",
"decl_address",
")",
"{",
"struct",
"elv_data",
"dta",
";",
"gimple",
"stmt",
"=",
"gsi_stmt",
"(",
"*",
"gsi",
")",
";",
"memset",
"(",
"&",
"dta",
".",
"info",
",",
"'",
"\\0",
"'",
",",
"sizeof",
"(",
"dta",
".",
"info",
")",
")",
";",
"dta",
".",
"entry",
"=",
"entry",
";",
"dta",
".",
"decl_address",
"=",
"decl_address",
";",
"dta",
".",
"changed",
"=",
"false",
";",
"dta",
".",
"reset",
"=",
"false",
";",
"if",
"(",
"gimple_debug_bind_p",
"(",
"stmt",
")",
")",
"{",
"dta",
".",
"gsi",
"=",
"NULL",
";",
"walk_tree",
"(",
"gimple_debug_bind_get_value_ptr",
"(",
"stmt",
")",
",",
"eliminate_local_variables_1",
",",
"&",
"dta",
".",
"info",
",",
"NULL",
")",
";",
"if",
"(",
"dta",
".",
"reset",
")",
"{",
"gimple_debug_bind_reset_value",
"(",
"stmt",
")",
";",
"dta",
".",
"changed",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"dta",
".",
"gsi",
"=",
"gsi",
";",
"walk_gimple_op",
"(",
"stmt",
",",
"eliminate_local_variables_1",
",",
"&",
"dta",
".",
"info",
")",
";",
"}",
"if",
"(",
"dta",
".",
"changed",
")",
"update_stmt",
"(",
"stmt",
")",
";",
"}"
] | Moves the references to local variables in STMT at *GSI out of the single
entry single exit region starting at ENTRY. | [
"Moves",
"the",
"references",
"to",
"local",
"variables",
"in",
"STMT",
"at",
"*",
"GSI",
"out",
"of",
"the",
"single",
"entry",
"single",
"exit",
"region",
"starting",
"at",
"ENTRY",
"."
] | [] | [
{
"param": "entry",
"type": "edge"
},
{
"param": "gsi",
"type": "gimple_stmt_iterator"
},
{
"param": "decl_address",
"type": "htab_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gsi",
"type": "gimple_stmt_iterator",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "decl_address",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | eliminate_local_variables | void | static void
eliminate_local_variables (edge entry, edge exit)
{
basic_block bb;
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
unsigned i;
gimple_stmt_iterator gsi;
bool has_debug_stmt = false;
htab_t decl_address = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
basic_block entry_bb = entry->src;
basic_block exit_bb = exit->dest;
gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (is_gimple_debug (gsi_stmt (gsi)))
{
if (gimple_debug_bind_p (gsi_stmt (gsi)))
has_debug_stmt = true;
}
else
eliminate_local_variables_stmt (entry, &gsi, decl_address);
if (has_debug_stmt)
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (gimple_debug_bind_p (gsi_stmt (gsi)))
eliminate_local_variables_stmt (entry, &gsi, decl_address);
htab_delete (decl_address);
VEC_free (basic_block, heap, body);
} | /* Eliminates the references to local variables from the single entry
single exit region between the ENTRY and EXIT edges.
This includes:
1) Taking address of a local variable -- these are moved out of the
region (and temporary variable is created to hold the address if
necessary).
2) Dereferencing a local variable -- these are replaced with indirect
references. */ | Eliminates the references to local variables from the single entry
single exit region between the ENTRY and EXIT edges.
This includes:
1) Taking address of a local variable -- these are moved out of the
region (and temporary variable is created to hold the address if
necessary).
2) Dereferencing a local variable -- these are replaced with indirect
references. | [
"Eliminates",
"the",
"references",
"to",
"local",
"variables",
"from",
"the",
"single",
"entry",
"single",
"exit",
"region",
"between",
"the",
"ENTRY",
"and",
"EXIT",
"edges",
".",
"This",
"includes",
":",
"1",
")",
"Taking",
"address",
"of",
"a",
"local",
"variable",
"--",
"these",
"are",
"moved",
"out",
"of",
"the",
"region",
"(",
"and",
"temporary",
"variable",
"is",
"created",
"to",
"hold",
"the",
"address",
"if",
"necessary",
")",
".",
"2",
")",
"Dereferencing",
"a",
"local",
"variable",
"--",
"these",
"are",
"replaced",
"with",
"indirect",
"references",
"."
] | static void
eliminate_local_variables (edge entry, edge exit)
{
basic_block bb;
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
unsigned i;
gimple_stmt_iterator gsi;
bool has_debug_stmt = false;
htab_t decl_address = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
basic_block entry_bb = entry->src;
basic_block exit_bb = exit->dest;
gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (is_gimple_debug (gsi_stmt (gsi)))
{
if (gimple_debug_bind_p (gsi_stmt (gsi)))
has_debug_stmt = true;
}
else
eliminate_local_variables_stmt (entry, &gsi, decl_address);
if (has_debug_stmt)
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
if (gimple_debug_bind_p (gsi_stmt (gsi)))
eliminate_local_variables_stmt (entry, &gsi, decl_address);
htab_delete (decl_address);
VEC_free (basic_block, heap, body);
} | [
"static",
"void",
"eliminate_local_variables",
"(",
"edge",
"entry",
",",
"edge",
"exit",
")",
"{",
"basic_block",
"bb",
";",
"VEC",
"(",
"basic_block",
",",
"heap",
")",
"*",
"body",
"=",
"VEC_alloc",
"(",
"basic_block",
",",
"heap",
",",
"3",
")",
";",
"unsigned",
"i",
";",
"gimple_stmt_iterator",
"gsi",
";",
"bool",
"has_debug_stmt",
"=",
"false",
";",
"htab_t",
"decl_address",
"=",
"htab_create",
"(",
"10",
",",
"int_tree_map_hash",
",",
"int_tree_map_eq",
",",
"free",
")",
";",
"basic_block",
"entry_bb",
"=",
"entry",
"->",
"src",
";",
"basic_block",
"exit_bb",
"=",
"exit",
"->",
"dest",
";",
"gather_blocks_in_sese_region",
"(",
"entry_bb",
",",
"exit_bb",
",",
"&",
"body",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"basic_block",
",",
"body",
",",
"i",
",",
"bb",
")",
"",
"if",
"(",
"bb",
"!=",
"entry_bb",
"&&",
"bb",
"!=",
"exit_bb",
")",
"for",
"(",
"gsi",
"=",
"gsi_start_bb",
"(",
"bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"if",
"(",
"is_gimple_debug",
"(",
"gsi_stmt",
"(",
"gsi",
")",
")",
")",
"{",
"if",
"(",
"gimple_debug_bind_p",
"(",
"gsi_stmt",
"(",
"gsi",
")",
")",
")",
"has_debug_stmt",
"=",
"true",
";",
"}",
"else",
"eliminate_local_variables_stmt",
"(",
"entry",
",",
"&",
"gsi",
",",
"decl_address",
")",
";",
"if",
"(",
"has_debug_stmt",
")",
"FOR_EACH_VEC_ELT",
"(",
"basic_block",
",",
"body",
",",
"i",
",",
"bb",
")",
"",
"if",
"(",
"bb",
"!=",
"entry_bb",
"&&",
"bb",
"!=",
"exit_bb",
")",
"for",
"(",
"gsi",
"=",
"gsi_start_bb",
"(",
"bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"if",
"(",
"gimple_debug_bind_p",
"(",
"gsi_stmt",
"(",
"gsi",
")",
")",
")",
"eliminate_local_variables_stmt",
"(",
"entry",
",",
"&",
"gsi",
",",
"decl_address",
")",
";",
"htab_delete",
"(",
"decl_address",
")",
";",
"VEC_free",
"(",
"basic_block",
",",
"heap",
",",
"body",
")",
";",
"}"
] | Eliminates the references to local variables from the single entry
single exit region between the ENTRY and EXIT edges. | [
"Eliminates",
"the",
"references",
"to",
"local",
"variables",
"from",
"the",
"single",
"entry",
"single",
"exit",
"region",
"between",
"the",
"ENTRY",
"and",
"EXIT",
"edges",
"."
] | [] | [
{
"param": "entry",
"type": "edge"
},
{
"param": "exit",
"type": "edge"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exit",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | expr_invariant_in_region_p | bool | static bool
expr_invariant_in_region_p (edge entry, edge exit, tree expr)
{
basic_block entry_bb = entry->src;
basic_block exit_bb = exit->dest;
basic_block def_bb;
if (is_gimple_min_invariant (expr))
return true;
if (TREE_CODE (expr) == SSA_NAME)
{
def_bb = gimple_bb (SSA_NAME_DEF_STMT (expr));
if (def_bb
&& dominated_by_p (CDI_DOMINATORS, def_bb, entry_bb)
&& !dominated_by_p (CDI_DOMINATORS, def_bb, exit_bb))
return false;
return true;
}
return false;
} | /* Returns true if expression EXPR is not defined between ENTRY and
EXIT, i.e. if all its operands are defined outside of the region. */ | Returns true if expression EXPR is not defined between ENTRY and
EXIT, i.e. if all its operands are defined outside of the region. | [
"Returns",
"true",
"if",
"expression",
"EXPR",
"is",
"not",
"defined",
"between",
"ENTRY",
"and",
"EXIT",
"i",
".",
"e",
".",
"if",
"all",
"its",
"operands",
"are",
"defined",
"outside",
"of",
"the",
"region",
"."
] | static bool
expr_invariant_in_region_p (edge entry, edge exit, tree expr)
{
basic_block entry_bb = entry->src;
basic_block exit_bb = exit->dest;
basic_block def_bb;
if (is_gimple_min_invariant (expr))
return true;
if (TREE_CODE (expr) == SSA_NAME)
{
def_bb = gimple_bb (SSA_NAME_DEF_STMT (expr));
if (def_bb
&& dominated_by_p (CDI_DOMINATORS, def_bb, entry_bb)
&& !dominated_by_p (CDI_DOMINATORS, def_bb, exit_bb))
return false;
return true;
}
return false;
} | [
"static",
"bool",
"expr_invariant_in_region_p",
"(",
"edge",
"entry",
",",
"edge",
"exit",
",",
"tree",
"expr",
")",
"{",
"basic_block",
"entry_bb",
"=",
"entry",
"->",
"src",
";",
"basic_block",
"exit_bb",
"=",
"exit",
"->",
"dest",
";",
"basic_block",
"def_bb",
";",
"if",
"(",
"is_gimple_min_invariant",
"(",
"expr",
")",
")",
"return",
"true",
";",
"if",
"(",
"TREE_CODE",
"(",
"expr",
")",
"==",
"SSA_NAME",
")",
"{",
"def_bb",
"=",
"gimple_bb",
"(",
"SSA_NAME_DEF_STMT",
"(",
"expr",
")",
")",
";",
"if",
"(",
"def_bb",
"&&",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"def_bb",
",",
"entry_bb",
")",
"&&",
"!",
"dominated_by_p",
"(",
"CDI_DOMINATORS",
",",
"def_bb",
",",
"exit_bb",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if expression EXPR is not defined between ENTRY and
EXIT, i.e. | [
"Returns",
"true",
"if",
"expression",
"EXPR",
"is",
"not",
"defined",
"between",
"ENTRY",
"and",
"EXIT",
"i",
".",
"e",
"."
] | [] | [
{
"param": "entry",
"type": "edge"
},
{
"param": "exit",
"type": "edge"
},
{
"param": "expr",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exit",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "expr",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | separate_decls_in_region_stmt | void | static void
separate_decls_in_region_stmt (edge entry, edge exit, gimple stmt,
htab_t name_copies, htab_t decl_copies)
{
use_operand_p use;
def_operand_p def;
ssa_op_iter oi;
tree name, copy;
bool copy_name_p;
mark_virtual_ops_for_renaming (stmt);
FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
{
name = DEF_FROM_PTR (def);
gcc_assert (TREE_CODE (name) == SSA_NAME);
copy = separate_decls_in_region_name (name, name_copies, decl_copies,
false);
gcc_assert (copy == name);
}
FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
{
name = USE_FROM_PTR (use);
if (TREE_CODE (name) != SSA_NAME)
continue;
copy_name_p = expr_invariant_in_region_p (entry, exit, name);
copy = separate_decls_in_region_name (name, name_copies, decl_copies,
copy_name_p);
SET_USE (use, copy);
}
} | /* Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. The duplicates are stored to NAME_COPIES. Base
decls of all ssa names used in STMT (including those defined in
LOOP) are replaced with the new temporary variables; the
replacement decls are stored in DECL_COPIES. */ | Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. The duplicates are stored to NAME_COPIES. Base
decls of all ssa names used in STMT (including those defined in
LOOP) are replaced with the new temporary variables; the
replacement decls are stored in DECL_COPIES. | [
"Finds",
"the",
"ssa",
"names",
"used",
"in",
"STMT",
"that",
"are",
"defined",
"outside",
"the",
"region",
"between",
"ENTRY",
"and",
"EXIT",
"and",
"replaces",
"such",
"ssa",
"names",
"with",
"their",
"duplicates",
".",
"The",
"duplicates",
"are",
"stored",
"to",
"NAME_COPIES",
".",
"Base",
"decls",
"of",
"all",
"ssa",
"names",
"used",
"in",
"STMT",
"(",
"including",
"those",
"defined",
"in",
"LOOP",
")",
"are",
"replaced",
"with",
"the",
"new",
"temporary",
"variables",
";",
"the",
"replacement",
"decls",
"are",
"stored",
"in",
"DECL_COPIES",
"."
] | static void
separate_decls_in_region_stmt (edge entry, edge exit, gimple stmt,
htab_t name_copies, htab_t decl_copies)
{
use_operand_p use;
def_operand_p def;
ssa_op_iter oi;
tree name, copy;
bool copy_name_p;
mark_virtual_ops_for_renaming (stmt);
FOR_EACH_PHI_OR_STMT_DEF (def, stmt, oi, SSA_OP_DEF)
{
name = DEF_FROM_PTR (def);
gcc_assert (TREE_CODE (name) == SSA_NAME);
copy = separate_decls_in_region_name (name, name_copies, decl_copies,
false);
gcc_assert (copy == name);
}
FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
{
name = USE_FROM_PTR (use);
if (TREE_CODE (name) != SSA_NAME)
continue;
copy_name_p = expr_invariant_in_region_p (entry, exit, name);
copy = separate_decls_in_region_name (name, name_copies, decl_copies,
copy_name_p);
SET_USE (use, copy);
}
} | [
"static",
"void",
"separate_decls_in_region_stmt",
"(",
"edge",
"entry",
",",
"edge",
"exit",
",",
"gimple",
"stmt",
",",
"htab_t",
"name_copies",
",",
"htab_t",
"decl_copies",
")",
"{",
"use_operand_p",
"use",
";",
"def_operand_p",
"def",
";",
"ssa_op_iter",
"oi",
";",
"tree",
"name",
",",
"copy",
";",
"bool",
"copy_name_p",
";",
"mark_virtual_ops_for_renaming",
"(",
"stmt",
")",
";",
"FOR_EACH_PHI_OR_STMT_DEF",
"(",
"def",
",",
"stmt",
",",
"oi",
",",
"SSA_OP_DEF",
")",
"",
"{",
"name",
"=",
"DEF_FROM_PTR",
"(",
"def",
")",
";",
"gcc_assert",
"(",
"TREE_CODE",
"(",
"name",
")",
"==",
"SSA_NAME",
")",
";",
"copy",
"=",
"separate_decls_in_region_name",
"(",
"name",
",",
"name_copies",
",",
"decl_copies",
",",
"false",
")",
";",
"gcc_assert",
"(",
"copy",
"==",
"name",
")",
";",
"}",
"FOR_EACH_PHI_OR_STMT_USE",
"(",
"use",
",",
"stmt",
",",
"oi",
",",
"SSA_OP_USE",
")",
"",
"{",
"name",
"=",
"USE_FROM_PTR",
"(",
"use",
")",
";",
"if",
"(",
"TREE_CODE",
"(",
"name",
")",
"!=",
"SSA_NAME",
")",
"continue",
";",
"copy_name_p",
"=",
"expr_invariant_in_region_p",
"(",
"entry",
",",
"exit",
",",
"name",
")",
";",
"copy",
"=",
"separate_decls_in_region_name",
"(",
"name",
",",
"name_copies",
",",
"decl_copies",
",",
"copy_name_p",
")",
";",
"SET_USE",
"(",
"use",
",",
"copy",
")",
";",
"}",
"}"
] | Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. | [
"Finds",
"the",
"ssa",
"names",
"used",
"in",
"STMT",
"that",
"are",
"defined",
"outside",
"the",
"region",
"between",
"ENTRY",
"and",
"EXIT",
"and",
"replaces",
"such",
"ssa",
"names",
"with",
"their",
"duplicates",
"."
] | [] | [
{
"param": "entry",
"type": "edge"
},
{
"param": "exit",
"type": "edge"
},
{
"param": "stmt",
"type": "gimple"
},
{
"param": "name_copies",
"type": "htab_t"
},
{
"param": "decl_copies",
"type": "htab_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exit",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stmt",
"type": "gimple",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name_copies",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "decl_copies",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | separate_decls_in_region_debug | bool | static bool
separate_decls_in_region_debug (gimple stmt, htab_t name_copies,
htab_t decl_copies)
{
use_operand_p use;
ssa_op_iter oi;
tree var, name;
struct int_tree_map ielt;
struct name_to_copy_elt elt;
void **slot, **dslot;
if (gimple_debug_bind_p (stmt))
var = gimple_debug_bind_get_var (stmt);
else if (gimple_debug_source_bind_p (stmt))
var = gimple_debug_source_bind_get_var (stmt);
else
return true;
if (TREE_CODE (var) == DEBUG_EXPR_DECL || TREE_CODE (var) == LABEL_DECL)
return true;
gcc_assert (DECL_P (var) && SSA_VAR_P (var));
ielt.uid = DECL_UID (var);
dslot = htab_find_slot_with_hash (decl_copies, &ielt, ielt.uid, NO_INSERT);
if (!dslot)
return true;
if (gimple_debug_bind_p (stmt))
gimple_debug_bind_set_var (stmt, ((struct int_tree_map *) *dslot)->to);
else if (gimple_debug_source_bind_p (stmt))
gimple_debug_source_bind_set_var (stmt, ((struct int_tree_map *) *dslot)->to);
FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
{
name = USE_FROM_PTR (use);
if (TREE_CODE (name) != SSA_NAME)
continue;
elt.version = SSA_NAME_VERSION (name);
slot = htab_find_slot_with_hash (name_copies, &elt, elt.version, NO_INSERT);
if (!slot)
{
gimple_debug_bind_reset_value (stmt);
update_stmt (stmt);
break;
}
SET_USE (use, ((struct name_to_copy_elt *) *slot)->new_name);
}
return false;
} | /* Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. The duplicates are stored to NAME_COPIES. Base
decls of all ssa names used in STMT (including those defined in
LOOP) are replaced with the new temporary variables; the
replacement decls are stored in DECL_COPIES. */ | Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. The duplicates are stored to NAME_COPIES. Base
decls of all ssa names used in STMT (including those defined in
LOOP) are replaced with the new temporary variables; the
replacement decls are stored in DECL_COPIES. | [
"Finds",
"the",
"ssa",
"names",
"used",
"in",
"STMT",
"that",
"are",
"defined",
"outside",
"the",
"region",
"between",
"ENTRY",
"and",
"EXIT",
"and",
"replaces",
"such",
"ssa",
"names",
"with",
"their",
"duplicates",
".",
"The",
"duplicates",
"are",
"stored",
"to",
"NAME_COPIES",
".",
"Base",
"decls",
"of",
"all",
"ssa",
"names",
"used",
"in",
"STMT",
"(",
"including",
"those",
"defined",
"in",
"LOOP",
")",
"are",
"replaced",
"with",
"the",
"new",
"temporary",
"variables",
";",
"the",
"replacement",
"decls",
"are",
"stored",
"in",
"DECL_COPIES",
"."
] | static bool
separate_decls_in_region_debug (gimple stmt, htab_t name_copies,
htab_t decl_copies)
{
use_operand_p use;
ssa_op_iter oi;
tree var, name;
struct int_tree_map ielt;
struct name_to_copy_elt elt;
void **slot, **dslot;
if (gimple_debug_bind_p (stmt))
var = gimple_debug_bind_get_var (stmt);
else if (gimple_debug_source_bind_p (stmt))
var = gimple_debug_source_bind_get_var (stmt);
else
return true;
if (TREE_CODE (var) == DEBUG_EXPR_DECL || TREE_CODE (var) == LABEL_DECL)
return true;
gcc_assert (DECL_P (var) && SSA_VAR_P (var));
ielt.uid = DECL_UID (var);
dslot = htab_find_slot_with_hash (decl_copies, &ielt, ielt.uid, NO_INSERT);
if (!dslot)
return true;
if (gimple_debug_bind_p (stmt))
gimple_debug_bind_set_var (stmt, ((struct int_tree_map *) *dslot)->to);
else if (gimple_debug_source_bind_p (stmt))
gimple_debug_source_bind_set_var (stmt, ((struct int_tree_map *) *dslot)->to);
FOR_EACH_PHI_OR_STMT_USE (use, stmt, oi, SSA_OP_USE)
{
name = USE_FROM_PTR (use);
if (TREE_CODE (name) != SSA_NAME)
continue;
elt.version = SSA_NAME_VERSION (name);
slot = htab_find_slot_with_hash (name_copies, &elt, elt.version, NO_INSERT);
if (!slot)
{
gimple_debug_bind_reset_value (stmt);
update_stmt (stmt);
break;
}
SET_USE (use, ((struct name_to_copy_elt *) *slot)->new_name);
}
return false;
} | [
"static",
"bool",
"separate_decls_in_region_debug",
"(",
"gimple",
"stmt",
",",
"htab_t",
"name_copies",
",",
"htab_t",
"decl_copies",
")",
"{",
"use_operand_p",
"use",
";",
"ssa_op_iter",
"oi",
";",
"tree",
"var",
",",
"name",
";",
"struct",
"int_tree_map",
"ielt",
";",
"struct",
"name_to_copy_elt",
"elt",
";",
"void",
"*",
"*",
"slot",
",",
"*",
"*",
"dslot",
";",
"if",
"(",
"gimple_debug_bind_p",
"(",
"stmt",
")",
")",
"var",
"=",
"gimple_debug_bind_get_var",
"(",
"stmt",
")",
";",
"else",
"if",
"(",
"gimple_debug_source_bind_p",
"(",
"stmt",
")",
")",
"var",
"=",
"gimple_debug_source_bind_get_var",
"(",
"stmt",
")",
";",
"else",
"return",
"true",
";",
"if",
"(",
"TREE_CODE",
"(",
"var",
")",
"==",
"DEBUG_EXPR_DECL",
"||",
"TREE_CODE",
"(",
"var",
")",
"==",
"LABEL_DECL",
")",
"return",
"true",
";",
"gcc_assert",
"(",
"DECL_P",
"(",
"var",
")",
"&&",
"SSA_VAR_P",
"(",
"var",
")",
")",
";",
"ielt",
".",
"uid",
"=",
"DECL_UID",
"(",
"var",
")",
";",
"dslot",
"=",
"htab_find_slot_with_hash",
"(",
"decl_copies",
",",
"&",
"ielt",
",",
"ielt",
".",
"uid",
",",
"NO_INSERT",
")",
";",
"if",
"(",
"!",
"dslot",
")",
"return",
"true",
";",
"if",
"(",
"gimple_debug_bind_p",
"(",
"stmt",
")",
")",
"gimple_debug_bind_set_var",
"(",
"stmt",
",",
"(",
"(",
"struct",
"int_tree_map",
"*",
")",
"*",
"dslot",
")",
"->",
"to",
")",
";",
"else",
"if",
"(",
"gimple_debug_source_bind_p",
"(",
"stmt",
")",
")",
"gimple_debug_source_bind_set_var",
"(",
"stmt",
",",
"(",
"(",
"struct",
"int_tree_map",
"*",
")",
"*",
"dslot",
")",
"->",
"to",
")",
";",
"FOR_EACH_PHI_OR_STMT_USE",
"(",
"use",
",",
"stmt",
",",
"oi",
",",
"SSA_OP_USE",
")",
"",
"{",
"name",
"=",
"USE_FROM_PTR",
"(",
"use",
")",
";",
"if",
"(",
"TREE_CODE",
"(",
"name",
")",
"!=",
"SSA_NAME",
")",
"continue",
";",
"elt",
".",
"version",
"=",
"SSA_NAME_VERSION",
"(",
"name",
")",
";",
"slot",
"=",
"htab_find_slot_with_hash",
"(",
"name_copies",
",",
"&",
"elt",
",",
"elt",
".",
"version",
",",
"NO_INSERT",
")",
";",
"if",
"(",
"!",
"slot",
")",
"{",
"gimple_debug_bind_reset_value",
"(",
"stmt",
")",
";",
"update_stmt",
"(",
"stmt",
")",
";",
"break",
";",
"}",
"SET_USE",
"(",
"use",
",",
"(",
"(",
"struct",
"name_to_copy_elt",
"*",
")",
"*",
"slot",
")",
"->",
"new_name",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Finds the ssa names used in STMT that are defined outside the
region between ENTRY and EXIT and replaces such ssa names with
their duplicates. | [
"Finds",
"the",
"ssa",
"names",
"used",
"in",
"STMT",
"that",
"are",
"defined",
"outside",
"the",
"region",
"between",
"ENTRY",
"and",
"EXIT",
"and",
"replaces",
"such",
"ssa",
"names",
"with",
"their",
"duplicates",
"."
] | [] | [
{
"param": "stmt",
"type": "gimple"
},
{
"param": "name_copies",
"type": "htab_t"
},
{
"param": "decl_copies",
"type": "htab_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stmt",
"type": "gimple",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name_copies",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "decl_copies",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | create_call_for_reduction | void | static void
create_call_for_reduction (struct loop *loop, htab_t reduction_list,
struct clsn_data *ld_st_data)
{
htab_traverse (reduction_list, create_phi_for_local_result, loop);
/* Find the fallthru edge from GIMPLE_OMP_CONTINUE. */
ld_st_data->load_bb = FALLTHRU_EDGE (loop->latch)->dest;
htab_traverse (reduction_list, create_call_for_reduction_1, ld_st_data);
} | /* Create the atomic operation at the join point of the threads.
REDUCTION_LIST describes the reductions in the LOOP.
LD_ST_DATA describes the shared data structure where
shared data is stored in and loaded from. */ | Create the atomic operation at the join point of the threads.
REDUCTION_LIST describes the reductions in the LOOP.
LD_ST_DATA describes the shared data structure where
shared data is stored in and loaded from. | [
"Create",
"the",
"atomic",
"operation",
"at",
"the",
"join",
"point",
"of",
"the",
"threads",
".",
"REDUCTION_LIST",
"describes",
"the",
"reductions",
"in",
"the",
"LOOP",
".",
"LD_ST_DATA",
"describes",
"the",
"shared",
"data",
"structure",
"where",
"shared",
"data",
"is",
"stored",
"in",
"and",
"loaded",
"from",
"."
] | static void
create_call_for_reduction (struct loop *loop, htab_t reduction_list,
struct clsn_data *ld_st_data)
{
htab_traverse (reduction_list, create_phi_for_local_result, loop);
ld_st_data->load_bb = FALLTHRU_EDGE (loop->latch)->dest;
htab_traverse (reduction_list, create_call_for_reduction_1, ld_st_data);
} | [
"static",
"void",
"create_call_for_reduction",
"(",
"struct",
"loop",
"*",
"loop",
",",
"htab_t",
"reduction_list",
",",
"struct",
"clsn_data",
"*",
"ld_st_data",
")",
"{",
"htab_traverse",
"(",
"reduction_list",
",",
"create_phi_for_local_result",
",",
"loop",
")",
";",
"ld_st_data",
"->",
"load_bb",
"=",
"FALLTHRU_EDGE",
"(",
"loop",
"->",
"latch",
")",
"->",
"dest",
";",
"htab_traverse",
"(",
"reduction_list",
",",
"create_call_for_reduction_1",
",",
"ld_st_data",
")",
";",
"}"
] | Create the atomic operation at the join point of the threads. | [
"Create",
"the",
"atomic",
"operation",
"at",
"the",
"join",
"point",
"of",
"the",
"threads",
"."
] | [
"/* Find the fallthru edge from GIMPLE_OMP_CONTINUE. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "reduction_list",
"type": "htab_t"
},
{
"param": "ld_st_data",
"type": "struct clsn_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ld_st_data",
"type": "struct clsn_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | create_final_loads_for_reduction | void | static void
create_final_loads_for_reduction (htab_t reduction_list,
struct clsn_data *ld_st_data)
{
gimple_stmt_iterator gsi;
tree t;
gimple stmt;
gsi = gsi_after_labels (ld_st_data->load_bb);
t = build_fold_addr_expr (ld_st_data->store);
stmt = gimple_build_assign (ld_st_data->load, t);
gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (ld_st_data->load) = stmt;
htab_traverse (reduction_list, create_loads_for_reductions, ld_st_data);
} | /* Load the reduction result that was stored in LD_ST_DATA.
REDUCTION_LIST describes the list of reductions that the
loads should be generated for. */ | Load the reduction result that was stored in LD_ST_DATA.
REDUCTION_LIST describes the list of reductions that the
loads should be generated for. | [
"Load",
"the",
"reduction",
"result",
"that",
"was",
"stored",
"in",
"LD_ST_DATA",
".",
"REDUCTION_LIST",
"describes",
"the",
"list",
"of",
"reductions",
"that",
"the",
"loads",
"should",
"be",
"generated",
"for",
"."
] | static void
create_final_loads_for_reduction (htab_t reduction_list,
struct clsn_data *ld_st_data)
{
gimple_stmt_iterator gsi;
tree t;
gimple stmt;
gsi = gsi_after_labels (ld_st_data->load_bb);
t = build_fold_addr_expr (ld_st_data->store);
stmt = gimple_build_assign (ld_st_data->load, t);
gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (ld_st_data->load) = stmt;
htab_traverse (reduction_list, create_loads_for_reductions, ld_st_data);
} | [
"static",
"void",
"create_final_loads_for_reduction",
"(",
"htab_t",
"reduction_list",
",",
"struct",
"clsn_data",
"*",
"ld_st_data",
")",
"{",
"gimple_stmt_iterator",
"gsi",
";",
"tree",
"t",
";",
"gimple",
"stmt",
";",
"gsi",
"=",
"gsi_after_labels",
"(",
"ld_st_data",
"->",
"load_bb",
")",
";",
"t",
"=",
"build_fold_addr_expr",
"(",
"ld_st_data",
"->",
"store",
")",
";",
"stmt",
"=",
"gimple_build_assign",
"(",
"ld_st_data",
"->",
"load",
",",
"t",
")",
";",
"gsi_insert_before",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"ld_st_data",
"->",
"load",
")",
"=",
"stmt",
";",
"htab_traverse",
"(",
"reduction_list",
",",
"create_loads_for_reductions",
",",
"ld_st_data",
")",
";",
"}"
] | Load the reduction result that was stored in LD_ST_DATA. | [
"Load",
"the",
"reduction",
"result",
"that",
"was",
"stored",
"in",
"LD_ST_DATA",
"."
] | [] | [
{
"param": "reduction_list",
"type": "htab_t"
},
{
"param": "ld_st_data",
"type": "struct clsn_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ld_st_data",
"type": "struct clsn_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | separate_decls_in_region | void | static void
separate_decls_in_region (edge entry, edge exit, htab_t reduction_list,
tree *arg_struct, tree *new_arg_struct,
struct clsn_data *ld_st_data)
{
basic_block bb1 = split_edge (entry);
basic_block bb0 = single_pred (bb1);
htab_t name_copies = htab_create (10, name_to_copy_elt_hash,
name_to_copy_elt_eq, free);
htab_t decl_copies = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
unsigned i;
tree type, type_name, nvar;
gimple_stmt_iterator gsi;
struct clsn_data clsn_data;
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
basic_block bb;
basic_block entry_bb = bb1;
basic_block exit_bb = exit->dest;
bool has_debug_stmt = false;
entry = single_succ_edge (entry_bb);
gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
{
if (bb != entry_bb && bb != exit_bb)
{
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
separate_decls_in_region_stmt (entry, exit, gsi_stmt (gsi),
name_copies, decl_copies);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
has_debug_stmt = true;
else
separate_decls_in_region_stmt (entry, exit, stmt,
name_copies, decl_copies);
}
}
}
/* Now process debug bind stmts. We must not create decls while
processing debug stmts, so we defer their processing so as to
make sure we will have debug info for as many variables as
possible (all of those that were dealt with in the loop above),
and discard those for which we know there's nothing we can
do. */
if (has_debug_stmt)
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
{
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
{
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
{
if (separate_decls_in_region_debug (stmt, name_copies,
decl_copies))
{
gsi_remove (&gsi, true);
continue;
}
}
gsi_next (&gsi);
}
}
VEC_free (basic_block, heap, body);
if (htab_elements (name_copies) == 0 && htab_elements (reduction_list) == 0)
{
/* It may happen that there is nothing to copy (if there are only
loop carried and external variables in the loop). */
*arg_struct = NULL;
*new_arg_struct = NULL;
}
else
{
/* Create the type for the structure to store the ssa names to. */
type = lang_hooks.types.make_type (RECORD_TYPE);
type_name = build_decl (UNKNOWN_LOCATION,
TYPE_DECL, create_tmp_var_name (".paral_data"),
type);
TYPE_NAME (type) = type_name;
htab_traverse (name_copies, add_field_for_name, type);
if (reduction_list && htab_elements (reduction_list) > 0)
{
/* Create the fields for reductions. */
htab_traverse (reduction_list, add_field_for_reduction,
type);
}
layout_type (type);
/* Create the loads and stores. */
*arg_struct = create_tmp_var (type, ".paral_data_store");
add_referenced_var (*arg_struct);
nvar = create_tmp_var (build_pointer_type (type), ".paral_data_load");
add_referenced_var (nvar);
*new_arg_struct = make_ssa_name (nvar, NULL);
ld_st_data->store = *arg_struct;
ld_st_data->load = *new_arg_struct;
ld_st_data->store_bb = bb0;
ld_st_data->load_bb = bb1;
htab_traverse (name_copies, create_loads_and_stores_for_name,
ld_st_data);
/* Load the calculation from memory (after the join of the threads). */
if (reduction_list && htab_elements (reduction_list) > 0)
{
htab_traverse (reduction_list, create_stores_for_reduction,
ld_st_data);
clsn_data.load = make_ssa_name (nvar, NULL);
clsn_data.load_bb = exit->dest;
clsn_data.store = ld_st_data->store;
create_final_loads_for_reduction (reduction_list, &clsn_data);
}
}
htab_delete (decl_copies);
htab_delete (name_copies);
} | /* Moves all the variables used in LOOP and defined outside of it (including
the initial values of loop phi nodes, and *PER_THREAD if it is a ssa
name) to a structure created for this purpose. The code
while (1)
{
use (a);
use (b);
}
is transformed this way:
bb0:
old.a = a;
old.b = b;
bb1:
a' = new->a;
b' = new->b;
while (1)
{
use (a');
use (b');
}
`old' is stored to *ARG_STRUCT and `new' is stored to NEW_ARG_STRUCT. The
pointer `new' is intentionally not initialized (the loop will be split to a
separate function later, and `new' will be initialized from its arguments).
LD_ST_DATA holds information about the shared data structure used to pass
information among the threads. It is initialized here, and
gen_parallel_loop will pass it to create_call_for_reduction that
needs this information. REDUCTION_LIST describes the reductions
in LOOP. */ | Moves all the variables used in LOOP and defined outside of it (including
the initial values of loop phi nodes, and *PER_THREAD if it is a ssa
name) to a structure created for this purpose. The code
`old' is stored to *ARG_STRUCT and `new' is stored to NEW_ARG_STRUCT. The
pointer `new' is intentionally not initialized (the loop will be split to a
separate function later, and `new' will be initialized from its arguments).
LD_ST_DATA holds information about the shared data structure used to pass
information among the threads. It is initialized here, and
gen_parallel_loop will pass it to create_call_for_reduction that
needs this information. REDUCTION_LIST describes the reductions
in LOOP. | [
"Moves",
"all",
"the",
"variables",
"used",
"in",
"LOOP",
"and",
"defined",
"outside",
"of",
"it",
"(",
"including",
"the",
"initial",
"values",
"of",
"loop",
"phi",
"nodes",
"and",
"*",
"PER_THREAD",
"if",
"it",
"is",
"a",
"ssa",
"name",
")",
"to",
"a",
"structure",
"created",
"for",
"this",
"purpose",
".",
"The",
"code",
"`",
"old",
"'",
"is",
"stored",
"to",
"*",
"ARG_STRUCT",
"and",
"`",
"new",
"'",
"is",
"stored",
"to",
"NEW_ARG_STRUCT",
".",
"The",
"pointer",
"`",
"new",
"'",
"is",
"intentionally",
"not",
"initialized",
"(",
"the",
"loop",
"will",
"be",
"split",
"to",
"a",
"separate",
"function",
"later",
"and",
"`",
"new",
"'",
"will",
"be",
"initialized",
"from",
"its",
"arguments",
")",
".",
"LD_ST_DATA",
"holds",
"information",
"about",
"the",
"shared",
"data",
"structure",
"used",
"to",
"pass",
"information",
"among",
"the",
"threads",
".",
"It",
"is",
"initialized",
"here",
"and",
"gen_parallel_loop",
"will",
"pass",
"it",
"to",
"create_call_for_reduction",
"that",
"needs",
"this",
"information",
".",
"REDUCTION_LIST",
"describes",
"the",
"reductions",
"in",
"LOOP",
"."
] | static void
separate_decls_in_region (edge entry, edge exit, htab_t reduction_list,
tree *arg_struct, tree *new_arg_struct,
struct clsn_data *ld_st_data)
{
basic_block bb1 = split_edge (entry);
basic_block bb0 = single_pred (bb1);
htab_t name_copies = htab_create (10, name_to_copy_elt_hash,
name_to_copy_elt_eq, free);
htab_t decl_copies = htab_create (10, int_tree_map_hash, int_tree_map_eq,
free);
unsigned i;
tree type, type_name, nvar;
gimple_stmt_iterator gsi;
struct clsn_data clsn_data;
VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3);
basic_block bb;
basic_block entry_bb = bb1;
basic_block exit_bb = exit->dest;
bool has_debug_stmt = false;
entry = single_succ_edge (entry_bb);
gather_blocks_in_sese_region (entry_bb, exit_bb, &body);
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
{
if (bb != entry_bb && bb != exit_bb)
{
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
separate_decls_in_region_stmt (entry, exit, gsi_stmt (gsi),
name_copies, decl_copies);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
has_debug_stmt = true;
else
separate_decls_in_region_stmt (entry, exit, stmt,
name_copies, decl_copies);
}
}
}
if (has_debug_stmt)
FOR_EACH_VEC_ELT (basic_block, body, i, bb)
if (bb != entry_bb && bb != exit_bb)
{
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
{
gimple stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
{
if (separate_decls_in_region_debug (stmt, name_copies,
decl_copies))
{
gsi_remove (&gsi, true);
continue;
}
}
gsi_next (&gsi);
}
}
VEC_free (basic_block, heap, body);
if (htab_elements (name_copies) == 0 && htab_elements (reduction_list) == 0)
{
*arg_struct = NULL;
*new_arg_struct = NULL;
}
else
{
type = lang_hooks.types.make_type (RECORD_TYPE);
type_name = build_decl (UNKNOWN_LOCATION,
TYPE_DECL, create_tmp_var_name (".paral_data"),
type);
TYPE_NAME (type) = type_name;
htab_traverse (name_copies, add_field_for_name, type);
if (reduction_list && htab_elements (reduction_list) > 0)
{
htab_traverse (reduction_list, add_field_for_reduction,
type);
}
layout_type (type);
*arg_struct = create_tmp_var (type, ".paral_data_store");
add_referenced_var (*arg_struct);
nvar = create_tmp_var (build_pointer_type (type), ".paral_data_load");
add_referenced_var (nvar);
*new_arg_struct = make_ssa_name (nvar, NULL);
ld_st_data->store = *arg_struct;
ld_st_data->load = *new_arg_struct;
ld_st_data->store_bb = bb0;
ld_st_data->load_bb = bb1;
htab_traverse (name_copies, create_loads_and_stores_for_name,
ld_st_data);
if (reduction_list && htab_elements (reduction_list) > 0)
{
htab_traverse (reduction_list, create_stores_for_reduction,
ld_st_data);
clsn_data.load = make_ssa_name (nvar, NULL);
clsn_data.load_bb = exit->dest;
clsn_data.store = ld_st_data->store;
create_final_loads_for_reduction (reduction_list, &clsn_data);
}
}
htab_delete (decl_copies);
htab_delete (name_copies);
} | [
"static",
"void",
"separate_decls_in_region",
"(",
"edge",
"entry",
",",
"edge",
"exit",
",",
"htab_t",
"reduction_list",
",",
"tree",
"*",
"arg_struct",
",",
"tree",
"*",
"new_arg_struct",
",",
"struct",
"clsn_data",
"*",
"ld_st_data",
")",
"{",
"basic_block",
"bb1",
"=",
"split_edge",
"(",
"entry",
")",
";",
"basic_block",
"bb0",
"=",
"single_pred",
"(",
"bb1",
")",
";",
"htab_t",
"name_copies",
"=",
"htab_create",
"(",
"10",
",",
"name_to_copy_elt_hash",
",",
"name_to_copy_elt_eq",
",",
"free",
")",
";",
"htab_t",
"decl_copies",
"=",
"htab_create",
"(",
"10",
",",
"int_tree_map_hash",
",",
"int_tree_map_eq",
",",
"free",
")",
";",
"unsigned",
"i",
";",
"tree",
"type",
",",
"type_name",
",",
"nvar",
";",
"gimple_stmt_iterator",
"gsi",
";",
"struct",
"clsn_data",
"clsn_data",
";",
"VEC",
"(",
"basic_block",
",",
"heap",
")",
"*",
"body",
"=",
"VEC_alloc",
"(",
"basic_block",
",",
"heap",
",",
"3",
")",
";",
"basic_block",
"bb",
";",
"basic_block",
"entry_bb",
"=",
"bb1",
";",
"basic_block",
"exit_bb",
"=",
"exit",
"->",
"dest",
";",
"bool",
"has_debug_stmt",
"=",
"false",
";",
"entry",
"=",
"single_succ_edge",
"(",
"entry_bb",
")",
";",
"gather_blocks_in_sese_region",
"(",
"entry_bb",
",",
"exit_bb",
",",
"&",
"body",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"basic_block",
",",
"body",
",",
"i",
",",
"bb",
")",
"",
"{",
"if",
"(",
"bb",
"!=",
"entry_bb",
"&&",
"bb",
"!=",
"exit_bb",
")",
"{",
"for",
"(",
"gsi",
"=",
"gsi_start_phis",
"(",
"bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"separate_decls_in_region_stmt",
"(",
"entry",
",",
"exit",
",",
"gsi_stmt",
"(",
"gsi",
")",
",",
"name_copies",
",",
"decl_copies",
")",
";",
"for",
"(",
"gsi",
"=",
"gsi_start_bb",
"(",
"bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"{",
"gimple",
"stmt",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"if",
"(",
"is_gimple_debug",
"(",
"stmt",
")",
")",
"has_debug_stmt",
"=",
"true",
";",
"else",
"separate_decls_in_region_stmt",
"(",
"entry",
",",
"exit",
",",
"stmt",
",",
"name_copies",
",",
"decl_copies",
")",
";",
"}",
"}",
"}",
"if",
"(",
"has_debug_stmt",
")",
"FOR_EACH_VEC_ELT",
"(",
"basic_block",
",",
"body",
",",
"i",
",",
"bb",
")",
"",
"if",
"(",
"bb",
"!=",
"entry_bb",
"&&",
"bb",
"!=",
"exit_bb",
")",
"{",
"for",
"(",
"gsi",
"=",
"gsi_start_bb",
"(",
"bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
")",
"{",
"gimple",
"stmt",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"if",
"(",
"is_gimple_debug",
"(",
"stmt",
")",
")",
"{",
"if",
"(",
"separate_decls_in_region_debug",
"(",
"stmt",
",",
"name_copies",
",",
"decl_copies",
")",
")",
"{",
"gsi_remove",
"(",
"&",
"gsi",
",",
"true",
")",
";",
"continue",
";",
"}",
"}",
"gsi_next",
"(",
"&",
"gsi",
")",
";",
"}",
"}",
"VEC_free",
"(",
"basic_block",
",",
"heap",
",",
"body",
")",
";",
"if",
"(",
"htab_elements",
"(",
"name_copies",
")",
"==",
"0",
"&&",
"htab_elements",
"(",
"reduction_list",
")",
"==",
"0",
")",
"{",
"*",
"arg_struct",
"=",
"NULL",
";",
"*",
"new_arg_struct",
"=",
"NULL",
";",
"}",
"else",
"{",
"type",
"=",
"lang_hooks",
".",
"types",
".",
"make_type",
"(",
"RECORD_TYPE",
")",
";",
"type_name",
"=",
"build_decl",
"(",
"UNKNOWN_LOCATION",
",",
"TYPE_DECL",
",",
"create_tmp_var_name",
"(",
"\"",
"\"",
")",
",",
"type",
")",
";",
"TYPE_NAME",
"(",
"type",
")",
"=",
"type_name",
";",
"htab_traverse",
"(",
"name_copies",
",",
"add_field_for_name",
",",
"type",
")",
";",
"if",
"(",
"reduction_list",
"&&",
"htab_elements",
"(",
"reduction_list",
")",
">",
"0",
")",
"{",
"htab_traverse",
"(",
"reduction_list",
",",
"add_field_for_reduction",
",",
"type",
")",
";",
"}",
"layout_type",
"(",
"type",
")",
";",
"*",
"arg_struct",
"=",
"create_tmp_var",
"(",
"type",
",",
"\"",
"\"",
")",
";",
"add_referenced_var",
"(",
"*",
"arg_struct",
")",
";",
"nvar",
"=",
"create_tmp_var",
"(",
"build_pointer_type",
"(",
"type",
")",
",",
"\"",
"\"",
")",
";",
"add_referenced_var",
"(",
"nvar",
")",
";",
"*",
"new_arg_struct",
"=",
"make_ssa_name",
"(",
"nvar",
",",
"NULL",
")",
";",
"ld_st_data",
"->",
"store",
"=",
"*",
"arg_struct",
";",
"ld_st_data",
"->",
"load",
"=",
"*",
"new_arg_struct",
";",
"ld_st_data",
"->",
"store_bb",
"=",
"bb0",
";",
"ld_st_data",
"->",
"load_bb",
"=",
"bb1",
";",
"htab_traverse",
"(",
"name_copies",
",",
"create_loads_and_stores_for_name",
",",
"ld_st_data",
")",
";",
"if",
"(",
"reduction_list",
"&&",
"htab_elements",
"(",
"reduction_list",
")",
">",
"0",
")",
"{",
"htab_traverse",
"(",
"reduction_list",
",",
"create_stores_for_reduction",
",",
"ld_st_data",
")",
";",
"clsn_data",
".",
"load",
"=",
"make_ssa_name",
"(",
"nvar",
",",
"NULL",
")",
";",
"clsn_data",
".",
"load_bb",
"=",
"exit",
"->",
"dest",
";",
"clsn_data",
".",
"store",
"=",
"ld_st_data",
"->",
"store",
";",
"create_final_loads_for_reduction",
"(",
"reduction_list",
",",
"&",
"clsn_data",
")",
";",
"}",
"}",
"htab_delete",
"(",
"decl_copies",
")",
";",
"htab_delete",
"(",
"name_copies",
")",
";",
"}"
] | Moves all the variables used in LOOP and defined outside of it (including
the initial values of loop phi nodes, and *PER_THREAD if it is a ssa
name) to a structure created for this purpose. | [
"Moves",
"all",
"the",
"variables",
"used",
"in",
"LOOP",
"and",
"defined",
"outside",
"of",
"it",
"(",
"including",
"the",
"initial",
"values",
"of",
"loop",
"phi",
"nodes",
"and",
"*",
"PER_THREAD",
"if",
"it",
"is",
"a",
"ssa",
"name",
")",
"to",
"a",
"structure",
"created",
"for",
"this",
"purpose",
"."
] | [
"/* Now process debug bind stmts. We must not create decls while\n processing debug stmts, so we defer their processing so as to\n make sure we will have debug info for as many variables as\n possible (all of those that were dealt with in the loop above),\n and discard those for which we know there's nothing we can\n do. */",
"/* It may happen that there is nothing to copy (if there are only\n loop carried and external variables in the loop). */",
"/* Create the type for the structure to store the ssa names to. */",
"/* Create the fields for reductions. */",
"/* Create the loads and stores. */",
"/* Load the calculation from memory (after the join of the threads). */"
] | [
{
"param": "entry",
"type": "edge"
},
{
"param": "exit",
"type": "edge"
},
{
"param": "reduction_list",
"type": "htab_t"
},
{
"param": "arg_struct",
"type": "tree"
},
{
"param": "new_arg_struct",
"type": "tree"
},
{
"param": "ld_st_data",
"type": "struct clsn_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exit",
"type": "edge",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg_struct",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_arg_struct",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ld_st_data",
"type": "struct clsn_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | parallelized_function_p | bool | static bool
parallelized_function_p (tree fn)
{
if (!parallelized_functions || !DECL_ARTIFICIAL (fn))
return false;
return bitmap_bit_p (parallelized_functions, DECL_UID (fn));
} | /* Returns true if FN was created by create_loop_fn. */ | Returns true if FN was created by create_loop_fn. | [
"Returns",
"true",
"if",
"FN",
"was",
"created",
"by",
"create_loop_fn",
"."
] | static bool
parallelized_function_p (tree fn)
{
if (!parallelized_functions || !DECL_ARTIFICIAL (fn))
return false;
return bitmap_bit_p (parallelized_functions, DECL_UID (fn));
} | [
"static",
"bool",
"parallelized_function_p",
"(",
"tree",
"fn",
")",
"{",
"if",
"(",
"!",
"parallelized_functions",
"||",
"!",
"DECL_ARTIFICIAL",
"(",
"fn",
")",
")",
"return",
"false",
";",
"return",
"bitmap_bit_p",
"(",
"parallelized_functions",
",",
"DECL_UID",
"(",
"fn",
")",
")",
";",
"}"
] | Returns true if FN was created by create_loop_fn. | [
"Returns",
"true",
"if",
"FN",
"was",
"created",
"by",
"create_loop_fn",
"."
] | [] | [
{
"param": "fn",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fn",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | create_loop_fn | tree | static tree
create_loop_fn (location_t loc)
{
char buf[100];
char *tname;
tree decl, type, name, t;
struct function *act_cfun = cfun;
static unsigned loopfn_num;
snprintf (buf, 100, "%s.$loopfn", current_function_name ());
ASM_FORMAT_PRIVATE_NAME (tname, buf, loopfn_num++);
clean_symbol_name (tname);
name = get_identifier (tname);
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
decl = build_decl (loc, FUNCTION_DECL, name, type);
if (!parallelized_functions)
parallelized_functions = BITMAP_GGC_ALLOC ();
bitmap_set_bit (parallelized_functions, DECL_UID (decl));
TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 0;
TREE_PUBLIC (decl) = 0;
DECL_UNINLINABLE (decl) = 1;
DECL_EXTERNAL (decl) = 0;
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
t = build_decl (loc, RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_RESULT (decl) = t;
t = build_decl (loc, PARM_DECL, get_identifier (".paral_data_param"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
DECL_CONTEXT (t) = decl;
TREE_USED (t) = 1;
DECL_ARGUMENTS (decl) = t;
allocate_struct_function (decl, false);
/* The call to allocate_struct_function clobbers CFUN, so we need to restore
it. */
set_cfun (act_cfun);
return decl;
} | /* Creates and returns an empty function that will receive the body of
a parallelized loop. */ | Creates and returns an empty function that will receive the body of
a parallelized loop. | [
"Creates",
"and",
"returns",
"an",
"empty",
"function",
"that",
"will",
"receive",
"the",
"body",
"of",
"a",
"parallelized",
"loop",
"."
] | static tree
create_loop_fn (location_t loc)
{
char buf[100];
char *tname;
tree decl, type, name, t;
struct function *act_cfun = cfun;
static unsigned loopfn_num;
snprintf (buf, 100, "%s.$loopfn", current_function_name ());
ASM_FORMAT_PRIVATE_NAME (tname, buf, loopfn_num++);
clean_symbol_name (tname);
name = get_identifier (tname);
type = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
decl = build_decl (loc, FUNCTION_DECL, name, type);
if (!parallelized_functions)
parallelized_functions = BITMAP_GGC_ALLOC ();
bitmap_set_bit (parallelized_functions, DECL_UID (decl));
TREE_STATIC (decl) = 1;
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 0;
TREE_PUBLIC (decl) = 0;
DECL_UNINLINABLE (decl) = 1;
DECL_EXTERNAL (decl) = 0;
DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = make_node (BLOCK);
t = build_decl (loc, RESULT_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_IGNORED_P (t) = 1;
DECL_RESULT (decl) = t;
t = build_decl (loc, PARM_DECL, get_identifier (".paral_data_param"),
ptr_type_node);
DECL_ARTIFICIAL (t) = 1;
DECL_ARG_TYPE (t) = ptr_type_node;
DECL_CONTEXT (t) = decl;
TREE_USED (t) = 1;
DECL_ARGUMENTS (decl) = t;
allocate_struct_function (decl, false);
set_cfun (act_cfun);
return decl;
} | [
"static",
"tree",
"create_loop_fn",
"(",
"location_t",
"loc",
")",
"{",
"char",
"buf",
"[",
"100",
"]",
";",
"char",
"*",
"tname",
";",
"tree",
"decl",
",",
"type",
",",
"name",
",",
"t",
";",
"struct",
"function",
"*",
"act_cfun",
"=",
"cfun",
";",
"static",
"unsigned",
"loopfn_num",
";",
"snprintf",
"(",
"buf",
",",
"100",
",",
"\"",
"\"",
",",
"current_function_name",
"(",
")",
")",
";",
"ASM_FORMAT_PRIVATE_NAME",
"(",
"tname",
",",
"buf",
",",
"loopfn_num",
"++",
")",
";",
"clean_symbol_name",
"(",
"tname",
")",
";",
"name",
"=",
"get_identifier",
"(",
"tname",
")",
";",
"type",
"=",
"build_function_type_list",
"(",
"void_type_node",
",",
"ptr_type_node",
",",
"NULL_TREE",
")",
";",
"decl",
"=",
"build_decl",
"(",
"loc",
",",
"FUNCTION_DECL",
",",
"name",
",",
"type",
")",
";",
"if",
"(",
"!",
"parallelized_functions",
")",
"parallelized_functions",
"=",
"BITMAP_GGC_ALLOC",
"(",
")",
";",
"bitmap_set_bit",
"(",
"parallelized_functions",
",",
"DECL_UID",
"(",
"decl",
")",
")",
";",
"TREE_STATIC",
"(",
"decl",
")",
"=",
"1",
";",
"TREE_USED",
"(",
"decl",
")",
"=",
"1",
";",
"DECL_ARTIFICIAL",
"(",
"decl",
")",
"=",
"1",
";",
"DECL_IGNORED_P",
"(",
"decl",
")",
"=",
"0",
";",
"TREE_PUBLIC",
"(",
"decl",
")",
"=",
"0",
";",
"DECL_UNINLINABLE",
"(",
"decl",
")",
"=",
"1",
";",
"DECL_EXTERNAL",
"(",
"decl",
")",
"=",
"0",
";",
"DECL_CONTEXT",
"(",
"decl",
")",
"=",
"NULL_TREE",
";",
"DECL_INITIAL",
"(",
"decl",
")",
"=",
"make_node",
"(",
"BLOCK",
")",
";",
"t",
"=",
"build_decl",
"(",
"loc",
",",
"RESULT_DECL",
",",
"NULL_TREE",
",",
"void_type_node",
")",
";",
"DECL_ARTIFICIAL",
"(",
"t",
")",
"=",
"1",
";",
"DECL_IGNORED_P",
"(",
"t",
")",
"=",
"1",
";",
"DECL_RESULT",
"(",
"decl",
")",
"=",
"t",
";",
"t",
"=",
"build_decl",
"(",
"loc",
",",
"PARM_DECL",
",",
"get_identifier",
"(",
"\"",
"\"",
")",
",",
"ptr_type_node",
")",
";",
"DECL_ARTIFICIAL",
"(",
"t",
")",
"=",
"1",
";",
"DECL_ARG_TYPE",
"(",
"t",
")",
"=",
"ptr_type_node",
";",
"DECL_CONTEXT",
"(",
"t",
")",
"=",
"decl",
";",
"TREE_USED",
"(",
"t",
")",
"=",
"1",
";",
"DECL_ARGUMENTS",
"(",
"decl",
")",
"=",
"t",
";",
"allocate_struct_function",
"(",
"decl",
",",
"false",
")",
";",
"set_cfun",
"(",
"act_cfun",
")",
";",
"return",
"decl",
";",
"}"
] | Creates and returns an empty function that will receive the body of
a parallelized loop. | [
"Creates",
"and",
"returns",
"an",
"empty",
"function",
"that",
"will",
"receive",
"the",
"body",
"of",
"a",
"parallelized",
"loop",
"."
] | [
"/* The call to allocate_struct_function clobbers CFUN, so we need to restore\n it. */"
] | [
{
"param": "loc",
"type": "location_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loc",
"type": "location_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | transform_to_exit_first_loop | void | static void
transform_to_exit_first_loop (struct loop *loop, htab_t reduction_list, tree nit)
{
basic_block *bbs, *nbbs, ex_bb, orig_header;
unsigned n;
bool ok;
edge exit = single_dom_exit (loop), hpred;
tree control, control_name, res, t;
gimple phi, nphi, cond_stmt, stmt, cond_nit;
gimple_stmt_iterator gsi;
tree nit_1;
edge exit_1;
tree new_rhs;
split_block_after_labels (loop->header);
orig_header = single_succ (loop->header);
hpred = single_succ_edge (loop->header);
cond_stmt = last_stmt (exit->src);
control = gimple_cond_lhs (cond_stmt);
gcc_assert (gimple_cond_rhs (cond_stmt) == nit);
/* Make sure that we have phi nodes on exit for all loop header phis
(create_parallel_loop requires that). */
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
phi = gsi_stmt (gsi);
res = PHI_RESULT (phi);
t = make_ssa_name (SSA_NAME_VAR (res), phi);
SET_PHI_RESULT (phi, t);
nphi = create_phi_node (res, orig_header);
SSA_NAME_DEF_STMT (res) = nphi;
add_phi_arg (nphi, t, hpred, UNKNOWN_LOCATION);
if (res == control)
{
gimple_cond_set_lhs (cond_stmt, t);
update_stmt (cond_stmt);
control = t;
}
}
/* Setting the condition towards peeling the last iteration:
If the block consisting of the exit condition has the latch as
successor, then the body of the loop is executed before
the exit condition is tested. In such case, moving the
condition to the entry, causes that the loop will iterate
one less iteration (which is the wanted outcome, since we
peel out the last iteration). If the body is executed after
the condition, moving the condition to the entry requires
decrementing one iteration. */
exit_1 = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit);
if (exit_1->dest == loop->latch)
new_rhs = gimple_cond_rhs (cond_stmt);
else
{
new_rhs = fold_build2 (MINUS_EXPR, TREE_TYPE (gimple_cond_rhs (cond_stmt)),
gimple_cond_rhs (cond_stmt),
build_int_cst (TREE_TYPE (gimple_cond_rhs (cond_stmt)), 1));
if (TREE_CODE (gimple_cond_rhs (cond_stmt)) == SSA_NAME)
{
basic_block preheader;
gimple_stmt_iterator gsi1;
preheader = loop_preheader_edge(loop)->src;
gsi1 = gsi_after_labels (preheader);
new_rhs = force_gimple_operand_gsi (&gsi1, new_rhs, true,
NULL_TREE,false,GSI_CONTINUE_LINKING);
}
}
gimple_cond_set_rhs (cond_stmt, unshare_expr (new_rhs));
gimple_cond_set_lhs (cond_stmt, unshare_expr (gimple_cond_lhs (cond_stmt)));
bbs = get_loop_body_in_dom_order (loop);
for (n = 0; bbs[n] != loop->latch; n++)
continue;
nbbs = XNEWVEC (basic_block, n);
ok = gimple_duplicate_sese_tail (single_succ_edge (loop->header), exit,
bbs + 1, n, nbbs);
gcc_assert (ok);
free (bbs);
ex_bb = nbbs[0];
free (nbbs);
/* Other than reductions, the only gimple reg that should be copied
out of the loop is the control variable. */
control_name = NULL_TREE;
for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); )
{
phi = gsi_stmt (gsi);
res = PHI_RESULT (phi);
if (!is_gimple_reg (res))
{
gsi_next (&gsi);
continue;
}
/* Check if it is a part of reduction. If it is,
keep the phi at the reduction's keep_res field. The
PHI_RESULT of this phi is the resulting value of the reduction
variable when exiting the loop. */
exit = single_dom_exit (loop);
if (htab_elements (reduction_list) > 0)
{
struct reduction_info *red;
tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
red = reduction_phi (reduction_list, SSA_NAME_DEF_STMT (val));
if (red)
{
red->keep_res = phi;
gsi_next (&gsi);
continue;
}
}
gcc_assert (control_name == NULL_TREE
&& SSA_NAME_VAR (res) == SSA_NAME_VAR (control));
control_name = res;
remove_phi_node (&gsi, false);
}
gcc_assert (control_name != NULL_TREE);
/* Initialize the control variable to number of iterations
according to the rhs of the exit condition. */
gsi = gsi_after_labels (ex_bb);
cond_nit = last_stmt (exit->src);
nit_1 = gimple_cond_rhs (cond_nit);
nit_1 = force_gimple_operand_gsi (&gsi,
fold_convert (TREE_TYPE (control_name), nit_1),
false, NULL_TREE, false, GSI_SAME_STMT);
stmt = gimple_build_assign (control_name, nit_1);
gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (control_name) = stmt;
} | /* Moves the exit condition of LOOP to the beginning of its header, and
duplicates the part of the last iteration that gets disabled to the
exit of the loop. NIT is the number of iterations of the loop
(used to initialize the variables in the duplicated part).
TODO: the common case is that latch of the loop is empty and immediately
follows the loop exit. In this case, it would be better not to copy the
body of the loop, but only move the entry of the loop directly before the
exit check and increase the number of iterations of the loop by one.
This may need some additional preconditioning in case NIT = ~0.
REDUCTION_LIST describes the reductions in LOOP. */ | Moves the exit condition of LOOP to the beginning of its header, and
duplicates the part of the last iteration that gets disabled to the
exit of the loop. NIT is the number of iterations of the loop
(used to initialize the variables in the duplicated part).
the common case is that latch of the loop is empty and immediately
follows the loop exit. In this case, it would be better not to copy the
body of the loop, but only move the entry of the loop directly before the
exit check and increase the number of iterations of the loop by one.
This may need some additional preconditioning in case NIT = ~0.
REDUCTION_LIST describes the reductions in LOOP. | [
"Moves",
"the",
"exit",
"condition",
"of",
"LOOP",
"to",
"the",
"beginning",
"of",
"its",
"header",
"and",
"duplicates",
"the",
"part",
"of",
"the",
"last",
"iteration",
"that",
"gets",
"disabled",
"to",
"the",
"exit",
"of",
"the",
"loop",
".",
"NIT",
"is",
"the",
"number",
"of",
"iterations",
"of",
"the",
"loop",
"(",
"used",
"to",
"initialize",
"the",
"variables",
"in",
"the",
"duplicated",
"part",
")",
".",
"the",
"common",
"case",
"is",
"that",
"latch",
"of",
"the",
"loop",
"is",
"empty",
"and",
"immediately",
"follows",
"the",
"loop",
"exit",
".",
"In",
"this",
"case",
"it",
"would",
"be",
"better",
"not",
"to",
"copy",
"the",
"body",
"of",
"the",
"loop",
"but",
"only",
"move",
"the",
"entry",
"of",
"the",
"loop",
"directly",
"before",
"the",
"exit",
"check",
"and",
"increase",
"the",
"number",
"of",
"iterations",
"of",
"the",
"loop",
"by",
"one",
".",
"This",
"may",
"need",
"some",
"additional",
"preconditioning",
"in",
"case",
"NIT",
"=",
"~0",
".",
"REDUCTION_LIST",
"describes",
"the",
"reductions",
"in",
"LOOP",
"."
] | static void
transform_to_exit_first_loop (struct loop *loop, htab_t reduction_list, tree nit)
{
basic_block *bbs, *nbbs, ex_bb, orig_header;
unsigned n;
bool ok;
edge exit = single_dom_exit (loop), hpred;
tree control, control_name, res, t;
gimple phi, nphi, cond_stmt, stmt, cond_nit;
gimple_stmt_iterator gsi;
tree nit_1;
edge exit_1;
tree new_rhs;
split_block_after_labels (loop->header);
orig_header = single_succ (loop->header);
hpred = single_succ_edge (loop->header);
cond_stmt = last_stmt (exit->src);
control = gimple_cond_lhs (cond_stmt);
gcc_assert (gimple_cond_rhs (cond_stmt) == nit);
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
phi = gsi_stmt (gsi);
res = PHI_RESULT (phi);
t = make_ssa_name (SSA_NAME_VAR (res), phi);
SET_PHI_RESULT (phi, t);
nphi = create_phi_node (res, orig_header);
SSA_NAME_DEF_STMT (res) = nphi;
add_phi_arg (nphi, t, hpred, UNKNOWN_LOCATION);
if (res == control)
{
gimple_cond_set_lhs (cond_stmt, t);
update_stmt (cond_stmt);
control = t;
}
}
exit_1 = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit);
if (exit_1->dest == loop->latch)
new_rhs = gimple_cond_rhs (cond_stmt);
else
{
new_rhs = fold_build2 (MINUS_EXPR, TREE_TYPE (gimple_cond_rhs (cond_stmt)),
gimple_cond_rhs (cond_stmt),
build_int_cst (TREE_TYPE (gimple_cond_rhs (cond_stmt)), 1));
if (TREE_CODE (gimple_cond_rhs (cond_stmt)) == SSA_NAME)
{
basic_block preheader;
gimple_stmt_iterator gsi1;
preheader = loop_preheader_edge(loop)->src;
gsi1 = gsi_after_labels (preheader);
new_rhs = force_gimple_operand_gsi (&gsi1, new_rhs, true,
NULL_TREE,false,GSI_CONTINUE_LINKING);
}
}
gimple_cond_set_rhs (cond_stmt, unshare_expr (new_rhs));
gimple_cond_set_lhs (cond_stmt, unshare_expr (gimple_cond_lhs (cond_stmt)));
bbs = get_loop_body_in_dom_order (loop);
for (n = 0; bbs[n] != loop->latch; n++)
continue;
nbbs = XNEWVEC (basic_block, n);
ok = gimple_duplicate_sese_tail (single_succ_edge (loop->header), exit,
bbs + 1, n, nbbs);
gcc_assert (ok);
free (bbs);
ex_bb = nbbs[0];
free (nbbs);
control_name = NULL_TREE;
for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); )
{
phi = gsi_stmt (gsi);
res = PHI_RESULT (phi);
if (!is_gimple_reg (res))
{
gsi_next (&gsi);
continue;
}
exit = single_dom_exit (loop);
if (htab_elements (reduction_list) > 0)
{
struct reduction_info *red;
tree val = PHI_ARG_DEF_FROM_EDGE (phi, exit);
red = reduction_phi (reduction_list, SSA_NAME_DEF_STMT (val));
if (red)
{
red->keep_res = phi;
gsi_next (&gsi);
continue;
}
}
gcc_assert (control_name == NULL_TREE
&& SSA_NAME_VAR (res) == SSA_NAME_VAR (control));
control_name = res;
remove_phi_node (&gsi, false);
}
gcc_assert (control_name != NULL_TREE);
gsi = gsi_after_labels (ex_bb);
cond_nit = last_stmt (exit->src);
nit_1 = gimple_cond_rhs (cond_nit);
nit_1 = force_gimple_operand_gsi (&gsi,
fold_convert (TREE_TYPE (control_name), nit_1),
false, NULL_TREE, false, GSI_SAME_STMT);
stmt = gimple_build_assign (control_name, nit_1);
gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (control_name) = stmt;
} | [
"static",
"void",
"transform_to_exit_first_loop",
"(",
"struct",
"loop",
"*",
"loop",
",",
"htab_t",
"reduction_list",
",",
"tree",
"nit",
")",
"{",
"basic_block",
"*",
"bbs",
",",
"*",
"nbbs",
",",
"ex_bb",
",",
"orig_header",
";",
"unsigned",
"n",
";",
"bool",
"ok",
";",
"edge",
"exit",
"=",
"single_dom_exit",
"(",
"loop",
")",
",",
"hpred",
";",
"tree",
"control",
",",
"control_name",
",",
"res",
",",
"t",
";",
"gimple",
"phi",
",",
"nphi",
",",
"cond_stmt",
",",
"stmt",
",",
"cond_nit",
";",
"gimple_stmt_iterator",
"gsi",
";",
"tree",
"nit_1",
";",
"edge",
"exit_1",
";",
"tree",
"new_rhs",
";",
"split_block_after_labels",
"(",
"loop",
"->",
"header",
")",
";",
"orig_header",
"=",
"single_succ",
"(",
"loop",
"->",
"header",
")",
";",
"hpred",
"=",
"single_succ_edge",
"(",
"loop",
"->",
"header",
")",
";",
"cond_stmt",
"=",
"last_stmt",
"(",
"exit",
"->",
"src",
")",
";",
"control",
"=",
"gimple_cond_lhs",
"(",
"cond_stmt",
")",
";",
"gcc_assert",
"(",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
"==",
"nit",
")",
";",
"for",
"(",
"gsi",
"=",
"gsi_start_phis",
"(",
"loop",
"->",
"header",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"{",
"phi",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"res",
"=",
"PHI_RESULT",
"(",
"phi",
")",
";",
"t",
"=",
"make_ssa_name",
"(",
"SSA_NAME_VAR",
"(",
"res",
")",
",",
"phi",
")",
";",
"SET_PHI_RESULT",
"(",
"phi",
",",
"t",
")",
";",
"nphi",
"=",
"create_phi_node",
"(",
"res",
",",
"orig_header",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"res",
")",
"=",
"nphi",
";",
"add_phi_arg",
"(",
"nphi",
",",
"t",
",",
"hpred",
",",
"UNKNOWN_LOCATION",
")",
";",
"if",
"(",
"res",
"==",
"control",
")",
"{",
"gimple_cond_set_lhs",
"(",
"cond_stmt",
",",
"t",
")",
";",
"update_stmt",
"(",
"cond_stmt",
")",
";",
"control",
"=",
"t",
";",
"}",
"}",
"exit_1",
"=",
"EDGE_SUCC",
"(",
"exit",
"->",
"src",
",",
"EDGE_SUCC",
"(",
"exit",
"->",
"src",
",",
"0",
")",
"==",
"exit",
")",
";",
"if",
"(",
"exit_1",
"->",
"dest",
"==",
"loop",
"->",
"latch",
")",
"new_rhs",
"=",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
";",
"else",
"{",
"new_rhs",
"=",
"fold_build2",
"(",
"MINUS_EXPR",
",",
"TREE_TYPE",
"(",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
")",
",",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
",",
"build_int_cst",
"(",
"TREE_TYPE",
"(",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
")",
",",
"1",
")",
")",
";",
"if",
"(",
"TREE_CODE",
"(",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
")",
"==",
"SSA_NAME",
")",
"{",
"basic_block",
"preheader",
";",
"gimple_stmt_iterator",
"gsi1",
";",
"preheader",
"=",
"loop_preheader_edge",
"(",
"loop",
")",
"->",
"src",
";",
"gsi1",
"=",
"gsi_after_labels",
"(",
"preheader",
")",
";",
"new_rhs",
"=",
"force_gimple_operand_gsi",
"(",
"&",
"gsi1",
",",
"new_rhs",
",",
"true",
",",
"NULL_TREE",
",",
"false",
",",
"GSI_CONTINUE_LINKING",
")",
";",
"}",
"}",
"gimple_cond_set_rhs",
"(",
"cond_stmt",
",",
"unshare_expr",
"(",
"new_rhs",
")",
")",
";",
"gimple_cond_set_lhs",
"(",
"cond_stmt",
",",
"unshare_expr",
"(",
"gimple_cond_lhs",
"(",
"cond_stmt",
")",
")",
")",
";",
"bbs",
"=",
"get_loop_body_in_dom_order",
"(",
"loop",
")",
";",
"for",
"(",
"n",
"=",
"0",
";",
"bbs",
"[",
"n",
"]",
"!=",
"loop",
"->",
"latch",
";",
"n",
"++",
")",
"continue",
";",
"nbbs",
"=",
"XNEWVEC",
"(",
"basic_block",
",",
"n",
")",
";",
"ok",
"=",
"gimple_duplicate_sese_tail",
"(",
"single_succ_edge",
"(",
"loop",
"->",
"header",
")",
",",
"exit",
",",
"bbs",
"+",
"1",
",",
"n",
",",
"nbbs",
")",
";",
"gcc_assert",
"(",
"ok",
")",
";",
"free",
"(",
"bbs",
")",
";",
"ex_bb",
"=",
"nbbs",
"[",
"0",
"]",
";",
"free",
"(",
"nbbs",
")",
";",
"control_name",
"=",
"NULL_TREE",
";",
"for",
"(",
"gsi",
"=",
"gsi_start_phis",
"(",
"ex_bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
")",
"{",
"phi",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"res",
"=",
"PHI_RESULT",
"(",
"phi",
")",
";",
"if",
"(",
"!",
"is_gimple_reg",
"(",
"res",
")",
")",
"{",
"gsi_next",
"(",
"&",
"gsi",
")",
";",
"continue",
";",
"}",
"exit",
"=",
"single_dom_exit",
"(",
"loop",
")",
";",
"if",
"(",
"htab_elements",
"(",
"reduction_list",
")",
">",
"0",
")",
"{",
"struct",
"reduction_info",
"*",
"red",
";",
"tree",
"val",
"=",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"phi",
",",
"exit",
")",
";",
"red",
"=",
"reduction_phi",
"(",
"reduction_list",
",",
"SSA_NAME_DEF_STMT",
"(",
"val",
")",
")",
";",
"if",
"(",
"red",
")",
"{",
"red",
"->",
"keep_res",
"=",
"phi",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
";",
"continue",
";",
"}",
"}",
"gcc_assert",
"(",
"control_name",
"==",
"NULL_TREE",
"&&",
"SSA_NAME_VAR",
"(",
"res",
")",
"==",
"SSA_NAME_VAR",
"(",
"control",
")",
")",
";",
"control_name",
"=",
"res",
";",
"remove_phi_node",
"(",
"&",
"gsi",
",",
"false",
")",
";",
"}",
"gcc_assert",
"(",
"control_name",
"!=",
"NULL_TREE",
")",
";",
"gsi",
"=",
"gsi_after_labels",
"(",
"ex_bb",
")",
";",
"cond_nit",
"=",
"last_stmt",
"(",
"exit",
"->",
"src",
")",
";",
"nit_1",
"=",
"gimple_cond_rhs",
"(",
"cond_nit",
")",
";",
"nit_1",
"=",
"force_gimple_operand_gsi",
"(",
"&",
"gsi",
",",
"fold_convert",
"(",
"TREE_TYPE",
"(",
"control_name",
")",
",",
"nit_1",
")",
",",
"false",
",",
"NULL_TREE",
",",
"false",
",",
"GSI_SAME_STMT",
")",
";",
"stmt",
"=",
"gimple_build_assign",
"(",
"control_name",
",",
"nit_1",
")",
";",
"gsi_insert_before",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"control_name",
")",
"=",
"stmt",
";",
"}"
] | Moves the exit condition of LOOP to the beginning of its header, and
duplicates the part of the last iteration that gets disabled to the
exit of the loop. | [
"Moves",
"the",
"exit",
"condition",
"of",
"LOOP",
"to",
"the",
"beginning",
"of",
"its",
"header",
"and",
"duplicates",
"the",
"part",
"of",
"the",
"last",
"iteration",
"that",
"gets",
"disabled",
"to",
"the",
"exit",
"of",
"the",
"loop",
"."
] | [
"/* Make sure that we have phi nodes on exit for all loop header phis\n (create_parallel_loop requires that). */",
"/* Setting the condition towards peeling the last iteration:\n If the block consisting of the exit condition has the latch as\n successor, then the body of the loop is executed before\n the exit condition is tested. In such case, moving the\n condition to the entry, causes that the loop will iterate\n one less iteration (which is the wanted outcome, since we\n peel out the last iteration). If the body is executed after\n the condition, moving the condition to the entry requires\n decrementing one iteration. */",
"/* Other than reductions, the only gimple reg that should be copied\n out of the loop is the control variable. */",
"/* Check if it is a part of reduction. If it is,\n keep the phi at the reduction's keep_res field. The\n PHI_RESULT of this phi is the resulting value of the reduction\n variable when exiting the loop. */",
"/* Initialize the control variable to number of iterations\n according to the rhs of the exit condition. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "reduction_list",
"type": "htab_t"
},
{
"param": "nit",
"type": "tree"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nit",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | create_parallel_loop | basic_block | static basic_block
create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
tree new_data, unsigned n_threads, location_t loc)
{
gimple_stmt_iterator gsi;
basic_block bb, paral_bb, for_bb, ex_bb;
tree t, param;
gimple stmt, for_stmt, phi, cond_stmt;
tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
edge exit, nexit, guard, end, e;
/* Prepare the GIMPLE_OMP_PARALLEL statement. */
bb = loop_preheader_edge (loop)->src;
paral_bb = single_pred (bb);
gsi = gsi_last_bb (paral_bb);
t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (t)
= build_int_cst (integer_type_node, n_threads);
stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
/* Initialize NEW_DATA. */
if (data)
{
gsi = gsi_after_labels (bb);
param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL);
stmt = gimple_build_assign (param, build_fold_addr_expr (data));
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
SSA_NAME_DEF_STMT (param) = stmt;
stmt = gimple_build_assign (new_data,
fold_convert (TREE_TYPE (new_data), param));
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
SSA_NAME_DEF_STMT (new_data) = stmt;
}
/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL. */
bb = split_loop_exit_edge (single_dom_exit (loop));
gsi = gsi_last_bb (bb);
stmt = gimple_build_omp_return (false);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
/* Extract data for GIMPLE_OMP_FOR. */
gcc_assert (loop->header == single_dom_exit (loop)->src);
cond_stmt = last_stmt (loop->header);
cvar = gimple_cond_lhs (cond_stmt);
cvar_base = SSA_NAME_VAR (cvar);
phi = SSA_NAME_DEF_STMT (cvar);
cvar_init = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
initvar = make_ssa_name (cvar_base, NULL);
SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, loop_preheader_edge (loop)),
initvar);
cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
gsi = gsi_last_nondebug_bb (loop->latch);
gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next));
gsi_remove (&gsi, true);
/* Prepare cfg. */
for_bb = split_edge (loop_preheader_edge (loop));
ex_bb = split_loop_exit_edge (single_dom_exit (loop));
extract_true_false_edges_from_block (loop->header, &nexit, &exit);
gcc_assert (exit == single_dom_exit (loop));
guard = make_edge (for_bb, ex_bb, 0);
single_succ_edge (loop->latch)->flags = 0;
end = make_edge (loop->latch, ex_bb, EDGE_FALLTHRU);
for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
source_location locus;
tree def;
phi = gsi_stmt (gsi);
stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
locus = gimple_phi_arg_location_from_edge (stmt,
loop_preheader_edge (loop));
add_phi_arg (phi, def, guard, locus);
def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_latch_edge (loop));
locus = gimple_phi_arg_location_from_edge (stmt, loop_latch_edge (loop));
add_phi_arg (phi, def, end, locus);
}
e = redirect_edge_and_branch (exit, nexit->dest);
PENDING_STMT (e) = NULL;
/* Emit GIMPLE_OMP_FOR. */
gimple_cond_set_lhs (cond_stmt, cvar_base);
type = TREE_TYPE (cvar);
t = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
for_stmt = gimple_build_omp_for (NULL, t, 1, NULL);
gimple_set_location (for_stmt, loc);
gimple_omp_for_set_index (for_stmt, 0, initvar);
gimple_omp_for_set_initial (for_stmt, 0, cvar_init);
gimple_omp_for_set_final (for_stmt, 0, gimple_cond_rhs (cond_stmt));
gimple_omp_for_set_cond (for_stmt, 0, gimple_cond_code (cond_stmt));
gimple_omp_for_set_incr (for_stmt, 0, build2 (PLUS_EXPR, type,
cvar_base,
build_int_cst (type, 1)));
gsi = gsi_last_bb (for_bb);
gsi_insert_after (&gsi, for_stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (initvar) = for_stmt;
/* Emit GIMPLE_OMP_CONTINUE. */
gsi = gsi_last_bb (loop->latch);
stmt = gimple_build_omp_continue (cvar_next, cvar);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (cvar_next) = stmt;
/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR. */
gsi = gsi_last_bb (ex_bb);
stmt = gimple_build_omp_return (true);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
return paral_bb;
} | /* Create the parallel constructs for LOOP as described in gen_parallel_loop.
LOOP_FN and DATA are the arguments of GIMPLE_OMP_PARALLEL.
NEW_DATA is the variable that should be initialized from the argument
of LOOP_FN. N_THREADS is the requested number of threads. Returns the
basic block containing GIMPLE_OMP_PARALLEL tree. */ | Create the parallel constructs for LOOP as described in gen_parallel_loop.
LOOP_FN and DATA are the arguments of GIMPLE_OMP_PARALLEL.
NEW_DATA is the variable that should be initialized from the argument
of LOOP_FN. N_THREADS is the requested number of threads. Returns the
basic block containing GIMPLE_OMP_PARALLEL tree. | [
"Create",
"the",
"parallel",
"constructs",
"for",
"LOOP",
"as",
"described",
"in",
"gen_parallel_loop",
".",
"LOOP_FN",
"and",
"DATA",
"are",
"the",
"arguments",
"of",
"GIMPLE_OMP_PARALLEL",
".",
"NEW_DATA",
"is",
"the",
"variable",
"that",
"should",
"be",
"initialized",
"from",
"the",
"argument",
"of",
"LOOP_FN",
".",
"N_THREADS",
"is",
"the",
"requested",
"number",
"of",
"threads",
".",
"Returns",
"the",
"basic",
"block",
"containing",
"GIMPLE_OMP_PARALLEL",
"tree",
"."
] | static basic_block
create_parallel_loop (struct loop *loop, tree loop_fn, tree data,
tree new_data, unsigned n_threads, location_t loc)
{
gimple_stmt_iterator gsi;
basic_block bb, paral_bb, for_bb, ex_bb;
tree t, param;
gimple stmt, for_stmt, phi, cond_stmt;
tree cvar, cvar_init, initvar, cvar_next, cvar_base, type;
edge exit, nexit, guard, end, e;
bb = loop_preheader_edge (loop)->src;
paral_bb = single_pred (bb);
gsi = gsi_last_bb (paral_bb);
t = build_omp_clause (loc, OMP_CLAUSE_NUM_THREADS);
OMP_CLAUSE_NUM_THREADS_EXPR (t)
= build_int_cst (integer_type_node, n_threads);
stmt = gimple_build_omp_parallel (NULL, t, loop_fn, data);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
if (data)
{
gsi = gsi_after_labels (bb);
param = make_ssa_name (DECL_ARGUMENTS (loop_fn), NULL);
stmt = gimple_build_assign (param, build_fold_addr_expr (data));
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
SSA_NAME_DEF_STMT (param) = stmt;
stmt = gimple_build_assign (new_data,
fold_convert (TREE_TYPE (new_data), param));
gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
SSA_NAME_DEF_STMT (new_data) = stmt;
}
bb = split_loop_exit_edge (single_dom_exit (loop));
gsi = gsi_last_bb (bb);
stmt = gimple_build_omp_return (false);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
gcc_assert (loop->header == single_dom_exit (loop)->src);
cond_stmt = last_stmt (loop->header);
cvar = gimple_cond_lhs (cond_stmt);
cvar_base = SSA_NAME_VAR (cvar);
phi = SSA_NAME_DEF_STMT (cvar);
cvar_init = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
initvar = make_ssa_name (cvar_base, NULL);
SET_USE (PHI_ARG_DEF_PTR_FROM_EDGE (phi, loop_preheader_edge (loop)),
initvar);
cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
gsi = gsi_last_nondebug_bb (loop->latch);
gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next));
gsi_remove (&gsi, true);
for_bb = split_edge (loop_preheader_edge (loop));
ex_bb = split_loop_exit_edge (single_dom_exit (loop));
extract_true_false_edges_from_block (loop->header, &nexit, &exit);
gcc_assert (exit == single_dom_exit (loop));
guard = make_edge (for_bb, ex_bb, 0);
single_succ_edge (loop->latch)->flags = 0;
end = make_edge (loop->latch, ex_bb, EDGE_FALLTHRU);
for (gsi = gsi_start_phis (ex_bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
source_location locus;
tree def;
phi = gsi_stmt (gsi);
stmt = SSA_NAME_DEF_STMT (PHI_ARG_DEF_FROM_EDGE (phi, exit));
def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_preheader_edge (loop));
locus = gimple_phi_arg_location_from_edge (stmt,
loop_preheader_edge (loop));
add_phi_arg (phi, def, guard, locus);
def = PHI_ARG_DEF_FROM_EDGE (stmt, loop_latch_edge (loop));
locus = gimple_phi_arg_location_from_edge (stmt, loop_latch_edge (loop));
add_phi_arg (phi, def, end, locus);
}
e = redirect_edge_and_branch (exit, nexit->dest);
PENDING_STMT (e) = NULL;
gimple_cond_set_lhs (cond_stmt, cvar_base);
type = TREE_TYPE (cvar);
t = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE);
OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC;
for_stmt = gimple_build_omp_for (NULL, t, 1, NULL);
gimple_set_location (for_stmt, loc);
gimple_omp_for_set_index (for_stmt, 0, initvar);
gimple_omp_for_set_initial (for_stmt, 0, cvar_init);
gimple_omp_for_set_final (for_stmt, 0, gimple_cond_rhs (cond_stmt));
gimple_omp_for_set_cond (for_stmt, 0, gimple_cond_code (cond_stmt));
gimple_omp_for_set_incr (for_stmt, 0, build2 (PLUS_EXPR, type,
cvar_base,
build_int_cst (type, 1)));
gsi = gsi_last_bb (for_bb);
gsi_insert_after (&gsi, for_stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (initvar) = for_stmt;
gsi = gsi_last_bb (loop->latch);
stmt = gimple_build_omp_continue (cvar_next, cvar);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
SSA_NAME_DEF_STMT (cvar_next) = stmt;
gsi = gsi_last_bb (ex_bb);
stmt = gimple_build_omp_return (true);
gimple_set_location (stmt, loc);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
return paral_bb;
} | [
"static",
"basic_block",
"create_parallel_loop",
"(",
"struct",
"loop",
"*",
"loop",
",",
"tree",
"loop_fn",
",",
"tree",
"data",
",",
"tree",
"new_data",
",",
"unsigned",
"n_threads",
",",
"location_t",
"loc",
")",
"{",
"gimple_stmt_iterator",
"gsi",
";",
"basic_block",
"bb",
",",
"paral_bb",
",",
"for_bb",
",",
"ex_bb",
";",
"tree",
"t",
",",
"param",
";",
"gimple",
"stmt",
",",
"for_stmt",
",",
"phi",
",",
"cond_stmt",
";",
"tree",
"cvar",
",",
"cvar_init",
",",
"initvar",
",",
"cvar_next",
",",
"cvar_base",
",",
"type",
";",
"edge",
"exit",
",",
"nexit",
",",
"guard",
",",
"end",
",",
"e",
";",
"bb",
"=",
"loop_preheader_edge",
"(",
"loop",
")",
"->",
"src",
";",
"paral_bb",
"=",
"single_pred",
"(",
"bb",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"paral_bb",
")",
";",
"t",
"=",
"build_omp_clause",
"(",
"loc",
",",
"OMP_CLAUSE_NUM_THREADS",
")",
";",
"OMP_CLAUSE_NUM_THREADS_EXPR",
"(",
"t",
")",
"=",
"build_int_cst",
"(",
"integer_type_node",
",",
"n_threads",
")",
";",
"stmt",
"=",
"gimple_build_omp_parallel",
"(",
"NULL",
",",
"t",
",",
"loop_fn",
",",
"data",
")",
";",
"gimple_set_location",
"(",
"stmt",
",",
"loc",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"if",
"(",
"data",
")",
"{",
"gsi",
"=",
"gsi_after_labels",
"(",
"bb",
")",
";",
"param",
"=",
"make_ssa_name",
"(",
"DECL_ARGUMENTS",
"(",
"loop_fn",
")",
",",
"NULL",
")",
";",
"stmt",
"=",
"gimple_build_assign",
"(",
"param",
",",
"build_fold_addr_expr",
"(",
"data",
")",
")",
";",
"gsi_insert_before",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_SAME_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"param",
")",
"=",
"stmt",
";",
"stmt",
"=",
"gimple_build_assign",
"(",
"new_data",
",",
"fold_convert",
"(",
"TREE_TYPE",
"(",
"new_data",
")",
",",
"param",
")",
")",
";",
"gsi_insert_before",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_SAME_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"new_data",
")",
"=",
"stmt",
";",
"}",
"bb",
"=",
"split_loop_exit_edge",
"(",
"single_dom_exit",
"(",
"loop",
")",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"bb",
")",
";",
"stmt",
"=",
"gimple_build_omp_return",
"(",
"false",
")",
";",
"gimple_set_location",
"(",
"stmt",
",",
"loc",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"gcc_assert",
"(",
"loop",
"->",
"header",
"==",
"single_dom_exit",
"(",
"loop",
")",
"->",
"src",
")",
";",
"cond_stmt",
"=",
"last_stmt",
"(",
"loop",
"->",
"header",
")",
";",
"cvar",
"=",
"gimple_cond_lhs",
"(",
"cond_stmt",
")",
";",
"cvar_base",
"=",
"SSA_NAME_VAR",
"(",
"cvar",
")",
";",
"phi",
"=",
"SSA_NAME_DEF_STMT",
"(",
"cvar",
")",
";",
"cvar_init",
"=",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"phi",
",",
"loop_preheader_edge",
"(",
"loop",
")",
")",
";",
"initvar",
"=",
"make_ssa_name",
"(",
"cvar_base",
",",
"NULL",
")",
";",
"SET_USE",
"(",
"PHI_ARG_DEF_PTR_FROM_EDGE",
"(",
"phi",
",",
"loop_preheader_edge",
"(",
"loop",
")",
")",
",",
"initvar",
")",
";",
"cvar_next",
"=",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"phi",
",",
"loop_latch_edge",
"(",
"loop",
")",
")",
";",
"gsi",
"=",
"gsi_last_nondebug_bb",
"(",
"loop",
"->",
"latch",
")",
";",
"gcc_assert",
"(",
"gsi_stmt",
"(",
"gsi",
")",
"==",
"SSA_NAME_DEF_STMT",
"(",
"cvar_next",
")",
")",
";",
"gsi_remove",
"(",
"&",
"gsi",
",",
"true",
")",
";",
"for_bb",
"=",
"split_edge",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
")",
";",
"ex_bb",
"=",
"split_loop_exit_edge",
"(",
"single_dom_exit",
"(",
"loop",
")",
")",
";",
"extract_true_false_edges_from_block",
"(",
"loop",
"->",
"header",
",",
"&",
"nexit",
",",
"&",
"exit",
")",
";",
"gcc_assert",
"(",
"exit",
"==",
"single_dom_exit",
"(",
"loop",
")",
")",
";",
"guard",
"=",
"make_edge",
"(",
"for_bb",
",",
"ex_bb",
",",
"0",
")",
";",
"single_succ_edge",
"(",
"loop",
"->",
"latch",
")",
"->",
"flags",
"=",
"0",
";",
"end",
"=",
"make_edge",
"(",
"loop",
"->",
"latch",
",",
"ex_bb",
",",
"EDGE_FALLTHRU",
")",
";",
"for",
"(",
"gsi",
"=",
"gsi_start_phis",
"(",
"ex_bb",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"{",
"source_location",
"locus",
";",
"tree",
"def",
";",
"phi",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"stmt",
"=",
"SSA_NAME_DEF_STMT",
"(",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"phi",
",",
"exit",
")",
")",
";",
"def",
"=",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"stmt",
",",
"loop_preheader_edge",
"(",
"loop",
")",
")",
";",
"locus",
"=",
"gimple_phi_arg_location_from_edge",
"(",
"stmt",
",",
"loop_preheader_edge",
"(",
"loop",
")",
")",
";",
"add_phi_arg",
"(",
"phi",
",",
"def",
",",
"guard",
",",
"locus",
")",
";",
"def",
"=",
"PHI_ARG_DEF_FROM_EDGE",
"(",
"stmt",
",",
"loop_latch_edge",
"(",
"loop",
")",
")",
";",
"locus",
"=",
"gimple_phi_arg_location_from_edge",
"(",
"stmt",
",",
"loop_latch_edge",
"(",
"loop",
")",
")",
";",
"add_phi_arg",
"(",
"phi",
",",
"def",
",",
"end",
",",
"locus",
")",
";",
"}",
"e",
"=",
"redirect_edge_and_branch",
"(",
"exit",
",",
"nexit",
"->",
"dest",
")",
";",
"PENDING_STMT",
"(",
"e",
")",
"=",
"NULL",
";",
"gimple_cond_set_lhs",
"(",
"cond_stmt",
",",
"cvar_base",
")",
";",
"type",
"=",
"TREE_TYPE",
"(",
"cvar",
")",
";",
"t",
"=",
"build_omp_clause",
"(",
"loc",
",",
"OMP_CLAUSE_SCHEDULE",
")",
";",
"OMP_CLAUSE_SCHEDULE_KIND",
"(",
"t",
")",
"=",
"OMP_CLAUSE_SCHEDULE_STATIC",
";",
"for_stmt",
"=",
"gimple_build_omp_for",
"(",
"NULL",
",",
"t",
",",
"1",
",",
"NULL",
")",
";",
"gimple_set_location",
"(",
"for_stmt",
",",
"loc",
")",
";",
"gimple_omp_for_set_index",
"(",
"for_stmt",
",",
"0",
",",
"initvar",
")",
";",
"gimple_omp_for_set_initial",
"(",
"for_stmt",
",",
"0",
",",
"cvar_init",
")",
";",
"gimple_omp_for_set_final",
"(",
"for_stmt",
",",
"0",
",",
"gimple_cond_rhs",
"(",
"cond_stmt",
")",
")",
";",
"gimple_omp_for_set_cond",
"(",
"for_stmt",
",",
"0",
",",
"gimple_cond_code",
"(",
"cond_stmt",
")",
")",
";",
"gimple_omp_for_set_incr",
"(",
"for_stmt",
",",
"0",
",",
"build2",
"(",
"PLUS_EXPR",
",",
"type",
",",
"cvar_base",
",",
"build_int_cst",
"(",
"type",
",",
"1",
")",
")",
")",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"for_bb",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"for_stmt",
",",
"GSI_NEW_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"initvar",
")",
"=",
"for_stmt",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"loop",
"->",
"latch",
")",
";",
"stmt",
"=",
"gimple_build_omp_continue",
"(",
"cvar_next",
",",
"cvar",
")",
";",
"gimple_set_location",
"(",
"stmt",
",",
"loc",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"SSA_NAME_DEF_STMT",
"(",
"cvar_next",
")",
"=",
"stmt",
";",
"gsi",
"=",
"gsi_last_bb",
"(",
"ex_bb",
")",
";",
"stmt",
"=",
"gimple_build_omp_return",
"(",
"true",
")",
";",
"gimple_set_location",
"(",
"stmt",
",",
"loc",
")",
";",
"gsi_insert_after",
"(",
"&",
"gsi",
",",
"stmt",
",",
"GSI_NEW_STMT",
")",
";",
"return",
"paral_bb",
";",
"}"
] | Create the parallel constructs for LOOP as described in gen_parallel_loop. | [
"Create",
"the",
"parallel",
"constructs",
"for",
"LOOP",
"as",
"described",
"in",
"gen_parallel_loop",
"."
] | [
"/* Prepare the GIMPLE_OMP_PARALLEL statement. */",
"/* Initialize NEW_DATA. */",
"/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_PARALLEL. */",
"/* Extract data for GIMPLE_OMP_FOR. */",
"/* Prepare cfg. */",
"/* Emit GIMPLE_OMP_FOR. */",
"/* Emit GIMPLE_OMP_CONTINUE. */",
"/* Emit GIMPLE_OMP_RETURN for GIMPLE_OMP_FOR. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "loop_fn",
"type": "tree"
},
{
"param": "data",
"type": "tree"
},
{
"param": "new_data",
"type": "tree"
},
{
"param": "n_threads",
"type": "unsigned"
},
{
"param": "loc",
"type": "location_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loop_fn",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_data",
"type": "tree",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n_threads",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loc",
"type": "location_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | gen_parallel_loop | void | static void
gen_parallel_loop (struct loop *loop, htab_t reduction_list,
unsigned n_threads, struct tree_niter_desc *niter)
{
loop_iterator li;
tree many_iterations_cond, type, nit;
tree arg_struct, new_arg_struct;
gimple_seq stmts;
basic_block parallel_head;
edge entry, exit;
struct clsn_data clsn_data;
unsigned prob;
location_t loc;
gimple cond_stmt;
/* From
---------------------------------------------------------------------
loop
{
IV = phi (INIT, IV + STEP)
BODY1;
if (COND)
break;
BODY2;
}
---------------------------------------------------------------------
with # of iterations NITER (possibly with MAY_BE_ZERO assumption),
we generate the following code:
---------------------------------------------------------------------
if (MAY_BE_ZERO
|| NITER < MIN_PER_THREAD * N_THREADS)
goto original;
BODY1;
store all local loop-invariant variables used in body of the loop to DATA.
GIMPLE_OMP_PARALLEL (OMP_CLAUSE_NUM_THREADS (N_THREADS), LOOPFN, DATA);
load the variables from DATA.
GIMPLE_OMP_FOR (IV = INIT; COND; IV += STEP) (OMP_CLAUSE_SCHEDULE (static))
BODY2;
BODY1;
GIMPLE_OMP_CONTINUE;
GIMPLE_OMP_RETURN -- GIMPLE_OMP_FOR
GIMPLE_OMP_RETURN -- GIMPLE_OMP_PARALLEL
goto end;
original:
loop
{
IV = phi (INIT, IV + STEP)
BODY1;
if (COND)
break;
BODY2;
}
end:
*/
/* Create two versions of the loop -- in the old one, we know that the
number of iterations is large enough, and we will transform it into the
loop that will be split to loop_fn, the new one will be used for the
remaining iterations. */
type = TREE_TYPE (niter->niter);
nit = force_gimple_operand (unshare_expr (niter->niter), &stmts, true,
NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
many_iterations_cond =
fold_build2 (GE_EXPR, boolean_type_node,
nit, build_int_cst (type, MIN_PER_THREAD * n_threads));
many_iterations_cond
= fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
invert_truthvalue (unshare_expr (niter->may_be_zero)),
many_iterations_cond);
many_iterations_cond
= force_gimple_operand (many_iterations_cond, &stmts, false, NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
if (!is_gimple_condexpr (many_iterations_cond))
{
many_iterations_cond
= force_gimple_operand (many_iterations_cond, &stmts,
true, NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
}
initialize_original_copy_tables ();
/* We assume that the loop usually iterates a lot. */
prob = 4 * REG_BR_PROB_BASE / 5;
loop_version (loop, many_iterations_cond, NULL,
prob, prob, REG_BR_PROB_BASE - prob, true);
update_ssa (TODO_update_ssa);
free_original_copy_tables ();
/* Base all the induction variables in LOOP on a single control one. */
canonicalize_loop_ivs (loop, &nit, true);
/* Ensure that the exit condition is the first statement in the loop. */
transform_to_exit_first_loop (loop, reduction_list, nit);
/* Generate initializations for reductions. */
if (htab_elements (reduction_list) > 0)
htab_traverse (reduction_list, initialize_reductions, loop);
/* Eliminate the references to local variables from the loop. */
gcc_assert (single_exit (loop));
entry = loop_preheader_edge (loop);
exit = single_dom_exit (loop);
eliminate_local_variables (entry, exit);
/* In the old loop, move all variables non-local to the loop to a structure
and back, and create separate decls for the variables used in loop. */
separate_decls_in_region (entry, exit, reduction_list, &arg_struct,
&new_arg_struct, &clsn_data);
/* Create the parallel constructs. */
loc = UNKNOWN_LOCATION;
cond_stmt = last_stmt (loop->header);
if (cond_stmt)
loc = gimple_location (cond_stmt);
parallel_head = create_parallel_loop (loop, create_loop_fn (loc), arg_struct,
new_arg_struct, n_threads, loc);
if (htab_elements (reduction_list) > 0)
create_call_for_reduction (loop, reduction_list, &clsn_data);
scev_reset ();
/* Cancel the loop (it is simpler to do it here rather than to teach the
expander to do it). */
cancel_loop_tree (loop);
/* Free loop bound estimations that could contain references to
removed statements. */
FOR_EACH_LOOP (li, loop, 0)
free_numbers_of_iterations_estimates_loop (loop);
/* Expand the parallel constructs. We do it directly here instead of running
a separate expand_omp pass, since it is more efficient, and less likely to
cause troubles with further analyses not being able to deal with the
OMP trees. */
omp_expand_local (parallel_head);
} | /* Generates code to execute the iterations of LOOP in N_THREADS
threads in parallel.
NITER describes number of iterations of LOOP.
REDUCTION_LIST describes the reductions existent in the LOOP. */ | Generates code to execute the iterations of LOOP in N_THREADS
threads in parallel.
NITER describes number of iterations of LOOP.
REDUCTION_LIST describes the reductions existent in the LOOP. | [
"Generates",
"code",
"to",
"execute",
"the",
"iterations",
"of",
"LOOP",
"in",
"N_THREADS",
"threads",
"in",
"parallel",
".",
"NITER",
"describes",
"number",
"of",
"iterations",
"of",
"LOOP",
".",
"REDUCTION_LIST",
"describes",
"the",
"reductions",
"existent",
"in",
"the",
"LOOP",
"."
] | static void
gen_parallel_loop (struct loop *loop, htab_t reduction_list,
unsigned n_threads, struct tree_niter_desc *niter)
{
loop_iterator li;
tree many_iterations_cond, type, nit;
tree arg_struct, new_arg_struct;
gimple_seq stmts;
basic_block parallel_head;
edge entry, exit;
struct clsn_data clsn_data;
unsigned prob;
location_t loc;
gimple cond_stmt;
type = TREE_TYPE (niter->niter);
nit = force_gimple_operand (unshare_expr (niter->niter), &stmts, true,
NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
many_iterations_cond =
fold_build2 (GE_EXPR, boolean_type_node,
nit, build_int_cst (type, MIN_PER_THREAD * n_threads));
many_iterations_cond
= fold_build2 (TRUTH_AND_EXPR, boolean_type_node,
invert_truthvalue (unshare_expr (niter->may_be_zero)),
many_iterations_cond);
many_iterations_cond
= force_gimple_operand (many_iterations_cond, &stmts, false, NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
if (!is_gimple_condexpr (many_iterations_cond))
{
many_iterations_cond
= force_gimple_operand (many_iterations_cond, &stmts,
true, NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
}
initialize_original_copy_tables ();
prob = 4 * REG_BR_PROB_BASE / 5;
loop_version (loop, many_iterations_cond, NULL,
prob, prob, REG_BR_PROB_BASE - prob, true);
update_ssa (TODO_update_ssa);
free_original_copy_tables ();
canonicalize_loop_ivs (loop, &nit, true);
transform_to_exit_first_loop (loop, reduction_list, nit);
if (htab_elements (reduction_list) > 0)
htab_traverse (reduction_list, initialize_reductions, loop);
gcc_assert (single_exit (loop));
entry = loop_preheader_edge (loop);
exit = single_dom_exit (loop);
eliminate_local_variables (entry, exit);
separate_decls_in_region (entry, exit, reduction_list, &arg_struct,
&new_arg_struct, &clsn_data);
loc = UNKNOWN_LOCATION;
cond_stmt = last_stmt (loop->header);
if (cond_stmt)
loc = gimple_location (cond_stmt);
parallel_head = create_parallel_loop (loop, create_loop_fn (loc), arg_struct,
new_arg_struct, n_threads, loc);
if (htab_elements (reduction_list) > 0)
create_call_for_reduction (loop, reduction_list, &clsn_data);
scev_reset ();
cancel_loop_tree (loop);
FOR_EACH_LOOP (li, loop, 0)
free_numbers_of_iterations_estimates_loop (loop);
omp_expand_local (parallel_head);
} | [
"static",
"void",
"gen_parallel_loop",
"(",
"struct",
"loop",
"*",
"loop",
",",
"htab_t",
"reduction_list",
",",
"unsigned",
"n_threads",
",",
"struct",
"tree_niter_desc",
"*",
"niter",
")",
"{",
"loop_iterator",
"li",
";",
"tree",
"many_iterations_cond",
",",
"type",
",",
"nit",
";",
"tree",
"arg_struct",
",",
"new_arg_struct",
";",
"gimple_seq",
"stmts",
";",
"basic_block",
"parallel_head",
";",
"edge",
"entry",
",",
"exit",
";",
"struct",
"clsn_data",
"clsn_data",
";",
"unsigned",
"prob",
";",
"location_t",
"loc",
";",
"gimple",
"cond_stmt",
";",
"type",
"=",
"TREE_TYPE",
"(",
"niter",
"->",
"niter",
")",
";",
"nit",
"=",
"force_gimple_operand",
"(",
"unshare_expr",
"(",
"niter",
"->",
"niter",
")",
",",
"&",
"stmts",
",",
"true",
",",
"NULL_TREE",
")",
";",
"if",
"(",
"stmts",
")",
"gsi_insert_seq_on_edge_immediate",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
",",
"stmts",
")",
";",
"many_iterations_cond",
"=",
"fold_build2",
"(",
"GE_EXPR",
",",
"boolean_type_node",
",",
"nit",
",",
"build_int_cst",
"(",
"type",
",",
"MIN_PER_THREAD",
"*",
"n_threads",
")",
")",
";",
"many_iterations_cond",
"=",
"fold_build2",
"(",
"TRUTH_AND_EXPR",
",",
"boolean_type_node",
",",
"invert_truthvalue",
"(",
"unshare_expr",
"(",
"niter",
"->",
"may_be_zero",
")",
")",
",",
"many_iterations_cond",
")",
";",
"many_iterations_cond",
"=",
"force_gimple_operand",
"(",
"many_iterations_cond",
",",
"&",
"stmts",
",",
"false",
",",
"NULL_TREE",
")",
";",
"if",
"(",
"stmts",
")",
"gsi_insert_seq_on_edge_immediate",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
",",
"stmts",
")",
";",
"if",
"(",
"!",
"is_gimple_condexpr",
"(",
"many_iterations_cond",
")",
")",
"{",
"many_iterations_cond",
"=",
"force_gimple_operand",
"(",
"many_iterations_cond",
",",
"&",
"stmts",
",",
"true",
",",
"NULL_TREE",
")",
";",
"if",
"(",
"stmts",
")",
"gsi_insert_seq_on_edge_immediate",
"(",
"loop_preheader_edge",
"(",
"loop",
")",
",",
"stmts",
")",
";",
"}",
"initialize_original_copy_tables",
"(",
")",
";",
"prob",
"=",
"4",
"*",
"REG_BR_PROB_BASE",
"/",
"5",
";",
"loop_version",
"(",
"loop",
",",
"many_iterations_cond",
",",
"NULL",
",",
"prob",
",",
"prob",
",",
"REG_BR_PROB_BASE",
"-",
"prob",
",",
"true",
")",
";",
"update_ssa",
"(",
"TODO_update_ssa",
")",
";",
"free_original_copy_tables",
"(",
")",
";",
"canonicalize_loop_ivs",
"(",
"loop",
",",
"&",
"nit",
",",
"true",
")",
";",
"transform_to_exit_first_loop",
"(",
"loop",
",",
"reduction_list",
",",
"nit",
")",
";",
"if",
"(",
"htab_elements",
"(",
"reduction_list",
")",
">",
"0",
")",
"htab_traverse",
"(",
"reduction_list",
",",
"initialize_reductions",
",",
"loop",
")",
";",
"gcc_assert",
"(",
"single_exit",
"(",
"loop",
")",
")",
";",
"entry",
"=",
"loop_preheader_edge",
"(",
"loop",
")",
";",
"exit",
"=",
"single_dom_exit",
"(",
"loop",
")",
";",
"eliminate_local_variables",
"(",
"entry",
",",
"exit",
")",
";",
"separate_decls_in_region",
"(",
"entry",
",",
"exit",
",",
"reduction_list",
",",
"&",
"arg_struct",
",",
"&",
"new_arg_struct",
",",
"&",
"clsn_data",
")",
";",
"loc",
"=",
"UNKNOWN_LOCATION",
";",
"cond_stmt",
"=",
"last_stmt",
"(",
"loop",
"->",
"header",
")",
";",
"if",
"(",
"cond_stmt",
")",
"loc",
"=",
"gimple_location",
"(",
"cond_stmt",
")",
";",
"parallel_head",
"=",
"create_parallel_loop",
"(",
"loop",
",",
"create_loop_fn",
"(",
"loc",
")",
",",
"arg_struct",
",",
"new_arg_struct",
",",
"n_threads",
",",
"loc",
")",
";",
"if",
"(",
"htab_elements",
"(",
"reduction_list",
")",
">",
"0",
")",
"create_call_for_reduction",
"(",
"loop",
",",
"reduction_list",
",",
"&",
"clsn_data",
")",
";",
"scev_reset",
"(",
")",
";",
"cancel_loop_tree",
"(",
"loop",
")",
";",
"FOR_EACH_LOOP",
"(",
"li",
",",
"loop",
",",
"0",
")",
"",
"free_numbers_of_iterations_estimates_loop",
"(",
"loop",
")",
";",
"omp_expand_local",
"(",
"parallel_head",
")",
";",
"}"
] | Generates code to execute the iterations of LOOP in N_THREADS
threads in parallel. | [
"Generates",
"code",
"to",
"execute",
"the",
"iterations",
"of",
"LOOP",
"in",
"N_THREADS",
"threads",
"in",
"parallel",
"."
] | [
"/* From\n\n ---------------------------------------------------------------------\n loop\n {\n\t IV = phi (INIT, IV + STEP)\n\t BODY1;\n\t if (COND)\n\t break;\n\t BODY2;\n }\n ---------------------------------------------------------------------\n\n with # of iterations NITER (possibly with MAY_BE_ZERO assumption),\n we generate the following code:\n\n ---------------------------------------------------------------------\n\n if (MAY_BE_ZERO\n || NITER < MIN_PER_THREAD * N_THREADS)\n goto original;\n\n BODY1;\n store all local loop-invariant variables used in body of the loop to DATA.\n GIMPLE_OMP_PARALLEL (OMP_CLAUSE_NUM_THREADS (N_THREADS), LOOPFN, DATA);\n load the variables from DATA.\n GIMPLE_OMP_FOR (IV = INIT; COND; IV += STEP) (OMP_CLAUSE_SCHEDULE (static))\n BODY2;\n BODY1;\n GIMPLE_OMP_CONTINUE;\n GIMPLE_OMP_RETURN -- GIMPLE_OMP_FOR\n GIMPLE_OMP_RETURN -- GIMPLE_OMP_PARALLEL\n goto end;\n\n original:\n loop\n {\n\t IV = phi (INIT, IV + STEP)\n\t BODY1;\n\t if (COND)\n\t break;\n\t BODY2;\n }\n\n end:\n\n */",
"/* Create two versions of the loop -- in the old one, we know that the\n number of iterations is large enough, and we will transform it into the\n loop that will be split to loop_fn, the new one will be used for the\n remaining iterations. */",
"/* We assume that the loop usually iterates a lot. */",
"/* Base all the induction variables in LOOP on a single control one. */",
"/* Ensure that the exit condition is the first statement in the loop. */",
"/* Generate initializations for reductions. */",
"/* Eliminate the references to local variables from the loop. */",
"/* In the old loop, move all variables non-local to the loop to a structure\n and back, and create separate decls for the variables used in loop. */",
"/* Create the parallel constructs. */",
"/* Cancel the loop (it is simpler to do it here rather than to teach the\n expander to do it). */",
"/* Free loop bound estimations that could contain references to\n removed statements. */",
"/* Expand the parallel constructs. We do it directly here instead of running\n a separate expand_omp pass, since it is more efficient, and less likely to\n cause troubles with further analyses not being able to deal with the\n OMP trees. */"
] | [
{
"param": "loop",
"type": "struct loop"
},
{
"param": "reduction_list",
"type": "htab_t"
},
{
"param": "n_threads",
"type": "unsigned"
},
{
"param": "niter",
"type": "struct tree_niter_desc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "struct loop",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n_threads",
"type": "unsigned",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "niter",
"type": "struct tree_niter_desc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ae5d444e671bc005e1cbf08f54f6cc9f1faedbd | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-parloops.c | [
"BSD-3-Clause"
] | C | gather_scalar_reductions | void | static void
gather_scalar_reductions (loop_p loop, htab_t reduction_list)
{
gimple_stmt_iterator gsi;
loop_vec_info simple_loop_info;
vect_dump = NULL;
simple_loop_info = vect_analyze_loop_form (loop);
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple phi = gsi_stmt (gsi);
affine_iv iv;
tree res = PHI_RESULT (phi);
bool double_reduc;
if (!is_gimple_reg (res))
continue;
if (!simple_iv (loop, loop, res, &iv, true)
&& simple_loop_info)
{
gimple reduc_stmt = vect_force_simple_reduction (simple_loop_info,
phi, true,
&double_reduc);
if (reduc_stmt && !double_reduc)
build_new_reduction (reduction_list, reduc_stmt, phi);
}
}
destroy_loop_vec_info (simple_loop_info, true);
/* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
and destroy_loop_vec_info, we can set gimple_uid of reduc_phi stmts
only now. */
htab_traverse (reduction_list, set_reduc_phi_uids, NULL);
} | /* Detect all reductions in the LOOP, insert them into REDUCTION_LIST. */ | Detect all reductions in the LOOP, insert them into REDUCTION_LIST. | [
"Detect",
"all",
"reductions",
"in",
"the",
"LOOP",
"insert",
"them",
"into",
"REDUCTION_LIST",
"."
] | static void
gather_scalar_reductions (loop_p loop, htab_t reduction_list)
{
gimple_stmt_iterator gsi;
loop_vec_info simple_loop_info;
vect_dump = NULL;
simple_loop_info = vect_analyze_loop_form (loop);
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple phi = gsi_stmt (gsi);
affine_iv iv;
tree res = PHI_RESULT (phi);
bool double_reduc;
if (!is_gimple_reg (res))
continue;
if (!simple_iv (loop, loop, res, &iv, true)
&& simple_loop_info)
{
gimple reduc_stmt = vect_force_simple_reduction (simple_loop_info,
phi, true,
&double_reduc);
if (reduc_stmt && !double_reduc)
build_new_reduction (reduction_list, reduc_stmt, phi);
}
}
destroy_loop_vec_info (simple_loop_info, true);
htab_traverse (reduction_list, set_reduc_phi_uids, NULL);
} | [
"static",
"void",
"gather_scalar_reductions",
"(",
"loop_p",
"loop",
",",
"htab_t",
"reduction_list",
")",
"{",
"gimple_stmt_iterator",
"gsi",
";",
"loop_vec_info",
"simple_loop_info",
";",
"vect_dump",
"=",
"NULL",
";",
"simple_loop_info",
"=",
"vect_analyze_loop_form",
"(",
"loop",
")",
";",
"for",
"(",
"gsi",
"=",
"gsi_start_phis",
"(",
"loop",
"->",
"header",
")",
";",
"!",
"gsi_end_p",
"(",
"gsi",
")",
";",
"gsi_next",
"(",
"&",
"gsi",
")",
")",
"{",
"gimple",
"phi",
"=",
"gsi_stmt",
"(",
"gsi",
")",
";",
"affine_iv",
"iv",
";",
"tree",
"res",
"=",
"PHI_RESULT",
"(",
"phi",
")",
";",
"bool",
"double_reduc",
";",
"if",
"(",
"!",
"is_gimple_reg",
"(",
"res",
")",
")",
"continue",
";",
"if",
"(",
"!",
"simple_iv",
"(",
"loop",
",",
"loop",
",",
"res",
",",
"&",
"iv",
",",
"true",
")",
"&&",
"simple_loop_info",
")",
"{",
"gimple",
"reduc_stmt",
"=",
"vect_force_simple_reduction",
"(",
"simple_loop_info",
",",
"phi",
",",
"true",
",",
"&",
"double_reduc",
")",
";",
"if",
"(",
"reduc_stmt",
"&&",
"!",
"double_reduc",
")",
"build_new_reduction",
"(",
"reduction_list",
",",
"reduc_stmt",
",",
"phi",
")",
";",
"}",
"}",
"destroy_loop_vec_info",
"(",
"simple_loop_info",
",",
"true",
")",
";",
"htab_traverse",
"(",
"reduction_list",
",",
"set_reduc_phi_uids",
",",
"NULL",
")",
";",
"}"
] | Detect all reductions in the LOOP, insert them into REDUCTION_LIST. | [
"Detect",
"all",
"reductions",
"in",
"the",
"LOOP",
"insert",
"them",
"into",
"REDUCTION_LIST",
"."
] | [
"/* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form\n and destroy_loop_vec_info, we can set gimple_uid of reduc_phi stmts\n only now. */"
] | [
{
"param": "loop",
"type": "loop_p"
},
{
"param": "reduction_list",
"type": "htab_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loop",
"type": "loop_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reduction_list",
"type": "htab_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.