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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_get_composite_etype | null | static const struct ng_parse_type *
ng_get_composite_etype(const struct ng_parse_type *type,
int index, const enum comptype ctype)
{
const struct ng_parse_type *etype = NULL;
switch (ctype) {
case CT_STRUCT:
{
const struct ng_parse_struct_field *const fields = type->info;
etype = fields[index].type;
break;
}
case CT_ARRAY:
{
const struct ng_parse_array_info *const ai = type->info;
etype = ai->elementType;
break;
}
case CT_FIXEDARRAY:
{
const struct ng_parse_fixedarray_info *const fi = type->info;
etype = fi->elementType;
break;
}
default:
panic("%s", __func__);
}
return (etype);
} | /*
* Return the type of the index'th element of a composite structure
*/ | Return the type of the index'th element of a composite structure | [
"Return",
"the",
"type",
"of",
"the",
"index",
"'",
"th",
"element",
"of",
"a",
"composite",
"structure"
] | static const struct ng_parse_type *
ng_get_composite_etype(const struct ng_parse_type *type,
int index, const enum comptype ctype)
{
const struct ng_parse_type *etype = NULL;
switch (ctype) {
case CT_STRUCT:
{
const struct ng_parse_struct_field *const fields = type->info;
etype = fields[index].type;
break;
}
case CT_ARRAY:
{
const struct ng_parse_array_info *const ai = type->info;
etype = ai->elementType;
break;
}
case CT_FIXEDARRAY:
{
const struct ng_parse_fixedarray_info *const fi = type->info;
etype = fi->elementType;
break;
}
default:
panic("%s", __func__);
}
return (etype);
} | [
"static",
"const",
"struct",
"ng_parse_type",
"*",
"ng_get_composite_etype",
"(",
"const",
"struct",
"ng_parse_type",
"*",
"type",
",",
"int",
"index",
",",
"const",
"enum",
"comptype",
"ctype",
")",
"{",
"const",
"struct",
"ng_parse_type",
"*",
"etype",
"=",
"NULL",
";",
"switch",
"(",
"ctype",
")",
"{",
"case",
"CT_STRUCT",
":",
"{",
"const",
"struct",
"ng_parse_struct_field",
"*",
"const",
"fields",
"=",
"type",
"->",
"info",
";",
"etype",
"=",
"fields",
"[",
"index",
"]",
".",
"type",
";",
"break",
";",
"}",
"case",
"CT_ARRAY",
":",
"{",
"const",
"struct",
"ng_parse_array_info",
"*",
"const",
"ai",
"=",
"type",
"->",
"info",
";",
"etype",
"=",
"ai",
"->",
"elementType",
";",
"break",
";",
"}",
"case",
"CT_FIXEDARRAY",
":",
"{",
"const",
"struct",
"ng_parse_fixedarray_info",
"*",
"const",
"fi",
"=",
"type",
"->",
"info",
";",
"etype",
"=",
"fi",
"->",
"elementType",
";",
"break",
";",
"}",
"default",
":",
"panic",
"(",
"\"",
"\"",
",",
"__func__",
")",
";",
"}",
"return",
"(",
"etype",
")",
";",
"}"
] | Return the type of the index'th element of a composite structure | [
"Return",
"the",
"type",
"of",
"the",
"index",
"'",
"th",
"element",
"of",
"a",
"composite",
"structure"
] | [] | [
{
"param": "type",
"type": "struct ng_parse_type"
},
{
"param": "index",
"type": "int"
},
{
"param": "ctype",
"type": "enum comptype"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type",
"type": "struct ng_parse_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctype",
"type": "enum comptype",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_parse_get_elem_pad | int | static int
ng_parse_get_elem_pad(const struct ng_parse_type *type,
int index, enum comptype ctype, int posn)
{
const struct ng_parse_type *const
etype = ng_get_composite_etype(type, index, ctype);
int align;
/* Get element's alignment, and possibly override */
align = ALIGNMENT(etype);
if (ctype == CT_STRUCT) {
const struct ng_parse_struct_field *const fields = type->info;
if (fields[index].alignment != 0)
align = fields[index].alignment;
}
/* Return number of bytes to skip to align */
return (align ? (align - (posn % align)) % align : 0);
} | /*
* Get the number of bytes to skip to align for the next
* element in a composite structure.
*/ | Get the number of bytes to skip to align for the next
element in a composite structure. | [
"Get",
"the",
"number",
"of",
"bytes",
"to",
"skip",
"to",
"align",
"for",
"the",
"next",
"element",
"in",
"a",
"composite",
"structure",
"."
] | static int
ng_parse_get_elem_pad(const struct ng_parse_type *type,
int index, enum comptype ctype, int posn)
{
const struct ng_parse_type *const
etype = ng_get_composite_etype(type, index, ctype);
int align;
align = ALIGNMENT(etype);
if (ctype == CT_STRUCT) {
const struct ng_parse_struct_field *const fields = type->info;
if (fields[index].alignment != 0)
align = fields[index].alignment;
}
return (align ? (align - (posn % align)) % align : 0);
} | [
"static",
"int",
"ng_parse_get_elem_pad",
"(",
"const",
"struct",
"ng_parse_type",
"*",
"type",
",",
"int",
"index",
",",
"enum",
"comptype",
"ctype",
",",
"int",
"posn",
")",
"{",
"const",
"struct",
"ng_parse_type",
"*",
"const",
"etype",
"=",
"ng_get_composite_etype",
"(",
"type",
",",
"index",
",",
"ctype",
")",
";",
"int",
"align",
";",
"align",
"=",
"ALIGNMENT",
"(",
"etype",
")",
";",
"if",
"(",
"ctype",
"==",
"CT_STRUCT",
")",
"{",
"const",
"struct",
"ng_parse_struct_field",
"*",
"const",
"fields",
"=",
"type",
"->",
"info",
";",
"if",
"(",
"fields",
"[",
"index",
"]",
".",
"alignment",
"!=",
"0",
")",
"align",
"=",
"fields",
"[",
"index",
"]",
".",
"alignment",
";",
"}",
"return",
"(",
"align",
"?",
"(",
"align",
"-",
"(",
"posn",
"%",
"align",
")",
")",
"%",
"align",
":",
"0",
")",
";",
"}"
] | Get the number of bytes to skip to align for the next
element in a composite structure. | [
"Get",
"the",
"number",
"of",
"bytes",
"to",
"skip",
"to",
"align",
"for",
"the",
"next",
"element",
"in",
"a",
"composite",
"structure",
"."
] | [
"/* Get element's alignment, and possibly override */",
"/* Return number of bytes to skip to align */"
] | [
{
"param": "type",
"type": "struct ng_parse_type"
},
{
"param": "index",
"type": "int"
},
{
"param": "ctype",
"type": "enum comptype"
},
{
"param": "posn",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "type",
"type": "struct ng_parse_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctype",
"type": "enum comptype",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "posn",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_parse_append | int | static int
ng_parse_append(char **cbufp, int *cbuflenp, const char *fmt, ...)
{
va_list args;
int len;
va_start(args, fmt);
len = kvsnprintf(*cbufp, *cbuflenp, fmt, args);
va_end(args);
if (len >= *cbuflenp)
return ERANGE;
*cbufp += len;
*cbuflenp -= len;
return (0);
} | /*
* Append to a fixed length string buffer.
*/ | Append to a fixed length string buffer. | [
"Append",
"to",
"a",
"fixed",
"length",
"string",
"buffer",
"."
] | static int
ng_parse_append(char **cbufp, int *cbuflenp, const char *fmt, ...)
{
va_list args;
int len;
va_start(args, fmt);
len = kvsnprintf(*cbufp, *cbuflenp, fmt, args);
va_end(args);
if (len >= *cbuflenp)
return ERANGE;
*cbufp += len;
*cbuflenp -= len;
return (0);
} | [
"static",
"int",
"ng_parse_append",
"(",
"char",
"*",
"*",
"cbufp",
",",
"int",
"*",
"cbuflenp",
",",
"const",
"char",
"*",
"fmt",
",",
"...",
")",
"{",
"va_list",
"args",
";",
"int",
"len",
";",
"va_start",
"(",
"args",
",",
"fmt",
")",
";",
"len",
"=",
"kvsnprintf",
"(",
"*",
"cbufp",
",",
"*",
"cbuflenp",
",",
"fmt",
",",
"args",
")",
";",
"va_end",
"(",
"args",
")",
";",
"if",
"(",
"len",
">=",
"*",
"cbuflenp",
")",
"return",
"ERANGE",
";",
"*",
"cbufp",
"+=",
"len",
";",
"*",
"cbuflenp",
"-=",
"len",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Append to a fixed length string buffer. | [
"Append",
"to",
"a",
"fixed",
"length",
"string",
"buffer",
"."
] | [] | [
{
"param": "cbufp",
"type": "char"
},
{
"param": "cbuflenp",
"type": "int"
},
{
"param": "fmt",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cbufp",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cbuflenp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fmt",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_parse_get_token | null | enum ng_parse_token
ng_parse_get_token(const char *s, int *startp, int *lenp)
{
char *t;
int i;
while (isspace(s[*startp]))
(*startp)++;
switch (s[*startp]) {
case '\0':
*lenp = 0;
return T_EOF;
case '{':
*lenp = 1;
return T_LBRACE;
case '}':
*lenp = 1;
return T_RBRACE;
case '[':
*lenp = 1;
return T_LBRACKET;
case ']':
*lenp = 1;
return T_RBRACKET;
case '=':
*lenp = 1;
return T_EQUALS;
case '"':
if ((t = ng_get_string_token(s, startp, lenp, NULL)) == NULL)
return T_ERROR;
kfree(t, M_NETGRAPH_PARSE);
return T_STRING;
default:
for (i = *startp + 1; s[i] != '\0' && !isspace(s[i])
&& s[i] != '{' && s[i] != '}' && s[i] != '['
&& s[i] != ']' && s[i] != '=' && s[i] != '"'; i++)
;
*lenp = i - *startp;
return T_WORD;
}
} | /*
* Find the next token in the string, starting at offset *startp.
* Returns the token type, with *startp pointing to the first char
* and *lenp the length.
*/ | Find the next token in the string, starting at offset *startp.
Returns the token type, with *startp pointing to the first char
and *lenp the length. | [
"Find",
"the",
"next",
"token",
"in",
"the",
"string",
"starting",
"at",
"offset",
"*",
"startp",
".",
"Returns",
"the",
"token",
"type",
"with",
"*",
"startp",
"pointing",
"to",
"the",
"first",
"char",
"and",
"*",
"lenp",
"the",
"length",
"."
] | enum ng_parse_token
ng_parse_get_token(const char *s, int *startp, int *lenp)
{
char *t;
int i;
while (isspace(s[*startp]))
(*startp)++;
switch (s[*startp]) {
case '\0':
*lenp = 0;
return T_EOF;
case '{':
*lenp = 1;
return T_LBRACE;
case '}':
*lenp = 1;
return T_RBRACE;
case '[':
*lenp = 1;
return T_LBRACKET;
case ']':
*lenp = 1;
return T_RBRACKET;
case '=':
*lenp = 1;
return T_EQUALS;
case '"':
if ((t = ng_get_string_token(s, startp, lenp, NULL)) == NULL)
return T_ERROR;
kfree(t, M_NETGRAPH_PARSE);
return T_STRING;
default:
for (i = *startp + 1; s[i] != '\0' && !isspace(s[i])
&& s[i] != '{' && s[i] != '}' && s[i] != '['
&& s[i] != ']' && s[i] != '=' && s[i] != '"'; i++)
;
*lenp = i - *startp;
return T_WORD;
}
} | [
"enum",
"ng_parse_token",
"ng_parse_get_token",
"(",
"const",
"char",
"*",
"s",
",",
"int",
"*",
"startp",
",",
"int",
"*",
"lenp",
")",
"{",
"char",
"*",
"t",
";",
"int",
"i",
";",
"while",
"(",
"isspace",
"(",
"s",
"[",
"*",
"startp",
"]",
")",
")",
"(",
"*",
"startp",
")",
"++",
";",
"switch",
"(",
"s",
"[",
"*",
"startp",
"]",
")",
"{",
"case",
"'",
"\\0",
"'",
":",
"*",
"lenp",
"=",
"0",
";",
"return",
"T_EOF",
";",
"case",
"'",
"'",
":",
"*",
"lenp",
"=",
"1",
";",
"return",
"T_LBRACE",
";",
"case",
"'",
"'",
":",
"*",
"lenp",
"=",
"1",
";",
"return",
"T_RBRACE",
";",
"case",
"'",
"'",
":",
"*",
"lenp",
"=",
"1",
";",
"return",
"T_LBRACKET",
";",
"case",
"'",
"'",
":",
"*",
"lenp",
"=",
"1",
";",
"return",
"T_RBRACKET",
";",
"case",
"'",
"'",
":",
"*",
"lenp",
"=",
"1",
";",
"return",
"T_EQUALS",
";",
"case",
"'",
"'",
":",
"if",
"(",
"(",
"t",
"=",
"ng_get_string_token",
"(",
"s",
",",
"startp",
",",
"lenp",
",",
"NULL",
")",
")",
"==",
"NULL",
")",
"return",
"T_ERROR",
";",
"kfree",
"(",
"t",
",",
"M_NETGRAPH_PARSE",
")",
";",
"return",
"T_STRING",
";",
"default",
":",
"for",
"(",
"i",
"=",
"*",
"startp",
"+",
"1",
";",
"s",
"[",
"i",
"]",
"!=",
"'",
"\\0",
"'",
"&&",
"!",
"isspace",
"(",
"s",
"[",
"i",
"]",
")",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
"&&",
"s",
"[",
"i",
"]",
"!=",
"'",
"'",
";",
"i",
"++",
")",
";",
"*",
"lenp",
"=",
"i",
"-",
"*",
"startp",
";",
"return",
"T_WORD",
";",
"}",
"}"
] | Find the next token in the string, starting at offset *startp. | [
"Find",
"the",
"next",
"token",
"in",
"the",
"string",
"starting",
"at",
"offset",
"*",
"startp",
"."
] | [] | [
{
"param": "s",
"type": "char"
},
{
"param": "startp",
"type": "int"
},
{
"param": "lenp",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lenp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_get_string_token | char | char *
ng_get_string_token(const char *s, int *startp, int *lenp, int *slenp)
{
char *cbuf, *p;
int start, off;
int slen;
while (isspace(s[*startp]))
(*startp)++;
start = *startp;
if (s[*startp] != '"')
return (NULL);
cbuf = kmalloc(strlen(s + start), M_NETGRAPH_PARSE,
M_WAITOK | M_NULLOK);
if (cbuf == NULL)
return (NULL);
strcpy(cbuf, s + start + 1);
for (slen = 0, off = 1, p = cbuf; *p != '\0'; slen++, off++, p++) {
if (*p == '"') {
*p = '\0';
*lenp = off + 1;
if (slenp != NULL)
*slenp = slen;
return (cbuf);
} else if (p[0] == '\\' && p[1] != '\0') {
int x, k;
char *v;
strcpy(p, p + 1);
v = p;
switch (*p) {
case 't':
*v = '\t';
off++;
continue;
case 'n':
*v = '\n';
off++;
continue;
case 'r':
*v = '\r';
off++;
continue;
case 'v':
*v = '\v';
off++;
continue;
case 'f':
*v = '\f';
off++;
continue;
case '"':
*v = '"';
off++;
continue;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
for (x = k = 0;
k < 3 && *v >= '0' && *v <= '7'; v++) {
x = (x << 3) + (*v - '0');
off++;
}
*--v = (char)x;
break;
case 'x':
for (v++, x = k = 0;
k < 2 && isxdigit(*v); v++) {
x = (x << 4) + (isdigit(*v) ?
(*v - '0') :
(tolower(*v) - 'a' + 10));
off++;
}
*--v = (char)x;
break;
default:
continue;
}
strcpy(p, v);
}
}
kfree(cbuf, M_NETGRAPH_PARSE);
return (NULL); /* no closing quote */
} | /*
* Get a string token, which must be enclosed in double quotes.
* The normal C backslash escapes are recognized.
*/ | Get a string token, which must be enclosed in double quotes.
The normal C backslash escapes are recognized. | [
"Get",
"a",
"string",
"token",
"which",
"must",
"be",
"enclosed",
"in",
"double",
"quotes",
".",
"The",
"normal",
"C",
"backslash",
"escapes",
"are",
"recognized",
"."
] | char *
ng_get_string_token(const char *s, int *startp, int *lenp, int *slenp)
{
char *cbuf, *p;
int start, off;
int slen;
while (isspace(s[*startp]))
(*startp)++;
start = *startp;
if (s[*startp] != '"')
return (NULL);
cbuf = kmalloc(strlen(s + start), M_NETGRAPH_PARSE,
M_WAITOK | M_NULLOK);
if (cbuf == NULL)
return (NULL);
strcpy(cbuf, s + start + 1);
for (slen = 0, off = 1, p = cbuf; *p != '\0'; slen++, off++, p++) {
if (*p == '"') {
*p = '\0';
*lenp = off + 1;
if (slenp != NULL)
*slenp = slen;
return (cbuf);
} else if (p[0] == '\\' && p[1] != '\0') {
int x, k;
char *v;
strcpy(p, p + 1);
v = p;
switch (*p) {
case 't':
*v = '\t';
off++;
continue;
case 'n':
*v = '\n';
off++;
continue;
case 'r':
*v = '\r';
off++;
continue;
case 'v':
*v = '\v';
off++;
continue;
case 'f':
*v = '\f';
off++;
continue;
case '"':
*v = '"';
off++;
continue;
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
for (x = k = 0;
k < 3 && *v >= '0' && *v <= '7'; v++) {
x = (x << 3) + (*v - '0');
off++;
}
*--v = (char)x;
break;
case 'x':
for (v++, x = k = 0;
k < 2 && isxdigit(*v); v++) {
x = (x << 4) + (isdigit(*v) ?
(*v - '0') :
(tolower(*v) - 'a' + 10));
off++;
}
*--v = (char)x;
break;
default:
continue;
}
strcpy(p, v);
}
}
kfree(cbuf, M_NETGRAPH_PARSE);
return (NULL);
} | [
"char",
"*",
"ng_get_string_token",
"(",
"const",
"char",
"*",
"s",
",",
"int",
"*",
"startp",
",",
"int",
"*",
"lenp",
",",
"int",
"*",
"slenp",
")",
"{",
"char",
"*",
"cbuf",
",",
"*",
"p",
";",
"int",
"start",
",",
"off",
";",
"int",
"slen",
";",
"while",
"(",
"isspace",
"(",
"s",
"[",
"*",
"startp",
"]",
")",
")",
"(",
"*",
"startp",
")",
"++",
";",
"start",
"=",
"*",
"startp",
";",
"if",
"(",
"s",
"[",
"*",
"startp",
"]",
"!=",
"'",
"'",
")",
"return",
"(",
"NULL",
")",
";",
"cbuf",
"=",
"kmalloc",
"(",
"strlen",
"(",
"s",
"+",
"start",
")",
",",
"M_NETGRAPH_PARSE",
",",
"M_WAITOK",
"|",
"M_NULLOK",
")",
";",
"if",
"(",
"cbuf",
"==",
"NULL",
")",
"return",
"(",
"NULL",
")",
";",
"strcpy",
"(",
"cbuf",
",",
"s",
"+",
"start",
"+",
"1",
")",
";",
"for",
"(",
"slen",
"=",
"0",
",",
"off",
"=",
"1",
",",
"p",
"=",
"cbuf",
";",
"*",
"p",
"!=",
"'",
"\\0",
"'",
";",
"slen",
"++",
",",
"off",
"++",
",",
"p",
"++",
")",
"{",
"if",
"(",
"*",
"p",
"==",
"'",
"'",
")",
"{",
"*",
"p",
"=",
"'",
"\\0",
"'",
";",
"*",
"lenp",
"=",
"off",
"+",
"1",
";",
"if",
"(",
"slenp",
"!=",
"NULL",
")",
"*",
"slenp",
"=",
"slen",
";",
"return",
"(",
"cbuf",
")",
";",
"}",
"else",
"if",
"(",
"p",
"[",
"0",
"]",
"==",
"'",
"\\\\",
"'",
"&&",
"p",
"[",
"1",
"]",
"!=",
"'",
"\\0",
"'",
")",
"{",
"int",
"x",
",",
"k",
";",
"char",
"*",
"v",
";",
"strcpy",
"(",
"p",
",",
"p",
"+",
"1",
")",
";",
"v",
"=",
"p",
";",
"switch",
"(",
"*",
"p",
")",
"{",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"\\t",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"\\n",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"\\r",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"\\v",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"\\f",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"*",
"v",
"=",
"'",
"'",
";",
"off",
"++",
";",
"continue",
";",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"case",
"'",
"'",
":",
"for",
"(",
"x",
"=",
"k",
"=",
"0",
";",
"k",
"<",
"3",
"&&",
"*",
"v",
">=",
"'",
"'",
"&&",
"*",
"v",
"<=",
"'",
"'",
";",
"v",
"++",
")",
"{",
"x",
"=",
"(",
"x",
"<<",
"3",
")",
"+",
"(",
"*",
"v",
"-",
"'",
"'",
")",
";",
"off",
"++",
";",
"}",
"*",
"--",
"v",
"=",
"(",
"char",
")",
"x",
";",
"break",
";",
"case",
"'",
"'",
":",
"for",
"(",
"v",
"++",
",",
"x",
"=",
"k",
"=",
"0",
";",
"k",
"<",
"2",
"&&",
"isxdigit",
"(",
"*",
"v",
")",
";",
"v",
"++",
")",
"{",
"x",
"=",
"(",
"x",
"<<",
"4",
")",
"+",
"(",
"isdigit",
"(",
"*",
"v",
")",
"?",
"(",
"*",
"v",
"-",
"'",
"'",
")",
":",
"(",
"tolower",
"(",
"*",
"v",
")",
"-",
"'",
"'",
"+",
"10",
")",
")",
";",
"off",
"++",
";",
"}",
"*",
"--",
"v",
"=",
"(",
"char",
")",
"x",
";",
"break",
";",
"default",
":",
"continue",
";",
"}",
"strcpy",
"(",
"p",
",",
"v",
")",
";",
"}",
"}",
"kfree",
"(",
"cbuf",
",",
"M_NETGRAPH_PARSE",
")",
";",
"return",
"(",
"NULL",
")",
";",
"}"
] | Get a string token, which must be enclosed in double quotes. | [
"Get",
"a",
"string",
"token",
"which",
"must",
"be",
"enclosed",
"in",
"double",
"quotes",
"."
] | [
"/* no closing quote */"
] | [
{
"param": "s",
"type": "char"
},
{
"param": "startp",
"type": "int"
},
{
"param": "lenp",
"type": "int"
},
{
"param": "slenp",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "startp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lenp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slenp",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f22a872c9b68f7feaa267b9a108687293a3277b4 | atrens/DragonFlyBSD-src | sys/netgraph7/netgraph/ng_parse.c | [
"BSD-3-Clause"
] | C | ng_encode_string | char | char *
ng_encode_string(const char *raw, int slen)
{
char *cbuf;
int off = 0;
int i;
cbuf = kmalloc(strlen(raw) * 4 + 3, M_NETGRAPH_PARSE,
M_WAITOK | M_NULLOK);
if (cbuf == NULL)
return (NULL);
cbuf[off++] = '"';
for (i = 0; i < slen; i++, raw++) {
switch (*raw) {
case '\t':
cbuf[off++] = '\\';
cbuf[off++] = 't';
break;
case '\f':
cbuf[off++] = '\\';
cbuf[off++] = 'f';
break;
case '\n':
cbuf[off++] = '\\';
cbuf[off++] = 'n';
break;
case '\r':
cbuf[off++] = '\\';
cbuf[off++] = 'r';
break;
case '\v':
cbuf[off++] = '\\';
cbuf[off++] = 'v';
break;
case '"':
case '\\':
cbuf[off++] = '\\';
cbuf[off++] = *raw;
break;
default:
if (*raw < 0x20 || *raw > 0x7e) {
off += ksprintf(cbuf + off,
"\\x%02x", (u_char)*raw);
break;
}
cbuf[off++] = *raw;
break;
}
}
cbuf[off++] = '"';
cbuf[off] = '\0';
return (cbuf);
} | /*
* Encode a string so it can be safely put in double quotes.
* Caller must free the result. Exactly "slen" characters
* are encoded.
*/ | Encode a string so it can be safely put in double quotes.
Caller must free the result. Exactly "slen" characters
are encoded. | [
"Encode",
"a",
"string",
"so",
"it",
"can",
"be",
"safely",
"put",
"in",
"double",
"quotes",
".",
"Caller",
"must",
"free",
"the",
"result",
".",
"Exactly",
"\"",
"slen",
"\"",
"characters",
"are",
"encoded",
"."
] | char *
ng_encode_string(const char *raw, int slen)
{
char *cbuf;
int off = 0;
int i;
cbuf = kmalloc(strlen(raw) * 4 + 3, M_NETGRAPH_PARSE,
M_WAITOK | M_NULLOK);
if (cbuf == NULL)
return (NULL);
cbuf[off++] = '"';
for (i = 0; i < slen; i++, raw++) {
switch (*raw) {
case '\t':
cbuf[off++] = '\\';
cbuf[off++] = 't';
break;
case '\f':
cbuf[off++] = '\\';
cbuf[off++] = 'f';
break;
case '\n':
cbuf[off++] = '\\';
cbuf[off++] = 'n';
break;
case '\r':
cbuf[off++] = '\\';
cbuf[off++] = 'r';
break;
case '\v':
cbuf[off++] = '\\';
cbuf[off++] = 'v';
break;
case '"':
case '\\':
cbuf[off++] = '\\';
cbuf[off++] = *raw;
break;
default:
if (*raw < 0x20 || *raw > 0x7e) {
off += ksprintf(cbuf + off,
"\\x%02x", (u_char)*raw);
break;
}
cbuf[off++] = *raw;
break;
}
}
cbuf[off++] = '"';
cbuf[off] = '\0';
return (cbuf);
} | [
"char",
"*",
"ng_encode_string",
"(",
"const",
"char",
"*",
"raw",
",",
"int",
"slen",
")",
"{",
"char",
"*",
"cbuf",
";",
"int",
"off",
"=",
"0",
";",
"int",
"i",
";",
"cbuf",
"=",
"kmalloc",
"(",
"strlen",
"(",
"raw",
")",
"*",
"4",
"+",
"3",
",",
"M_NETGRAPH_PARSE",
",",
"M_WAITOK",
"|",
"M_NULLOK",
")",
";",
"if",
"(",
"cbuf",
"==",
"NULL",
")",
"return",
"(",
"NULL",
")",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"slen",
";",
"i",
"++",
",",
"raw",
"++",
")",
"{",
"switch",
"(",
"*",
"raw",
")",
"{",
"case",
"'",
"\\t",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"\\f",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"\\n",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"\\r",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"\\v",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"break",
";",
"case",
"'",
"'",
":",
"case",
"'",
"\\\\",
"'",
":",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"\\\\",
"'",
";",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"*",
"raw",
";",
"break",
";",
"default",
":",
"if",
"(",
"*",
"raw",
"<",
"0x20",
"||",
"*",
"raw",
">",
"0x7e",
")",
"{",
"off",
"+=",
"ksprintf",
"(",
"cbuf",
"+",
"off",
",",
"\"",
"\\\\",
"\"",
",",
"(",
"u_char",
")",
"*",
"raw",
")",
";",
"break",
";",
"}",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"*",
"raw",
";",
"break",
";",
"}",
"}",
"cbuf",
"[",
"off",
"++",
"]",
"=",
"'",
"'",
";",
"cbuf",
"[",
"off",
"]",
"=",
"'",
"\\0",
"'",
";",
"return",
"(",
"cbuf",
")",
";",
"}"
] | Encode a string so it can be safely put in double quotes. | [
"Encode",
"a",
"string",
"so",
"it",
"can",
"be",
"safely",
"put",
"in",
"double",
"quotes",
"."
] | [] | [
{
"param": "raw",
"type": "char"
},
{
"param": "slen",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "raw",
"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": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | sack_block_lookup | boolean_t | static boolean_t
sack_block_lookup(struct scoreboard *scb, tcp_seq seq, struct sackblock **sb)
{
static struct krate sackkrate = { .freq = 1 };
struct sackblock *hint = scb->lastfound;
struct sackblock *cur, *last, *prev;
if (TAILQ_EMPTY(&scb->sackblocks)) {
*sb = NULL;
return FALSE;
}
if (hint == NULL) {
/* No hint. Search from start to end. */
cur = TAILQ_FIRST(&scb->sackblocks);
last = NULL;
prev = TAILQ_LAST(&scb->sackblocks, sackblock_list);
} else {
if (SEQ_GEQ(seq, hint->sblk_start)) {
/* Search from hint to end of list. */
cur = hint;
last = NULL;
prev = TAILQ_LAST(&scb->sackblocks, sackblock_list);
} else {
/* Search from front of list to hint. */
cur = TAILQ_FIRST(&scb->sackblocks);
last = hint;
prev = TAILQ_PREV(hint, sackblock_list, sblk_list);
}
}
do {
/*
* Ensure we can't crash if the list really blows up due to
* delta sign wraps when comparing seq against sblk_start vs
* sblk_end.
*/
if (cur == NULL) {
krateprintf(&sackkrate,
"tcp_sack: fatal corrupt seq\n");
*sb = NULL;
return FALSE;
}
/*
* Check completion
*/
if (SEQ_GT(cur->sblk_end, seq)) {
if (SEQ_GEQ(seq, cur->sblk_start)) {
*sb = scb->lastfound = cur;
return TRUE;
} else {
*sb = scb->lastfound =
TAILQ_PREV(cur, sackblock_list, sblk_list);
return FALSE;
}
}
/*
* seq is greater than sblk_end, nominally proceed to the
* next block.
*
* It is possible for an overflow to cause the comparison
* between seq an sblk_start vs sblk_end to make it appear
* that seq is less than sblk_start and also greater than
* sblk_end. If we allow the case to fall through we can
* end up with cur == NULL on the next loop.
*/
if (SEQ_LT(seq, cur->sblk_start)) {
krateprintf(&sackkrate,
"tcp_sack: corrupt seq "
"0x%08x vs 0x%08x-0x%08x\n",
seq, cur->sblk_start, cur->sblk_end);
if (SEQ_GEQ(seq, cur->sblk_start)) {
*sb = scb->lastfound = cur;
return TRUE;
} else {
*sb = scb->lastfound =
TAILQ_PREV(cur, sackblock_list, sblk_list);
return FALSE;
}
}
cur = TAILQ_NEXT(cur, sblk_list);
} while (cur != last);
*sb = scb->lastfound = prev;
return FALSE;
} | /*
* Find the SACK block containing or immediately preceding "seq".
* The boolean result indicates whether the sequence is actually
* contained in the SACK block.
*/ | Find the SACK block containing or immediately preceding "seq".
The boolean result indicates whether the sequence is actually
contained in the SACK block. | [
"Find",
"the",
"SACK",
"block",
"containing",
"or",
"immediately",
"preceding",
"\"",
"seq",
"\"",
".",
"The",
"boolean",
"result",
"indicates",
"whether",
"the",
"sequence",
"is",
"actually",
"contained",
"in",
"the",
"SACK",
"block",
"."
] | static boolean_t
sack_block_lookup(struct scoreboard *scb, tcp_seq seq, struct sackblock **sb)
{
static struct krate sackkrate = { .freq = 1 };
struct sackblock *hint = scb->lastfound;
struct sackblock *cur, *last, *prev;
if (TAILQ_EMPTY(&scb->sackblocks)) {
*sb = NULL;
return FALSE;
}
if (hint == NULL) {
cur = TAILQ_FIRST(&scb->sackblocks);
last = NULL;
prev = TAILQ_LAST(&scb->sackblocks, sackblock_list);
} else {
if (SEQ_GEQ(seq, hint->sblk_start)) {
cur = hint;
last = NULL;
prev = TAILQ_LAST(&scb->sackblocks, sackblock_list);
} else {
cur = TAILQ_FIRST(&scb->sackblocks);
last = hint;
prev = TAILQ_PREV(hint, sackblock_list, sblk_list);
}
}
do {
if (cur == NULL) {
krateprintf(&sackkrate,
"tcp_sack: fatal corrupt seq\n");
*sb = NULL;
return FALSE;
}
if (SEQ_GT(cur->sblk_end, seq)) {
if (SEQ_GEQ(seq, cur->sblk_start)) {
*sb = scb->lastfound = cur;
return TRUE;
} else {
*sb = scb->lastfound =
TAILQ_PREV(cur, sackblock_list, sblk_list);
return FALSE;
}
}
if (SEQ_LT(seq, cur->sblk_start)) {
krateprintf(&sackkrate,
"tcp_sack: corrupt seq "
"0x%08x vs 0x%08x-0x%08x\n",
seq, cur->sblk_start, cur->sblk_end);
if (SEQ_GEQ(seq, cur->sblk_start)) {
*sb = scb->lastfound = cur;
return TRUE;
} else {
*sb = scb->lastfound =
TAILQ_PREV(cur, sackblock_list, sblk_list);
return FALSE;
}
}
cur = TAILQ_NEXT(cur, sblk_list);
} while (cur != last);
*sb = scb->lastfound = prev;
return FALSE;
} | [
"static",
"boolean_t",
"sack_block_lookup",
"(",
"struct",
"scoreboard",
"*",
"scb",
",",
"tcp_seq",
"seq",
",",
"struct",
"sackblock",
"*",
"*",
"sb",
")",
"{",
"static",
"struct",
"krate",
"sackkrate",
"=",
"{",
".",
"freq",
"=",
"1",
"}",
";",
"struct",
"sackblock",
"*",
"hint",
"=",
"scb",
"->",
"lastfound",
";",
"struct",
"sackblock",
"*",
"cur",
",",
"*",
"last",
",",
"*",
"prev",
";",
"if",
"(",
"TAILQ_EMPTY",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
")",
"{",
"*",
"sb",
"=",
"NULL",
";",
"return",
"FALSE",
";",
"}",
"if",
"(",
"hint",
"==",
"NULL",
")",
"{",
"cur",
"=",
"TAILQ_FIRST",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
";",
"last",
"=",
"NULL",
";",
"prev",
"=",
"TAILQ_LAST",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sackblock_list",
")",
";",
"}",
"else",
"{",
"if",
"(",
"SEQ_GEQ",
"(",
"seq",
",",
"hint",
"->",
"sblk_start",
")",
")",
"{",
"cur",
"=",
"hint",
";",
"last",
"=",
"NULL",
";",
"prev",
"=",
"TAILQ_LAST",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sackblock_list",
")",
";",
"}",
"else",
"{",
"cur",
"=",
"TAILQ_FIRST",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
";",
"last",
"=",
"hint",
";",
"prev",
"=",
"TAILQ_PREV",
"(",
"hint",
",",
"sackblock_list",
",",
"sblk_list",
")",
";",
"}",
"}",
"do",
"{",
"if",
"(",
"cur",
"==",
"NULL",
")",
"{",
"krateprintf",
"(",
"&",
"sackkrate",
",",
"\"",
"\\n",
"\"",
")",
";",
"*",
"sb",
"=",
"NULL",
";",
"return",
"FALSE",
";",
"}",
"if",
"(",
"SEQ_GT",
"(",
"cur",
"->",
"sblk_end",
",",
"seq",
")",
")",
"{",
"if",
"(",
"SEQ_GEQ",
"(",
"seq",
",",
"cur",
"->",
"sblk_start",
")",
")",
"{",
"*",
"sb",
"=",
"scb",
"->",
"lastfound",
"=",
"cur",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"*",
"sb",
"=",
"scb",
"->",
"lastfound",
"=",
"TAILQ_PREV",
"(",
"cur",
",",
"sackblock_list",
",",
"sblk_list",
")",
";",
"return",
"FALSE",
";",
"}",
"}",
"if",
"(",
"SEQ_LT",
"(",
"seq",
",",
"cur",
"->",
"sblk_start",
")",
")",
"{",
"krateprintf",
"(",
"&",
"sackkrate",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"seq",
",",
"cur",
"->",
"sblk_start",
",",
"cur",
"->",
"sblk_end",
")",
";",
"if",
"(",
"SEQ_GEQ",
"(",
"seq",
",",
"cur",
"->",
"sblk_start",
")",
")",
"{",
"*",
"sb",
"=",
"scb",
"->",
"lastfound",
"=",
"cur",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"*",
"sb",
"=",
"scb",
"->",
"lastfound",
"=",
"TAILQ_PREV",
"(",
"cur",
",",
"sackblock_list",
",",
"sblk_list",
")",
";",
"return",
"FALSE",
";",
"}",
"}",
"cur",
"=",
"TAILQ_NEXT",
"(",
"cur",
",",
"sblk_list",
")",
";",
"}",
"while",
"(",
"cur",
"!=",
"last",
")",
";",
"*",
"sb",
"=",
"scb",
"->",
"lastfound",
"=",
"prev",
";",
"return",
"FALSE",
";",
"}"
] | Find the SACK block containing or immediately preceding "seq". | [
"Find",
"the",
"SACK",
"block",
"containing",
"or",
"immediately",
"preceding",
"\"",
"seq",
"\"",
"."
] | [
"/* No hint. Search from start to end. */",
"/* Search from hint to end of list. */",
"/* Search from front of list to hint. */",
"/*\n\t\t * Ensure we can't crash if the list really blows up due to\n\t\t * delta sign wraps when comparing seq against sblk_start vs\n\t\t * sblk_end.\n\t\t */",
"/*\n\t\t * Check completion\n\t\t */",
"/*\n\t\t * seq is greater than sblk_end, nominally proceed to the\n\t\t * next block.\n\t\t *\n\t\t * It is possible for an overflow to cause the comparison\n\t\t * between seq an sblk_start vs sblk_end to make it appear\n\t\t * that seq is less than sblk_start and also greater than\n\t\t * sblk_end. If we allow the case to fall through we can\n\t\t * end up with cur == NULL on the next loop.\n\t\t */"
] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "seq",
"type": "tcp_seq"
},
{
"param": "sb",
"type": "struct sackblock"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sb",
"type": "struct sackblock",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_ack_blocks | void | static void
tcp_sack_ack_blocks(struct tcpcb *tp, tcp_seq th_ack)
{
struct scoreboard *scb = &tp->scb;
struct sackblock *sb, *nb;
sb = TAILQ_FIRST(&scb->sackblocks);
while (sb && SEQ_LEQ(sb->sblk_end, th_ack)) {
nb = TAILQ_NEXT(sb, sblk_list);
if (scb->lastfound == sb)
scb->lastfound = NULL;
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks >= 0,
("SACK block count underflow: %d < 0", scb->nblocks));
sb = nb;
}
if (sb && SEQ_GEQ(th_ack, sb->sblk_start)) {
/* Other side reneged? XXX */
tcpstat.tcps_sackrenege++;
tcp_sack_discard(tp);
}
} | /*
* Free up SACK blocks for data that's been acked.
*/ | Free up SACK blocks for data that's been acked. | [
"Free",
"up",
"SACK",
"blocks",
"for",
"data",
"that",
"'",
"s",
"been",
"acked",
"."
] | static void
tcp_sack_ack_blocks(struct tcpcb *tp, tcp_seq th_ack)
{
struct scoreboard *scb = &tp->scb;
struct sackblock *sb, *nb;
sb = TAILQ_FIRST(&scb->sackblocks);
while (sb && SEQ_LEQ(sb->sblk_end, th_ack)) {
nb = TAILQ_NEXT(sb, sblk_list);
if (scb->lastfound == sb)
scb->lastfound = NULL;
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks >= 0,
("SACK block count underflow: %d < 0", scb->nblocks));
sb = nb;
}
if (sb && SEQ_GEQ(th_ack, sb->sblk_start)) {
tcpstat.tcps_sackrenege++;
tcp_sack_discard(tp);
}
} | [
"static",
"void",
"tcp_sack_ack_blocks",
"(",
"struct",
"tcpcb",
"*",
"tp",
",",
"tcp_seq",
"th_ack",
")",
"{",
"struct",
"scoreboard",
"*",
"scb",
"=",
"&",
"tp",
"->",
"scb",
";",
"struct",
"sackblock",
"*",
"sb",
",",
"*",
"nb",
";",
"sb",
"=",
"TAILQ_FIRST",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
";",
"while",
"(",
"sb",
"&&",
"SEQ_LEQ",
"(",
"sb",
"->",
"sblk_end",
",",
"th_ack",
")",
")",
"{",
"nb",
"=",
"TAILQ_NEXT",
"(",
"sb",
",",
"sblk_list",
")",
";",
"if",
"(",
"scb",
"->",
"lastfound",
"==",
"sb",
")",
"scb",
"->",
"lastfound",
"=",
"NULL",
";",
"TAILQ_REMOVE",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sb",
",",
"sblk_list",
")",
";",
"free_sackblock",
"(",
"scb",
",",
"sb",
")",
";",
"--",
"scb",
"->",
"nblocks",
";",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
">=",
"0",
",",
"(",
"\"",
"\"",
",",
"scb",
"->",
"nblocks",
")",
")",
";",
"sb",
"=",
"nb",
";",
"}",
"if",
"(",
"sb",
"&&",
"SEQ_GEQ",
"(",
"th_ack",
",",
"sb",
"->",
"sblk_start",
")",
")",
"{",
"tcpstat",
".",
"tcps_sackrenege",
"++",
";",
"tcp_sack_discard",
"(",
"tp",
")",
";",
"}",
"}"
] | Free up SACK blocks for data that's been acked. | [
"Free",
"up",
"SACK",
"blocks",
"for",
"data",
"that",
"'",
"s",
"been",
"acked",
"."
] | [
"/* Other side reneged? XXX */"
] | [
{
"param": "tp",
"type": "struct tcpcb"
},
{
"param": "th_ack",
"type": "tcp_seq"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "th_ack",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_cleanup | void | static void
tcp_sack_cleanup(struct scoreboard *scb)
{
struct sackblock *sb, *nb;
TAILQ_FOREACH_MUTABLE(sb, &scb->sackblocks, sblk_list, nb) {
free_sackblock(scb, sb);
--scb->nblocks;
}
KASSERT(scb->nblocks == 0,
("SACK block %d count not zero", scb->nblocks));
TAILQ_INIT(&scb->sackblocks);
scb->lastfound = NULL;
} | /*
* Delete and free SACK blocks saved in scoreboard.
*/ | Delete and free SACK blocks saved in scoreboard. | [
"Delete",
"and",
"free",
"SACK",
"blocks",
"saved",
"in",
"scoreboard",
"."
] | static void
tcp_sack_cleanup(struct scoreboard *scb)
{
struct sackblock *sb, *nb;
TAILQ_FOREACH_MUTABLE(sb, &scb->sackblocks, sblk_list, nb) {
free_sackblock(scb, sb);
--scb->nblocks;
}
KASSERT(scb->nblocks == 0,
("SACK block %d count not zero", scb->nblocks));
TAILQ_INIT(&scb->sackblocks);
scb->lastfound = NULL;
} | [
"static",
"void",
"tcp_sack_cleanup",
"(",
"struct",
"scoreboard",
"*",
"scb",
")",
"{",
"struct",
"sackblock",
"*",
"sb",
",",
"*",
"nb",
";",
"TAILQ_FOREACH_MUTABLE",
"(",
"sb",
",",
"&",
"scb",
"->",
"sackblocks",
",",
"sblk_list",
",",
"nb",
")",
"",
"{",
"free_sackblock",
"(",
"scb",
",",
"sb",
")",
";",
"--",
"scb",
"->",
"nblocks",
";",
"}",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
"==",
"0",
",",
"(",
"\"",
"\"",
",",
"scb",
"->",
"nblocks",
")",
")",
";",
"TAILQ_INIT",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
";",
"scb",
"->",
"lastfound",
"=",
"NULL",
";",
"}"
] | Delete and free SACK blocks saved in scoreboard. | [
"Delete",
"and",
"free",
"SACK",
"blocks",
"saved",
"in",
"scoreboard",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_destroy | void | void
tcp_sack_destroy(struct scoreboard *scb)
{
tcp_sack_cleanup(scb);
if (scb->freecache != NULL) {
kfree(scb->freecache, M_SACKBLOCK);
scb->freecache = NULL;
}
} | /*
* Delete and free SACK blocks saved in scoreboard.
* Delete the one slot block cache.
*/ | Delete and free SACK blocks saved in scoreboard.
Delete the one slot block cache. | [
"Delete",
"and",
"free",
"SACK",
"blocks",
"saved",
"in",
"scoreboard",
".",
"Delete",
"the",
"one",
"slot",
"block",
"cache",
"."
] | void
tcp_sack_destroy(struct scoreboard *scb)
{
tcp_sack_cleanup(scb);
if (scb->freecache != NULL) {
kfree(scb->freecache, M_SACKBLOCK);
scb->freecache = NULL;
}
} | [
"void",
"tcp_sack_destroy",
"(",
"struct",
"scoreboard",
"*",
"scb",
")",
"{",
"tcp_sack_cleanup",
"(",
"scb",
")",
";",
"if",
"(",
"scb",
"->",
"freecache",
"!=",
"NULL",
")",
"{",
"kfree",
"(",
"scb",
"->",
"freecache",
",",
"M_SACKBLOCK",
")",
";",
"scb",
"->",
"freecache",
"=",
"NULL",
";",
"}",
"}"
] | Delete and free SACK blocks saved in scoreboard. | [
"Delete",
"and",
"free",
"SACK",
"blocks",
"saved",
"in",
"scoreboard",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_report_cleanup | void | void
tcp_sack_report_cleanup(struct tcpcb *tp)
{
tp->sack_flags &=
~(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT);
tp->reportblk.rblk_start = tp->reportblk.rblk_end;
} | /*
* Cleanup the reported SACK block information
*/ | Cleanup the reported SACK block information | [
"Cleanup",
"the",
"reported",
"SACK",
"block",
"information"
] | void
tcp_sack_report_cleanup(struct tcpcb *tp)
{
tp->sack_flags &=
~(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT);
tp->reportblk.rblk_start = tp->reportblk.rblk_end;
} | [
"void",
"tcp_sack_report_cleanup",
"(",
"struct",
"tcpcb",
"*",
"tp",
")",
"{",
"tp",
"->",
"sack_flags",
"&=",
"~",
"(",
"TSACK_F_DUPSEG",
"|",
"TSACK_F_ENCLOSESEG",
"|",
"TSACK_F_SACKLEFT",
")",
";",
"tp",
"->",
"reportblk",
".",
"rblk_start",
"=",
"tp",
"->",
"reportblk",
".",
"rblk_end",
";",
"}"
] | Cleanup the reported SACK block information | [
"Cleanup",
"the",
"reported",
"SACK",
"block",
"information"
] | [] | [
{
"param": "tp",
"type": "struct tcpcb"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_report_needed | boolean_t | boolean_t
tcp_sack_report_needed(const struct tcpcb *tp)
{
if ((tp->sack_flags &
(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT)) ||
tp->reportblk.rblk_start != tp->reportblk.rblk_end)
return TRUE;
else
return FALSE;
} | /*
* Whether SACK report is needed or not
*/ | Whether SACK report is needed or not | [
"Whether",
"SACK",
"report",
"is",
"needed",
"or",
"not"
] | boolean_t
tcp_sack_report_needed(const struct tcpcb *tp)
{
if ((tp->sack_flags &
(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT)) ||
tp->reportblk.rblk_start != tp->reportblk.rblk_end)
return TRUE;
else
return FALSE;
} | [
"boolean_t",
"tcp_sack_report_needed",
"(",
"const",
"struct",
"tcpcb",
"*",
"tp",
")",
"{",
"if",
"(",
"(",
"tp",
"->",
"sack_flags",
"&",
"(",
"TSACK_F_DUPSEG",
"|",
"TSACK_F_ENCLOSESEG",
"|",
"TSACK_F_SACKLEFT",
")",
")",
"||",
"tp",
"->",
"reportblk",
".",
"rblk_start",
"!=",
"tp",
"->",
"reportblk",
".",
"rblk_end",
")",
"return",
"TRUE",
";",
"else",
"return",
"FALSE",
";",
"}"
] | Whether SACK report is needed or not | [
"Whether",
"SACK",
"report",
"is",
"needed",
"or",
"not"
] | [] | [
{
"param": "tp",
"type": "struct tcpcb"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_add_blocks | void | static void
tcp_sack_add_blocks(struct tcpcb *tp, struct tcpopt *to)
{
const int numblocks = to->to_nsackblocks;
struct raw_sackblock *blocks = to->to_sackblocks;
struct scoreboard *scb = &tp->scb;
int startblock, i;
if (tcp_sack_ndsack_blocks(blocks, numblocks, tp->snd_una) > 0)
startblock = 1;
else
startblock = 0;
to->to_flags |= TOF_SACK_REDUNDANT;
for (i = startblock; i < numblocks; i++) {
struct raw_sackblock *newsackblock = &blocks[i];
boolean_t update;
int error;
/* Guard against ACK reordering */
if (SEQ_LEQ(newsackblock->rblk_start, tp->snd_una))
continue;
/* Don't accept bad SACK blocks */
if (SEQ_GT(newsackblock->rblk_end, tp->snd_max)) {
tcpstat.tcps_rcvbadsackopt++;
break; /* skip all other blocks */
}
tcpstat.tcps_sacksbupdate++;
error = insert_block(scb, newsackblock, &update);
if (update)
to->to_flags &= ~TOF_SACK_REDUNDANT;
if (error)
break;
}
} | /*
* Update scoreboard on new incoming ACK.
*/ | Update scoreboard on new incoming ACK. | [
"Update",
"scoreboard",
"on",
"new",
"incoming",
"ACK",
"."
] | static void
tcp_sack_add_blocks(struct tcpcb *tp, struct tcpopt *to)
{
const int numblocks = to->to_nsackblocks;
struct raw_sackblock *blocks = to->to_sackblocks;
struct scoreboard *scb = &tp->scb;
int startblock, i;
if (tcp_sack_ndsack_blocks(blocks, numblocks, tp->snd_una) > 0)
startblock = 1;
else
startblock = 0;
to->to_flags |= TOF_SACK_REDUNDANT;
for (i = startblock; i < numblocks; i++) {
struct raw_sackblock *newsackblock = &blocks[i];
boolean_t update;
int error;
if (SEQ_LEQ(newsackblock->rblk_start, tp->snd_una))
continue;
if (SEQ_GT(newsackblock->rblk_end, tp->snd_max)) {
tcpstat.tcps_rcvbadsackopt++;
break;
}
tcpstat.tcps_sacksbupdate++;
error = insert_block(scb, newsackblock, &update);
if (update)
to->to_flags &= ~TOF_SACK_REDUNDANT;
if (error)
break;
}
} | [
"static",
"void",
"tcp_sack_add_blocks",
"(",
"struct",
"tcpcb",
"*",
"tp",
",",
"struct",
"tcpopt",
"*",
"to",
")",
"{",
"const",
"int",
"numblocks",
"=",
"to",
"->",
"to_nsackblocks",
";",
"struct",
"raw_sackblock",
"*",
"blocks",
"=",
"to",
"->",
"to_sackblocks",
";",
"struct",
"scoreboard",
"*",
"scb",
"=",
"&",
"tp",
"->",
"scb",
";",
"int",
"startblock",
",",
"i",
";",
"if",
"(",
"tcp_sack_ndsack_blocks",
"(",
"blocks",
",",
"numblocks",
",",
"tp",
"->",
"snd_una",
")",
">",
"0",
")",
"startblock",
"=",
"1",
";",
"else",
"startblock",
"=",
"0",
";",
"to",
"->",
"to_flags",
"|=",
"TOF_SACK_REDUNDANT",
";",
"for",
"(",
"i",
"=",
"startblock",
";",
"i",
"<",
"numblocks",
";",
"i",
"++",
")",
"{",
"struct",
"raw_sackblock",
"*",
"newsackblock",
"=",
"&",
"blocks",
"[",
"i",
"]",
";",
"boolean_t",
"update",
";",
"int",
"error",
";",
"if",
"(",
"SEQ_LEQ",
"(",
"newsackblock",
"->",
"rblk_start",
",",
"tp",
"->",
"snd_una",
")",
")",
"continue",
";",
"if",
"(",
"SEQ_GT",
"(",
"newsackblock",
"->",
"rblk_end",
",",
"tp",
"->",
"snd_max",
")",
")",
"{",
"tcpstat",
".",
"tcps_rcvbadsackopt",
"++",
";",
"break",
";",
"}",
"tcpstat",
".",
"tcps_sacksbupdate",
"++",
";",
"error",
"=",
"insert_block",
"(",
"scb",
",",
"newsackblock",
",",
"&",
"update",
")",
";",
"if",
"(",
"update",
")",
"to",
"->",
"to_flags",
"&=",
"~",
"TOF_SACK_REDUNDANT",
";",
"if",
"(",
"error",
")",
"break",
";",
"}",
"}"
] | Update scoreboard on new incoming ACK. | [
"Update",
"scoreboard",
"on",
"new",
"incoming",
"ACK",
"."
] | [
"/* Guard against ACK reordering */",
"/* Don't accept bad SACK blocks */",
"/* skip all other blocks */"
] | [
{
"param": "tp",
"type": "struct tcpcb"
},
{
"param": "to",
"type": "struct tcpopt"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "to",
"type": "struct tcpopt",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | insert_block | int | static int
insert_block(struct scoreboard *scb, const struct raw_sackblock *raw_sb,
boolean_t *update)
{
struct sackblock *sb, *workingblock;
boolean_t overlap_front;
*update = TRUE;
if (TAILQ_EMPTY(&scb->sackblocks)) {
struct sackblock *newblock;
KASSERT(scb->nblocks == 0, ("emply scb w/ blocks"));
newblock = alloc_sackblock(scb, raw_sb);
if (newblock == NULL)
return ENOMEM;
TAILQ_INSERT_HEAD(&scb->sackblocks, newblock, sblk_list);
scb->nblocks = 1;
return 0;
}
KASSERT(scb->nblocks > 0, ("insert_block() called w/ no blocks"));
KASSERT(scb->nblocks <= MAXSAVEDBLOCKS,
("too many SACK blocks %d", scb->nblocks));
overlap_front = sack_block_lookup(scb, raw_sb->rblk_start, &sb);
if (sb == NULL) {
workingblock = alloc_sackblock_limit(scb, raw_sb);
if (workingblock == NULL)
return ENOMEM;
TAILQ_INSERT_HEAD(&scb->sackblocks, workingblock, sblk_list);
++scb->nblocks;
} else {
if (overlap_front || sb->sblk_end == raw_sb->rblk_start) {
tcpstat.tcps_sacksbreused++;
/* Extend old block */
workingblock = sb;
if (SEQ_GT(raw_sb->rblk_end, sb->sblk_end)) {
sb->sblk_end = raw_sb->rblk_end;
} else {
/* Exact match, nothing to consolidate */
*update = FALSE;
return 0;
}
} else {
workingblock = alloc_sackblock_limit(scb, raw_sb);
if (workingblock == NULL)
return ENOMEM;
TAILQ_INSERT_AFTER(&scb->sackblocks, sb, workingblock,
sblk_list);
++scb->nblocks;
}
}
/* Consolidate right-hand side. */
sb = TAILQ_NEXT(workingblock, sblk_list);
while (sb != NULL &&
SEQ_GEQ(workingblock->sblk_end, sb->sblk_end)) {
struct sackblock *nextblock;
nextblock = TAILQ_NEXT(sb, sblk_list);
if (scb->lastfound == sb)
scb->lastfound = NULL;
/* Remove completely overlapped block */
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks > 0,
("removed overlapped block: %d blocks left", scb->nblocks));
sb = nextblock;
}
if (sb != NULL &&
SEQ_GEQ(workingblock->sblk_end, sb->sblk_start)) {
/* Extend new block to cover partially overlapped old block. */
workingblock->sblk_end = sb->sblk_end;
if (scb->lastfound == sb)
scb->lastfound = NULL;
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks > 0,
("removed partial right: %d blocks left", scb->nblocks));
}
return 0;
} | /*
* Insert SACK block into sender's scoreboard.
*/ | Insert SACK block into sender's scoreboard. | [
"Insert",
"SACK",
"block",
"into",
"sender",
"'",
"s",
"scoreboard",
"."
] | static int
insert_block(struct scoreboard *scb, const struct raw_sackblock *raw_sb,
boolean_t *update)
{
struct sackblock *sb, *workingblock;
boolean_t overlap_front;
*update = TRUE;
if (TAILQ_EMPTY(&scb->sackblocks)) {
struct sackblock *newblock;
KASSERT(scb->nblocks == 0, ("emply scb w/ blocks"));
newblock = alloc_sackblock(scb, raw_sb);
if (newblock == NULL)
return ENOMEM;
TAILQ_INSERT_HEAD(&scb->sackblocks, newblock, sblk_list);
scb->nblocks = 1;
return 0;
}
KASSERT(scb->nblocks > 0, ("insert_block() called w/ no blocks"));
KASSERT(scb->nblocks <= MAXSAVEDBLOCKS,
("too many SACK blocks %d", scb->nblocks));
overlap_front = sack_block_lookup(scb, raw_sb->rblk_start, &sb);
if (sb == NULL) {
workingblock = alloc_sackblock_limit(scb, raw_sb);
if (workingblock == NULL)
return ENOMEM;
TAILQ_INSERT_HEAD(&scb->sackblocks, workingblock, sblk_list);
++scb->nblocks;
} else {
if (overlap_front || sb->sblk_end == raw_sb->rblk_start) {
tcpstat.tcps_sacksbreused++;
workingblock = sb;
if (SEQ_GT(raw_sb->rblk_end, sb->sblk_end)) {
sb->sblk_end = raw_sb->rblk_end;
} else {
*update = FALSE;
return 0;
}
} else {
workingblock = alloc_sackblock_limit(scb, raw_sb);
if (workingblock == NULL)
return ENOMEM;
TAILQ_INSERT_AFTER(&scb->sackblocks, sb, workingblock,
sblk_list);
++scb->nblocks;
}
}
sb = TAILQ_NEXT(workingblock, sblk_list);
while (sb != NULL &&
SEQ_GEQ(workingblock->sblk_end, sb->sblk_end)) {
struct sackblock *nextblock;
nextblock = TAILQ_NEXT(sb, sblk_list);
if (scb->lastfound == sb)
scb->lastfound = NULL;
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks > 0,
("removed overlapped block: %d blocks left", scb->nblocks));
sb = nextblock;
}
if (sb != NULL &&
SEQ_GEQ(workingblock->sblk_end, sb->sblk_start)) {
workingblock->sblk_end = sb->sblk_end;
if (scb->lastfound == sb)
scb->lastfound = NULL;
TAILQ_REMOVE(&scb->sackblocks, sb, sblk_list);
free_sackblock(scb, sb);
--scb->nblocks;
KASSERT(scb->nblocks > 0,
("removed partial right: %d blocks left", scb->nblocks));
}
return 0;
} | [
"static",
"int",
"insert_block",
"(",
"struct",
"scoreboard",
"*",
"scb",
",",
"const",
"struct",
"raw_sackblock",
"*",
"raw_sb",
",",
"boolean_t",
"*",
"update",
")",
"{",
"struct",
"sackblock",
"*",
"sb",
",",
"*",
"workingblock",
";",
"boolean_t",
"overlap_front",
";",
"*",
"update",
"=",
"TRUE",
";",
"if",
"(",
"TAILQ_EMPTY",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
")",
"{",
"struct",
"sackblock",
"*",
"newblock",
";",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
"==",
"0",
",",
"(",
"\"",
"\"",
")",
")",
";",
"newblock",
"=",
"alloc_sackblock",
"(",
"scb",
",",
"raw_sb",
")",
";",
"if",
"(",
"newblock",
"==",
"NULL",
")",
"return",
"ENOMEM",
";",
"TAILQ_INSERT_HEAD",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"newblock",
",",
"sblk_list",
")",
";",
"scb",
"->",
"nblocks",
"=",
"1",
";",
"return",
"0",
";",
"}",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
">",
"0",
",",
"(",
"\"",
"\"",
")",
")",
";",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
"<=",
"MAXSAVEDBLOCKS",
",",
"(",
"\"",
"\"",
",",
"scb",
"->",
"nblocks",
")",
")",
";",
"overlap_front",
"=",
"sack_block_lookup",
"(",
"scb",
",",
"raw_sb",
"->",
"rblk_start",
",",
"&",
"sb",
")",
";",
"if",
"(",
"sb",
"==",
"NULL",
")",
"{",
"workingblock",
"=",
"alloc_sackblock_limit",
"(",
"scb",
",",
"raw_sb",
")",
";",
"if",
"(",
"workingblock",
"==",
"NULL",
")",
"return",
"ENOMEM",
";",
"TAILQ_INSERT_HEAD",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"workingblock",
",",
"sblk_list",
")",
";",
"++",
"scb",
"->",
"nblocks",
";",
"}",
"else",
"{",
"if",
"(",
"overlap_front",
"||",
"sb",
"->",
"sblk_end",
"==",
"raw_sb",
"->",
"rblk_start",
")",
"{",
"tcpstat",
".",
"tcps_sacksbreused",
"++",
";",
"workingblock",
"=",
"sb",
";",
"if",
"(",
"SEQ_GT",
"(",
"raw_sb",
"->",
"rblk_end",
",",
"sb",
"->",
"sblk_end",
")",
")",
"{",
"sb",
"->",
"sblk_end",
"=",
"raw_sb",
"->",
"rblk_end",
";",
"}",
"else",
"{",
"*",
"update",
"=",
"FALSE",
";",
"return",
"0",
";",
"}",
"}",
"else",
"{",
"workingblock",
"=",
"alloc_sackblock_limit",
"(",
"scb",
",",
"raw_sb",
")",
";",
"if",
"(",
"workingblock",
"==",
"NULL",
")",
"return",
"ENOMEM",
";",
"TAILQ_INSERT_AFTER",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sb",
",",
"workingblock",
",",
"sblk_list",
")",
";",
"++",
"scb",
"->",
"nblocks",
";",
"}",
"}",
"sb",
"=",
"TAILQ_NEXT",
"(",
"workingblock",
",",
"sblk_list",
")",
";",
"while",
"(",
"sb",
"!=",
"NULL",
"&&",
"SEQ_GEQ",
"(",
"workingblock",
"->",
"sblk_end",
",",
"sb",
"->",
"sblk_end",
")",
")",
"{",
"struct",
"sackblock",
"*",
"nextblock",
";",
"nextblock",
"=",
"TAILQ_NEXT",
"(",
"sb",
",",
"sblk_list",
")",
";",
"if",
"(",
"scb",
"->",
"lastfound",
"==",
"sb",
")",
"scb",
"->",
"lastfound",
"=",
"NULL",
";",
"TAILQ_REMOVE",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sb",
",",
"sblk_list",
")",
";",
"free_sackblock",
"(",
"scb",
",",
"sb",
")",
";",
"--",
"scb",
"->",
"nblocks",
";",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
">",
"0",
",",
"(",
"\"",
"\"",
",",
"scb",
"->",
"nblocks",
")",
")",
";",
"sb",
"=",
"nextblock",
";",
"}",
"if",
"(",
"sb",
"!=",
"NULL",
"&&",
"SEQ_GEQ",
"(",
"workingblock",
"->",
"sblk_end",
",",
"sb",
"->",
"sblk_start",
")",
")",
"{",
"workingblock",
"->",
"sblk_end",
"=",
"sb",
"->",
"sblk_end",
";",
"if",
"(",
"scb",
"->",
"lastfound",
"==",
"sb",
")",
"scb",
"->",
"lastfound",
"=",
"NULL",
";",
"TAILQ_REMOVE",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sb",
",",
"sblk_list",
")",
";",
"free_sackblock",
"(",
"scb",
",",
"sb",
")",
";",
"--",
"scb",
"->",
"nblocks",
";",
"KASSERT",
"(",
"scb",
"->",
"nblocks",
">",
"0",
",",
"(",
"\"",
"\"",
",",
"scb",
"->",
"nblocks",
")",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Insert SACK block into sender's scoreboard. | [
"Insert",
"SACK",
"block",
"into",
"sender",
"'",
"s",
"scoreboard",
"."
] | [
"/* Extend old block */",
"/* Exact match, nothing to consolidate */",
"/* Consolidate right-hand side. */",
"/* Remove completely overlapped block */",
"/* Extend new block to cover partially overlapped old block. */"
] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "raw_sb",
"type": "struct raw_sackblock"
},
{
"param": "update",
"type": "boolean_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw_sb",
"type": "struct raw_sackblock",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "update",
"type": "boolean_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_update_lostseq | void | void
tcp_sack_update_lostseq(struct scoreboard *scb, tcp_seq snd_una, u_int maxseg,
int rxtthresh)
{
struct sackblock *sb;
int nsackblocks = 0;
int bytes_sacked = 0;
int rxtthresh_bytes;
if (tcp_do_rfc6675)
rxtthresh_bytes = (rxtthresh - 1) * maxseg;
else
rxtthresh_bytes = rxtthresh * maxseg;
sb = TAILQ_LAST(&scb->sackblocks, sackblock_list);
while (sb != NULL) {
++nsackblocks;
bytes_sacked += sb->sblk_end - sb->sblk_start;
if (nsackblocks == rxtthresh ||
bytes_sacked >= rxtthresh_bytes) {
scb->lostseq = sb->sblk_start;
return;
}
sb = TAILQ_PREV(sb, sackblock_list, sblk_list);
}
scb->lostseq = snd_una;
} | /*
* Optimization to quickly determine which packets are lost.
*/ | Optimization to quickly determine which packets are lost. | [
"Optimization",
"to",
"quickly",
"determine",
"which",
"packets",
"are",
"lost",
"."
] | void
tcp_sack_update_lostseq(struct scoreboard *scb, tcp_seq snd_una, u_int maxseg,
int rxtthresh)
{
struct sackblock *sb;
int nsackblocks = 0;
int bytes_sacked = 0;
int rxtthresh_bytes;
if (tcp_do_rfc6675)
rxtthresh_bytes = (rxtthresh - 1) * maxseg;
else
rxtthresh_bytes = rxtthresh * maxseg;
sb = TAILQ_LAST(&scb->sackblocks, sackblock_list);
while (sb != NULL) {
++nsackblocks;
bytes_sacked += sb->sblk_end - sb->sblk_start;
if (nsackblocks == rxtthresh ||
bytes_sacked >= rxtthresh_bytes) {
scb->lostseq = sb->sblk_start;
return;
}
sb = TAILQ_PREV(sb, sackblock_list, sblk_list);
}
scb->lostseq = snd_una;
} | [
"void",
"tcp_sack_update_lostseq",
"(",
"struct",
"scoreboard",
"*",
"scb",
",",
"tcp_seq",
"snd_una",
",",
"u_int",
"maxseg",
",",
"int",
"rxtthresh",
")",
"{",
"struct",
"sackblock",
"*",
"sb",
";",
"int",
"nsackblocks",
"=",
"0",
";",
"int",
"bytes_sacked",
"=",
"0",
";",
"int",
"rxtthresh_bytes",
";",
"if",
"(",
"tcp_do_rfc6675",
")",
"rxtthresh_bytes",
"=",
"(",
"rxtthresh",
"-",
"1",
")",
"*",
"maxseg",
";",
"else",
"rxtthresh_bytes",
"=",
"rxtthresh",
"*",
"maxseg",
";",
"sb",
"=",
"TAILQ_LAST",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sackblock_list",
")",
";",
"while",
"(",
"sb",
"!=",
"NULL",
")",
"{",
"++",
"nsackblocks",
";",
"bytes_sacked",
"+=",
"sb",
"->",
"sblk_end",
"-",
"sb",
"->",
"sblk_start",
";",
"if",
"(",
"nsackblocks",
"==",
"rxtthresh",
"||",
"bytes_sacked",
">=",
"rxtthresh_bytes",
")",
"{",
"scb",
"->",
"lostseq",
"=",
"sb",
"->",
"sblk_start",
";",
"return",
";",
"}",
"sb",
"=",
"TAILQ_PREV",
"(",
"sb",
",",
"sackblock_list",
",",
"sblk_list",
")",
";",
"}",
"scb",
"->",
"lostseq",
"=",
"snd_una",
";",
"}"
] | Optimization to quickly determine which packets are lost. | [
"Optimization",
"to",
"quickly",
"determine",
"which",
"packets",
"are",
"lost",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "snd_una",
"type": "tcp_seq"
},
{
"param": "maxseg",
"type": "u_int"
},
{
"param": "rxtthresh",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "snd_una",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "maxseg",
"type": "u_int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rxtthresh",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_islost | boolean_t | boolean_t
tcp_sack_islost(const struct scoreboard *scb, tcp_seq seqnum)
{
return SEQ_LT(seqnum, scb->lostseq);
} | /*
* Return whether the given sequence number is considered lost.
*/ | Return whether the given sequence number is considered lost. | [
"Return",
"whether",
"the",
"given",
"sequence",
"number",
"is",
"considered",
"lost",
"."
] | boolean_t
tcp_sack_islost(const struct scoreboard *scb, tcp_seq seqnum)
{
return SEQ_LT(seqnum, scb->lostseq);
} | [
"boolean_t",
"tcp_sack_islost",
"(",
"const",
"struct",
"scoreboard",
"*",
"scb",
",",
"tcp_seq",
"seqnum",
")",
"{",
"return",
"SEQ_LT",
"(",
"seqnum",
",",
"scb",
"->",
"lostseq",
")",
";",
"}"
] | Return whether the given sequence number is considered lost. | [
"Return",
"whether",
"the",
"given",
"sequence",
"number",
"is",
"considered",
"lost",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "seqnum",
"type": "tcp_seq"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seqnum",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_has_sacked | boolean_t | boolean_t
tcp_sack_has_sacked(const struct scoreboard *scb, u_int amount)
{
const struct sackblock *sb;
int bytes_sacked = 0;
TAILQ_FOREACH(sb, &scb->sackblocks, sblk_list) {
bytes_sacked += sb->sblk_end - sb->sblk_start;
if (bytes_sacked >= amount)
return TRUE;
}
return FALSE;
} | /*
* True if at least "amount" has been SACKed. Used by Early Retransmit.
*/ | True if at least "amount" has been SACKed. Used by Early Retransmit. | [
"True",
"if",
"at",
"least",
"\"",
"amount",
"\"",
"has",
"been",
"SACKed",
".",
"Used",
"by",
"Early",
"Retransmit",
"."
] | boolean_t
tcp_sack_has_sacked(const struct scoreboard *scb, u_int amount)
{
const struct sackblock *sb;
int bytes_sacked = 0;
TAILQ_FOREACH(sb, &scb->sackblocks, sblk_list) {
bytes_sacked += sb->sblk_end - sb->sblk_start;
if (bytes_sacked >= amount)
return TRUE;
}
return FALSE;
} | [
"boolean_t",
"tcp_sack_has_sacked",
"(",
"const",
"struct",
"scoreboard",
"*",
"scb",
",",
"u_int",
"amount",
")",
"{",
"const",
"struct",
"sackblock",
"*",
"sb",
";",
"int",
"bytes_sacked",
"=",
"0",
";",
"TAILQ_FOREACH",
"(",
"sb",
",",
"&",
"scb",
"->",
"sackblocks",
",",
"sblk_list",
")",
"",
"{",
"bytes_sacked",
"+=",
"sb",
"->",
"sblk_end",
"-",
"sb",
"->",
"sblk_start",
";",
"if",
"(",
"bytes_sacked",
">=",
"amount",
")",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | True if at least "amount" has been SACKed. | [
"True",
"if",
"at",
"least",
"\"",
"amount",
"\"",
"has",
"been",
"SACKed",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "amount",
"type": "u_int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "amount",
"type": "u_int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_bytes_below | int | int
tcp_sack_bytes_below(const struct scoreboard *scb, tcp_seq seq)
{
const struct sackblock *sb;
int bytes_sacked = 0;
sb = TAILQ_FIRST(&scb->sackblocks);
while (sb && SEQ_GT(seq, sb->sblk_start)) {
bytes_sacked += seq_min(seq, sb->sblk_end) - sb->sblk_start;
sb = TAILQ_NEXT(sb, sblk_list);
}
return bytes_sacked;
} | /*
* Number of bytes SACKed below seq.
*/ | Number of bytes SACKed below seq. | [
"Number",
"of",
"bytes",
"SACKed",
"below",
"seq",
"."
] | int
tcp_sack_bytes_below(const struct scoreboard *scb, tcp_seq seq)
{
const struct sackblock *sb;
int bytes_sacked = 0;
sb = TAILQ_FIRST(&scb->sackblocks);
while (sb && SEQ_GT(seq, sb->sblk_start)) {
bytes_sacked += seq_min(seq, sb->sblk_end) - sb->sblk_start;
sb = TAILQ_NEXT(sb, sblk_list);
}
return bytes_sacked;
} | [
"int",
"tcp_sack_bytes_below",
"(",
"const",
"struct",
"scoreboard",
"*",
"scb",
",",
"tcp_seq",
"seq",
")",
"{",
"const",
"struct",
"sackblock",
"*",
"sb",
";",
"int",
"bytes_sacked",
"=",
"0",
";",
"sb",
"=",
"TAILQ_FIRST",
"(",
"&",
"scb",
"->",
"sackblocks",
")",
";",
"while",
"(",
"sb",
"&&",
"SEQ_GT",
"(",
"seq",
",",
"sb",
"->",
"sblk_start",
")",
")",
"{",
"bytes_sacked",
"+=",
"seq_min",
"(",
"seq",
",",
"sb",
"->",
"sblk_end",
")",
"-",
"sb",
"->",
"sblk_start",
";",
"sb",
"=",
"TAILQ_NEXT",
"(",
"sb",
",",
"sblk_list",
")",
";",
"}",
"return",
"bytes_sacked",
";",
"}"
] | Number of bytes SACKed below seq. | [
"Number",
"of",
"bytes",
"SACKed",
"below",
"seq",
"."
] | [] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "seq",
"type": "tcp_seq"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seq",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_compute_pipe | uint32_t | uint32_t
tcp_sack_compute_pipe(const struct tcpcb *tp)
{
const struct scoreboard *scb = &tp->scb;
const struct sackblock *sb;
int nlost, nretransmitted;
tcp_seq end;
nlost = tp->snd_max - scb->lostseq;
nretransmitted = tp->rexmt_high - tp->snd_una;
TAILQ_FOREACH(sb, &scb->sackblocks, sblk_list) {
if (SEQ_LT(sb->sblk_start, tp->rexmt_high)) {
end = seq_min(sb->sblk_end, tp->rexmt_high);
nretransmitted -= end - sb->sblk_start;
}
if (SEQ_GEQ(sb->sblk_start, scb->lostseq))
nlost -= sb->sblk_end - sb->sblk_start;
}
return (nlost + nretransmitted);
} | /*
* Return estimate of the number of bytes outstanding in the network.
*/ | Return estimate of the number of bytes outstanding in the network. | [
"Return",
"estimate",
"of",
"the",
"number",
"of",
"bytes",
"outstanding",
"in",
"the",
"network",
"."
] | uint32_t
tcp_sack_compute_pipe(const struct tcpcb *tp)
{
const struct scoreboard *scb = &tp->scb;
const struct sackblock *sb;
int nlost, nretransmitted;
tcp_seq end;
nlost = tp->snd_max - scb->lostseq;
nretransmitted = tp->rexmt_high - tp->snd_una;
TAILQ_FOREACH(sb, &scb->sackblocks, sblk_list) {
if (SEQ_LT(sb->sblk_start, tp->rexmt_high)) {
end = seq_min(sb->sblk_end, tp->rexmt_high);
nretransmitted -= end - sb->sblk_start;
}
if (SEQ_GEQ(sb->sblk_start, scb->lostseq))
nlost -= sb->sblk_end - sb->sblk_start;
}
return (nlost + nretransmitted);
} | [
"uint32_t",
"tcp_sack_compute_pipe",
"(",
"const",
"struct",
"tcpcb",
"*",
"tp",
")",
"{",
"const",
"struct",
"scoreboard",
"*",
"scb",
"=",
"&",
"tp",
"->",
"scb",
";",
"const",
"struct",
"sackblock",
"*",
"sb",
";",
"int",
"nlost",
",",
"nretransmitted",
";",
"tcp_seq",
"end",
";",
"nlost",
"=",
"tp",
"->",
"snd_max",
"-",
"scb",
"->",
"lostseq",
";",
"nretransmitted",
"=",
"tp",
"->",
"rexmt_high",
"-",
"tp",
"->",
"snd_una",
";",
"TAILQ_FOREACH",
"(",
"sb",
",",
"&",
"scb",
"->",
"sackblocks",
",",
"sblk_list",
")",
"",
"{",
"if",
"(",
"SEQ_LT",
"(",
"sb",
"->",
"sblk_start",
",",
"tp",
"->",
"rexmt_high",
")",
")",
"{",
"end",
"=",
"seq_min",
"(",
"sb",
"->",
"sblk_end",
",",
"tp",
"->",
"rexmt_high",
")",
";",
"nretransmitted",
"-=",
"end",
"-",
"sb",
"->",
"sblk_start",
";",
"}",
"if",
"(",
"SEQ_GEQ",
"(",
"sb",
"->",
"sblk_start",
",",
"scb",
"->",
"lostseq",
")",
")",
"nlost",
"-=",
"sb",
"->",
"sblk_end",
"-",
"sb",
"->",
"sblk_start",
";",
"}",
"return",
"(",
"nlost",
"+",
"nretransmitted",
")",
";",
"}"
] | Return estimate of the number of bytes outstanding in the network. | [
"Return",
"estimate",
"of",
"the",
"number",
"of",
"bytes",
"outstanding",
"in",
"the",
"network",
"."
] | [] | [
{
"param": "tp",
"type": "struct tcpcb"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_nextseg | boolean_t | boolean_t
tcp_sack_nextseg(struct tcpcb *tp, tcp_seq *nextrexmt, uint32_t *plen,
boolean_t *rescue)
{
struct scoreboard *scb = &tp->scb;
struct socket *so = tp->t_inpcb->inp_socket;
struct sackblock *sb;
const struct sackblock *lastblock =
TAILQ_LAST(&scb->sackblocks, sackblock_list);
tcp_seq torexmt;
long len, off, sendwin;
/* skip SACKed data */
tcp_sack_skip_sacked(scb, &tp->rexmt_high);
/* Look for lost data. */
torexmt = tp->rexmt_high;
*rescue = FALSE;
if (lastblock != NULL) {
if (SEQ_LT(torexmt, lastblock->sblk_end) &&
tcp_sack_islost(scb, torexmt)) {
sendunsacked:
*nextrexmt = torexmt;
/* If the left-hand edge has been SACKed, pull it in. */
if (sack_block_lookup(scb, torexmt + tp->t_maxseg, &sb))
*plen = sb->sblk_start - torexmt;
else
*plen = tp->t_maxseg;
return TRUE;
}
}
/* See if unsent data available within send window. */
off = tp->snd_max - tp->snd_una;
sendwin = min(tp->snd_wnd, tp->snd_bwnd);
len = (long) ulmin(so->so_snd.ssb_cc, sendwin) - off;
if (len > 0) {
*nextrexmt = tp->snd_max; /* Send new data. */
*plen = tp->t_maxseg;
return TRUE;
}
/* We're less certain this data has been lost. */
if (lastblock != NULL && SEQ_LT(torexmt, lastblock->sblk_end))
goto sendunsacked;
/* Rescue retransmission */
if (tcp_do_rescuesack || tcp_do_rfc6675) {
tcpstat.tcps_sackrescue_try++;
if (tp->sack_flags & TSACK_F_SACKRESCUED) {
if (!tcp_aggressive_rescuesack)
return FALSE;
/*
* Aggressive variant of the rescue retransmission.
*
* The idea of the rescue retransmission is to sustain
* the ACK clock thus to avoid timeout retransmission.
*
* Under some situations, the conservative approach
* suggested in the draft
* http://tools.ietf.org/html/
* draft-nishida-tcpm-rescue-retransmission-00
* could not sustain ACK clock, since it only allows
* one rescue retransmission before a cumulative ACK
* covers the segement transmitted by rescue
* retransmission.
*
* We try to locate the next unSACKed segment which
* follows the previously sent rescue segment. If
* there is no such segment, we loop back to the first
* unacknowledged segment.
*/
/*
* Skip SACKed data, but here we follow
* the last transmitted rescue segment.
*/
torexmt = tp->rexmt_rescue;
tcp_sack_skip_sacked(scb, &torexmt);
}
if (torexmt == tp->snd_max) {
/* Nothing left to retransmit; restart */
torexmt = tp->snd_una;
}
*rescue = TRUE;
goto sendunsacked;
} else if (tcp_do_smartsack && lastblock == NULL) {
tcpstat.tcps_sackrescue_try++;
*rescue = TRUE;
goto sendunsacked;
}
return FALSE;
} | /*
* Return the sequence number and length of the next segment to transmit
* when in Fast Recovery.
*/ | Return the sequence number and length of the next segment to transmit
when in Fast Recovery. | [
"Return",
"the",
"sequence",
"number",
"and",
"length",
"of",
"the",
"next",
"segment",
"to",
"transmit",
"when",
"in",
"Fast",
"Recovery",
"."
] | boolean_t
tcp_sack_nextseg(struct tcpcb *tp, tcp_seq *nextrexmt, uint32_t *plen,
boolean_t *rescue)
{
struct scoreboard *scb = &tp->scb;
struct socket *so = tp->t_inpcb->inp_socket;
struct sackblock *sb;
const struct sackblock *lastblock =
TAILQ_LAST(&scb->sackblocks, sackblock_list);
tcp_seq torexmt;
long len, off, sendwin;
tcp_sack_skip_sacked(scb, &tp->rexmt_high);
torexmt = tp->rexmt_high;
*rescue = FALSE;
if (lastblock != NULL) {
if (SEQ_LT(torexmt, lastblock->sblk_end) &&
tcp_sack_islost(scb, torexmt)) {
sendunsacked:
*nextrexmt = torexmt;
if (sack_block_lookup(scb, torexmt + tp->t_maxseg, &sb))
*plen = sb->sblk_start - torexmt;
else
*plen = tp->t_maxseg;
return TRUE;
}
}
off = tp->snd_max - tp->snd_una;
sendwin = min(tp->snd_wnd, tp->snd_bwnd);
len = (long) ulmin(so->so_snd.ssb_cc, sendwin) - off;
if (len > 0) {
*nextrexmt = tp->snd_max;
*plen = tp->t_maxseg;
return TRUE;
}
if (lastblock != NULL && SEQ_LT(torexmt, lastblock->sblk_end))
goto sendunsacked;
if (tcp_do_rescuesack || tcp_do_rfc6675) {
tcpstat.tcps_sackrescue_try++;
if (tp->sack_flags & TSACK_F_SACKRESCUED) {
if (!tcp_aggressive_rescuesack)
return FALSE;
torexmt = tp->rexmt_rescue;
tcp_sack_skip_sacked(scb, &torexmt);
}
if (torexmt == tp->snd_max) {
torexmt = tp->snd_una;
}
*rescue = TRUE;
goto sendunsacked;
} else if (tcp_do_smartsack && lastblock == NULL) {
tcpstat.tcps_sackrescue_try++;
*rescue = TRUE;
goto sendunsacked;
}
return FALSE;
} | [
"boolean_t",
"tcp_sack_nextseg",
"(",
"struct",
"tcpcb",
"*",
"tp",
",",
"tcp_seq",
"*",
"nextrexmt",
",",
"uint32_t",
"*",
"plen",
",",
"boolean_t",
"*",
"rescue",
")",
"{",
"struct",
"scoreboard",
"*",
"scb",
"=",
"&",
"tp",
"->",
"scb",
";",
"struct",
"socket",
"*",
"so",
"=",
"tp",
"->",
"t_inpcb",
"->",
"inp_socket",
";",
"struct",
"sackblock",
"*",
"sb",
";",
"const",
"struct",
"sackblock",
"*",
"lastblock",
"=",
"TAILQ_LAST",
"(",
"&",
"scb",
"->",
"sackblocks",
",",
"sackblock_list",
")",
";",
"tcp_seq",
"torexmt",
";",
"long",
"len",
",",
"off",
",",
"sendwin",
";",
"tcp_sack_skip_sacked",
"(",
"scb",
",",
"&",
"tp",
"->",
"rexmt_high",
")",
";",
"torexmt",
"=",
"tp",
"->",
"rexmt_high",
";",
"*",
"rescue",
"=",
"FALSE",
";",
"if",
"(",
"lastblock",
"!=",
"NULL",
")",
"{",
"if",
"(",
"SEQ_LT",
"(",
"torexmt",
",",
"lastblock",
"->",
"sblk_end",
")",
"&&",
"tcp_sack_islost",
"(",
"scb",
",",
"torexmt",
")",
")",
"{",
"sendunsacked",
":",
"*",
"nextrexmt",
"=",
"torexmt",
";",
"if",
"(",
"sack_block_lookup",
"(",
"scb",
",",
"torexmt",
"+",
"tp",
"->",
"t_maxseg",
",",
"&",
"sb",
")",
")",
"*",
"plen",
"=",
"sb",
"->",
"sblk_start",
"-",
"torexmt",
";",
"else",
"*",
"plen",
"=",
"tp",
"->",
"t_maxseg",
";",
"return",
"TRUE",
";",
"}",
"}",
"off",
"=",
"tp",
"->",
"snd_max",
"-",
"tp",
"->",
"snd_una",
";",
"sendwin",
"=",
"min",
"(",
"tp",
"->",
"snd_wnd",
",",
"tp",
"->",
"snd_bwnd",
")",
";",
"len",
"=",
"(",
"long",
")",
"ulmin",
"(",
"so",
"->",
"so_snd",
".",
"ssb_cc",
",",
"sendwin",
")",
"-",
"off",
";",
"if",
"(",
"len",
">",
"0",
")",
"{",
"*",
"nextrexmt",
"=",
"tp",
"->",
"snd_max",
";",
"*",
"plen",
"=",
"tp",
"->",
"t_maxseg",
";",
"return",
"TRUE",
";",
"}",
"if",
"(",
"lastblock",
"!=",
"NULL",
"&&",
"SEQ_LT",
"(",
"torexmt",
",",
"lastblock",
"->",
"sblk_end",
")",
")",
"goto",
"sendunsacked",
";",
"if",
"(",
"tcp_do_rescuesack",
"||",
"tcp_do_rfc6675",
")",
"{",
"tcpstat",
".",
"tcps_sackrescue_try",
"++",
";",
"if",
"(",
"tp",
"->",
"sack_flags",
"&",
"TSACK_F_SACKRESCUED",
")",
"{",
"if",
"(",
"!",
"tcp_aggressive_rescuesack",
")",
"return",
"FALSE",
";",
"torexmt",
"=",
"tp",
"->",
"rexmt_rescue",
";",
"tcp_sack_skip_sacked",
"(",
"scb",
",",
"&",
"torexmt",
")",
";",
"}",
"if",
"(",
"torexmt",
"==",
"tp",
"->",
"snd_max",
")",
"{",
"torexmt",
"=",
"tp",
"->",
"snd_una",
";",
"}",
"*",
"rescue",
"=",
"TRUE",
";",
"goto",
"sendunsacked",
";",
"}",
"else",
"if",
"(",
"tcp_do_smartsack",
"&&",
"lastblock",
"==",
"NULL",
")",
"{",
"tcpstat",
".",
"tcps_sackrescue_try",
"++",
";",
"*",
"rescue",
"=",
"TRUE",
";",
"goto",
"sendunsacked",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Return the sequence number and length of the next segment to transmit
when in Fast Recovery. | [
"Return",
"the",
"sequence",
"number",
"and",
"length",
"of",
"the",
"next",
"segment",
"to",
"transmit",
"when",
"in",
"Fast",
"Recovery",
"."
] | [
"/* skip SACKed data */",
"/* Look for lost data. */",
"/* If the left-hand edge has been SACKed, pull it in. */",
"/* See if unsent data available within send window. */",
"/* Send new data. */",
"/* We're less certain this data has been lost. */",
"/* Rescue retransmission */",
"/*\n\t\t\t * Aggressive variant of the rescue retransmission.\n\t\t\t *\n\t\t\t * The idea of the rescue retransmission is to sustain\n\t\t\t * the ACK clock thus to avoid timeout retransmission.\n\t\t\t *\n\t\t\t * Under some situations, the conservative approach\n\t\t\t * suggested in the draft\n \t\t\t * http://tools.ietf.org/html/\n\t\t\t * draft-nishida-tcpm-rescue-retransmission-00\n\t\t\t * could not sustain ACK clock, since it only allows\n\t\t\t * one rescue retransmission before a cumulative ACK\n\t\t\t * covers the segement transmitted by rescue\n\t\t\t * retransmission.\n\t\t\t *\n\t\t\t * We try to locate the next unSACKed segment which\n\t\t\t * follows the previously sent rescue segment. If\n\t\t\t * there is no such segment, we loop back to the first\n\t\t\t * unacknowledged segment.\n\t\t\t */",
"/*\n\t\t\t * Skip SACKed data, but here we follow\n\t\t\t * the last transmitted rescue segment.\n\t\t\t */",
"/* Nothing left to retransmit; restart */"
] | [
{
"param": "tp",
"type": "struct tcpcb"
},
{
"param": "nextrexmt",
"type": "tcp_seq"
},
{
"param": "plen",
"type": "uint32_t"
},
{
"param": "rescue",
"type": "boolean_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nextrexmt",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plen",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rescue",
"type": "boolean_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_skip_sacked | void | void
tcp_sack_skip_sacked(struct scoreboard *scb, tcp_seq *prexmt)
{
struct sackblock *sb;
/* skip SACKed data */
if (sack_block_lookup(scb, *prexmt, &sb))
*prexmt = sb->sblk_end;
} | /*
* Return the next sequence number higher than "*prexmt" that has
* not been SACKed.
*/ | Return the next sequence number higher than "*prexmt" that has
not been SACKed. | [
"Return",
"the",
"next",
"sequence",
"number",
"higher",
"than",
"\"",
"*",
"prexmt",
"\"",
"that",
"has",
"not",
"been",
"SACKed",
"."
] | void
tcp_sack_skip_sacked(struct scoreboard *scb, tcp_seq *prexmt)
{
struct sackblock *sb;
if (sack_block_lookup(scb, *prexmt, &sb))
*prexmt = sb->sblk_end;
} | [
"void",
"tcp_sack_skip_sacked",
"(",
"struct",
"scoreboard",
"*",
"scb",
",",
"tcp_seq",
"*",
"prexmt",
")",
"{",
"struct",
"sackblock",
"*",
"sb",
";",
"if",
"(",
"sack_block_lookup",
"(",
"scb",
",",
"*",
"prexmt",
",",
"&",
"sb",
")",
")",
"*",
"prexmt",
"=",
"sb",
"->",
"sblk_end",
";",
"}"
] | Return the next sequence number higher than "*prexmt" that has
not been SACKed. | [
"Return",
"the",
"next",
"sequence",
"number",
"higher",
"than",
"\"",
"*",
"prexmt",
"\"",
"that",
"has",
"not",
"been",
"SACKed",
"."
] | [
"/* skip SACKed data */"
] | [
{
"param": "scb",
"type": "struct scoreboard"
},
{
"param": "prexmt",
"type": "tcp_seq"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scb",
"type": "struct scoreboard",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prexmt",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_first_unsacked_len | uint32_t | uint32_t
tcp_sack_first_unsacked_len(const struct tcpcb *tp)
{
const struct sackblock *sb;
sb = TAILQ_FIRST(&tp->scb.sackblocks);
if (sb == NULL)
return tp->t_maxseg;
KASSERT(SEQ_LT(tp->snd_una, sb->sblk_start),
("invalid sb start %u, snd_una %u",
sb->sblk_start, tp->snd_una));
return (sb->sblk_start - tp->snd_una);
} | /*
* The length of the first amount of unSACKed data
*/ | The length of the first amount of unSACKed data | [
"The",
"length",
"of",
"the",
"first",
"amount",
"of",
"unSACKed",
"data"
] | uint32_t
tcp_sack_first_unsacked_len(const struct tcpcb *tp)
{
const struct sackblock *sb;
sb = TAILQ_FIRST(&tp->scb.sackblocks);
if (sb == NULL)
return tp->t_maxseg;
KASSERT(SEQ_LT(tp->snd_una, sb->sblk_start),
("invalid sb start %u, snd_una %u",
sb->sblk_start, tp->snd_una));
return (sb->sblk_start - tp->snd_una);
} | [
"uint32_t",
"tcp_sack_first_unsacked_len",
"(",
"const",
"struct",
"tcpcb",
"*",
"tp",
")",
"{",
"const",
"struct",
"sackblock",
"*",
"sb",
";",
"sb",
"=",
"TAILQ_FIRST",
"(",
"&",
"tp",
"->",
"scb",
".",
"sackblocks",
")",
";",
"if",
"(",
"sb",
"==",
"NULL",
")",
"return",
"tp",
"->",
"t_maxseg",
";",
"KASSERT",
"(",
"SEQ_LT",
"(",
"tp",
"->",
"snd_una",
",",
"sb",
"->",
"sblk_start",
")",
",",
"(",
"\"",
"\"",
",",
"sb",
"->",
"sblk_start",
",",
"tp",
"->",
"snd_una",
")",
")",
";",
"return",
"(",
"sb",
"->",
"sblk_start",
"-",
"tp",
"->",
"snd_una",
")",
";",
"}"
] | The length of the first amount of unSACKed data | [
"The",
"length",
"of",
"the",
"first",
"amount",
"of",
"unSACKed",
"data"
] | [] | [
{
"param": "tp",
"type": "struct tcpcb"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_ack_history | void | static void
tcp_sack_ack_history(struct tcpcb *tp)
{
int i, nblocks, openslot;
tcp_sack_dump_history("before tcp_sack_ack_history", tp);
nblocks = tp->nsackhistory;
for (i = openslot = 0; i < nblocks; ++i) {
if (SEQ_LEQ(tp->sackhistory[i].rblk_end, tp->rcv_nxt)) {
--tp->nsackhistory;
continue;
}
if (SEQ_LT(tp->sackhistory[i].rblk_start, tp->rcv_nxt))
tp->sackhistory[i].rblk_start = tp->rcv_nxt;
if (i == openslot)
++openslot;
else
tp->sackhistory[openslot++] = tp->sackhistory[i];
}
tcp_sack_dump_history("after tcp_sack_ack_history", tp);
KASSERT(openslot == tp->nsackhistory,
("tcp_sack_ack_history miscounted: %d != %d",
openslot, tp->nsackhistory));
} | /*
* Remove old SACK blocks from the SACK history that have already been ACKed.
*/ | Remove old SACK blocks from the SACK history that have already been ACKed. | [
"Remove",
"old",
"SACK",
"blocks",
"from",
"the",
"SACK",
"history",
"that",
"have",
"already",
"been",
"ACKed",
"."
] | static void
tcp_sack_ack_history(struct tcpcb *tp)
{
int i, nblocks, openslot;
tcp_sack_dump_history("before tcp_sack_ack_history", tp);
nblocks = tp->nsackhistory;
for (i = openslot = 0; i < nblocks; ++i) {
if (SEQ_LEQ(tp->sackhistory[i].rblk_end, tp->rcv_nxt)) {
--tp->nsackhistory;
continue;
}
if (SEQ_LT(tp->sackhistory[i].rblk_start, tp->rcv_nxt))
tp->sackhistory[i].rblk_start = tp->rcv_nxt;
if (i == openslot)
++openslot;
else
tp->sackhistory[openslot++] = tp->sackhistory[i];
}
tcp_sack_dump_history("after tcp_sack_ack_history", tp);
KASSERT(openslot == tp->nsackhistory,
("tcp_sack_ack_history miscounted: %d != %d",
openslot, tp->nsackhistory));
} | [
"static",
"void",
"tcp_sack_ack_history",
"(",
"struct",
"tcpcb",
"*",
"tp",
")",
"{",
"int",
"i",
",",
"nblocks",
",",
"openslot",
";",
"tcp_sack_dump_history",
"(",
"\"",
"\"",
",",
"tp",
")",
";",
"nblocks",
"=",
"tp",
"->",
"nsackhistory",
";",
"for",
"(",
"i",
"=",
"openslot",
"=",
"0",
";",
"i",
"<",
"nblocks",
";",
"++",
"i",
")",
"{",
"if",
"(",
"SEQ_LEQ",
"(",
"tp",
"->",
"sackhistory",
"[",
"i",
"]",
".",
"rblk_end",
",",
"tp",
"->",
"rcv_nxt",
")",
")",
"{",
"--",
"tp",
"->",
"nsackhistory",
";",
"continue",
";",
"}",
"if",
"(",
"SEQ_LT",
"(",
"tp",
"->",
"sackhistory",
"[",
"i",
"]",
".",
"rblk_start",
",",
"tp",
"->",
"rcv_nxt",
")",
")",
"tp",
"->",
"sackhistory",
"[",
"i",
"]",
".",
"rblk_start",
"=",
"tp",
"->",
"rcv_nxt",
";",
"if",
"(",
"i",
"==",
"openslot",
")",
"++",
"openslot",
";",
"else",
"tp",
"->",
"sackhistory",
"[",
"openslot",
"++",
"]",
"=",
"tp",
"->",
"sackhistory",
"[",
"i",
"]",
";",
"}",
"tcp_sack_dump_history",
"(",
"\"",
"\"",
",",
"tp",
")",
";",
"KASSERT",
"(",
"openslot",
"==",
"tp",
"->",
"nsackhistory",
",",
"(",
"\"",
"\"",
",",
"openslot",
",",
"tp",
"->",
"nsackhistory",
")",
")",
";",
"}"
] | Remove old SACK blocks from the SACK history that have already been ACKed. | [
"Remove",
"old",
"SACK",
"blocks",
"from",
"the",
"SACK",
"history",
"that",
"have",
"already",
"been",
"ACKed",
"."
] | [] | [
{
"param": "tp",
"type": "struct tcpcb"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_update_reported_history | void | static void
tcp_sack_update_reported_history(struct tcpcb *tp, tcp_seq start, tcp_seq end)
{
struct raw_sackblock copy[MAX_SACK_REPORT_BLOCKS];
int i, cindex;
tcp_sack_dump_history("before tcp_sack_update_reported_history", tp);
/*
* Six cases:
* 0) no overlap
* 1) newblock == oldblock
* 2) oldblock contains newblock
* 3) newblock contains oldblock
* 4) tail of oldblock overlaps or abuts start of newblock
* 5) tail of newblock overlaps or abuts head of oldblock
*/
for (i = cindex = 0; i < tp->nsackhistory; ++i) {
struct raw_sackblock *oldblock = &tp->sackhistory[i];
tcp_seq old_start = oldblock->rblk_start;
tcp_seq old_end = oldblock->rblk_end;
if (SEQ_LT(end, old_start) || SEQ_GT(start, old_end)) {
/* Case 0: no overlap. Copy old block. */
copy[cindex++] = *oldblock;
continue;
}
if (SEQ_GEQ(start, old_start) && SEQ_LEQ(end, old_end)) {
/* Cases 1 & 2. Move block to front of history. */
int j;
start = old_start;
end = old_end;
/* no need to check rest of blocks */
for (j = i + 1; j < tp->nsackhistory; ++j)
copy[cindex++] = tp->sackhistory[j];
break;
}
if (SEQ_GEQ(old_end, start) && SEQ_LT(old_start, start)) {
/* Case 4: extend start of new block. */
start = old_start;
} else if (SEQ_GEQ(end, old_start) && SEQ_GT(old_end, end)) {
/* Case 5: extend end of new block */
end = old_end;
} else {
/* Case 3. Delete old block by not copying it. */
KASSERT(SEQ_LEQ(start, old_start) &&
SEQ_GEQ(end, old_end),
("bad logic: old [%u, %u), new [%u, %u)",
old_start, old_end, start, end));
}
}
/* insert new block */
tp->sackhistory[0].rblk_start = start;
tp->sackhistory[0].rblk_end = end;
cindex = min(cindex, MAX_SACK_REPORT_BLOCKS - 1);
for (i = 0; i < cindex; ++i)
tp->sackhistory[i + 1] = copy[i];
tp->nsackhistory = cindex + 1;
tcp_sack_dump_history("after tcp_sack_update_reported_history", tp);
} | /*
* Add or merge newblock into reported history.
* Also remove or update SACK blocks that will be acked.
*/ | Add or merge newblock into reported history.
Also remove or update SACK blocks that will be acked. | [
"Add",
"or",
"merge",
"newblock",
"into",
"reported",
"history",
".",
"Also",
"remove",
"or",
"update",
"SACK",
"blocks",
"that",
"will",
"be",
"acked",
"."
] | static void
tcp_sack_update_reported_history(struct tcpcb *tp, tcp_seq start, tcp_seq end)
{
struct raw_sackblock copy[MAX_SACK_REPORT_BLOCKS];
int i, cindex;
tcp_sack_dump_history("before tcp_sack_update_reported_history", tp);
for (i = cindex = 0; i < tp->nsackhistory; ++i) {
struct raw_sackblock *oldblock = &tp->sackhistory[i];
tcp_seq old_start = oldblock->rblk_start;
tcp_seq old_end = oldblock->rblk_end;
if (SEQ_LT(end, old_start) || SEQ_GT(start, old_end)) {
copy[cindex++] = *oldblock;
continue;
}
if (SEQ_GEQ(start, old_start) && SEQ_LEQ(end, old_end)) {
int j;
start = old_start;
end = old_end;
for (j = i + 1; j < tp->nsackhistory; ++j)
copy[cindex++] = tp->sackhistory[j];
break;
}
if (SEQ_GEQ(old_end, start) && SEQ_LT(old_start, start)) {
start = old_start;
} else if (SEQ_GEQ(end, old_start) && SEQ_GT(old_end, end)) {
end = old_end;
} else {
KASSERT(SEQ_LEQ(start, old_start) &&
SEQ_GEQ(end, old_end),
("bad logic: old [%u, %u), new [%u, %u)",
old_start, old_end, start, end));
}
}
tp->sackhistory[0].rblk_start = start;
tp->sackhistory[0].rblk_end = end;
cindex = min(cindex, MAX_SACK_REPORT_BLOCKS - 1);
for (i = 0; i < cindex; ++i)
tp->sackhistory[i + 1] = copy[i];
tp->nsackhistory = cindex + 1;
tcp_sack_dump_history("after tcp_sack_update_reported_history", tp);
} | [
"static",
"void",
"tcp_sack_update_reported_history",
"(",
"struct",
"tcpcb",
"*",
"tp",
",",
"tcp_seq",
"start",
",",
"tcp_seq",
"end",
")",
"{",
"struct",
"raw_sackblock",
"copy",
"[",
"MAX_SACK_REPORT_BLOCKS",
"]",
";",
"int",
"i",
",",
"cindex",
";",
"tcp_sack_dump_history",
"(",
"\"",
"\"",
",",
"tp",
")",
";",
"for",
"(",
"i",
"=",
"cindex",
"=",
"0",
";",
"i",
"<",
"tp",
"->",
"nsackhistory",
";",
"++",
"i",
")",
"{",
"struct",
"raw_sackblock",
"*",
"oldblock",
"=",
"&",
"tp",
"->",
"sackhistory",
"[",
"i",
"]",
";",
"tcp_seq",
"old_start",
"=",
"oldblock",
"->",
"rblk_start",
";",
"tcp_seq",
"old_end",
"=",
"oldblock",
"->",
"rblk_end",
";",
"if",
"(",
"SEQ_LT",
"(",
"end",
",",
"old_start",
")",
"||",
"SEQ_GT",
"(",
"start",
",",
"old_end",
")",
")",
"{",
"copy",
"[",
"cindex",
"++",
"]",
"=",
"*",
"oldblock",
";",
"continue",
";",
"}",
"if",
"(",
"SEQ_GEQ",
"(",
"start",
",",
"old_start",
")",
"&&",
"SEQ_LEQ",
"(",
"end",
",",
"old_end",
")",
")",
"{",
"int",
"j",
";",
"start",
"=",
"old_start",
";",
"end",
"=",
"old_end",
";",
"for",
"(",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"tp",
"->",
"nsackhistory",
";",
"++",
"j",
")",
"copy",
"[",
"cindex",
"++",
"]",
"=",
"tp",
"->",
"sackhistory",
"[",
"j",
"]",
";",
"break",
";",
"}",
"if",
"(",
"SEQ_GEQ",
"(",
"old_end",
",",
"start",
")",
"&&",
"SEQ_LT",
"(",
"old_start",
",",
"start",
")",
")",
"{",
"start",
"=",
"old_start",
";",
"}",
"else",
"if",
"(",
"SEQ_GEQ",
"(",
"end",
",",
"old_start",
")",
"&&",
"SEQ_GT",
"(",
"old_end",
",",
"end",
")",
")",
"{",
"end",
"=",
"old_end",
";",
"}",
"else",
"{",
"KASSERT",
"(",
"SEQ_LEQ",
"(",
"start",
",",
"old_start",
")",
"&&",
"SEQ_GEQ",
"(",
"end",
",",
"old_end",
")",
",",
"(",
"\"",
"\"",
",",
"old_start",
",",
"old_end",
",",
"start",
",",
"end",
")",
")",
";",
"}",
"}",
"tp",
"->",
"sackhistory",
"[",
"0",
"]",
".",
"rblk_start",
"=",
"start",
";",
"tp",
"->",
"sackhistory",
"[",
"0",
"]",
".",
"rblk_end",
"=",
"end",
";",
"cindex",
"=",
"min",
"(",
"cindex",
",",
"MAX_SACK_REPORT_BLOCKS",
"-",
"1",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"cindex",
";",
"++",
"i",
")",
"tp",
"->",
"sackhistory",
"[",
"i",
"+",
"1",
"]",
"=",
"copy",
"[",
"i",
"]",
";",
"tp",
"->",
"nsackhistory",
"=",
"cindex",
"+",
"1",
";",
"tcp_sack_dump_history",
"(",
"\"",
"\"",
",",
"tp",
")",
";",
"}"
] | Add or merge newblock into reported history. | [
"Add",
"or",
"merge",
"newblock",
"into",
"reported",
"history",
"."
] | [
"/*\n\t * Six cases:\n\t *\t0) no overlap\n\t *\t1) newblock == oldblock\n\t *\t2) oldblock contains newblock\n\t *\t3) newblock contains oldblock\n\t *\t4) tail of oldblock overlaps or abuts start of newblock\n\t *\t5) tail of newblock overlaps or abuts head of oldblock\n\t */",
"/* Case 0: no overlap. Copy old block. */",
"/* Cases 1 & 2. Move block to front of history. */",
"/* no need to check rest of blocks */",
"/* Case 4: extend start of new block. */",
"/* Case 5: extend end of new block */",
"/* Case 3. Delete old block by not copying it. */",
"/* insert new block */"
] | [
{
"param": "tp",
"type": "struct tcpcb"
},
{
"param": "start",
"type": "tcp_seq"
},
{
"param": "end",
"type": "tcp_seq"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "end",
"type": "tcp_seq",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33927ffae30be1be2a78f55ffa5a200ed2b1b08c | atrens/DragonFlyBSD-src | sys/netinet/tcp_sack.c | [
"BSD-3-Clause"
] | C | tcp_sack_fill_report | void | void
tcp_sack_fill_report(struct tcpcb *tp, u_char *opt, u_int *plen)
{
u_int optlen = *plen;
uint32_t *lp = (uint32_t *)(opt + optlen);
uint32_t *olp;
tcp_seq hstart = tp->rcv_nxt, hend;
int nblocks;
KASSERT(TCP_MAXOLEN - optlen >=
TCPOLEN_SACK_ALIGNED + TCPOLEN_SACK_BLOCK,
("no room for SACK header and one block: optlen %d", optlen));
if (tp->sack_flags & TSACK_F_DUPSEG)
tcpstat.tcps_snddsackopt++;
else
tcpstat.tcps_sndsackopt++;
olp = lp++;
optlen += TCPOLEN_SACK_ALIGNED;
tcp_sack_ack_history(tp);
if (tp->reportblk.rblk_start != tp->reportblk.rblk_end) {
*lp++ = htonl(tp->reportblk.rblk_start);
*lp++ = htonl(tp->reportblk.rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
hstart = tp->reportblk.rblk_start;
hend = tp->reportblk.rblk_end;
if (tp->sack_flags & TSACK_F_ENCLOSESEG) {
KASSERT(TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK,
("no room for enclosing SACK block: oplen %d",
optlen));
*lp++ = htonl(tp->encloseblk.rblk_start);
*lp++ = htonl(tp->encloseblk.rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
hstart = tp->encloseblk.rblk_start;
hend = tp->encloseblk.rblk_end;
}
if (SEQ_GT(hstart, tp->rcv_nxt))
tcp_sack_update_reported_history(tp, hstart, hend);
}
if (tcp_do_smartsack && (tp->sack_flags & TSACK_F_SACKLEFT)) {
/* Fill in from left! Walk re-assembly queue. */
struct tseg_qent *q;
q = TAILQ_FIRST(&tp->t_segq);
while (q != NULL &&
TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK) {
*lp++ = htonl(q->tqe_th->th_seq);
*lp++ = htonl(TCP_SACK_BLKEND(
q->tqe_th->th_seq + q->tqe_len,
q->tqe_th->th_flags));
optlen += TCPOLEN_SACK_BLOCK;
q = TAILQ_NEXT(q, tqe_q);
}
} else {
int n = 0;
/* Fill in SACK blocks from right side. */
while (n < tp->nsackhistory &&
TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK) {
if (tp->sackhistory[n].rblk_start != hstart) {
*lp++ = htonl(tp->sackhistory[n].rblk_start);
*lp++ = htonl(tp->sackhistory[n].rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
}
++n;
}
}
tp->reportblk.rblk_start = tp->reportblk.rblk_end;
tp->sack_flags &=
~(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT);
nblocks = (lp - olp - 1) / 2;
*olp = htonl(TCPOPT_SACK_ALIGNED |
(TCPOLEN_SACK + nblocks * TCPOLEN_SACK_BLOCK));
*plen = optlen;
} | /*
* Fill in SACK report to return to data sender.
*/ | Fill in SACK report to return to data sender. | [
"Fill",
"in",
"SACK",
"report",
"to",
"return",
"to",
"data",
"sender",
"."
] | void
tcp_sack_fill_report(struct tcpcb *tp, u_char *opt, u_int *plen)
{
u_int optlen = *plen;
uint32_t *lp = (uint32_t *)(opt + optlen);
uint32_t *olp;
tcp_seq hstart = tp->rcv_nxt, hend;
int nblocks;
KASSERT(TCP_MAXOLEN - optlen >=
TCPOLEN_SACK_ALIGNED + TCPOLEN_SACK_BLOCK,
("no room for SACK header and one block: optlen %d", optlen));
if (tp->sack_flags & TSACK_F_DUPSEG)
tcpstat.tcps_snddsackopt++;
else
tcpstat.tcps_sndsackopt++;
olp = lp++;
optlen += TCPOLEN_SACK_ALIGNED;
tcp_sack_ack_history(tp);
if (tp->reportblk.rblk_start != tp->reportblk.rblk_end) {
*lp++ = htonl(tp->reportblk.rblk_start);
*lp++ = htonl(tp->reportblk.rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
hstart = tp->reportblk.rblk_start;
hend = tp->reportblk.rblk_end;
if (tp->sack_flags & TSACK_F_ENCLOSESEG) {
KASSERT(TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK,
("no room for enclosing SACK block: oplen %d",
optlen));
*lp++ = htonl(tp->encloseblk.rblk_start);
*lp++ = htonl(tp->encloseblk.rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
hstart = tp->encloseblk.rblk_start;
hend = tp->encloseblk.rblk_end;
}
if (SEQ_GT(hstart, tp->rcv_nxt))
tcp_sack_update_reported_history(tp, hstart, hend);
}
if (tcp_do_smartsack && (tp->sack_flags & TSACK_F_SACKLEFT)) {
struct tseg_qent *q;
q = TAILQ_FIRST(&tp->t_segq);
while (q != NULL &&
TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK) {
*lp++ = htonl(q->tqe_th->th_seq);
*lp++ = htonl(TCP_SACK_BLKEND(
q->tqe_th->th_seq + q->tqe_len,
q->tqe_th->th_flags));
optlen += TCPOLEN_SACK_BLOCK;
q = TAILQ_NEXT(q, tqe_q);
}
} else {
int n = 0;
while (n < tp->nsackhistory &&
TCP_MAXOLEN - optlen >= TCPOLEN_SACK_BLOCK) {
if (tp->sackhistory[n].rblk_start != hstart) {
*lp++ = htonl(tp->sackhistory[n].rblk_start);
*lp++ = htonl(tp->sackhistory[n].rblk_end);
optlen += TCPOLEN_SACK_BLOCK;
}
++n;
}
}
tp->reportblk.rblk_start = tp->reportblk.rblk_end;
tp->sack_flags &=
~(TSACK_F_DUPSEG | TSACK_F_ENCLOSESEG | TSACK_F_SACKLEFT);
nblocks = (lp - olp - 1) / 2;
*olp = htonl(TCPOPT_SACK_ALIGNED |
(TCPOLEN_SACK + nblocks * TCPOLEN_SACK_BLOCK));
*plen = optlen;
} | [
"void",
"tcp_sack_fill_report",
"(",
"struct",
"tcpcb",
"*",
"tp",
",",
"u_char",
"*",
"opt",
",",
"u_int",
"*",
"plen",
")",
"{",
"u_int",
"optlen",
"=",
"*",
"plen",
";",
"uint32_t",
"*",
"lp",
"=",
"(",
"uint32_t",
"*",
")",
"(",
"opt",
"+",
"optlen",
")",
";",
"uint32_t",
"*",
"olp",
";",
"tcp_seq",
"hstart",
"=",
"tp",
"->",
"rcv_nxt",
",",
"hend",
";",
"int",
"nblocks",
";",
"KASSERT",
"(",
"TCP_MAXOLEN",
"-",
"optlen",
">=",
"TCPOLEN_SACK_ALIGNED",
"+",
"TCPOLEN_SACK_BLOCK",
",",
"(",
"\"",
"\"",
",",
"optlen",
")",
")",
";",
"if",
"(",
"tp",
"->",
"sack_flags",
"&",
"TSACK_F_DUPSEG",
")",
"tcpstat",
".",
"tcps_snddsackopt",
"++",
";",
"else",
"tcpstat",
".",
"tcps_sndsackopt",
"++",
";",
"olp",
"=",
"lp",
"++",
";",
"optlen",
"+=",
"TCPOLEN_SACK_ALIGNED",
";",
"tcp_sack_ack_history",
"(",
"tp",
")",
";",
"if",
"(",
"tp",
"->",
"reportblk",
".",
"rblk_start",
"!=",
"tp",
"->",
"reportblk",
".",
"rblk_end",
")",
"{",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"reportblk",
".",
"rblk_start",
")",
";",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"reportblk",
".",
"rblk_end",
")",
";",
"optlen",
"+=",
"TCPOLEN_SACK_BLOCK",
";",
"hstart",
"=",
"tp",
"->",
"reportblk",
".",
"rblk_start",
";",
"hend",
"=",
"tp",
"->",
"reportblk",
".",
"rblk_end",
";",
"if",
"(",
"tp",
"->",
"sack_flags",
"&",
"TSACK_F_ENCLOSESEG",
")",
"{",
"KASSERT",
"(",
"TCP_MAXOLEN",
"-",
"optlen",
">=",
"TCPOLEN_SACK_BLOCK",
",",
"(",
"\"",
"\"",
",",
"optlen",
")",
")",
";",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"encloseblk",
".",
"rblk_start",
")",
";",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"encloseblk",
".",
"rblk_end",
")",
";",
"optlen",
"+=",
"TCPOLEN_SACK_BLOCK",
";",
"hstart",
"=",
"tp",
"->",
"encloseblk",
".",
"rblk_start",
";",
"hend",
"=",
"tp",
"->",
"encloseblk",
".",
"rblk_end",
";",
"}",
"if",
"(",
"SEQ_GT",
"(",
"hstart",
",",
"tp",
"->",
"rcv_nxt",
")",
")",
"tcp_sack_update_reported_history",
"(",
"tp",
",",
"hstart",
",",
"hend",
")",
";",
"}",
"if",
"(",
"tcp_do_smartsack",
"&&",
"(",
"tp",
"->",
"sack_flags",
"&",
"TSACK_F_SACKLEFT",
")",
")",
"{",
"struct",
"tseg_qent",
"*",
"q",
";",
"q",
"=",
"TAILQ_FIRST",
"(",
"&",
"tp",
"->",
"t_segq",
")",
";",
"while",
"(",
"q",
"!=",
"NULL",
"&&",
"TCP_MAXOLEN",
"-",
"optlen",
">=",
"TCPOLEN_SACK_BLOCK",
")",
"{",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"q",
"->",
"tqe_th",
"->",
"th_seq",
")",
";",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"TCP_SACK_BLKEND",
"(",
"q",
"->",
"tqe_th",
"->",
"th_seq",
"+",
"q",
"->",
"tqe_len",
",",
"q",
"->",
"tqe_th",
"->",
"th_flags",
")",
")",
";",
"optlen",
"+=",
"TCPOLEN_SACK_BLOCK",
";",
"q",
"=",
"TAILQ_NEXT",
"(",
"q",
",",
"tqe_q",
")",
";",
"}",
"}",
"else",
"{",
"int",
"n",
"=",
"0",
";",
"while",
"(",
"n",
"<",
"tp",
"->",
"nsackhistory",
"&&",
"TCP_MAXOLEN",
"-",
"optlen",
">=",
"TCPOLEN_SACK_BLOCK",
")",
"{",
"if",
"(",
"tp",
"->",
"sackhistory",
"[",
"n",
"]",
".",
"rblk_start",
"!=",
"hstart",
")",
"{",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"sackhistory",
"[",
"n",
"]",
".",
"rblk_start",
")",
";",
"*",
"lp",
"++",
"=",
"htonl",
"(",
"tp",
"->",
"sackhistory",
"[",
"n",
"]",
".",
"rblk_end",
")",
";",
"optlen",
"+=",
"TCPOLEN_SACK_BLOCK",
";",
"}",
"++",
"n",
";",
"}",
"}",
"tp",
"->",
"reportblk",
".",
"rblk_start",
"=",
"tp",
"->",
"reportblk",
".",
"rblk_end",
";",
"tp",
"->",
"sack_flags",
"&=",
"~",
"(",
"TSACK_F_DUPSEG",
"|",
"TSACK_F_ENCLOSESEG",
"|",
"TSACK_F_SACKLEFT",
")",
";",
"nblocks",
"=",
"(",
"lp",
"-",
"olp",
"-",
"1",
")",
"/",
"2",
";",
"*",
"olp",
"=",
"htonl",
"(",
"TCPOPT_SACK_ALIGNED",
"|",
"(",
"TCPOLEN_SACK",
"+",
"nblocks",
"*",
"TCPOLEN_SACK_BLOCK",
")",
")",
";",
"*",
"plen",
"=",
"optlen",
";",
"}"
] | Fill in SACK report to return to data sender. | [
"Fill",
"in",
"SACK",
"report",
"to",
"return",
"to",
"data",
"sender",
"."
] | [
"/* Fill in from left! Walk re-assembly queue. */",
"/* Fill in SACK blocks from right side. */"
] | [
{
"param": "tp",
"type": "struct tcpcb"
},
{
"param": "opt",
"type": "u_char"
},
{
"param": "plen",
"type": "u_int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tp",
"type": "struct tcpcb",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "opt",
"type": "u_char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "plen",
"type": "u_int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | lst_linearized_niter | void | static void
lst_linearized_niter (lst_p lst, mpz_t res)
{
int i;
lst_p l;
mpz_t n;
mpz_init (n);
mpz_set_si (res, 0);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
lst_linearized_niter (l, n);
mpz_add (res, res, n);
}
if (LST_LOOP_P (lst))
{
lst_niter_for_loop (lst, n);
if (mpz_cmp_si (res, 0) != 0)
mpz_mul (res, res, n);
else
mpz_set (res, n);
}
mpz_clear (n);
} | /* Initializes RES to the number of iterations of the linearized loop
LST. RES is the cardinal of the iteration domain of LST. */ | Initializes RES to the number of iterations of the linearized loop
LST. RES is the cardinal of the iteration domain of LST. | [
"Initializes",
"RES",
"to",
"the",
"number",
"of",
"iterations",
"of",
"the",
"linearized",
"loop",
"LST",
".",
"RES",
"is",
"the",
"cardinal",
"of",
"the",
"iteration",
"domain",
"of",
"LST",
"."
] | static void
lst_linearized_niter (lst_p lst, mpz_t res)
{
int i;
lst_p l;
mpz_t n;
mpz_init (n);
mpz_set_si (res, 0);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
lst_linearized_niter (l, n);
mpz_add (res, res, n);
}
if (LST_LOOP_P (lst))
{
lst_niter_for_loop (lst, n);
if (mpz_cmp_si (res, 0) != 0)
mpz_mul (res, res, n);
else
mpz_set (res, n);
}
mpz_clear (n);
} | [
"static",
"void",
"lst_linearized_niter",
"(",
"lst_p",
"lst",
",",
"mpz_t",
"res",
")",
"{",
"int",
"i",
";",
"lst_p",
"l",
";",
"mpz_t",
"n",
";",
"mpz_init",
"(",
"n",
")",
";",
"mpz_set_si",
"(",
"res",
",",
"0",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"lst",
")",
",",
"i",
",",
"l",
")",
"",
"if",
"(",
"LST_LOOP_P",
"(",
"l",
")",
")",
"{",
"lst_linearized_niter",
"(",
"l",
",",
"n",
")",
";",
"mpz_add",
"(",
"res",
",",
"res",
",",
"n",
")",
";",
"}",
"if",
"(",
"LST_LOOP_P",
"(",
"lst",
")",
")",
"{",
"lst_niter_for_loop",
"(",
"lst",
",",
"n",
")",
";",
"if",
"(",
"mpz_cmp_si",
"(",
"res",
",",
"0",
")",
"!=",
"0",
")",
"mpz_mul",
"(",
"res",
",",
"res",
",",
"n",
")",
";",
"else",
"mpz_set",
"(",
"res",
",",
"n",
")",
";",
"}",
"mpz_clear",
"(",
"n",
")",
";",
"}"
] | Initializes RES to the number of iterations of the linearized loop
LST. | [
"Initializes",
"RES",
"to",
"the",
"number",
"of",
"iterations",
"of",
"the",
"linearized",
"loop",
"LST",
"."
] | [] | [
{
"param": "lst",
"type": "lst_p"
},
{
"param": "res",
"type": "mpz_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lst",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "res",
"type": "mpz_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | lst_scale | void | static void
lst_scale (lst_p lst, lst_p stmt, mpz_t factor)
{
mpz_t x;
ppl_Coefficient_t one;
int outer_depth = lst_depth (lst);
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
ppl_Linear_Expression_t expr;
ppl_dimension_type dim;
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
ppl_Polyhedron_space_dimension (poly, &dim);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
/* outer_dim = factor * outer_dim. */
ppl_set_coef_gmp (expr, outer_dim, factor);
ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
ppl_delete_Linear_Expression (expr);
mpz_clear (x);
ppl_delete_Coefficient (one);
} | /* Scale by FACTOR the loop LST containing STMT. */ | Scale by FACTOR the loop LST containing STMT. | [
"Scale",
"by",
"FACTOR",
"the",
"loop",
"LST",
"containing",
"STMT",
"."
] | static void
lst_scale (lst_p lst, lst_p stmt, mpz_t factor)
{
mpz_t x;
ppl_Coefficient_t one;
int outer_depth = lst_depth (lst);
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
ppl_Linear_Expression_t expr;
ppl_dimension_type dim;
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
ppl_Polyhedron_space_dimension (poly, &dim);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_set_coef_gmp (expr, outer_dim, factor);
ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
ppl_delete_Linear_Expression (expr);
mpz_clear (x);
ppl_delete_Coefficient (one);
} | [
"static",
"void",
"lst_scale",
"(",
"lst_p",
"lst",
",",
"lst_p",
"stmt",
",",
"mpz_t",
"factor",
")",
"{",
"mpz_t",
"x",
";",
"ppl_Coefficient_t",
"one",
";",
"int",
"outer_depth",
"=",
"lst_depth",
"(",
"lst",
")",
";",
"poly_bb_p",
"pbb",
"=",
"LST_PBB",
"(",
"stmt",
")",
";",
"ppl_Polyhedron_t",
"poly",
"=",
"PBB_TRANSFORMED_SCATTERING",
"(",
"pbb",
")",
";",
"ppl_dimension_type",
"outer_dim",
"=",
"psct_dynamic_dim",
"(",
"pbb",
",",
"outer_depth",
")",
";",
"ppl_Linear_Expression_t",
"expr",
";",
"ppl_dimension_type",
"dim",
";",
"mpz_init",
"(",
"x",
")",
";",
"mpz_set_si",
"(",
"x",
",",
"1",
")",
";",
"ppl_new_Coefficient",
"(",
"&",
"one",
")",
";",
"ppl_assign_Coefficient_from_mpz_t",
"(",
"one",
",",
"x",
")",
";",
"ppl_Polyhedron_space_dimension",
"(",
"poly",
",",
"&",
"dim",
")",
";",
"ppl_new_Linear_Expression_with_dimension",
"(",
"&",
"expr",
",",
"dim",
")",
";",
"ppl_set_coef_gmp",
"(",
"expr",
",",
"outer_dim",
",",
"factor",
")",
";",
"ppl_Polyhedron_affine_image",
"(",
"poly",
",",
"outer_dim",
",",
"expr",
",",
"one",
")",
";",
"ppl_delete_Linear_Expression",
"(",
"expr",
")",
";",
"mpz_clear",
"(",
"x",
")",
";",
"ppl_delete_Coefficient",
"(",
"one",
")",
";",
"}"
] | Scale by FACTOR the loop LST containing STMT. | [
"Scale",
"by",
"FACTOR",
"the",
"loop",
"LST",
"containing",
"STMT",
"."
] | [
"/* outer_dim = factor * outer_dim. */"
] | [
{
"param": "lst",
"type": "lst_p"
},
{
"param": "stmt",
"type": "lst_p"
},
{
"param": "factor",
"type": "mpz_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lst",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stmt",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "factor",
"type": "mpz_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | lst_project_loop | void | static void
lst_project_loop (lst_p outer, lst_p inner, mpz_t stride)
{
int i;
lst_p stmt;
mpz_t x;
ppl_Coefficient_t one;
int outer_depth = lst_depth (outer);
int inner_depth = lst_depth (inner);
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (inner), i, stmt)
{
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth);
ppl_Linear_Expression_t expr;
ppl_dimension_type dim;
ppl_dimension_type *ds;
/* There should be no loops under INNER. */
gcc_assert (!LST_LOOP_P (stmt));
ppl_Polyhedron_space_dimension (poly, &dim);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
/* outer_dim = outer_dim * stride + inner_dim. */
ppl_set_coef (expr, inner_dim, 1);
ppl_set_coef_gmp (expr, outer_dim, stride);
ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
ppl_delete_Linear_Expression (expr);
/* Project on inner_dim. */
ppl_new_Linear_Expression_with_dimension (&expr, dim - 1);
ppl_Polyhedron_affine_image (poly, inner_dim, expr, one);
ppl_delete_Linear_Expression (expr);
/* Remove inner loop and the static schedule of its body. */
/* FIXME: As long as we use PPL we are not able to remove the old
scattering dimensions. The reason is that these dimensions are not
entirely unused. They are not necessary as part of the scheduling
vector, as the earlier dimensions already unambiguously define the
execution time, however they may still be needed to carry modulo
constraints as introduced e.g. by strip mining. The correct solution
would be to project these dimensions out of the scattering polyhedra.
In case they are still required to carry modulo constraints they should be kept
internally as existentially quantified dimensions. PPL does only support
projection of rational polyhedra, however in this case we need an integer
projection. With isl this will be trivial to implement. For now we just
leave the dimensions. This is a little ugly, but should be correct. */
if (0) {
ds = XNEWVEC (ppl_dimension_type, 2);
ds[0] = inner_dim;
ds[1] = inner_dim + 1;
ppl_Polyhedron_remove_space_dimensions (poly, ds, 2);
PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2;
free (ds);
}
}
mpz_clear (x);
ppl_delete_Coefficient (one);
} | /* Project the INNER loop into the iteration domain of the OUTER loop.
STRIDE is the number of iterations between two iterations of the
outer loop. */ | Project the INNER loop into the iteration domain of the OUTER loop.
STRIDE is the number of iterations between two iterations of the
outer loop. | [
"Project",
"the",
"INNER",
"loop",
"into",
"the",
"iteration",
"domain",
"of",
"the",
"OUTER",
"loop",
".",
"STRIDE",
"is",
"the",
"number",
"of",
"iterations",
"between",
"two",
"iterations",
"of",
"the",
"outer",
"loop",
"."
] | static void
lst_project_loop (lst_p outer, lst_p inner, mpz_t stride)
{
int i;
lst_p stmt;
mpz_t x;
ppl_Coefficient_t one;
int outer_depth = lst_depth (outer);
int inner_depth = lst_depth (inner);
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (inner), i, stmt)
{
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
ppl_dimension_type outer_dim = psct_dynamic_dim (pbb, outer_depth);
ppl_dimension_type inner_dim = psct_dynamic_dim (pbb, inner_depth);
ppl_Linear_Expression_t expr;
ppl_dimension_type dim;
ppl_dimension_type *ds;
gcc_assert (!LST_LOOP_P (stmt));
ppl_Polyhedron_space_dimension (poly, &dim);
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_set_coef (expr, inner_dim, 1);
ppl_set_coef_gmp (expr, outer_dim, stride);
ppl_Polyhedron_affine_image (poly, outer_dim, expr, one);
ppl_delete_Linear_Expression (expr);
ppl_new_Linear_Expression_with_dimension (&expr, dim - 1);
ppl_Polyhedron_affine_image (poly, inner_dim, expr, one);
ppl_delete_Linear_Expression (expr);
if (0) {
ds = XNEWVEC (ppl_dimension_type, 2);
ds[0] = inner_dim;
ds[1] = inner_dim + 1;
ppl_Polyhedron_remove_space_dimensions (poly, ds, 2);
PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2;
free (ds);
}
}
mpz_clear (x);
ppl_delete_Coefficient (one);
} | [
"static",
"void",
"lst_project_loop",
"(",
"lst_p",
"outer",
",",
"lst_p",
"inner",
",",
"mpz_t",
"stride",
")",
"{",
"int",
"i",
";",
"lst_p",
"stmt",
";",
"mpz_t",
"x",
";",
"ppl_Coefficient_t",
"one",
";",
"int",
"outer_depth",
"=",
"lst_depth",
"(",
"outer",
")",
";",
"int",
"inner_depth",
"=",
"lst_depth",
"(",
"inner",
")",
";",
"mpz_init",
"(",
"x",
")",
";",
"mpz_set_si",
"(",
"x",
",",
"1",
")",
";",
"ppl_new_Coefficient",
"(",
"&",
"one",
")",
";",
"ppl_assign_Coefficient_from_mpz_t",
"(",
"one",
",",
"x",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"inner",
")",
",",
"i",
",",
"stmt",
")",
"",
"{",
"poly_bb_p",
"pbb",
"=",
"LST_PBB",
"(",
"stmt",
")",
";",
"ppl_Polyhedron_t",
"poly",
"=",
"PBB_TRANSFORMED_SCATTERING",
"(",
"pbb",
")",
";",
"ppl_dimension_type",
"outer_dim",
"=",
"psct_dynamic_dim",
"(",
"pbb",
",",
"outer_depth",
")",
";",
"ppl_dimension_type",
"inner_dim",
"=",
"psct_dynamic_dim",
"(",
"pbb",
",",
"inner_depth",
")",
";",
"ppl_Linear_Expression_t",
"expr",
";",
"ppl_dimension_type",
"dim",
";",
"ppl_dimension_type",
"*",
"ds",
";",
"gcc_assert",
"(",
"!",
"LST_LOOP_P",
"(",
"stmt",
")",
")",
";",
"ppl_Polyhedron_space_dimension",
"(",
"poly",
",",
"&",
"dim",
")",
";",
"ppl_new_Linear_Expression_with_dimension",
"(",
"&",
"expr",
",",
"dim",
")",
";",
"ppl_set_coef",
"(",
"expr",
",",
"inner_dim",
",",
"1",
")",
";",
"ppl_set_coef_gmp",
"(",
"expr",
",",
"outer_dim",
",",
"stride",
")",
";",
"ppl_Polyhedron_affine_image",
"(",
"poly",
",",
"outer_dim",
",",
"expr",
",",
"one",
")",
";",
"ppl_delete_Linear_Expression",
"(",
"expr",
")",
";",
"ppl_new_Linear_Expression_with_dimension",
"(",
"&",
"expr",
",",
"dim",
"-",
"1",
")",
";",
"ppl_Polyhedron_affine_image",
"(",
"poly",
",",
"inner_dim",
",",
"expr",
",",
"one",
")",
";",
"ppl_delete_Linear_Expression",
"(",
"expr",
")",
";",
"if",
"(",
"0",
")",
"{",
"ds",
"=",
"XNEWVEC",
"(",
"ppl_dimension_type",
",",
"2",
")",
";",
"ds",
"[",
"0",
"]",
"=",
"inner_dim",
";",
"ds",
"[",
"1",
"]",
"=",
"inner_dim",
"+",
"1",
";",
"ppl_Polyhedron_remove_space_dimensions",
"(",
"poly",
",",
"ds",
",",
"2",
")",
";",
"PBB_NB_SCATTERING_TRANSFORM",
"(",
"pbb",
")",
"-=",
"2",
";",
"free",
"(",
"ds",
")",
";",
"}",
"}",
"mpz_clear",
"(",
"x",
")",
";",
"ppl_delete_Coefficient",
"(",
"one",
")",
";",
"}"
] | Project the INNER loop into the iteration domain of the OUTER loop. | [
"Project",
"the",
"INNER",
"loop",
"into",
"the",
"iteration",
"domain",
"of",
"the",
"OUTER",
"loop",
"."
] | [
"/* There should be no loops under INNER. */",
"/* outer_dim = outer_dim * stride + inner_dim. */",
"/* Project on inner_dim. */",
"/* Remove inner loop and the static schedule of its body. */",
"/* FIXME: As long as we use PPL we are not able to remove the old\n\t scattering dimensions. The reason is that these dimensions are not\n\t entirely unused. They are not necessary as part of the scheduling\n\t vector, as the earlier dimensions already unambiguously define the\n\t execution time, however they may still be needed to carry modulo\n\t constraints as introduced e.g. by strip mining. The correct solution\n\t would be to project these dimensions out of the scattering polyhedra.\n\t In case they are still required to carry modulo constraints they should be kept\n\t internally as existentially quantified dimensions. PPL does only support\n projection of rational polyhedra, however in this case we need an integer\n\t projection. With isl this will be trivial to implement. For now we just\n\t leave the dimensions. This is a little ugly, but should be correct. */"
] | [
{
"param": "outer",
"type": "lst_p"
},
{
"param": "inner",
"type": "lst_p"
},
{
"param": "stride",
"type": "mpz_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outer",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inner",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stride",
"type": "mpz_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | lst_flatten_loop | bool | static bool
lst_flatten_loop (lst_p lst, mpz_t init_offset)
{
int i;
lst_p l;
bool res = false;
mpz_t n, one, offset, stride;
mpz_init (n);
mpz_init (one);
mpz_init (offset);
mpz_init (stride);
mpz_set (offset, init_offset);
mpz_set_si (one, 1);
lst_linearized_niter (lst, stride);
lst_niter_for_loop (lst, n);
mpz_tdiv_q (stride, stride, n);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
res = true;
lst_flatten_loop (l, offset);
lst_niter_for_loop (l, n);
lst_project_loop (lst, l, stride);
/* The offset is the number of iterations minus 1, as we want
to execute the next statements at the same iteration as the
last iteration of the loop. */
mpz_sub (n, n, one);
mpz_add (offset, offset, n);
}
else
{
lst_scale (lst, l, stride);
if (mpz_cmp_si (offset, 0) != 0)
lst_offset (l, offset);
}
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
lst_remove_loop_and_inline_stmts_in_loop_father (l);
mpz_clear (n);
mpz_clear (one);
mpz_clear (offset);
mpz_clear (stride);
return res;
} | /* Flattens the loop nest LST. Return true when something changed.
OFFSET is used to compute the number of iterations of the outermost
loop before the current LST is executed. */ | Flattens the loop nest LST. Return true when something changed.
OFFSET is used to compute the number of iterations of the outermost
loop before the current LST is executed. | [
"Flattens",
"the",
"loop",
"nest",
"LST",
".",
"Return",
"true",
"when",
"something",
"changed",
".",
"OFFSET",
"is",
"used",
"to",
"compute",
"the",
"number",
"of",
"iterations",
"of",
"the",
"outermost",
"loop",
"before",
"the",
"current",
"LST",
"is",
"executed",
"."
] | static bool
lst_flatten_loop (lst_p lst, mpz_t init_offset)
{
int i;
lst_p l;
bool res = false;
mpz_t n, one, offset, stride;
mpz_init (n);
mpz_init (one);
mpz_init (offset);
mpz_init (stride);
mpz_set (offset, init_offset);
mpz_set_si (one, 1);
lst_linearized_niter (lst, stride);
lst_niter_for_loop (lst, n);
mpz_tdiv_q (stride, stride, n);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
res = true;
lst_flatten_loop (l, offset);
lst_niter_for_loop (l, n);
lst_project_loop (lst, l, stride);
mpz_sub (n, n, one);
mpz_add (offset, offset, n);
}
else
{
lst_scale (lst, l, stride);
if (mpz_cmp_si (offset, 0) != 0)
lst_offset (l, offset);
}
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
lst_remove_loop_and_inline_stmts_in_loop_father (l);
mpz_clear (n);
mpz_clear (one);
mpz_clear (offset);
mpz_clear (stride);
return res;
} | [
"static",
"bool",
"lst_flatten_loop",
"(",
"lst_p",
"lst",
",",
"mpz_t",
"init_offset",
")",
"{",
"int",
"i",
";",
"lst_p",
"l",
";",
"bool",
"res",
"=",
"false",
";",
"mpz_t",
"n",
",",
"one",
",",
"offset",
",",
"stride",
";",
"mpz_init",
"(",
"n",
")",
";",
"mpz_init",
"(",
"one",
")",
";",
"mpz_init",
"(",
"offset",
")",
";",
"mpz_init",
"(",
"stride",
")",
";",
"mpz_set",
"(",
"offset",
",",
"init_offset",
")",
";",
"mpz_set_si",
"(",
"one",
",",
"1",
")",
";",
"lst_linearized_niter",
"(",
"lst",
",",
"stride",
")",
";",
"lst_niter_for_loop",
"(",
"lst",
",",
"n",
")",
";",
"mpz_tdiv_q",
"(",
"stride",
",",
"stride",
",",
"n",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"lst",
")",
",",
"i",
",",
"l",
")",
"",
"if",
"(",
"LST_LOOP_P",
"(",
"l",
")",
")",
"{",
"res",
"=",
"true",
";",
"lst_flatten_loop",
"(",
"l",
",",
"offset",
")",
";",
"lst_niter_for_loop",
"(",
"l",
",",
"n",
")",
";",
"lst_project_loop",
"(",
"lst",
",",
"l",
",",
"stride",
")",
";",
"mpz_sub",
"(",
"n",
",",
"n",
",",
"one",
")",
";",
"mpz_add",
"(",
"offset",
",",
"offset",
",",
"n",
")",
";",
"}",
"else",
"{",
"lst_scale",
"(",
"lst",
",",
"l",
",",
"stride",
")",
";",
"if",
"(",
"mpz_cmp_si",
"(",
"offset",
",",
"0",
")",
"!=",
"0",
")",
"lst_offset",
"(",
"l",
",",
"offset",
")",
";",
"}",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"lst",
")",
",",
"i",
",",
"l",
")",
"",
"if",
"(",
"LST_LOOP_P",
"(",
"l",
")",
")",
"lst_remove_loop_and_inline_stmts_in_loop_father",
"(",
"l",
")",
";",
"mpz_clear",
"(",
"n",
")",
";",
"mpz_clear",
"(",
"one",
")",
";",
"mpz_clear",
"(",
"offset",
")",
";",
"mpz_clear",
"(",
"stride",
")",
";",
"return",
"res",
";",
"}"
] | Flattens the loop nest LST. | [
"Flattens",
"the",
"loop",
"nest",
"LST",
"."
] | [
"/* The offset is the number of iterations minus 1, as we want\n\t to execute the next statements at the same iteration as the\n\t last iteration of the loop. */"
] | [
{
"param": "lst",
"type": "lst_p"
},
{
"param": "init_offset",
"type": "mpz_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lst",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "init_offset",
"type": "mpz_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | remove_unused_scattering_dimensions | void | static void
remove_unused_scattering_dimensions (lst_p lst)
{
int i;
lst_p stmt;
mpz_t x;
ppl_Coefficient_t one;
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, stmt)
{
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
int j, nb_dims_to_remove = PBB_NB_SCATTERING_TRANSFORM (pbb) - 3;
ppl_dimension_type *ds;
/* There should be no loops inside LST after flattening. */
gcc_assert (!LST_LOOP_P (stmt));
if (!nb_dims_to_remove)
continue;
ds = XNEWVEC (ppl_dimension_type, nb_dims_to_remove);
for (j = 0; j < nb_dims_to_remove; j++)
ds[j] = j + 3;
ppl_Polyhedron_remove_space_dimensions (poly, ds, nb_dims_to_remove);
PBB_NB_SCATTERING_TRANSFORM (pbb) -= nb_dims_to_remove;
free (ds);
}
mpz_clear (x);
ppl_delete_Coefficient (one);
} | /* Remove all but the first 3 dimensions of the scattering:
- dim0: the static schedule for the loop
- dim1: the dynamic schedule of the loop
- dim2: the static schedule for the loop body. */ | Remove all but the first 3 dimensions of the scattering:
dim0: the static schedule for the loop
dim1: the dynamic schedule of the loop
dim2: the static schedule for the loop body. | [
"Remove",
"all",
"but",
"the",
"first",
"3",
"dimensions",
"of",
"the",
"scattering",
":",
"dim0",
":",
"the",
"static",
"schedule",
"for",
"the",
"loop",
"dim1",
":",
"the",
"dynamic",
"schedule",
"of",
"the",
"loop",
"dim2",
":",
"the",
"static",
"schedule",
"for",
"the",
"loop",
"body",
"."
] | static void
remove_unused_scattering_dimensions (lst_p lst)
{
int i;
lst_p stmt;
mpz_t x;
ppl_Coefficient_t one;
mpz_init (x);
mpz_set_si (x, 1);
ppl_new_Coefficient (&one);
ppl_assign_Coefficient_from_mpz_t (one, x);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, stmt)
{
poly_bb_p pbb = LST_PBB (stmt);
ppl_Polyhedron_t poly = PBB_TRANSFORMED_SCATTERING (pbb);
int j, nb_dims_to_remove = PBB_NB_SCATTERING_TRANSFORM (pbb) - 3;
ppl_dimension_type *ds;
gcc_assert (!LST_LOOP_P (stmt));
if (!nb_dims_to_remove)
continue;
ds = XNEWVEC (ppl_dimension_type, nb_dims_to_remove);
for (j = 0; j < nb_dims_to_remove; j++)
ds[j] = j + 3;
ppl_Polyhedron_remove_space_dimensions (poly, ds, nb_dims_to_remove);
PBB_NB_SCATTERING_TRANSFORM (pbb) -= nb_dims_to_remove;
free (ds);
}
mpz_clear (x);
ppl_delete_Coefficient (one);
} | [
"static",
"void",
"remove_unused_scattering_dimensions",
"(",
"lst_p",
"lst",
")",
"{",
"int",
"i",
";",
"lst_p",
"stmt",
";",
"mpz_t",
"x",
";",
"ppl_Coefficient_t",
"one",
";",
"mpz_init",
"(",
"x",
")",
";",
"mpz_set_si",
"(",
"x",
",",
"1",
")",
";",
"ppl_new_Coefficient",
"(",
"&",
"one",
")",
";",
"ppl_assign_Coefficient_from_mpz_t",
"(",
"one",
",",
"x",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"lst",
")",
",",
"i",
",",
"stmt",
")",
"",
"{",
"poly_bb_p",
"pbb",
"=",
"LST_PBB",
"(",
"stmt",
")",
";",
"ppl_Polyhedron_t",
"poly",
"=",
"PBB_TRANSFORMED_SCATTERING",
"(",
"pbb",
")",
";",
"int",
"j",
",",
"nb_dims_to_remove",
"=",
"PBB_NB_SCATTERING_TRANSFORM",
"(",
"pbb",
")",
"-",
"3",
";",
"ppl_dimension_type",
"*",
"ds",
";",
"gcc_assert",
"(",
"!",
"LST_LOOP_P",
"(",
"stmt",
")",
")",
";",
"if",
"(",
"!",
"nb_dims_to_remove",
")",
"continue",
";",
"ds",
"=",
"XNEWVEC",
"(",
"ppl_dimension_type",
",",
"nb_dims_to_remove",
")",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"nb_dims_to_remove",
";",
"j",
"++",
")",
"ds",
"[",
"j",
"]",
"=",
"j",
"+",
"3",
";",
"ppl_Polyhedron_remove_space_dimensions",
"(",
"poly",
",",
"ds",
",",
"nb_dims_to_remove",
")",
";",
"PBB_NB_SCATTERING_TRANSFORM",
"(",
"pbb",
")",
"-=",
"nb_dims_to_remove",
";",
"free",
"(",
"ds",
")",
";",
"}",
"mpz_clear",
"(",
"x",
")",
";",
"ppl_delete_Coefficient",
"(",
"one",
")",
";",
"}"
] | Remove all but the first 3 dimensions of the scattering:
dim0: the static schedule for the loop
dim1: the dynamic schedule of the loop
dim2: the static schedule for the loop body. | [
"Remove",
"all",
"but",
"the",
"first",
"3",
"dimensions",
"of",
"the",
"scattering",
":",
"dim0",
":",
"the",
"static",
"schedule",
"for",
"the",
"loop",
"dim1",
":",
"the",
"dynamic",
"schedule",
"of",
"the",
"loop",
"dim2",
":",
"the",
"static",
"schedule",
"for",
"the",
"loop",
"body",
"."
] | [
"/* There should be no loops inside LST after flattening. */"
] | [
{
"param": "lst",
"type": "lst_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lst",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | lst_do_flatten | bool | static bool
lst_do_flatten (lst_p lst)
{
int i;
lst_p l;
bool res = false;
mpz_t zero;
if (!lst
|| !LST_LOOP_P (lst))
return false;
mpz_init (zero);
mpz_set_si (zero, 0);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
res |= lst_flatten_loop (l, zero);
/* FIXME: As long as we use PPL we are not able to remove the old
scattering dimensions. The reason is that these dimensions are not
entirely unused. They are not necessary as part of the scheduling
vector, as the earlier dimensions already unambiguously define the
execution time, however they may still be needed to carry modulo
constraints as introduced e.g. by strip mining. The correct solution
would be to project these dimensions out of the scattering polyhedra.
In case they are still required to carry modulo constraints they should be kept
internally as existentially quantified dimensions. PPL does only support
projection of rational polyhedra, however in this case we need an integer
projection. With isl this will be trivial to implement. For now we just
leave the dimensions. This is a little ugly, but should be correct. */
if (0)
remove_unused_scattering_dimensions (l);
}
lst_update_scattering (lst);
mpz_clear (zero);
return res;
} | /* Flattens all the loop nests of LST. Return true when something
changed. */ | Flattens all the loop nests of LST. Return true when something
changed. | [
"Flattens",
"all",
"the",
"loop",
"nests",
"of",
"LST",
".",
"Return",
"true",
"when",
"something",
"changed",
"."
] | static bool
lst_do_flatten (lst_p lst)
{
int i;
lst_p l;
bool res = false;
mpz_t zero;
if (!lst
|| !LST_LOOP_P (lst))
return false;
mpz_init (zero);
mpz_set_si (zero, 0);
FOR_EACH_VEC_ELT (lst_p, LST_SEQ (lst), i, l)
if (LST_LOOP_P (l))
{
res |= lst_flatten_loop (l, zero);
if (0)
remove_unused_scattering_dimensions (l);
}
lst_update_scattering (lst);
mpz_clear (zero);
return res;
} | [
"static",
"bool",
"lst_do_flatten",
"(",
"lst_p",
"lst",
")",
"{",
"int",
"i",
";",
"lst_p",
"l",
";",
"bool",
"res",
"=",
"false",
";",
"mpz_t",
"zero",
";",
"if",
"(",
"!",
"lst",
"||",
"!",
"LST_LOOP_P",
"(",
"lst",
")",
")",
"return",
"false",
";",
"mpz_init",
"(",
"zero",
")",
";",
"mpz_set_si",
"(",
"zero",
",",
"0",
")",
";",
"FOR_EACH_VEC_ELT",
"(",
"lst_p",
",",
"LST_SEQ",
"(",
"lst",
")",
",",
"i",
",",
"l",
")",
"",
"if",
"(",
"LST_LOOP_P",
"(",
"l",
")",
")",
"{",
"res",
"|=",
"lst_flatten_loop",
"(",
"l",
",",
"zero",
")",
";",
"if",
"(",
"0",
")",
"remove_unused_scattering_dimensions",
"(",
"l",
")",
";",
"}",
"lst_update_scattering",
"(",
"lst",
")",
";",
"mpz_clear",
"(",
"zero",
")",
";",
"return",
"res",
";",
"}"
] | Flattens all the loop nests of LST. | [
"Flattens",
"all",
"the",
"loop",
"nests",
"of",
"LST",
"."
] | [
"/* FIXME: As long as we use PPL we are not able to remove the old\n\t scattering dimensions. The reason is that these dimensions are not\n\t entirely unused. They are not necessary as part of the scheduling\n\t vector, as the earlier dimensions already unambiguously define the\n\t execution time, however they may still be needed to carry modulo\n\t constraints as introduced e.g. by strip mining. The correct solution\n\t would be to project these dimensions out of the scattering polyhedra.\n\t In case they are still required to carry modulo constraints they should be kept\n\t internally as existentially quantified dimensions. PPL does only support\n projection of rational polyhedra, however in this case we need an integer\n\t projection. With isl this will be trivial to implement. For now we just\n\t leave the dimensions. This is a little ugly, but should be correct. */"
] | [
{
"param": "lst",
"type": "lst_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lst",
"type": "lst_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33f25e01b03f680493f0b396a81cc8e421598a8c | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/graphite-flattening.c | [
"BSD-3-Clause"
] | C | flatten_all_loops | bool | bool
flatten_all_loops (scop_p scop)
{
return lst_do_flatten (SCOP_TRANSFORMED_SCHEDULE (scop));
} | /* Flatten all the loop nests in SCOP. Returns true when something
changed. */ | Flatten all the loop nests in SCOP. Returns true when something
changed. | [
"Flatten",
"all",
"the",
"loop",
"nests",
"in",
"SCOP",
".",
"Returns",
"true",
"when",
"something",
"changed",
"."
] | bool
flatten_all_loops (scop_p scop)
{
return lst_do_flatten (SCOP_TRANSFORMED_SCHEDULE (scop));
} | [
"bool",
"flatten_all_loops",
"(",
"scop_p",
"scop",
")",
"{",
"return",
"lst_do_flatten",
"(",
"SCOP_TRANSFORMED_SCHEDULE",
"(",
"scop",
")",
")",
";",
"}"
] | Flatten all the loop nests in SCOP. | [
"Flatten",
"all",
"the",
"loop",
"nests",
"in",
"SCOP",
"."
] | [] | [
{
"param": "scop",
"type": "scop_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scop",
"type": "scop_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | readline_internal | char | static char *
readline_internal ()
{
int eof;
readline_internal_setup ();
eof = readline_internal_charloop ();
return (readline_internal_teardown (eof));
} | /* Read a line of input from the global rl_instream, doing output on
the global rl_outstream.
If rl_prompt is non-null, then that is our prompt. */ | Read a line of input from the global rl_instream, doing output on
the global rl_outstream.
If rl_prompt is non-null, then that is our prompt. | [
"Read",
"a",
"line",
"of",
"input",
"from",
"the",
"global",
"rl_instream",
"doing",
"output",
"on",
"the",
"global",
"rl_outstream",
".",
"If",
"rl_prompt",
"is",
"non",
"-",
"null",
"then",
"that",
"is",
"our",
"prompt",
"."
] | static char *
readline_internal ()
{
int eof;
readline_internal_setup ();
eof = readline_internal_charloop ();
return (readline_internal_teardown (eof));
} | [
"static",
"char",
"*",
"readline_internal",
"(",
")",
"{",
"int",
"eof",
";",
"readline_internal_setup",
"(",
")",
";",
"eof",
"=",
"readline_internal_charloop",
"(",
")",
";",
"return",
"(",
"readline_internal_teardown",
"(",
"eof",
")",
")",
";",
"}"
] | Read a line of input from the global rl_instream, doing output on
the global rl_outstream. | [
"Read",
"a",
"line",
"of",
"input",
"from",
"the",
"global",
"rl_instream",
"doing",
"output",
"on",
"the",
"global",
"rl_outstream",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | rl_initialize | int | int
rl_initialize ()
{
/* If we have never been called before, initialize the
terminal and data structures. */
if (!rl_initialized)
{
RL_SETSTATE(RL_STATE_INITIALIZING);
readline_initialize_everything ();
RL_UNSETSTATE(RL_STATE_INITIALIZING);
rl_initialized++;
RL_SETSTATE(RL_STATE_INITIALIZED);
}
/* Initalize the current line information. */
_rl_init_line_state ();
/* We aren't done yet. We haven't even gotten started yet! */
rl_done = 0;
RL_UNSETSTATE(RL_STATE_DONE);
/* Tell the history routines what is going on. */
_rl_start_using_history ();
/* Make the display buffer match the state of the line. */
rl_reset_line_state ();
/* No such function typed yet. */
rl_last_func = (rl_command_func_t *)NULL;
/* Parsing of key-bindings begins in an enabled state. */
_rl_parsing_conditionalized_out = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
_rl_vi_initialize_line ();
#endif
/* Each line starts in insert mode (the default). */
_rl_set_insert_mode (RL_IM_DEFAULT, 1);
return 0;
} | /* Initialize readline (and terminal if not already). */ | Initialize readline (and terminal if not already). | [
"Initialize",
"readline",
"(",
"and",
"terminal",
"if",
"not",
"already",
")",
"."
] | int
rl_initialize ()
{
if (!rl_initialized)
{
RL_SETSTATE(RL_STATE_INITIALIZING);
readline_initialize_everything ();
RL_UNSETSTATE(RL_STATE_INITIALIZING);
rl_initialized++;
RL_SETSTATE(RL_STATE_INITIALIZED);
}
_rl_init_line_state ();
rl_done = 0;
RL_UNSETSTATE(RL_STATE_DONE);
_rl_start_using_history ();
rl_reset_line_state ();
rl_last_func = (rl_command_func_t *)NULL;
_rl_parsing_conditionalized_out = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
_rl_vi_initialize_line ();
#endif
_rl_set_insert_mode (RL_IM_DEFAULT, 1);
return 0;
} | [
"int",
"rl_initialize",
"(",
")",
"{",
"if",
"(",
"!",
"rl_initialized",
")",
"{",
"RL_SETSTATE",
"(",
"RL_STATE_INITIALIZING",
")",
";",
"readline_initialize_everything",
"(",
")",
";",
"RL_UNSETSTATE",
"(",
"RL_STATE_INITIALIZING",
")",
";",
"rl_initialized",
"++",
";",
"RL_SETSTATE",
"(",
"RL_STATE_INITIALIZED",
")",
";",
"}",
"_rl_init_line_state",
"(",
")",
";",
"rl_done",
"=",
"0",
";",
"RL_UNSETSTATE",
"(",
"RL_STATE_DONE",
")",
";",
"_rl_start_using_history",
"(",
")",
";",
"rl_reset_line_state",
"(",
")",
";",
"rl_last_func",
"=",
"(",
"rl_command_func_t",
"*",
")",
"NULL",
";",
"_rl_parsing_conditionalized_out",
"=",
"0",
";",
"#if",
"defined",
"(",
"VI_MODE",
")",
"\n",
"if",
"(",
"rl_editing_mode",
"==",
"vi_mode",
")",
"_rl_vi_initialize_line",
"(",
")",
";",
"#endif",
"_rl_set_insert_mode",
"(",
"RL_IM_DEFAULT",
",",
"1",
")",
";",
"return",
"0",
";",
"}"
] | Initialize readline (and terminal if not already). | [
"Initialize",
"readline",
"(",
"and",
"terminal",
"if",
"not",
"already",
")",
"."
] | [
"/* If we have never been called before, initialize the\n terminal and data structures. */",
"/* Initalize the current line information. */",
"/* We aren't done yet. We haven't even gotten started yet! */",
"/* Tell the history routines what is going on. */",
"/* Make the display buffer match the state of the line. */",
"/* No such function typed yet. */",
"/* Parsing of key-bindings begins in an enabled state. */",
"/* Each line starts in insert mode (the default). */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | readline_initialize_everything | void | static void
readline_initialize_everything ()
{
#if 0
#if defined (__EMX__)
if (environ == 0)
_emx_build_environ ();
#endif
#endif
#if 0
/* Find out if we are running in Emacs -- UNUSED. */
running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
#endif
/* Set up input and output if they are not already set up. */
if (!rl_instream)
rl_instream = stdin;
if (!rl_outstream)
rl_outstream = stdout;
/* Bind _rl_in_stream and _rl_out_stream immediately. These values
may change, but they may also be used before readline_internal ()
is called. */
_rl_in_stream = rl_instream;
_rl_out_stream = rl_outstream;
/* Allocate data structures. */
if (rl_line_buffer == 0)
rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
/* Initialize the terminal interface. */
if (rl_terminal_name == 0)
rl_terminal_name = sh_get_env_value ("TERM");
_rl_init_terminal_io (rl_terminal_name);
/* Bind tty characters to readline functions. */
readline_default_bindings ();
/* Initialize the function names. */
rl_initialize_funmap ();
/* Decide whether we should automatically go into eight-bit mode. */
_rl_init_eightbit ();
/* Read in the init file. */
rl_read_init_file ((char *)NULL);
/* XXX */
if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
{
_rl_screenwidth--;
_rl_screenchars -= _rl_screenheight;
}
/* Override the effect of any `set keymap' assignments in the
inputrc file. */
rl_set_keymap_from_edit_mode ();
/* Try to bind a common arrow key prefix, if not already bound. */
bind_arrow_keys ();
/* Enable the meta key, if this terminal has one. */
if (_rl_enable_meta)
_rl_enable_meta_key ();
/* If the completion parser's default word break characters haven't
been set yet, then do so now. */
if (rl_completer_word_break_characters == (char *)NULL)
rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
} | /* Initialize the entire state of the world. */ | Initialize the entire state of the world. | [
"Initialize",
"the",
"entire",
"state",
"of",
"the",
"world",
"."
] | static void
readline_initialize_everything ()
{
#if 0
#if defined (__EMX__)
if (environ == 0)
_emx_build_environ ();
#endif
#endif
#if 0
running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
#endif
if (!rl_instream)
rl_instream = stdin;
if (!rl_outstream)
rl_outstream = stdout;
_rl_in_stream = rl_instream;
_rl_out_stream = rl_outstream;
if (rl_line_buffer == 0)
rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
if (rl_terminal_name == 0)
rl_terminal_name = sh_get_env_value ("TERM");
_rl_init_terminal_io (rl_terminal_name);
readline_default_bindings ();
rl_initialize_funmap ();
_rl_init_eightbit ();
rl_read_init_file ((char *)NULL);
if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
{
_rl_screenwidth--;
_rl_screenchars -= _rl_screenheight;
}
rl_set_keymap_from_edit_mode ();
bind_arrow_keys ();
if (_rl_enable_meta)
_rl_enable_meta_key ();
if (rl_completer_word_break_characters == (char *)NULL)
rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
} | [
"static",
"void",
"readline_initialize_everything",
"(",
")",
"{",
"#if",
"0",
"\n",
"#if",
"defined",
"(",
"__EMX__",
")",
"\n",
"if",
"(",
"environ",
"==",
"0",
")",
"_emx_build_environ",
"(",
")",
";",
"#endif",
"#endif",
"#if",
"0",
"\n",
"running_in_emacs",
"=",
"sh_get_env_value",
"(",
"\"",
"\"",
")",
"!=",
"(",
"char",
"*",
")",
"0",
";",
"#endif",
"if",
"(",
"!",
"rl_instream",
")",
"rl_instream",
"=",
"stdin",
";",
"if",
"(",
"!",
"rl_outstream",
")",
"rl_outstream",
"=",
"stdout",
";",
"_rl_in_stream",
"=",
"rl_instream",
";",
"_rl_out_stream",
"=",
"rl_outstream",
";",
"if",
"(",
"rl_line_buffer",
"==",
"0",
")",
"rl_line_buffer",
"=",
"(",
"char",
"*",
")",
"xmalloc",
"(",
"rl_line_buffer_len",
"=",
"DEFAULT_BUFFER_SIZE",
")",
";",
"if",
"(",
"rl_terminal_name",
"==",
"0",
")",
"rl_terminal_name",
"=",
"sh_get_env_value",
"(",
"\"",
"\"",
")",
";",
"_rl_init_terminal_io",
"(",
"rl_terminal_name",
")",
";",
"readline_default_bindings",
"(",
")",
";",
"rl_initialize_funmap",
"(",
")",
";",
"_rl_init_eightbit",
"(",
")",
";",
"rl_read_init_file",
"(",
"(",
"char",
"*",
")",
"NULL",
")",
";",
"if",
"(",
"_rl_horizontal_scroll_mode",
"&&",
"_rl_term_autowrap",
")",
"{",
"_rl_screenwidth",
"--",
";",
"_rl_screenchars",
"-=",
"_rl_screenheight",
";",
"}",
"rl_set_keymap_from_edit_mode",
"(",
")",
";",
"bind_arrow_keys",
"(",
")",
";",
"if",
"(",
"_rl_enable_meta",
")",
"_rl_enable_meta_key",
"(",
")",
";",
"if",
"(",
"rl_completer_word_break_characters",
"==",
"(",
"char",
"*",
")",
"NULL",
")",
"rl_completer_word_break_characters",
"=",
"(",
"char",
"*",
")",
"rl_basic_word_break_characters",
";",
"}"
] | Initialize the entire state of the world. | [
"Initialize",
"the",
"entire",
"state",
"of",
"the",
"world",
"."
] | [
"/* Find out if we are running in Emacs -- UNUSED. */",
"/* Set up input and output if they are not already set up. */",
"/* Bind _rl_in_stream and _rl_out_stream immediately. These values\n may change, but they may also be used before readline_internal ()\n is called. */",
"/* Allocate data structures. */",
"/* Initialize the terminal interface. */",
"/* Bind tty characters to readline functions. */",
"/* Initialize the function names. */",
"/* Decide whether we should automatically go into eight-bit mode. */",
"/* Read in the init file. */",
"/* XXX */",
"/* Override the effect of any `set keymap' assignments in the\n inputrc file. */",
"/* Try to bind a common arrow key prefix, if not already bound. */",
"/* Enable the meta key, if this terminal has one. */",
"/* If the completion parser's default word break characters haven't\n been set yet, then do so now. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | readline_default_bindings | void | static void
readline_default_bindings ()
{
if (_rl_bind_stty_chars)
rl_tty_set_default_bindings (_rl_keymap);
} | /* If this system allows us to look at the values of the regular
input editing characters, then bind them to their readline
equivalents, iff the characters are not bound to keymaps. */ | If this system allows us to look at the values of the regular
input editing characters, then bind them to their readline
equivalents, iff the characters are not bound to keymaps. | [
"If",
"this",
"system",
"allows",
"us",
"to",
"look",
"at",
"the",
"values",
"of",
"the",
"regular",
"input",
"editing",
"characters",
"then",
"bind",
"them",
"to",
"their",
"readline",
"equivalents",
"iff",
"the",
"characters",
"are",
"not",
"bound",
"to",
"keymaps",
"."
] | static void
readline_default_bindings ()
{
if (_rl_bind_stty_chars)
rl_tty_set_default_bindings (_rl_keymap);
} | [
"static",
"void",
"readline_default_bindings",
"(",
")",
"{",
"if",
"(",
"_rl_bind_stty_chars",
")",
"rl_tty_set_default_bindings",
"(",
"_rl_keymap",
")",
";",
"}"
] | If this system allows us to look at the values of the regular
input editing characters, then bind them to their readline
equivalents, iff the characters are not bound to keymaps. | [
"If",
"this",
"system",
"allows",
"us",
"to",
"look",
"at",
"the",
"values",
"of",
"the",
"regular",
"input",
"editing",
"characters",
"then",
"bind",
"them",
"to",
"their",
"readline",
"equivalents",
"iff",
"the",
"characters",
"are",
"not",
"bound",
"to",
"keymaps",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | reset_default_bindings | void | static void
reset_default_bindings ()
{
if (_rl_bind_stty_chars)
{
rl_tty_unset_default_bindings (_rl_keymap);
rl_tty_set_default_bindings (_rl_keymap);
}
} | /* Reset the default bindings for the terminal special characters we're
interested in back to rl_insert and read the new ones. */ | Reset the default bindings for the terminal special characters we're
interested in back to rl_insert and read the new ones. | [
"Reset",
"the",
"default",
"bindings",
"for",
"the",
"terminal",
"special",
"characters",
"we",
"'",
"re",
"interested",
"in",
"back",
"to",
"rl_insert",
"and",
"read",
"the",
"new",
"ones",
"."
] | static void
reset_default_bindings ()
{
if (_rl_bind_stty_chars)
{
rl_tty_unset_default_bindings (_rl_keymap);
rl_tty_set_default_bindings (_rl_keymap);
}
} | [
"static",
"void",
"reset_default_bindings",
"(",
")",
"{",
"if",
"(",
"_rl_bind_stty_chars",
")",
"{",
"rl_tty_unset_default_bindings",
"(",
"_rl_keymap",
")",
";",
"rl_tty_set_default_bindings",
"(",
"_rl_keymap",
")",
";",
"}",
"}"
] | Reset the default bindings for the terminal special characters we're
interested in back to rl_insert and read the new ones. | [
"Reset",
"the",
"default",
"bindings",
"for",
"the",
"terminal",
"special",
"characters",
"we",
"'",
"re",
"interested",
"in",
"back",
"to",
"rl_insert",
"and",
"read",
"the",
"new",
"ones",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f2e4d933dfe6fe2784d53ee7687743c5799aaad4 | atrens/DragonFlyBSD-src | contrib/gdb-7/readline/readline.c | [
"BSD-3-Clause"
] | C | bind_arrow_keys | void | static void
bind_arrow_keys ()
{
bind_arrow_keys_internal (emacs_standard_keymap);
#if defined (VI_MODE)
bind_arrow_keys_internal (vi_movement_keymap);
/* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
in vi command mode while still allowing the arrow keys to work. */
if (vi_movement_keymap[ESC].type == ISKMAP)
rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
bind_arrow_keys_internal (vi_insertion_keymap);
#endif
} | /* Try and bind the common arrow key prefixes after giving termcap and
the inputrc file a chance to bind them and create `real' keymaps
for the arrow key prefix. */ | Try and bind the common arrow key prefixes after giving termcap and
the inputrc file a chance to bind them and create `real' keymaps
for the arrow key prefix. | [
"Try",
"and",
"bind",
"the",
"common",
"arrow",
"key",
"prefixes",
"after",
"giving",
"termcap",
"and",
"the",
"inputrc",
"file",
"a",
"chance",
"to",
"bind",
"them",
"and",
"create",
"`",
"real",
"'",
"keymaps",
"for",
"the",
"arrow",
"key",
"prefix",
"."
] | static void
bind_arrow_keys ()
{
bind_arrow_keys_internal (emacs_standard_keymap);
#if defined (VI_MODE)
bind_arrow_keys_internal (vi_movement_keymap);
if (vi_movement_keymap[ESC].type == ISKMAP)
rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
bind_arrow_keys_internal (vi_insertion_keymap);
#endif
} | [
"static",
"void",
"bind_arrow_keys",
"(",
")",
"{",
"bind_arrow_keys_internal",
"(",
"emacs_standard_keymap",
")",
";",
"#if",
"defined",
"(",
"VI_MODE",
")",
"\n",
"bind_arrow_keys_internal",
"(",
"vi_movement_keymap",
")",
";",
"if",
"(",
"vi_movement_keymap",
"[",
"ESC",
"]",
".",
"type",
"==",
"ISKMAP",
")",
"rl_bind_keyseq_in_map",
"(",
"\"",
"\\033",
"\"",
",",
"(",
"rl_command_func_t",
"*",
")",
"NULL",
",",
"vi_movement_keymap",
")",
";",
"bind_arrow_keys_internal",
"(",
"vi_insertion_keymap",
")",
";",
"#endif",
"}"
] | Try and bind the common arrow key prefixes after giving termcap and
the inputrc file a chance to bind them and create `real' keymaps
for the arrow key prefix. | [
"Try",
"and",
"bind",
"the",
"common",
"arrow",
"key",
"prefixes",
"after",
"giving",
"termcap",
"and",
"the",
"inputrc",
"file",
"a",
"chance",
"to",
"bind",
"them",
"and",
"create",
"`",
"real",
"'",
"keymaps",
"for",
"the",
"arrow",
"key",
"prefix",
"."
] | [
"/* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC\n in vi command mode while still allowing the arrow keys to work. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f21812d09488c90b5e8e7338f23bead55d1ebf38 | atrens/DragonFlyBSD-src | contrib/cvs-1.12/lib/xreadlink.c | [
"BSD-3-Clause"
] | C | xreadlink | char | char *
xreadlink (char const *file, size_t size)
{
/* The initial buffer size for the link value. A power of 2
detects arithmetic overflow earlier, but is not required. */
size_t buf_size = size < MAXSIZE ? size + 1 : MAXSIZE;
while (1)
{
char *buffer = xmalloc (buf_size);
ssize_t r = readlink (file, buffer, buf_size);
size_t link_length = r;
/* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1
with errno == ERANGE if the buffer is too small. */
if (r < 0 && errno != ERANGE)
{
int saved_errno = errno;
free (buffer);
errno = saved_errno;
return NULL;
}
if (link_length < buf_size)
{
buffer[link_length] = 0;
return buffer;
}
free (buffer);
if (buf_size <= MAXSIZE / 2)
buf_size *= 2;
else if (buf_size < MAXSIZE)
buf_size = MAXSIZE;
else
xalloc_die ();
}
} | /* Call readlink to get the symbolic link value of FILE.
SIZE is a hint as to how long the link is expected to be;
typically it is taken from st_size. It need not be correct.
Return a pointer to that NUL-terminated string in malloc'd storage.
If readlink fails, return NULL (caller may use errno to diagnose).
If malloc fails, or if the link value is longer than SSIZE_MAX :-),
give a diagnostic and exit. */ | Call readlink to get the symbolic link value of FILE.
SIZE is a hint as to how long the link is expected to be;
typically it is taken from st_size. It need not be correct.
Return a pointer to that NUL-terminated string in malloc'd storage.
If readlink fails, return NULL (caller may use errno to diagnose).
If malloc fails, or if the link value is longer than SSIZE_MAX :-),
give a diagnostic and exit. | [
"Call",
"readlink",
"to",
"get",
"the",
"symbolic",
"link",
"value",
"of",
"FILE",
".",
"SIZE",
"is",
"a",
"hint",
"as",
"to",
"how",
"long",
"the",
"link",
"is",
"expected",
"to",
"be",
";",
"typically",
"it",
"is",
"taken",
"from",
"st_size",
".",
"It",
"need",
"not",
"be",
"correct",
".",
"Return",
"a",
"pointer",
"to",
"that",
"NUL",
"-",
"terminated",
"string",
"in",
"malloc",
"'",
"d",
"storage",
".",
"If",
"readlink",
"fails",
"return",
"NULL",
"(",
"caller",
"may",
"use",
"errno",
"to",
"diagnose",
")",
".",
"If",
"malloc",
"fails",
"or",
"if",
"the",
"link",
"value",
"is",
"longer",
"than",
"SSIZE_MAX",
":",
"-",
")",
"give",
"a",
"diagnostic",
"and",
"exit",
"."
] | char *
xreadlink (char const *file, size_t size)
{
size_t buf_size = size < MAXSIZE ? size + 1 : MAXSIZE;
while (1)
{
char *buffer = xmalloc (buf_size);
ssize_t r = readlink (file, buffer, buf_size);
size_t link_length = r;
if (r < 0 && errno != ERANGE)
{
int saved_errno = errno;
free (buffer);
errno = saved_errno;
return NULL;
}
if (link_length < buf_size)
{
buffer[link_length] = 0;
return buffer;
}
free (buffer);
if (buf_size <= MAXSIZE / 2)
buf_size *= 2;
else if (buf_size < MAXSIZE)
buf_size = MAXSIZE;
else
xalloc_die ();
}
} | [
"char",
"*",
"xreadlink",
"(",
"char",
"const",
"*",
"file",
",",
"size_t",
"size",
")",
"{",
"size_t",
"buf_size",
"=",
"size",
"<",
"MAXSIZE",
"?",
"size",
"+",
"1",
":",
"MAXSIZE",
";",
"while",
"(",
"1",
")",
"{",
"char",
"*",
"buffer",
"=",
"xmalloc",
"(",
"buf_size",
")",
";",
"ssize_t",
"r",
"=",
"readlink",
"(",
"file",
",",
"buffer",
",",
"buf_size",
")",
";",
"size_t",
"link_length",
"=",
"r",
";",
"if",
"(",
"r",
"<",
"0",
"&&",
"errno",
"!=",
"ERANGE",
")",
"{",
"int",
"saved_errno",
"=",
"errno",
";",
"free",
"(",
"buffer",
")",
";",
"errno",
"=",
"saved_errno",
";",
"return",
"NULL",
";",
"}",
"if",
"(",
"link_length",
"<",
"buf_size",
")",
"{",
"buffer",
"[",
"link_length",
"]",
"=",
"0",
";",
"return",
"buffer",
";",
"}",
"free",
"(",
"buffer",
")",
";",
"if",
"(",
"buf_size",
"<=",
"MAXSIZE",
"/",
"2",
")",
"buf_size",
"*=",
"2",
";",
"else",
"if",
"(",
"buf_size",
"<",
"MAXSIZE",
")",
"buf_size",
"=",
"MAXSIZE",
";",
"else",
"xalloc_die",
"(",
")",
";",
"}",
"}"
] | Call readlink to get the symbolic link value of FILE. | [
"Call",
"readlink",
"to",
"get",
"the",
"symbolic",
"link",
"value",
"of",
"FILE",
"."
] | [
"/* The initial buffer size for the link value. A power of 2\n detects arithmetic overflow earlier, but is not required. */",
"/* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1\n\t with errno == ERANGE if the buffer is too small. */"
] | [
{
"param": "file",
"type": "char"
},
{
"param": "size",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | ggc_internal_cleared_alloc | void | void *ggc_internal_cleared_alloc (size_t, void (*)(void *),
size_t, size_t MEM_STAT_DECL)
{
return NULL;
} | /* Stubs for GGC referenced through instantiations triggered by hash-map. */ | Stubs for GGC referenced through instantiations triggered by hash-map. | [
"Stubs",
"for",
"GGC",
"referenced",
"through",
"instantiations",
"triggered",
"by",
"hash",
"-",
"map",
"."
] | void *ggc_internal_cleared_alloc (size_t, void (*)(void *),
size_t, size_t MEM_STAT_DECL)
{
return NULL;
} | [
"void",
"*",
"ggc_internal_cleared_alloc",
"(",
"size_t",
",",
"void",
"(",
"*",
")",
"(",
"void",
"*",
")",
",",
"size_t",
",",
"size_t",
"MEM_STAT_DECL",
")",
"{",
"return",
"NULL",
";",
"}"
] | Stubs for GGC referenced through instantiations triggered by hash-map. | [
"Stubs",
"for",
"GGC",
"referenced",
"through",
"instantiations",
"triggered",
"by",
"hash",
"-",
"map",
"."
] | [] | [
{
"param": "MEM_STAT_DECL",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "MEM_STAT_DECL",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | linemap_client_expand_location_to_spelling_point | expanded_location | expanded_location
linemap_client_expand_location_to_spelling_point (source_location loc,
enum location_aspect)
{
const struct line_map_ordinary *map;
loc = linemap_resolve_location (line_table, loc, LRK_SPELLING_LOCATION, &map);
return linemap_expand_location (line_table, map, loc);
} | /* The rich_location class within libcpp requires a way to expand
source_location instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this.
This is the implementation for genmatch. */ | The rich_location class within libcpp requires a way to expand
source_location instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this.
This is the implementation for genmatch. | [
"The",
"rich_location",
"class",
"within",
"libcpp",
"requires",
"a",
"way",
"to",
"expand",
"source_location",
"instances",
"and",
"relies",
"on",
"the",
"client",
"code",
"providing",
"a",
"symbol",
"named",
"linemap_client_expand_location_to_spelling_point",
"to",
"do",
"this",
".",
"This",
"is",
"the",
"implementation",
"for",
"genmatch",
"."
] | expanded_location
linemap_client_expand_location_to_spelling_point (source_location loc,
enum location_aspect)
{
const struct line_map_ordinary *map;
loc = linemap_resolve_location (line_table, loc, LRK_SPELLING_LOCATION, &map);
return linemap_expand_location (line_table, map, loc);
} | [
"expanded_location",
"linemap_client_expand_location_to_spelling_point",
"(",
"source_location",
"loc",
",",
"enum",
"location_aspect",
")",
"{",
"const",
"struct",
"line_map_ordinary",
"*",
"map",
";",
"loc",
"=",
"linemap_resolve_location",
"(",
"line_table",
",",
"loc",
",",
"LRK_SPELLING_LOCATION",
",",
"&",
"map",
")",
";",
"return",
"linemap_expand_location",
"(",
"line_table",
",",
"map",
",",
"loc",
")",
";",
"}"
] | The rich_location class within libcpp requires a way to expand
source_location instances, and relies on the client code
providing a symbol named
linemap_client_expand_location_to_spelling_point
to do this. | [
"The",
"rich_location",
"class",
"within",
"libcpp",
"requires",
"a",
"way",
"to",
"expand",
"source_location",
"instances",
"and",
"relies",
"on",
"the",
"client",
"code",
"providing",
"a",
"symbol",
"named",
"linemap_client_expand_location_to_spelling_point",
"to",
"do",
"this",
"."
] | [] | [
{
"param": "loc",
"type": "source_location"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "loc",
"type": "source_location",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | commutative_tree_code | bool | bool
commutative_tree_code (enum tree_code code)
{
switch (code)
{
case PLUS_EXPR:
case MULT_EXPR:
case MULT_HIGHPART_EXPR:
case MIN_EXPR:
case MAX_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case BIT_AND_EXPR:
case NE_EXPR:
case EQ_EXPR:
case UNORDERED_EXPR:
case ORDERED_EXPR:
case UNEQ_EXPR:
case LTGT_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_XOR_EXPR:
case TRUTH_OR_EXPR:
case WIDEN_MULT_EXPR:
case VEC_WIDEN_MULT_HI_EXPR:
case VEC_WIDEN_MULT_LO_EXPR:
case VEC_WIDEN_MULT_EVEN_EXPR:
case VEC_WIDEN_MULT_ODD_EXPR:
return true;
default:
break;
}
return false;
} | /* Return true if CODE represents a commutative tree code. Otherwise
return false. */ | Return true if CODE represents a commutative tree code. Otherwise
return false. | [
"Return",
"true",
"if",
"CODE",
"represents",
"a",
"commutative",
"tree",
"code",
".",
"Otherwise",
"return",
"false",
"."
] | bool
commutative_tree_code (enum tree_code code)
{
switch (code)
{
case PLUS_EXPR:
case MULT_EXPR:
case MULT_HIGHPART_EXPR:
case MIN_EXPR:
case MAX_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case BIT_AND_EXPR:
case NE_EXPR:
case EQ_EXPR:
case UNORDERED_EXPR:
case ORDERED_EXPR:
case UNEQ_EXPR:
case LTGT_EXPR:
case TRUTH_AND_EXPR:
case TRUTH_XOR_EXPR:
case TRUTH_OR_EXPR:
case WIDEN_MULT_EXPR:
case VEC_WIDEN_MULT_HI_EXPR:
case VEC_WIDEN_MULT_LO_EXPR:
case VEC_WIDEN_MULT_EVEN_EXPR:
case VEC_WIDEN_MULT_ODD_EXPR:
return true;
default:
break;
}
return false;
} | [
"bool",
"commutative_tree_code",
"(",
"enum",
"tree_code",
"code",
")",
"{",
"switch",
"(",
"code",
")",
"{",
"case",
"PLUS_EXPR",
":",
"case",
"MULT_EXPR",
":",
"case",
"MULT_HIGHPART_EXPR",
":",
"case",
"MIN_EXPR",
":",
"case",
"MAX_EXPR",
":",
"case",
"BIT_IOR_EXPR",
":",
"case",
"BIT_XOR_EXPR",
":",
"case",
"BIT_AND_EXPR",
":",
"case",
"NE_EXPR",
":",
"case",
"EQ_EXPR",
":",
"case",
"UNORDERED_EXPR",
":",
"case",
"ORDERED_EXPR",
":",
"case",
"UNEQ_EXPR",
":",
"case",
"LTGT_EXPR",
":",
"case",
"TRUTH_AND_EXPR",
":",
"case",
"TRUTH_XOR_EXPR",
":",
"case",
"TRUTH_OR_EXPR",
":",
"case",
"WIDEN_MULT_EXPR",
":",
"case",
"VEC_WIDEN_MULT_HI_EXPR",
":",
"case",
"VEC_WIDEN_MULT_LO_EXPR",
":",
"case",
"VEC_WIDEN_MULT_EVEN_EXPR",
":",
"case",
"VEC_WIDEN_MULT_ODD_EXPR",
":",
"return",
"true",
";",
"default",
":",
"break",
";",
"}",
"return",
"false",
";",
"}"
] | Return true if CODE represents a commutative tree code. | [
"Return",
"true",
"if",
"CODE",
"represents",
"a",
"commutative",
"tree",
"code",
"."
] | [] | [
{
"param": "code",
"type": "enum tree_code"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "code",
"type": "enum tree_code",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | commutative_ternary_tree_code | bool | bool
commutative_ternary_tree_code (enum tree_code code)
{
switch (code)
{
case WIDEN_MULT_PLUS_EXPR:
case WIDEN_MULT_MINUS_EXPR:
case DOT_PROD_EXPR:
case FMA_EXPR:
return true;
default:
break;
}
return false;
} | /* Return true if CODE represents a ternary tree code for which the
first two operands are commutative. Otherwise return false. */ | Return true if CODE represents a ternary tree code for which the
first two operands are commutative. Otherwise return false. | [
"Return",
"true",
"if",
"CODE",
"represents",
"a",
"ternary",
"tree",
"code",
"for",
"which",
"the",
"first",
"two",
"operands",
"are",
"commutative",
".",
"Otherwise",
"return",
"false",
"."
] | bool
commutative_ternary_tree_code (enum tree_code code)
{
switch (code)
{
case WIDEN_MULT_PLUS_EXPR:
case WIDEN_MULT_MINUS_EXPR:
case DOT_PROD_EXPR:
case FMA_EXPR:
return true;
default:
break;
}
return false;
} | [
"bool",
"commutative_ternary_tree_code",
"(",
"enum",
"tree_code",
"code",
")",
"{",
"switch",
"(",
"code",
")",
"{",
"case",
"WIDEN_MULT_PLUS_EXPR",
":",
"case",
"WIDEN_MULT_MINUS_EXPR",
":",
"case",
"DOT_PROD_EXPR",
":",
"case",
"FMA_EXPR",
":",
"return",
"true",
";",
"default",
":",
"break",
";",
"}",
"return",
"false",
";",
"}"
] | Return true if CODE represents a ternary tree code for which the
first two operands are commutative. | [
"Return",
"true",
"if",
"CODE",
"represents",
"a",
"ternary",
"tree",
"code",
"for",
"which",
"the",
"first",
"two",
"operands",
"are",
"commutative",
"."
] | [] | [
{
"param": "code",
"type": "enum tree_code"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "code",
"type": "enum tree_code",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | comparison_code_p | bool | bool
comparison_code_p (enum tree_code code)
{
switch (code)
{
case EQ_EXPR:
case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
case GT_EXPR:
case GE_EXPR:
case LT_EXPR:
case LE_EXPR:
case UNGT_EXPR:
case UNGE_EXPR:
case UNLT_EXPR:
case UNLE_EXPR:
return true;
default:
break;
}
return false;
} | /* Return true if CODE is a comparison. */ | Return true if CODE is a comparison. | [
"Return",
"true",
"if",
"CODE",
"is",
"a",
"comparison",
"."
] | bool
comparison_code_p (enum tree_code code)
{
switch (code)
{
case EQ_EXPR:
case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
case GT_EXPR:
case GE_EXPR:
case LT_EXPR:
case LE_EXPR:
case UNGT_EXPR:
case UNGE_EXPR:
case UNLT_EXPR:
case UNLE_EXPR:
return true;
default:
break;
}
return false;
} | [
"bool",
"comparison_code_p",
"(",
"enum",
"tree_code",
"code",
")",
"{",
"switch",
"(",
"code",
")",
"{",
"case",
"EQ_EXPR",
":",
"case",
"NE_EXPR",
":",
"case",
"ORDERED_EXPR",
":",
"case",
"UNORDERED_EXPR",
":",
"case",
"LTGT_EXPR",
":",
"case",
"UNEQ_EXPR",
":",
"case",
"GT_EXPR",
":",
"case",
"GE_EXPR",
":",
"case",
"LT_EXPR",
":",
"case",
"LE_EXPR",
":",
"case",
"UNGT_EXPR",
":",
"case",
"UNGE_EXPR",
":",
"case",
"UNLT_EXPR",
":",
"case",
"UNLE_EXPR",
":",
"return",
"true",
";",
"default",
":",
"break",
";",
"}",
"return",
"false",
";",
"}"
] | Return true if CODE is a comparison. | [
"Return",
"true",
"if",
"CODE",
"is",
"a",
"comparison",
"."
] | [] | [
{
"param": "code",
"type": "enum tree_code"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "code",
"type": "enum tree_code",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | swap_tree_comparison | id_base | id_base *
swap_tree_comparison (operator_id *p)
{
switch (p->code)
{
case EQ_EXPR:
case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
return p;
case GT_EXPR:
return get_operator ("LT_EXPR");
case GE_EXPR:
return get_operator ("LE_EXPR");
case LT_EXPR:
return get_operator ("GT_EXPR");
case LE_EXPR:
return get_operator ("GE_EXPR");
case UNGT_EXPR:
return get_operator ("UNLT_EXPR");
case UNGE_EXPR:
return get_operator ("UNLE_EXPR");
case UNLT_EXPR:
return get_operator ("UNGT_EXPR");
case UNLE_EXPR:
return get_operator ("UNGE_EXPR");
default:
gcc_unreachable ();
}
} | /* Return the comparison operators that results if the operands are
swapped. This is safe for floating-point. */ | Return the comparison operators that results if the operands are
swapped. This is safe for floating-point. | [
"Return",
"the",
"comparison",
"operators",
"that",
"results",
"if",
"the",
"operands",
"are",
"swapped",
".",
"This",
"is",
"safe",
"for",
"floating",
"-",
"point",
"."
] | id_base *
swap_tree_comparison (operator_id *p)
{
switch (p->code)
{
case EQ_EXPR:
case NE_EXPR:
case ORDERED_EXPR:
case UNORDERED_EXPR:
case LTGT_EXPR:
case UNEQ_EXPR:
return p;
case GT_EXPR:
return get_operator ("LT_EXPR");
case GE_EXPR:
return get_operator ("LE_EXPR");
case LT_EXPR:
return get_operator ("GT_EXPR");
case LE_EXPR:
return get_operator ("GE_EXPR");
case UNGT_EXPR:
return get_operator ("UNLT_EXPR");
case UNGE_EXPR:
return get_operator ("UNLE_EXPR");
case UNLT_EXPR:
return get_operator ("UNGT_EXPR");
case UNLE_EXPR:
return get_operator ("UNGE_EXPR");
default:
gcc_unreachable ();
}
} | [
"id_base",
"*",
"swap_tree_comparison",
"(",
"operator_id",
"*",
"p",
")",
"{",
"switch",
"(",
"p",
"->",
"code",
")",
"{",
"case",
"EQ_EXPR",
":",
"case",
"NE_EXPR",
":",
"case",
"ORDERED_EXPR",
":",
"case",
"UNORDERED_EXPR",
":",
"case",
"LTGT_EXPR",
":",
"case",
"UNEQ_EXPR",
":",
"return",
"p",
";",
"case",
"GT_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"GE_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"LT_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"LE_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"UNGT_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"UNGE_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"UNLT_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"case",
"UNLE_EXPR",
":",
"return",
"get_operator",
"(",
"\"",
"\"",
")",
";",
"default",
":",
"gcc_unreachable",
"(",
")",
";",
"}",
"}"
] | Return the comparison operators that results if the operands are
swapped. | [
"Return",
"the",
"comparison",
"operators",
"that",
"results",
"if",
"the",
"operands",
"are",
"swapped",
"."
] | [] | [
{
"param": "p",
"type": "operator_id"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p",
"type": "operator_id",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | binary_ok | bool | static bool
binary_ok (operator_id *op)
{
switch (op->code)
{
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
case TRUNC_DIV_EXPR:
case CEIL_DIV_EXPR:
case FLOOR_DIV_EXPR:
case ROUND_DIV_EXPR:
case TRUNC_MOD_EXPR:
case CEIL_MOD_EXPR:
case FLOOR_MOD_EXPR:
case ROUND_MOD_EXPR:
case RDIV_EXPR:
case EXACT_DIV_EXPR:
case MIN_EXPR:
case MAX_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case BIT_AND_EXPR:
return true;
default:
return false;
}
} | /* Return true if the binary operator OP is ok for delayed substitution
during for lowering. */ | Return true if the binary operator OP is ok for delayed substitution
during for lowering. | [
"Return",
"true",
"if",
"the",
"binary",
"operator",
"OP",
"is",
"ok",
"for",
"delayed",
"substitution",
"during",
"for",
"lowering",
"."
] | static bool
binary_ok (operator_id *op)
{
switch (op->code)
{
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
case TRUNC_DIV_EXPR:
case CEIL_DIV_EXPR:
case FLOOR_DIV_EXPR:
case ROUND_DIV_EXPR:
case TRUNC_MOD_EXPR:
case CEIL_MOD_EXPR:
case FLOOR_MOD_EXPR:
case ROUND_MOD_EXPR:
case RDIV_EXPR:
case EXACT_DIV_EXPR:
case MIN_EXPR:
case MAX_EXPR:
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case BIT_AND_EXPR:
return true;
default:
return false;
}
} | [
"static",
"bool",
"binary_ok",
"(",
"operator_id",
"*",
"op",
")",
"{",
"switch",
"(",
"op",
"->",
"code",
")",
"{",
"case",
"PLUS_EXPR",
":",
"case",
"MINUS_EXPR",
":",
"case",
"MULT_EXPR",
":",
"case",
"TRUNC_DIV_EXPR",
":",
"case",
"CEIL_DIV_EXPR",
":",
"case",
"FLOOR_DIV_EXPR",
":",
"case",
"ROUND_DIV_EXPR",
":",
"case",
"TRUNC_MOD_EXPR",
":",
"case",
"CEIL_MOD_EXPR",
":",
"case",
"FLOOR_MOD_EXPR",
":",
"case",
"ROUND_MOD_EXPR",
":",
"case",
"RDIV_EXPR",
":",
"case",
"EXACT_DIV_EXPR",
":",
"case",
"MIN_EXPR",
":",
"case",
"MAX_EXPR",
":",
"case",
"BIT_IOR_EXPR",
":",
"case",
"BIT_XOR_EXPR",
":",
"case",
"BIT_AND_EXPR",
":",
"return",
"true",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] | Return true if the binary operator OP is ok for delayed substitution
during for lowering. | [
"Return",
"true",
"if",
"the",
"binary",
"operator",
"OP",
"is",
"ok",
"for",
"delayed",
"substitution",
"during",
"for",
"lowering",
"."
] | [] | [
{
"param": "op",
"type": "operator_id"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "op",
"type": "operator_id",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | write_header | void | static void
write_header (FILE *f, const char *head)
{
fprintf (f, "/* Generated automatically by the program `genmatch' from\n");
fprintf (f, " a IL pattern matching and simplification description. */\n");
/* Include the header instead of writing it awkwardly quoted here. */
fprintf (f, "\n#include \"%s\"\n", head);
} | /* Write the common header for the GIMPLE/GENERIC IL matching routines. */ | Write the common header for the GIMPLE/GENERIC IL matching routines. | [
"Write",
"the",
"common",
"header",
"for",
"the",
"GIMPLE",
"/",
"GENERIC",
"IL",
"matching",
"routines",
"."
] | static void
write_header (FILE *f, const char *head)
{
fprintf (f, "/* Generated automatically by the program `genmatch' from\n");
fprintf (f, " a IL pattern matching and simplification description. */\n");
fprintf (f, "\n#include \"%s\"\n", head);
} | [
"static",
"void",
"write_header",
"(",
"FILE",
"*",
"f",
",",
"const",
"char",
"*",
"head",
")",
"{",
"fprintf",
"(",
"f",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"f",
",",
"\"",
"\\n",
"\"",
")",
";",
"fprintf",
"(",
"f",
",",
"\"",
"\\n",
"\\\"",
"\\\"",
"\\n",
"\"",
",",
"head",
")",
";",
"}"
] | Write the common header for the GIMPLE/GENERIC IL matching routines. | [
"Write",
"the",
"common",
"header",
"for",
"the",
"GIMPLE",
"/",
"GENERIC",
"IL",
"matching",
"routines",
"."
] | [
"/* Include the header instead of writing it awkwardly quoted here. */"
] | [
{
"param": "f",
"type": "FILE"
},
{
"param": "head",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "head",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a75d8b3bb5338d6397fd89fb24f3de5081b1ae4e | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/genmatch.c | [
"BSD-3-Clause"
] | C | round_alloc_size | size_t | static size_t
round_alloc_size (size_t s)
{
return s;
} | /* Helper for the linemap code. */ | Helper for the linemap code. | [
"Helper",
"for",
"the",
"linemap",
"code",
"."
] | static size_t
round_alloc_size (size_t s)
{
return s;
} | [
"static",
"size_t",
"round_alloc_size",
"(",
"size_t",
"s",
")",
"{",
"return",
"s",
";",
"}"
] | Helper for the linemap code. | [
"Helper",
"for",
"the",
"linemap",
"code",
"."
] | [] | [
{
"param": "s",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a71b399a76010356d662ca65ec588fc2c34e4b28 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/libgomp/oacc-parallel.c | [
"BSD-3-Clause"
] | C | GOACC_parallel | void | void
GOACC_parallel (int device, void (*fn) (void *),
size_t mapnum, void **hostaddrs, size_t *sizes,
unsigned short *kinds,
int num_gangs, int num_workers, int vector_length,
int async, int num_waits, ...)
{
goacc_save_and_set_bind (acc_device_host);
fn (hostaddrs);
goacc_restore_bind ();
} | /* Legacy entry point, only provide host execution. */ | Legacy entry point, only provide host execution. | [
"Legacy",
"entry",
"point",
"only",
"provide",
"host",
"execution",
"."
] | void
GOACC_parallel (int device, void (*fn) (void *),
size_t mapnum, void **hostaddrs, size_t *sizes,
unsigned short *kinds,
int num_gangs, int num_workers, int vector_length,
int async, int num_waits, ...)
{
goacc_save_and_set_bind (acc_device_host);
fn (hostaddrs);
goacc_restore_bind ();
} | [
"void",
"GOACC_parallel",
"(",
"int",
"device",
",",
"void",
"(",
"*",
"fn",
")",
"(",
"void",
"*",
")",
",",
"size_t",
"mapnum",
",",
"void",
"*",
"*",
"hostaddrs",
",",
"size_t",
"*",
"sizes",
",",
"unsigned",
"short",
"*",
"kinds",
",",
"int",
"num_gangs",
",",
"int",
"num_workers",
",",
"int",
"vector_length",
",",
"int",
"async",
",",
"int",
"num_waits",
",",
"...",
")",
"{",
"goacc_save_and_set_bind",
"(",
"acc_device_host",
")",
";",
"fn",
"(",
"hostaddrs",
")",
";",
"goacc_restore_bind",
"(",
")",
";",
"}"
] | Legacy entry point, only provide host execution. | [
"Legacy",
"entry",
"point",
"only",
"provide",
"host",
"execution",
"."
] | [] | [
{
"param": "device",
"type": "int"
},
{
"param": "fn",
"type": "void"
},
{
"param": "mapnum",
"type": "size_t"
},
{
"param": "hostaddrs",
"type": "void"
},
{
"param": "sizes",
"type": "size_t"
},
{
"param": "kinds",
"type": "unsigned short"
},
{
"param": "num_gangs",
"type": "int"
},
{
"param": "num_workers",
"type": "int"
},
{
"param": "vector_length",
"type": "int"
},
{
"param": "async",
"type": "int"
},
{
"param": "num_waits",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "device",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fn",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mapnum",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hostaddrs",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sizes",
"type": "size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kinds",
"type": "unsigned short",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_gangs",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_workers",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vector_length",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "async",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_waits",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | info_hash_table_newfunc | null | static struct bfd_hash_entry *
info_hash_table_newfunc (struct bfd_hash_entry *entry,
struct bfd_hash_table *table,
const char *string)
{
struct info_hash_entry *ret = (struct info_hash_entry *) entry;
/* Allocate the structure if it has not already been allocated by a
derived class. */
if (ret == NULL)
{
ret = (struct info_hash_entry *) bfd_hash_allocate (table,
sizeof (* ret));
if (ret == NULL)
return NULL;
}
/* Call the allocation method of the base class. */
ret = ((struct info_hash_entry *)
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
/* Initialize the local fields here. */
if (ret)
ret->head = NULL;
return (struct bfd_hash_entry *) ret;
} | /* Function to create a new entry in info hash table. */ | Function to create a new entry in info hash table. | [
"Function",
"to",
"create",
"a",
"new",
"entry",
"in",
"info",
"hash",
"table",
"."
] | static struct bfd_hash_entry *
info_hash_table_newfunc (struct bfd_hash_entry *entry,
struct bfd_hash_table *table,
const char *string)
{
struct info_hash_entry *ret = (struct info_hash_entry *) entry;
if (ret == NULL)
{
ret = (struct info_hash_entry *) bfd_hash_allocate (table,
sizeof (* ret));
if (ret == NULL)
return NULL;
}
ret = ((struct info_hash_entry *)
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
if (ret)
ret->head = NULL;
return (struct bfd_hash_entry *) ret;
} | [
"static",
"struct",
"bfd_hash_entry",
"*",
"info_hash_table_newfunc",
"(",
"struct",
"bfd_hash_entry",
"*",
"entry",
",",
"struct",
"bfd_hash_table",
"*",
"table",
",",
"const",
"char",
"*",
"string",
")",
"{",
"struct",
"info_hash_entry",
"*",
"ret",
"=",
"(",
"struct",
"info_hash_entry",
"*",
")",
"entry",
";",
"if",
"(",
"ret",
"==",
"NULL",
")",
"{",
"ret",
"=",
"(",
"struct",
"info_hash_entry",
"*",
")",
"bfd_hash_allocate",
"(",
"table",
",",
"sizeof",
"(",
"*",
"ret",
")",
")",
";",
"if",
"(",
"ret",
"==",
"NULL",
")",
"return",
"NULL",
";",
"}",
"ret",
"=",
"(",
"(",
"struct",
"info_hash_entry",
"*",
")",
"bfd_hash_newfunc",
"(",
"(",
"struct",
"bfd_hash_entry",
"*",
")",
"ret",
",",
"table",
",",
"string",
")",
")",
";",
"if",
"(",
"ret",
")",
"ret",
"->",
"head",
"=",
"NULL",
";",
"return",
"(",
"struct",
"bfd_hash_entry",
"*",
")",
"ret",
";",
"}"
] | Function to create a new entry in info hash table. | [
"Function",
"to",
"create",
"a",
"new",
"entry",
"in",
"info",
"hash",
"table",
"."
] | [
"/* Allocate the structure if it has not already been allocated by a\n derived class. */",
"/* Call the allocation method of the base class. */",
"/* Initialize the local fields here. */"
] | [
{
"param": "entry",
"type": "struct bfd_hash_entry"
},
{
"param": "table",
"type": "struct bfd_hash_table"
},
{
"param": "string",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "struct bfd_hash_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": "struct bfd_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | create_info_hash_table | null | static struct info_hash_table *
create_info_hash_table (bfd *abfd)
{
struct info_hash_table *hash_table;
hash_table = ((struct info_hash_table *)
bfd_alloc (abfd, sizeof (struct info_hash_table)));
if (!hash_table)
return hash_table;
if (!bfd_hash_table_init (&hash_table->base, info_hash_table_newfunc,
sizeof (struct info_hash_entry)))
{
bfd_release (abfd, hash_table);
return NULL;
}
return hash_table;
} | /* Function to create a new info hash table. It returns a pointer to the
newly created table or NULL if there is any error. We need abfd
solely for memory allocation. */ | Function to create a new info hash table. It returns a pointer to the
newly created table or NULL if there is any error. We need abfd
solely for memory allocation. | [
"Function",
"to",
"create",
"a",
"new",
"info",
"hash",
"table",
".",
"It",
"returns",
"a",
"pointer",
"to",
"the",
"newly",
"created",
"table",
"or",
"NULL",
"if",
"there",
"is",
"any",
"error",
".",
"We",
"need",
"abfd",
"solely",
"for",
"memory",
"allocation",
"."
] | static struct info_hash_table *
create_info_hash_table (bfd *abfd)
{
struct info_hash_table *hash_table;
hash_table = ((struct info_hash_table *)
bfd_alloc (abfd, sizeof (struct info_hash_table)));
if (!hash_table)
return hash_table;
if (!bfd_hash_table_init (&hash_table->base, info_hash_table_newfunc,
sizeof (struct info_hash_entry)))
{
bfd_release (abfd, hash_table);
return NULL;
}
return hash_table;
} | [
"static",
"struct",
"info_hash_table",
"*",
"create_info_hash_table",
"(",
"bfd",
"*",
"abfd",
")",
"{",
"struct",
"info_hash_table",
"*",
"hash_table",
";",
"hash_table",
"=",
"(",
"(",
"struct",
"info_hash_table",
"*",
")",
"bfd_alloc",
"(",
"abfd",
",",
"sizeof",
"(",
"struct",
"info_hash_table",
")",
")",
")",
";",
"if",
"(",
"!",
"hash_table",
")",
"return",
"hash_table",
";",
"if",
"(",
"!",
"bfd_hash_table_init",
"(",
"&",
"hash_table",
"->",
"base",
",",
"info_hash_table_newfunc",
",",
"sizeof",
"(",
"struct",
"info_hash_entry",
")",
")",
")",
"{",
"bfd_release",
"(",
"abfd",
",",
"hash_table",
")",
";",
"return",
"NULL",
";",
"}",
"return",
"hash_table",
";",
"}"
] | Function to create a new info hash table. | [
"Function",
"to",
"create",
"a",
"new",
"info",
"hash",
"table",
"."
] | [] | [
{
"param": "abfd",
"type": "bfd"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | insert_info_hash_table | bfd_boolean | static bfd_boolean
insert_info_hash_table (struct info_hash_table *hash_table,
const char *key,
void *info,
bfd_boolean copy_p)
{
struct info_hash_entry *entry;
struct info_list_node *node;
entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base,
key, TRUE, copy_p);
if (!entry)
return FALSE;
node = (struct info_list_node *) bfd_hash_allocate (&hash_table->base,
sizeof (*node));
if (!node)
return FALSE;
node->info = info;
node->next = entry->head;
entry->head = node;
return TRUE;
} | /* Insert an info entry into an info hash table. We do not check of
duplicate entries. Also, the caller need to guarantee that the
right type of info in inserted as info is passed as a void* pointer.
This function returns true if there is no error. */ | Insert an info entry into an info hash table. We do not check of
duplicate entries. Also, the caller need to guarantee that the
right type of info in inserted as info is passed as a void* pointer.
This function returns true if there is no error. | [
"Insert",
"an",
"info",
"entry",
"into",
"an",
"info",
"hash",
"table",
".",
"We",
"do",
"not",
"check",
"of",
"duplicate",
"entries",
".",
"Also",
"the",
"caller",
"need",
"to",
"guarantee",
"that",
"the",
"right",
"type",
"of",
"info",
"in",
"inserted",
"as",
"info",
"is",
"passed",
"as",
"a",
"void",
"*",
"pointer",
".",
"This",
"function",
"returns",
"true",
"if",
"there",
"is",
"no",
"error",
"."
] | static bfd_boolean
insert_info_hash_table (struct info_hash_table *hash_table,
const char *key,
void *info,
bfd_boolean copy_p)
{
struct info_hash_entry *entry;
struct info_list_node *node;
entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base,
key, TRUE, copy_p);
if (!entry)
return FALSE;
node = (struct info_list_node *) bfd_hash_allocate (&hash_table->base,
sizeof (*node));
if (!node)
return FALSE;
node->info = info;
node->next = entry->head;
entry->head = node;
return TRUE;
} | [
"static",
"bfd_boolean",
"insert_info_hash_table",
"(",
"struct",
"info_hash_table",
"*",
"hash_table",
",",
"const",
"char",
"*",
"key",
",",
"void",
"*",
"info",
",",
"bfd_boolean",
"copy_p",
")",
"{",
"struct",
"info_hash_entry",
"*",
"entry",
";",
"struct",
"info_list_node",
"*",
"node",
";",
"entry",
"=",
"(",
"struct",
"info_hash_entry",
"*",
")",
"bfd_hash_lookup",
"(",
"&",
"hash_table",
"->",
"base",
",",
"key",
",",
"TRUE",
",",
"copy_p",
")",
";",
"if",
"(",
"!",
"entry",
")",
"return",
"FALSE",
";",
"node",
"=",
"(",
"struct",
"info_list_node",
"*",
")",
"bfd_hash_allocate",
"(",
"&",
"hash_table",
"->",
"base",
",",
"sizeof",
"(",
"*",
"node",
")",
")",
";",
"if",
"(",
"!",
"node",
")",
"return",
"FALSE",
";",
"node",
"->",
"info",
"=",
"info",
";",
"node",
"->",
"next",
"=",
"entry",
"->",
"head",
";",
"entry",
"->",
"head",
"=",
"node",
";",
"return",
"TRUE",
";",
"}"
] | Insert an info entry into an info hash table. | [
"Insert",
"an",
"info",
"entry",
"into",
"an",
"info",
"hash",
"table",
"."
] | [] | [
{
"param": "hash_table",
"type": "struct info_hash_table"
},
{
"param": "key",
"type": "char"
},
{
"param": "info",
"type": "void"
},
{
"param": "copy_p",
"type": "bfd_boolean"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "copy_p",
"type": "bfd_boolean",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_info_hash_table | null | static struct info_list_node *
lookup_info_hash_table (struct info_hash_table *hash_table, const char *key)
{
struct info_hash_entry *entry;
entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base, key,
FALSE, FALSE);
return entry ? entry->head : NULL;
} | /* Look up an info entry list from an info hash table. Return NULL
if there is none. */ | Look up an info entry list from an info hash table. Return NULL
if there is none. | [
"Look",
"up",
"an",
"info",
"entry",
"list",
"from",
"an",
"info",
"hash",
"table",
".",
"Return",
"NULL",
"if",
"there",
"is",
"none",
"."
] | static struct info_list_node *
lookup_info_hash_table (struct info_hash_table *hash_table, const char *key)
{
struct info_hash_entry *entry;
entry = (struct info_hash_entry*) bfd_hash_lookup (&hash_table->base, key,
FALSE, FALSE);
return entry ? entry->head : NULL;
} | [
"static",
"struct",
"info_list_node",
"*",
"lookup_info_hash_table",
"(",
"struct",
"info_hash_table",
"*",
"hash_table",
",",
"const",
"char",
"*",
"key",
")",
"{",
"struct",
"info_hash_entry",
"*",
"entry",
";",
"entry",
"=",
"(",
"struct",
"info_hash_entry",
"*",
")",
"bfd_hash_lookup",
"(",
"&",
"hash_table",
"->",
"base",
",",
"key",
",",
"FALSE",
",",
"FALSE",
")",
";",
"return",
"entry",
"?",
"entry",
"->",
"head",
":",
"NULL",
";",
"}"
] | Look up an info entry list from an info hash table. | [
"Look",
"up",
"an",
"info",
"entry",
"list",
"from",
"an",
"info",
"hash",
"table",
"."
] | [] | [
{
"param": "hash_table",
"type": "struct info_hash_table"
},
{
"param": "key",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_section | bfd_boolean | static bfd_boolean
read_section (bfd * abfd,
const struct dwarf_debug_section *sec,
asymbol ** syms,
bfd_uint64_t offset,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
asection *msec;
const char *section_name = sec->uncompressed_name;
/* The section may have already been read. */
if (*section_buffer == NULL)
{
msec = bfd_get_section_by_name (abfd, section_name);
if (! msec)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
if (! msec)
{
(*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."),
sec->uncompressed_name);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
*section_size = msec->rawsize ? msec->rawsize : msec->size;
if (syms)
{
*section_buffer
= bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
if (! *section_buffer)
return FALSE;
}
else
{
*section_buffer = (bfd_byte *) bfd_malloc (*section_size);
if (! *section_buffer)
return FALSE;
if (! bfd_get_section_contents (abfd, msec, *section_buffer,
0, *section_size))
return FALSE;
}
}
/* It is possible to get a bad value for the offset into the section
that the client wants. Validate it here to avoid trouble later. */
if (offset != 0 && offset >= *section_size)
{
(*_bfd_error_handler) (_("Dwarf Error: Offset (%lu)"
" greater than or equal to %s size (%lu)."),
(long) offset, section_name, *section_size);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
return TRUE;
} | /* Read a section into its appropriate place in the dwarf2_debug
struct (indicated by SECTION_BUFFER and SECTION_SIZE). If SYMS is
not NULL, use bfd_simple_get_relocated_section_contents to read the
section contents, otherwise use bfd_get_section_contents. Fail if
the located section does not contain at least OFFSET bytes. */ | Read a section into its appropriate place in the dwarf2_debug
struct (indicated by SECTION_BUFFER and SECTION_SIZE). If SYMS is
not NULL, use bfd_simple_get_relocated_section_contents to read the
section contents, otherwise use bfd_get_section_contents. Fail if
the located section does not contain at least OFFSET bytes. | [
"Read",
"a",
"section",
"into",
"its",
"appropriate",
"place",
"in",
"the",
"dwarf2_debug",
"struct",
"(",
"indicated",
"by",
"SECTION_BUFFER",
"and",
"SECTION_SIZE",
")",
".",
"If",
"SYMS",
"is",
"not",
"NULL",
"use",
"bfd_simple_get_relocated_section_contents",
"to",
"read",
"the",
"section",
"contents",
"otherwise",
"use",
"bfd_get_section_contents",
".",
"Fail",
"if",
"the",
"located",
"section",
"does",
"not",
"contain",
"at",
"least",
"OFFSET",
"bytes",
"."
] | static bfd_boolean
read_section (bfd * abfd,
const struct dwarf_debug_section *sec,
asymbol ** syms,
bfd_uint64_t offset,
bfd_byte ** section_buffer,
bfd_size_type * section_size)
{
asection *msec;
const char *section_name = sec->uncompressed_name;
if (*section_buffer == NULL)
{
msec = bfd_get_section_by_name (abfd, section_name);
if (! msec)
{
section_name = sec->compressed_name;
if (section_name != NULL)
msec = bfd_get_section_by_name (abfd, section_name);
}
if (! msec)
{
(*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."),
sec->uncompressed_name);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
*section_size = msec->rawsize ? msec->rawsize : msec->size;
if (syms)
{
*section_buffer
= bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
if (! *section_buffer)
return FALSE;
}
else
{
*section_buffer = (bfd_byte *) bfd_malloc (*section_size);
if (! *section_buffer)
return FALSE;
if (! bfd_get_section_contents (abfd, msec, *section_buffer,
0, *section_size))
return FALSE;
}
}
if (offset != 0 && offset >= *section_size)
{
(*_bfd_error_handler) (_("Dwarf Error: Offset (%lu)"
" greater than or equal to %s size (%lu)."),
(long) offset, section_name, *section_size);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
return TRUE;
} | [
"static",
"bfd_boolean",
"read_section",
"(",
"bfd",
"*",
"abfd",
",",
"const",
"struct",
"dwarf_debug_section",
"*",
"sec",
",",
"asymbol",
"*",
"*",
"syms",
",",
"bfd_uint64_t",
"offset",
",",
"bfd_byte",
"*",
"*",
"section_buffer",
",",
"bfd_size_type",
"*",
"section_size",
")",
"{",
"asection",
"*",
"msec",
";",
"const",
"char",
"*",
"section_name",
"=",
"sec",
"->",
"uncompressed_name",
";",
"if",
"(",
"*",
"section_buffer",
"==",
"NULL",
")",
"{",
"msec",
"=",
"bfd_get_section_by_name",
"(",
"abfd",
",",
"section_name",
")",
";",
"if",
"(",
"!",
"msec",
")",
"{",
"section_name",
"=",
"sec",
"->",
"compressed_name",
";",
"if",
"(",
"section_name",
"!=",
"NULL",
")",
"msec",
"=",
"bfd_get_section_by_name",
"(",
"abfd",
",",
"section_name",
")",
";",
"}",
"if",
"(",
"!",
"msec",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
")",
",",
"sec",
"->",
"uncompressed_name",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"return",
"FALSE",
";",
"}",
"*",
"section_size",
"=",
"msec",
"->",
"rawsize",
"?",
"msec",
"->",
"rawsize",
":",
"msec",
"->",
"size",
";",
"if",
"(",
"syms",
")",
"{",
"*",
"section_buffer",
"=",
"bfd_simple_get_relocated_section_contents",
"(",
"abfd",
",",
"msec",
",",
"NULL",
",",
"syms",
")",
";",
"if",
"(",
"!",
"*",
"section_buffer",
")",
"return",
"FALSE",
";",
"}",
"else",
"{",
"*",
"section_buffer",
"=",
"(",
"bfd_byte",
"*",
")",
"bfd_malloc",
"(",
"*",
"section_size",
")",
";",
"if",
"(",
"!",
"*",
"section_buffer",
")",
"return",
"FALSE",
";",
"if",
"(",
"!",
"bfd_get_section_contents",
"(",
"abfd",
",",
"msec",
",",
"*",
"section_buffer",
",",
"0",
",",
"*",
"section_size",
")",
")",
"return",
"FALSE",
";",
"}",
"}",
"if",
"(",
"offset",
"!=",
"0",
"&&",
"offset",
">=",
"*",
"section_size",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"(",
"long",
")",
"offset",
",",
"section_name",
",",
"*",
"section_size",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Read a section into its appropriate place in the dwarf2_debug
struct (indicated by SECTION_BUFFER and SECTION_SIZE). | [
"Read",
"a",
"section",
"into",
"its",
"appropriate",
"place",
"in",
"the",
"dwarf2_debug",
"struct",
"(",
"indicated",
"by",
"SECTION_BUFFER",
"and",
"SECTION_SIZE",
")",
"."
] | [
"/* The section may have already been read. */",
"/* It is possible to get a bad value for the offset into the section\n that the client wants. Validate it here to avoid trouble later. */"
] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "sec",
"type": "struct dwarf_debug_section"
},
{
"param": "syms",
"type": "asymbol"
},
{
"param": "offset",
"type": "bfd_uint64_t"
},
{
"param": "section_buffer",
"type": "bfd_byte"
},
{
"param": "section_size",
"type": "bfd_size_type"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sec",
"type": "struct dwarf_debug_section",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "syms",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "bfd_uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "section_buffer",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "section_size",
"type": "bfd_size_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_indirect_string | char | static char *
read_indirect_string (struct comp_unit * unit,
bfd_byte * buf,
bfd_byte * buf_end,
unsigned int * bytes_read_ptr)
{
bfd_uint64_t offset;
struct dwarf2_debug *stash = unit->stash;
char *str;
if (buf + unit->offset_size > buf_end)
{
* bytes_read_ptr = 0;
return NULL;
}
if (unit->offset_size == 4)
offset = read_4_bytes (unit->abfd, buf, buf_end);
else
offset = read_8_bytes (unit->abfd, buf, buf_end);
*bytes_read_ptr = unit->offset_size;
if (! read_section (unit->abfd, &stash->debug_sections[debug_str],
stash->syms, offset,
&stash->dwarf_str_buffer, &stash->dwarf_str_size))
return NULL;
if (offset >= stash->dwarf_str_size)
return NULL;
str = (char *) stash->dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
return str;
} | /* Reads an offset from BUF and then locates the string at this offset
inside the debug string section. Returns a pointer to the string.
Returns the number of bytes read from BUF, *not* the length of the string,
in BYTES_READ_PTR. This value is set even if the function fails. Bytes
at or beyond BUF_END will not be read from BUF. Returns NULL if there was
a problem, or if the string is empty. Does not check for NUL termination
of the string. */ | Reads an offset from BUF and then locates the string at this offset
inside the debug string section. Returns a pointer to the string.
Returns the number of bytes read from BUF, *not* the length of the string,
in BYTES_READ_PTR. This value is set even if the function fails. Bytes
at or beyond BUF_END will not be read from BUF. Returns NULL if there was
a problem, or if the string is empty. Does not check for NUL termination
of the string. | [
"Reads",
"an",
"offset",
"from",
"BUF",
"and",
"then",
"locates",
"the",
"string",
"at",
"this",
"offset",
"inside",
"the",
"debug",
"string",
"section",
".",
"Returns",
"a",
"pointer",
"to",
"the",
"string",
".",
"Returns",
"the",
"number",
"of",
"bytes",
"read",
"from",
"BUF",
"*",
"not",
"*",
"the",
"length",
"of",
"the",
"string",
"in",
"BYTES_READ_PTR",
".",
"This",
"value",
"is",
"set",
"even",
"if",
"the",
"function",
"fails",
".",
"Bytes",
"at",
"or",
"beyond",
"BUF_END",
"will",
"not",
"be",
"read",
"from",
"BUF",
".",
"Returns",
"NULL",
"if",
"there",
"was",
"a",
"problem",
"or",
"if",
"the",
"string",
"is",
"empty",
".",
"Does",
"not",
"check",
"for",
"NUL",
"termination",
"of",
"the",
"string",
"."
] | static char *
read_indirect_string (struct comp_unit * unit,
bfd_byte * buf,
bfd_byte * buf_end,
unsigned int * bytes_read_ptr)
{
bfd_uint64_t offset;
struct dwarf2_debug *stash = unit->stash;
char *str;
if (buf + unit->offset_size > buf_end)
{
* bytes_read_ptr = 0;
return NULL;
}
if (unit->offset_size == 4)
offset = read_4_bytes (unit->abfd, buf, buf_end);
else
offset = read_8_bytes (unit->abfd, buf, buf_end);
*bytes_read_ptr = unit->offset_size;
if (! read_section (unit->abfd, &stash->debug_sections[debug_str],
stash->syms, offset,
&stash->dwarf_str_buffer, &stash->dwarf_str_size))
return NULL;
if (offset >= stash->dwarf_str_size)
return NULL;
str = (char *) stash->dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
return str;
} | [
"static",
"char",
"*",
"read_indirect_string",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_byte",
"*",
"buf",
",",
"bfd_byte",
"*",
"buf_end",
",",
"unsigned",
"int",
"*",
"bytes_read_ptr",
")",
"{",
"bfd_uint64_t",
"offset",
";",
"struct",
"dwarf2_debug",
"*",
"stash",
"=",
"unit",
"->",
"stash",
";",
"char",
"*",
"str",
";",
"if",
"(",
"buf",
"+",
"unit",
"->",
"offset_size",
">",
"buf_end",
")",
"{",
"*",
"bytes_read_ptr",
"=",
"0",
";",
"return",
"NULL",
";",
"}",
"if",
"(",
"unit",
"->",
"offset_size",
"==",
"4",
")",
"offset",
"=",
"read_4_bytes",
"(",
"unit",
"->",
"abfd",
",",
"buf",
",",
"buf_end",
")",
";",
"else",
"offset",
"=",
"read_8_bytes",
"(",
"unit",
"->",
"abfd",
",",
"buf",
",",
"buf_end",
")",
";",
"*",
"bytes_read_ptr",
"=",
"unit",
"->",
"offset_size",
";",
"if",
"(",
"!",
"read_section",
"(",
"unit",
"->",
"abfd",
",",
"&",
"stash",
"->",
"debug_sections",
"[",
"debug_str",
"]",
",",
"stash",
"->",
"syms",
",",
"offset",
",",
"&",
"stash",
"->",
"dwarf_str_buffer",
",",
"&",
"stash",
"->",
"dwarf_str_size",
")",
")",
"return",
"NULL",
";",
"if",
"(",
"offset",
">=",
"stash",
"->",
"dwarf_str_size",
")",
"return",
"NULL",
";",
"str",
"=",
"(",
"char",
"*",
")",
"stash",
"->",
"dwarf_str_buffer",
"+",
"offset",
";",
"if",
"(",
"*",
"str",
"==",
"'",
"\\0",
"'",
")",
"return",
"NULL",
";",
"return",
"str",
";",
"}"
] | Reads an offset from BUF and then locates the string at this offset
inside the debug string section. | [
"Reads",
"an",
"offset",
"from",
"BUF",
"and",
"then",
"locates",
"the",
"string",
"at",
"this",
"offset",
"inside",
"the",
"debug",
"string",
"section",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "buf",
"type": "bfd_byte"
},
{
"param": "buf_end",
"type": "bfd_byte"
},
{
"param": "bytes_read_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf_end",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytes_read_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_alt_indirect_string | char | static char *
read_alt_indirect_string (struct comp_unit * unit,
bfd_byte * buf,
bfd_byte * buf_end,
unsigned int * bytes_read_ptr)
{
bfd_uint64_t offset;
struct dwarf2_debug *stash = unit->stash;
char *str;
if (buf + unit->offset_size > buf_end)
{
* bytes_read_ptr = 0;
return NULL;
}
if (unit->offset_size == 4)
offset = read_4_bytes (unit->abfd, buf, buf_end);
else
offset = read_8_bytes (unit->abfd, buf, buf_end);
*bytes_read_ptr = unit->offset_size;
if (stash->alt_bfd_ptr == NULL)
{
bfd * debug_bfd;
char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
if (debug_filename == NULL)
return NULL;
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| ! bfd_check_format (debug_bfd, bfd_object))
{
if (debug_bfd)
bfd_close (debug_bfd);
/* FIXME: Should we report our failure to follow the debuglink ? */
free (debug_filename);
return NULL;
}
stash->alt_bfd_ptr = debug_bfd;
}
if (! read_section (unit->stash->alt_bfd_ptr,
stash->debug_sections + debug_str_alt,
NULL, /* FIXME: Do we need to load alternate symbols ? */
offset,
&stash->alt_dwarf_str_buffer,
&stash->alt_dwarf_str_size))
return NULL;
if (offset >= stash->alt_dwarf_str_size)
return NULL;
str = (char *) stash->alt_dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
return str;
} | /* Like read_indirect_string but uses a .debug_str located in
an alternate file pointed to by the .gnu_debugaltlink section.
Used to impement DW_FORM_GNU_strp_alt. */ | Like read_indirect_string but uses a .debug_str located in
an alternate file pointed to by the .gnu_debugaltlink section.
Used to impement DW_FORM_GNU_strp_alt. | [
"Like",
"read_indirect_string",
"but",
"uses",
"a",
".",
"debug_str",
"located",
"in",
"an",
"alternate",
"file",
"pointed",
"to",
"by",
"the",
".",
"gnu_debugaltlink",
"section",
".",
"Used",
"to",
"impement",
"DW_FORM_GNU_strp_alt",
"."
] | static char *
read_alt_indirect_string (struct comp_unit * unit,
bfd_byte * buf,
bfd_byte * buf_end,
unsigned int * bytes_read_ptr)
{
bfd_uint64_t offset;
struct dwarf2_debug *stash = unit->stash;
char *str;
if (buf + unit->offset_size > buf_end)
{
* bytes_read_ptr = 0;
return NULL;
}
if (unit->offset_size == 4)
offset = read_4_bytes (unit->abfd, buf, buf_end);
else
offset = read_8_bytes (unit->abfd, buf, buf_end);
*bytes_read_ptr = unit->offset_size;
if (stash->alt_bfd_ptr == NULL)
{
bfd * debug_bfd;
char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
if (debug_filename == NULL)
return NULL;
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| ! bfd_check_format (debug_bfd, bfd_object))
{
if (debug_bfd)
bfd_close (debug_bfd);
free (debug_filename);
return NULL;
}
stash->alt_bfd_ptr = debug_bfd;
}
if (! read_section (unit->stash->alt_bfd_ptr,
stash->debug_sections + debug_str_alt,
NULL,
offset,
&stash->alt_dwarf_str_buffer,
&stash->alt_dwarf_str_size))
return NULL;
if (offset >= stash->alt_dwarf_str_size)
return NULL;
str = (char *) stash->alt_dwarf_str_buffer + offset;
if (*str == '\0')
return NULL;
return str;
} | [
"static",
"char",
"*",
"read_alt_indirect_string",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_byte",
"*",
"buf",
",",
"bfd_byte",
"*",
"buf_end",
",",
"unsigned",
"int",
"*",
"bytes_read_ptr",
")",
"{",
"bfd_uint64_t",
"offset",
";",
"struct",
"dwarf2_debug",
"*",
"stash",
"=",
"unit",
"->",
"stash",
";",
"char",
"*",
"str",
";",
"if",
"(",
"buf",
"+",
"unit",
"->",
"offset_size",
">",
"buf_end",
")",
"{",
"*",
"bytes_read_ptr",
"=",
"0",
";",
"return",
"NULL",
";",
"}",
"if",
"(",
"unit",
"->",
"offset_size",
"==",
"4",
")",
"offset",
"=",
"read_4_bytes",
"(",
"unit",
"->",
"abfd",
",",
"buf",
",",
"buf_end",
")",
";",
"else",
"offset",
"=",
"read_8_bytes",
"(",
"unit",
"->",
"abfd",
",",
"buf",
",",
"buf_end",
")",
";",
"*",
"bytes_read_ptr",
"=",
"unit",
"->",
"offset_size",
";",
"if",
"(",
"stash",
"->",
"alt_bfd_ptr",
"==",
"NULL",
")",
"{",
"bfd",
"*",
"debug_bfd",
";",
"char",
"*",
"debug_filename",
"=",
"bfd_follow_gnu_debugaltlink",
"(",
"unit",
"->",
"abfd",
",",
"DEBUGDIR",
")",
";",
"if",
"(",
"debug_filename",
"==",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"(",
"debug_bfd",
"=",
"bfd_openr",
"(",
"debug_filename",
",",
"NULL",
")",
")",
"==",
"NULL",
"||",
"!",
"bfd_check_format",
"(",
"debug_bfd",
",",
"bfd_object",
")",
")",
"{",
"if",
"(",
"debug_bfd",
")",
"bfd_close",
"(",
"debug_bfd",
")",
";",
"free",
"(",
"debug_filename",
")",
";",
"return",
"NULL",
";",
"}",
"stash",
"->",
"alt_bfd_ptr",
"=",
"debug_bfd",
";",
"}",
"if",
"(",
"!",
"read_section",
"(",
"unit",
"->",
"stash",
"->",
"alt_bfd_ptr",
",",
"stash",
"->",
"debug_sections",
"+",
"debug_str_alt",
",",
"NULL",
",",
"offset",
",",
"&",
"stash",
"->",
"alt_dwarf_str_buffer",
",",
"&",
"stash",
"->",
"alt_dwarf_str_size",
")",
")",
"return",
"NULL",
";",
"if",
"(",
"offset",
">=",
"stash",
"->",
"alt_dwarf_str_size",
")",
"return",
"NULL",
";",
"str",
"=",
"(",
"char",
"*",
")",
"stash",
"->",
"alt_dwarf_str_buffer",
"+",
"offset",
";",
"if",
"(",
"*",
"str",
"==",
"'",
"\\0",
"'",
")",
"return",
"NULL",
";",
"return",
"str",
";",
"}"
] | Like read_indirect_string but uses a .debug_str located in
an alternate file pointed to by the .gnu_debugaltlink section. | [
"Like",
"read_indirect_string",
"but",
"uses",
"a",
".",
"debug_str",
"located",
"in",
"an",
"alternate",
"file",
"pointed",
"to",
"by",
"the",
".",
"gnu_debugaltlink",
"section",
"."
] | [
"/* FIXME: Should we report our failure to follow the debuglink ? */",
"/* FIXME: Do we need to load alternate symbols ? */"
] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "buf",
"type": "bfd_byte"
},
{
"param": "buf_end",
"type": "bfd_byte"
},
{
"param": "bytes_read_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf_end",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bytes_read_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_alt_indirect_ref | bfd_byte | static bfd_byte *
read_alt_indirect_ref (struct comp_unit * unit,
bfd_uint64_t offset)
{
struct dwarf2_debug *stash = unit->stash;
if (stash->alt_bfd_ptr == NULL)
{
bfd * debug_bfd;
char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
if (debug_filename == NULL)
return FALSE;
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| ! bfd_check_format (debug_bfd, bfd_object))
{
if (debug_bfd)
bfd_close (debug_bfd);
/* FIXME: Should we report our failure to follow the debuglink ? */
free (debug_filename);
return NULL;
}
stash->alt_bfd_ptr = debug_bfd;
}
if (! read_section (unit->stash->alt_bfd_ptr,
stash->debug_sections + debug_info_alt,
NULL, /* FIXME: Do we need to load alternate symbols ? */
offset,
&stash->alt_dwarf_info_buffer,
&stash->alt_dwarf_info_size))
return NULL;
if (offset >= stash->alt_dwarf_info_size)
return NULL;
return stash->alt_dwarf_info_buffer + offset;
} | /* Resolve an alternate reference from UNIT at OFFSET.
Returns a pointer into the loaded alternate CU upon success
or NULL upon failure. */ | Resolve an alternate reference from UNIT at OFFSET.
Returns a pointer into the loaded alternate CU upon success
or NULL upon failure. | [
"Resolve",
"an",
"alternate",
"reference",
"from",
"UNIT",
"at",
"OFFSET",
".",
"Returns",
"a",
"pointer",
"into",
"the",
"loaded",
"alternate",
"CU",
"upon",
"success",
"or",
"NULL",
"upon",
"failure",
"."
] | static bfd_byte *
read_alt_indirect_ref (struct comp_unit * unit,
bfd_uint64_t offset)
{
struct dwarf2_debug *stash = unit->stash;
if (stash->alt_bfd_ptr == NULL)
{
bfd * debug_bfd;
char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
if (debug_filename == NULL)
return FALSE;
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| ! bfd_check_format (debug_bfd, bfd_object))
{
if (debug_bfd)
bfd_close (debug_bfd);
free (debug_filename);
return NULL;
}
stash->alt_bfd_ptr = debug_bfd;
}
if (! read_section (unit->stash->alt_bfd_ptr,
stash->debug_sections + debug_info_alt,
NULL,
offset,
&stash->alt_dwarf_info_buffer,
&stash->alt_dwarf_info_size))
return NULL;
if (offset >= stash->alt_dwarf_info_size)
return NULL;
return stash->alt_dwarf_info_buffer + offset;
} | [
"static",
"bfd_byte",
"*",
"read_alt_indirect_ref",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_uint64_t",
"offset",
")",
"{",
"struct",
"dwarf2_debug",
"*",
"stash",
"=",
"unit",
"->",
"stash",
";",
"if",
"(",
"stash",
"->",
"alt_bfd_ptr",
"==",
"NULL",
")",
"{",
"bfd",
"*",
"debug_bfd",
";",
"char",
"*",
"debug_filename",
"=",
"bfd_follow_gnu_debugaltlink",
"(",
"unit",
"->",
"abfd",
",",
"DEBUGDIR",
")",
";",
"if",
"(",
"debug_filename",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"if",
"(",
"(",
"debug_bfd",
"=",
"bfd_openr",
"(",
"debug_filename",
",",
"NULL",
")",
")",
"==",
"NULL",
"||",
"!",
"bfd_check_format",
"(",
"debug_bfd",
",",
"bfd_object",
")",
")",
"{",
"if",
"(",
"debug_bfd",
")",
"bfd_close",
"(",
"debug_bfd",
")",
";",
"free",
"(",
"debug_filename",
")",
";",
"return",
"NULL",
";",
"}",
"stash",
"->",
"alt_bfd_ptr",
"=",
"debug_bfd",
";",
"}",
"if",
"(",
"!",
"read_section",
"(",
"unit",
"->",
"stash",
"->",
"alt_bfd_ptr",
",",
"stash",
"->",
"debug_sections",
"+",
"debug_info_alt",
",",
"NULL",
",",
"offset",
",",
"&",
"stash",
"->",
"alt_dwarf_info_buffer",
",",
"&",
"stash",
"->",
"alt_dwarf_info_size",
")",
")",
"return",
"NULL",
";",
"if",
"(",
"offset",
">=",
"stash",
"->",
"alt_dwarf_info_size",
")",
"return",
"NULL",
";",
"return",
"stash",
"->",
"alt_dwarf_info_buffer",
"+",
"offset",
";",
"}"
] | Resolve an alternate reference from UNIT at OFFSET. | [
"Resolve",
"an",
"alternate",
"reference",
"from",
"UNIT",
"at",
"OFFSET",
"."
] | [
"/* FIXME: Should we report our failure to follow the debuglink ? */",
"/* FIXME: Do we need to load alternate symbols ? */"
] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "offset",
"type": "bfd_uint64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "bfd_uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_abbrev | null | static struct abbrev_info *
lookup_abbrev (unsigned int number, struct abbrev_info **abbrevs)
{
unsigned int hash_number;
struct abbrev_info *abbrev;
hash_number = number % ABBREV_HASH_SIZE;
abbrev = abbrevs[hash_number];
while (abbrev)
{
if (abbrev->number == number)
return abbrev;
else
abbrev = abbrev->next;
}
return NULL;
} | /* Lookup an abbrev_info structure in the abbrev hash table. */ | Lookup an abbrev_info structure in the abbrev hash table. | [
"Lookup",
"an",
"abbrev_info",
"structure",
"in",
"the",
"abbrev",
"hash",
"table",
"."
] | static struct abbrev_info *
lookup_abbrev (unsigned int number, struct abbrev_info **abbrevs)
{
unsigned int hash_number;
struct abbrev_info *abbrev;
hash_number = number % ABBREV_HASH_SIZE;
abbrev = abbrevs[hash_number];
while (abbrev)
{
if (abbrev->number == number)
return abbrev;
else
abbrev = abbrev->next;
}
return NULL;
} | [
"static",
"struct",
"abbrev_info",
"*",
"lookup_abbrev",
"(",
"unsigned",
"int",
"number",
",",
"struct",
"abbrev_info",
"*",
"*",
"abbrevs",
")",
"{",
"unsigned",
"int",
"hash_number",
";",
"struct",
"abbrev_info",
"*",
"abbrev",
";",
"hash_number",
"=",
"number",
"%",
"ABBREV_HASH_SIZE",
";",
"abbrev",
"=",
"abbrevs",
"[",
"hash_number",
"]",
";",
"while",
"(",
"abbrev",
")",
"{",
"if",
"(",
"abbrev",
"->",
"number",
"==",
"number",
")",
"return",
"abbrev",
";",
"else",
"abbrev",
"=",
"abbrev",
"->",
"next",
";",
"}",
"return",
"NULL",
";",
"}"
] | Lookup an abbrev_info structure in the abbrev hash table. | [
"Lookup",
"an",
"abbrev_info",
"structure",
"in",
"the",
"abbrev",
"hash",
"table",
"."
] | [] | [
{
"param": "number",
"type": "unsigned int"
},
{
"param": "abbrevs",
"type": "struct abbrev_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "number",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "abbrevs",
"type": "struct abbrev_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | is_str_attr | bfd_boolean | static inline bfd_boolean
is_str_attr (enum dwarf_form form)
{
return form == DW_FORM_string || form == DW_FORM_strp || form == DW_FORM_GNU_strp_alt;
} | /* Returns true if the form is one which has a string value. */ | Returns true if the form is one which has a string value. | [
"Returns",
"true",
"if",
"the",
"form",
"is",
"one",
"which",
"has",
"a",
"string",
"value",
"."
] | static inline bfd_boolean
is_str_attr (enum dwarf_form form)
{
return form == DW_FORM_string || form == DW_FORM_strp || form == DW_FORM_GNU_strp_alt;
} | [
"static",
"inline",
"bfd_boolean",
"is_str_attr",
"(",
"enum",
"dwarf_form",
"form",
")",
"{",
"return",
"form",
"==",
"DW_FORM_string",
"||",
"form",
"==",
"DW_FORM_strp",
"||",
"form",
"==",
"DW_FORM_GNU_strp_alt",
";",
"}"
] | Returns true if the form is one which has a string value. | [
"Returns",
"true",
"if",
"the",
"form",
"is",
"one",
"which",
"has",
"a",
"string",
"value",
"."
] | [] | [
{
"param": "form",
"type": "enum dwarf_form"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "form",
"type": "enum dwarf_form",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_attribute | bfd_byte | static bfd_byte *
read_attribute (struct attribute * attr,
struct attr_abbrev * abbrev,
struct comp_unit * unit,
bfd_byte * info_ptr,
bfd_byte * info_ptr_end)
{
attr->name = abbrev->name;
info_ptr = read_attribute_value (attr, abbrev->form, unit, info_ptr, info_ptr_end);
return info_ptr;
} | /* Read an attribute described by an abbreviated attribute. */ | Read an attribute described by an abbreviated attribute. | [
"Read",
"an",
"attribute",
"described",
"by",
"an",
"abbreviated",
"attribute",
"."
] | static bfd_byte *
read_attribute (struct attribute * attr,
struct attr_abbrev * abbrev,
struct comp_unit * unit,
bfd_byte * info_ptr,
bfd_byte * info_ptr_end)
{
attr->name = abbrev->name;
info_ptr = read_attribute_value (attr, abbrev->form, unit, info_ptr, info_ptr_end);
return info_ptr;
} | [
"static",
"bfd_byte",
"*",
"read_attribute",
"(",
"struct",
"attribute",
"*",
"attr",
",",
"struct",
"attr_abbrev",
"*",
"abbrev",
",",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_byte",
"*",
"info_ptr",
",",
"bfd_byte",
"*",
"info_ptr_end",
")",
"{",
"attr",
"->",
"name",
"=",
"abbrev",
"->",
"name",
";",
"info_ptr",
"=",
"read_attribute_value",
"(",
"attr",
",",
"abbrev",
"->",
"form",
",",
"unit",
",",
"info_ptr",
",",
"info_ptr_end",
")",
";",
"return",
"info_ptr",
";",
"}"
] | Read an attribute described by an abbreviated attribute. | [
"Read",
"an",
"attribute",
"described",
"by",
"an",
"abbreviated",
"attribute",
"."
] | [] | [
{
"param": "attr",
"type": "struct attribute"
},
{
"param": "abbrev",
"type": "struct attr_abbrev"
},
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "info_ptr",
"type": "bfd_byte"
},
{
"param": "info_ptr_end",
"type": "bfd_byte"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "attr",
"type": "struct attribute",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "abbrev",
"type": "struct attr_abbrev",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info_ptr",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info_ptr_end",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | non_mangled | bfd_boolean | static bfd_boolean
non_mangled (int lang)
{
switch (lang)
{
default:
return FALSE;
case DW_LANG_C89:
case DW_LANG_C:
case DW_LANG_Ada83:
case DW_LANG_Cobol74:
case DW_LANG_Cobol85:
case DW_LANG_Fortran77:
case DW_LANG_Pascal83:
case DW_LANG_C99:
case DW_LANG_Ada95:
case DW_LANG_PLI:
case DW_LANG_UPC:
case DW_LANG_C11:
return TRUE;
}
} | /* Return whether DW_AT_name will return the same as DW_AT_linkage_name
for a function. */ | Return whether DW_AT_name will return the same as DW_AT_linkage_name
for a function. | [
"Return",
"whether",
"DW_AT_name",
"will",
"return",
"the",
"same",
"as",
"DW_AT_linkage_name",
"for",
"a",
"function",
"."
] | static bfd_boolean
non_mangled (int lang)
{
switch (lang)
{
default:
return FALSE;
case DW_LANG_C89:
case DW_LANG_C:
case DW_LANG_Ada83:
case DW_LANG_Cobol74:
case DW_LANG_Cobol85:
case DW_LANG_Fortran77:
case DW_LANG_Pascal83:
case DW_LANG_C99:
case DW_LANG_Ada95:
case DW_LANG_PLI:
case DW_LANG_UPC:
case DW_LANG_C11:
return TRUE;
}
} | [
"static",
"bfd_boolean",
"non_mangled",
"(",
"int",
"lang",
")",
"{",
"switch",
"(",
"lang",
")",
"{",
"default",
":",
"return",
"FALSE",
";",
"case",
"DW_LANG_C89",
":",
"case",
"DW_LANG_C",
":",
"case",
"DW_LANG_Ada83",
":",
"case",
"DW_LANG_Cobol74",
":",
"case",
"DW_LANG_Cobol85",
":",
"case",
"DW_LANG_Fortran77",
":",
"case",
"DW_LANG_Pascal83",
":",
"case",
"DW_LANG_C99",
":",
"case",
"DW_LANG_Ada95",
":",
"case",
"DW_LANG_PLI",
":",
"case",
"DW_LANG_UPC",
":",
"case",
"DW_LANG_C11",
":",
"return",
"TRUE",
";",
"}",
"}"
] | Return whether DW_AT_name will return the same as DW_AT_linkage_name
for a function. | [
"Return",
"whether",
"DW_AT_name",
"will",
"return",
"the",
"same",
"as",
"DW_AT_linkage_name",
"for",
"a",
"function",
"."
] | [] | [
{
"param": "lang",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lang",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | new_line_sorts_after | bfd_boolean | static inline bfd_boolean
new_line_sorts_after (struct line_info *new_line, struct line_info *line)
{
return (new_line->address > line->address
|| (new_line->address == line->address
&& (new_line->op_index > line->op_index
|| (new_line->op_index == line->op_index
&& new_line->end_sequence < line->end_sequence))));
} | /* Return TRUE if NEW_LINE should sort after LINE. */ | Return TRUE if NEW_LINE should sort after LINE. | [
"Return",
"TRUE",
"if",
"NEW_LINE",
"should",
"sort",
"after",
"LINE",
"."
] | static inline bfd_boolean
new_line_sorts_after (struct line_info *new_line, struct line_info *line)
{
return (new_line->address > line->address
|| (new_line->address == line->address
&& (new_line->op_index > line->op_index
|| (new_line->op_index == line->op_index
&& new_line->end_sequence < line->end_sequence))));
} | [
"static",
"inline",
"bfd_boolean",
"new_line_sorts_after",
"(",
"struct",
"line_info",
"*",
"new_line",
",",
"struct",
"line_info",
"*",
"line",
")",
"{",
"return",
"(",
"new_line",
"->",
"address",
">",
"line",
"->",
"address",
"||",
"(",
"new_line",
"->",
"address",
"==",
"line",
"->",
"address",
"&&",
"(",
"new_line",
"->",
"op_index",
">",
"line",
"->",
"op_index",
"||",
"(",
"new_line",
"->",
"op_index",
"==",
"line",
"->",
"op_index",
"&&",
"new_line",
"->",
"end_sequence",
"<",
"line",
"->",
"end_sequence",
")",
")",
")",
")",
";",
"}"
] | Return TRUE if NEW_LINE should sort after LINE. | [
"Return",
"TRUE",
"if",
"NEW_LINE",
"should",
"sort",
"after",
"LINE",
"."
] | [] | [
{
"param": "new_line",
"type": "struct line_info"
},
{
"param": "line",
"type": "struct line_info"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_line",
"type": "struct line_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "struct line_info",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | add_line_info | bfd_boolean | static bfd_boolean
add_line_info (struct line_info_table *table,
bfd_vma address,
unsigned char op_index,
char *filename,
unsigned int line,
unsigned int column,
unsigned int discriminator,
int end_sequence)
{
bfd_size_type amt = sizeof (struct line_info);
struct line_sequence* seq = table->sequences;
struct line_info* info = (struct line_info *) bfd_alloc (table->abfd, amt);
if (info == NULL)
return FALSE;
/* Set member data of 'info'. */
info->prev_line = NULL;
info->address = address;
info->op_index = op_index;
info->line = line;
info->column = column;
info->discriminator = discriminator;
info->end_sequence = end_sequence;
if (filename && filename[0])
{
info->filename = (char *) bfd_alloc (table->abfd, strlen (filename) + 1);
if (info->filename == NULL)
return FALSE;
strcpy (info->filename, filename);
}
else
info->filename = NULL;
/* Find the correct location for 'info'. Normally we will receive
new line_info data 1) in order and 2) with increasing VMAs.
However some compilers break the rules (cf. decode_line_info) and
so we include some heuristics for quickly finding the correct
location for 'info'. In particular, these heuristics optimize for
the common case in which the VMA sequence that we receive is a
list of locally sorted VMAs such as
p...z a...j (where a < j < p < z)
Note: table->lcl_head is used to head an *actual* or *possible*
sub-sequence within the list (such as a...j) that is not directly
headed by table->last_line
Note: we may receive duplicate entries from 'decode_line_info'. */
if (seq
&& seq->last_line->address == address
&& seq->last_line->op_index == op_index
&& seq->last_line->end_sequence == end_sequence)
{
/* We only keep the last entry with the same address and end
sequence. See PR ld/4986. */
if (table->lcl_head == seq->last_line)
table->lcl_head = info;
info->prev_line = seq->last_line->prev_line;
seq->last_line = info;
}
else if (!seq || seq->last_line->end_sequence)
{
/* Start a new line sequence. */
amt = sizeof (struct line_sequence);
seq = (struct line_sequence *) bfd_malloc (amt);
if (seq == NULL)
return FALSE;
seq->low_pc = address;
seq->prev_sequence = table->sequences;
seq->last_line = info;
table->lcl_head = info;
table->sequences = seq;
table->num_sequences++;
}
else if (new_line_sorts_after (info, seq->last_line))
{
/* Normal case: add 'info' to the beginning of the current sequence. */
info->prev_line = seq->last_line;
seq->last_line = info;
/* lcl_head: initialize to head a *possible* sequence at the end. */
if (!table->lcl_head)
table->lcl_head = info;
}
else if (!new_line_sorts_after (info, table->lcl_head)
&& (!table->lcl_head->prev_line
|| new_line_sorts_after (info, table->lcl_head->prev_line)))
{
/* Abnormal but easy: lcl_head is the head of 'info'. */
info->prev_line = table->lcl_head->prev_line;
table->lcl_head->prev_line = info;
}
else
{
/* Abnormal and hard: Neither 'last_line' nor 'lcl_head'
are valid heads for 'info'. Reset 'lcl_head'. */
struct line_info* li2 = seq->last_line; /* Always non-NULL. */
struct line_info* li1 = li2->prev_line;
while (li1)
{
if (!new_line_sorts_after (info, li2)
&& new_line_sorts_after (info, li1))
break;
li2 = li1; /* always non-NULL */
li1 = li1->prev_line;
}
table->lcl_head = li2;
info->prev_line = table->lcl_head->prev_line;
table->lcl_head->prev_line = info;
if (address < seq->low_pc)
seq->low_pc = address;
}
return TRUE;
} | /* Adds a new entry to the line_info list in the line_info_table, ensuring
that the list is sorted. Note that the line_info list is sorted from
highest to lowest VMA (with possible duplicates); that is,
line_info->prev_line always accesses an equal or smaller VMA. */ | Adds a new entry to the line_info list in the line_info_table, ensuring
that the list is sorted. Note that the line_info list is sorted from
highest to lowest VMA (with possible duplicates); that is,
line_info->prev_line always accesses an equal or smaller VMA. | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"line_info",
"list",
"in",
"the",
"line_info_table",
"ensuring",
"that",
"the",
"list",
"is",
"sorted",
".",
"Note",
"that",
"the",
"line_info",
"list",
"is",
"sorted",
"from",
"highest",
"to",
"lowest",
"VMA",
"(",
"with",
"possible",
"duplicates",
")",
";",
"that",
"is",
"line_info",
"-",
">",
"prev_line",
"always",
"accesses",
"an",
"equal",
"or",
"smaller",
"VMA",
"."
] | static bfd_boolean
add_line_info (struct line_info_table *table,
bfd_vma address,
unsigned char op_index,
char *filename,
unsigned int line,
unsigned int column,
unsigned int discriminator,
int end_sequence)
{
bfd_size_type amt = sizeof (struct line_info);
struct line_sequence* seq = table->sequences;
struct line_info* info = (struct line_info *) bfd_alloc (table->abfd, amt);
if (info == NULL)
return FALSE;
info->prev_line = NULL;
info->address = address;
info->op_index = op_index;
info->line = line;
info->column = column;
info->discriminator = discriminator;
info->end_sequence = end_sequence;
if (filename && filename[0])
{
info->filename = (char *) bfd_alloc (table->abfd, strlen (filename) + 1);
if (info->filename == NULL)
return FALSE;
strcpy (info->filename, filename);
}
else
info->filename = NULL;
if (seq
&& seq->last_line->address == address
&& seq->last_line->op_index == op_index
&& seq->last_line->end_sequence == end_sequence)
{
if (table->lcl_head == seq->last_line)
table->lcl_head = info;
info->prev_line = seq->last_line->prev_line;
seq->last_line = info;
}
else if (!seq || seq->last_line->end_sequence)
{
amt = sizeof (struct line_sequence);
seq = (struct line_sequence *) bfd_malloc (amt);
if (seq == NULL)
return FALSE;
seq->low_pc = address;
seq->prev_sequence = table->sequences;
seq->last_line = info;
table->lcl_head = info;
table->sequences = seq;
table->num_sequences++;
}
else if (new_line_sorts_after (info, seq->last_line))
{
info->prev_line = seq->last_line;
seq->last_line = info;
if (!table->lcl_head)
table->lcl_head = info;
}
else if (!new_line_sorts_after (info, table->lcl_head)
&& (!table->lcl_head->prev_line
|| new_line_sorts_after (info, table->lcl_head->prev_line)))
{
info->prev_line = table->lcl_head->prev_line;
table->lcl_head->prev_line = info;
}
else
{
struct line_info* li2 = seq->last_line;
struct line_info* li1 = li2->prev_line;
while (li1)
{
if (!new_line_sorts_after (info, li2)
&& new_line_sorts_after (info, li1))
break;
li2 = li1;
li1 = li1->prev_line;
}
table->lcl_head = li2;
info->prev_line = table->lcl_head->prev_line;
table->lcl_head->prev_line = info;
if (address < seq->low_pc)
seq->low_pc = address;
}
return TRUE;
} | [
"static",
"bfd_boolean",
"add_line_info",
"(",
"struct",
"line_info_table",
"*",
"table",
",",
"bfd_vma",
"address",
",",
"unsigned",
"char",
"op_index",
",",
"char",
"*",
"filename",
",",
"unsigned",
"int",
"line",
",",
"unsigned",
"int",
"column",
",",
"unsigned",
"int",
"discriminator",
",",
"int",
"end_sequence",
")",
"{",
"bfd_size_type",
"amt",
"=",
"sizeof",
"(",
"struct",
"line_info",
")",
";",
"struct",
"line_sequence",
"*",
"seq",
"=",
"table",
"->",
"sequences",
";",
"struct",
"line_info",
"*",
"info",
"=",
"(",
"struct",
"line_info",
"*",
")",
"bfd_alloc",
"(",
"table",
"->",
"abfd",
",",
"amt",
")",
";",
"if",
"(",
"info",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"info",
"->",
"prev_line",
"=",
"NULL",
";",
"info",
"->",
"address",
"=",
"address",
";",
"info",
"->",
"op_index",
"=",
"op_index",
";",
"info",
"->",
"line",
"=",
"line",
";",
"info",
"->",
"column",
"=",
"column",
";",
"info",
"->",
"discriminator",
"=",
"discriminator",
";",
"info",
"->",
"end_sequence",
"=",
"end_sequence",
";",
"if",
"(",
"filename",
"&&",
"filename",
"[",
"0",
"]",
")",
"{",
"info",
"->",
"filename",
"=",
"(",
"char",
"*",
")",
"bfd_alloc",
"(",
"table",
"->",
"abfd",
",",
"strlen",
"(",
"filename",
")",
"+",
"1",
")",
";",
"if",
"(",
"info",
"->",
"filename",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"strcpy",
"(",
"info",
"->",
"filename",
",",
"filename",
")",
";",
"}",
"else",
"info",
"->",
"filename",
"=",
"NULL",
";",
"if",
"(",
"seq",
"&&",
"seq",
"->",
"last_line",
"->",
"address",
"==",
"address",
"&&",
"seq",
"->",
"last_line",
"->",
"op_index",
"==",
"op_index",
"&&",
"seq",
"->",
"last_line",
"->",
"end_sequence",
"==",
"end_sequence",
")",
"{",
"if",
"(",
"table",
"->",
"lcl_head",
"==",
"seq",
"->",
"last_line",
")",
"table",
"->",
"lcl_head",
"=",
"info",
";",
"info",
"->",
"prev_line",
"=",
"seq",
"->",
"last_line",
"->",
"prev_line",
";",
"seq",
"->",
"last_line",
"=",
"info",
";",
"}",
"else",
"if",
"(",
"!",
"seq",
"||",
"seq",
"->",
"last_line",
"->",
"end_sequence",
")",
"{",
"amt",
"=",
"sizeof",
"(",
"struct",
"line_sequence",
")",
";",
"seq",
"=",
"(",
"struct",
"line_sequence",
"*",
")",
"bfd_malloc",
"(",
"amt",
")",
";",
"if",
"(",
"seq",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"seq",
"->",
"low_pc",
"=",
"address",
";",
"seq",
"->",
"prev_sequence",
"=",
"table",
"->",
"sequences",
";",
"seq",
"->",
"last_line",
"=",
"info",
";",
"table",
"->",
"lcl_head",
"=",
"info",
";",
"table",
"->",
"sequences",
"=",
"seq",
";",
"table",
"->",
"num_sequences",
"++",
";",
"}",
"else",
"if",
"(",
"new_line_sorts_after",
"(",
"info",
",",
"seq",
"->",
"last_line",
")",
")",
"{",
"info",
"->",
"prev_line",
"=",
"seq",
"->",
"last_line",
";",
"seq",
"->",
"last_line",
"=",
"info",
";",
"if",
"(",
"!",
"table",
"->",
"lcl_head",
")",
"table",
"->",
"lcl_head",
"=",
"info",
";",
"}",
"else",
"if",
"(",
"!",
"new_line_sorts_after",
"(",
"info",
",",
"table",
"->",
"lcl_head",
")",
"&&",
"(",
"!",
"table",
"->",
"lcl_head",
"->",
"prev_line",
"||",
"new_line_sorts_after",
"(",
"info",
",",
"table",
"->",
"lcl_head",
"->",
"prev_line",
")",
")",
")",
"{",
"info",
"->",
"prev_line",
"=",
"table",
"->",
"lcl_head",
"->",
"prev_line",
";",
"table",
"->",
"lcl_head",
"->",
"prev_line",
"=",
"info",
";",
"}",
"else",
"{",
"struct",
"line_info",
"*",
"li2",
"=",
"seq",
"->",
"last_line",
";",
"struct",
"line_info",
"*",
"li1",
"=",
"li2",
"->",
"prev_line",
";",
"while",
"(",
"li1",
")",
"{",
"if",
"(",
"!",
"new_line_sorts_after",
"(",
"info",
",",
"li2",
")",
"&&",
"new_line_sorts_after",
"(",
"info",
",",
"li1",
")",
")",
"break",
";",
"li2",
"=",
"li1",
";",
"li1",
"=",
"li1",
"->",
"prev_line",
";",
"}",
"table",
"->",
"lcl_head",
"=",
"li2",
";",
"info",
"->",
"prev_line",
"=",
"table",
"->",
"lcl_head",
"->",
"prev_line",
";",
"table",
"->",
"lcl_head",
"->",
"prev_line",
"=",
"info",
";",
"if",
"(",
"address",
"<",
"seq",
"->",
"low_pc",
")",
"seq",
"->",
"low_pc",
"=",
"address",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Adds a new entry to the line_info list in the line_info_table, ensuring
that the list is sorted. | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"line_info",
"list",
"in",
"the",
"line_info_table",
"ensuring",
"that",
"the",
"list",
"is",
"sorted",
"."
] | [
"/* Set member data of 'info'. */",
"/* Find the correct location for 'info'. Normally we will receive\n new line_info data 1) in order and 2) with increasing VMAs.\n However some compilers break the rules (cf. decode_line_info) and\n so we include some heuristics for quickly finding the correct\n location for 'info'. In particular, these heuristics optimize for\n the common case in which the VMA sequence that we receive is a\n list of locally sorted VMAs such as\n p...z a...j (where a < j < p < z)\n\n Note: table->lcl_head is used to head an *actual* or *possible*\n sub-sequence within the list (such as a...j) that is not directly\n headed by table->last_line\n\n Note: we may receive duplicate entries from 'decode_line_info'. */",
"/* We only keep the last entry with the same address and end\n\t sequence. See PR ld/4986. */",
"/* Start a new line sequence. */",
"/* Normal case: add 'info' to the beginning of the current sequence. */",
"/* lcl_head: initialize to head a *possible* sequence at the end. */",
"/* Abnormal but easy: lcl_head is the head of 'info'. */",
"/* Abnormal and hard: Neither 'last_line' nor 'lcl_head'\n\t are valid heads for 'info'. Reset 'lcl_head'. */",
"/* Always non-NULL. */",
"/* always non-NULL */"
] | [
{
"param": "table",
"type": "struct line_info_table"
},
{
"param": "address",
"type": "bfd_vma"
},
{
"param": "op_index",
"type": "unsigned char"
},
{
"param": "filename",
"type": "char"
},
{
"param": "line",
"type": "unsigned int"
},
{
"param": "column",
"type": "unsigned int"
},
{
"param": "discriminator",
"type": "unsigned int"
},
{
"param": "end_sequence",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "struct line_info_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "address",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "op_index",
"type": "unsigned char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "column",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "discriminator",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "end_sequence",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | concat_filename | char | static char *
concat_filename (struct line_info_table *table, unsigned int file)
{
char *filename;
if (file - 1 >= table->num_files)
{
/* FILE == 0 means unknown. */
if (file)
(*_bfd_error_handler)
(_("Dwarf Error: mangled line number section (bad file number)."));
return strdup ("<unknown>");
}
filename = table->files[file - 1].name;
if (!IS_ABSOLUTE_PATH (filename))
{
char *dir_name = NULL;
char *subdir_name = NULL;
char *name;
size_t len;
if (table->files[file - 1].dir
/* PR 17512: file: 0317e960. */
&& table->files[file - 1].dir <= table->num_dirs
/* PR 17512: file: 7f3d2e4b. */
&& table->dirs != NULL)
subdir_name = table->dirs[table->files[file - 1].dir - 1];
if (!subdir_name || !IS_ABSOLUTE_PATH (subdir_name))
dir_name = table->comp_dir;
if (!dir_name)
{
dir_name = subdir_name;
subdir_name = NULL;
}
if (!dir_name)
return strdup (filename);
len = strlen (dir_name) + strlen (filename) + 2;
if (subdir_name)
{
len += strlen (subdir_name) + 1;
name = (char *) bfd_malloc (len);
if (name)
sprintf (name, "%s/%s/%s", dir_name, subdir_name, filename);
}
else
{
name = (char *) bfd_malloc (len);
if (name)
sprintf (name, "%s/%s", dir_name, filename);
}
return name;
}
return strdup (filename);
} | /* Extract a fully qualified filename from a line info table.
The returned string has been malloc'ed and it is the caller's
responsibility to free it. */ | Extract a fully qualified filename from a line info table.
The returned string has been malloc'ed and it is the caller's
responsibility to free it. | [
"Extract",
"a",
"fully",
"qualified",
"filename",
"from",
"a",
"line",
"info",
"table",
".",
"The",
"returned",
"string",
"has",
"been",
"malloc",
"'",
"ed",
"and",
"it",
"is",
"the",
"caller",
"'",
"s",
"responsibility",
"to",
"free",
"it",
"."
] | static char *
concat_filename (struct line_info_table *table, unsigned int file)
{
char *filename;
if (file - 1 >= table->num_files)
{
if (file)
(*_bfd_error_handler)
(_("Dwarf Error: mangled line number section (bad file number)."));
return strdup ("<unknown>");
}
filename = table->files[file - 1].name;
if (!IS_ABSOLUTE_PATH (filename))
{
char *dir_name = NULL;
char *subdir_name = NULL;
char *name;
size_t len;
if (table->files[file - 1].dir
&& table->files[file - 1].dir <= table->num_dirs
&& table->dirs != NULL)
subdir_name = table->dirs[table->files[file - 1].dir - 1];
if (!subdir_name || !IS_ABSOLUTE_PATH (subdir_name))
dir_name = table->comp_dir;
if (!dir_name)
{
dir_name = subdir_name;
subdir_name = NULL;
}
if (!dir_name)
return strdup (filename);
len = strlen (dir_name) + strlen (filename) + 2;
if (subdir_name)
{
len += strlen (subdir_name) + 1;
name = (char *) bfd_malloc (len);
if (name)
sprintf (name, "%s/%s/%s", dir_name, subdir_name, filename);
}
else
{
name = (char *) bfd_malloc (len);
if (name)
sprintf (name, "%s/%s", dir_name, filename);
}
return name;
}
return strdup (filename);
} | [
"static",
"char",
"*",
"concat_filename",
"(",
"struct",
"line_info_table",
"*",
"table",
",",
"unsigned",
"int",
"file",
")",
"{",
"char",
"*",
"filename",
";",
"if",
"(",
"file",
"-",
"1",
">=",
"table",
"->",
"num_files",
")",
"{",
"if",
"(",
"file",
")",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"return",
"strdup",
"(",
"\"",
"\"",
")",
";",
"}",
"filename",
"=",
"table",
"->",
"files",
"[",
"file",
"-",
"1",
"]",
".",
"name",
";",
"if",
"(",
"!",
"IS_ABSOLUTE_PATH",
"(",
"filename",
")",
")",
"{",
"char",
"*",
"dir_name",
"=",
"NULL",
";",
"char",
"*",
"subdir_name",
"=",
"NULL",
";",
"char",
"*",
"name",
";",
"size_t",
"len",
";",
"if",
"(",
"table",
"->",
"files",
"[",
"file",
"-",
"1",
"]",
".",
"dir",
"&&",
"table",
"->",
"files",
"[",
"file",
"-",
"1",
"]",
".",
"dir",
"<=",
"table",
"->",
"num_dirs",
"&&",
"table",
"->",
"dirs",
"!=",
"NULL",
")",
"subdir_name",
"=",
"table",
"->",
"dirs",
"[",
"table",
"->",
"files",
"[",
"file",
"-",
"1",
"]",
".",
"dir",
"-",
"1",
"]",
";",
"if",
"(",
"!",
"subdir_name",
"||",
"!",
"IS_ABSOLUTE_PATH",
"(",
"subdir_name",
")",
")",
"dir_name",
"=",
"table",
"->",
"comp_dir",
";",
"if",
"(",
"!",
"dir_name",
")",
"{",
"dir_name",
"=",
"subdir_name",
";",
"subdir_name",
"=",
"NULL",
";",
"}",
"if",
"(",
"!",
"dir_name",
")",
"return",
"strdup",
"(",
"filename",
")",
";",
"len",
"=",
"strlen",
"(",
"dir_name",
")",
"+",
"strlen",
"(",
"filename",
")",
"+",
"2",
";",
"if",
"(",
"subdir_name",
")",
"{",
"len",
"+=",
"strlen",
"(",
"subdir_name",
")",
"+",
"1",
";",
"name",
"=",
"(",
"char",
"*",
")",
"bfd_malloc",
"(",
"len",
")",
";",
"if",
"(",
"name",
")",
"sprintf",
"(",
"name",
",",
"\"",
"\"",
",",
"dir_name",
",",
"subdir_name",
",",
"filename",
")",
";",
"}",
"else",
"{",
"name",
"=",
"(",
"char",
"*",
")",
"bfd_malloc",
"(",
"len",
")",
";",
"if",
"(",
"name",
")",
"sprintf",
"(",
"name",
",",
"\"",
"\"",
",",
"dir_name",
",",
"filename",
")",
";",
"}",
"return",
"name",
";",
"}",
"return",
"strdup",
"(",
"filename",
")",
";",
"}"
] | Extract a fully qualified filename from a line info table. | [
"Extract",
"a",
"fully",
"qualified",
"filename",
"from",
"a",
"line",
"info",
"table",
"."
] | [
"/* FILE == 0 means unknown. */",
"/* PR 17512: file: 0317e960. */",
"/* PR 17512: file: 7f3d2e4b. */"
] | [
{
"param": "table",
"type": "struct line_info_table"
},
{
"param": "file",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "struct line_info_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | compare_sequences | int | static int
compare_sequences (const void* a, const void* b)
{
const struct line_sequence* seq1 = a;
const struct line_sequence* seq2 = b;
/* Sort by low_pc as the primary key. */
if (seq1->low_pc < seq2->low_pc)
return -1;
if (seq1->low_pc > seq2->low_pc)
return 1;
/* If low_pc values are equal, sort in reverse order of
high_pc, so that the largest region comes first. */
if (seq1->last_line->address < seq2->last_line->address)
return 1;
if (seq1->last_line->address > seq2->last_line->address)
return -1;
if (seq1->last_line->op_index < seq2->last_line->op_index)
return 1;
if (seq1->last_line->op_index > seq2->last_line->op_index)
return -1;
return 0;
} | /* Compare function for line sequences. */ | Compare function for line sequences. | [
"Compare",
"function",
"for",
"line",
"sequences",
"."
] | static int
compare_sequences (const void* a, const void* b)
{
const struct line_sequence* seq1 = a;
const struct line_sequence* seq2 = b;
if (seq1->low_pc < seq2->low_pc)
return -1;
if (seq1->low_pc > seq2->low_pc)
return 1;
if (seq1->last_line->address < seq2->last_line->address)
return 1;
if (seq1->last_line->address > seq2->last_line->address)
return -1;
if (seq1->last_line->op_index < seq2->last_line->op_index)
return 1;
if (seq1->last_line->op_index > seq2->last_line->op_index)
return -1;
return 0;
} | [
"static",
"int",
"compare_sequences",
"(",
"const",
"void",
"*",
"a",
",",
"const",
"void",
"*",
"b",
")",
"{",
"const",
"struct",
"line_sequence",
"*",
"seq1",
"=",
"a",
";",
"const",
"struct",
"line_sequence",
"*",
"seq2",
"=",
"b",
";",
"if",
"(",
"seq1",
"->",
"low_pc",
"<",
"seq2",
"->",
"low_pc",
")",
"return",
"-1",
";",
"if",
"(",
"seq1",
"->",
"low_pc",
">",
"seq2",
"->",
"low_pc",
")",
"return",
"1",
";",
"if",
"(",
"seq1",
"->",
"last_line",
"->",
"address",
"<",
"seq2",
"->",
"last_line",
"->",
"address",
")",
"return",
"1",
";",
"if",
"(",
"seq1",
"->",
"last_line",
"->",
"address",
">",
"seq2",
"->",
"last_line",
"->",
"address",
")",
"return",
"-1",
";",
"if",
"(",
"seq1",
"->",
"last_line",
"->",
"op_index",
"<",
"seq2",
"->",
"last_line",
"->",
"op_index",
")",
"return",
"1",
";",
"if",
"(",
"seq1",
"->",
"last_line",
"->",
"op_index",
">",
"seq2",
"->",
"last_line",
"->",
"op_index",
")",
"return",
"-1",
";",
"return",
"0",
";",
"}"
] | Compare function for line sequences. | [
"Compare",
"function",
"for",
"line",
"sequences",
"."
] | [
"/* Sort by low_pc as the primary key. */",
"/* If low_pc values are equal, sort in reverse order of\n high_pc, so that the largest region comes first. */"
] | [
{
"param": "a",
"type": "void"
},
{
"param": "b",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | sort_line_sequences | bfd_boolean | static bfd_boolean
sort_line_sequences (struct line_info_table* table)
{
bfd_size_type amt;
struct line_sequence* sequences;
struct line_sequence* seq;
unsigned int n = 0;
unsigned int num_sequences = table->num_sequences;
bfd_vma last_high_pc;
if (num_sequences == 0)
return TRUE;
/* Allocate space for an array of sequences. */
amt = sizeof (struct line_sequence) * num_sequences;
sequences = (struct line_sequence *) bfd_alloc (table->abfd, amt);
if (sequences == NULL)
return FALSE;
/* Copy the linked list into the array, freeing the original nodes. */
seq = table->sequences;
for (n = 0; n < num_sequences; n++)
{
struct line_sequence* last_seq = seq;
BFD_ASSERT (seq);
sequences[n].low_pc = seq->low_pc;
sequences[n].prev_sequence = NULL;
sequences[n].last_line = seq->last_line;
seq = seq->prev_sequence;
free (last_seq);
}
BFD_ASSERT (seq == NULL);
qsort (sequences, n, sizeof (struct line_sequence), compare_sequences);
/* Make the list binary-searchable by trimming overlapping entries
and removing nested entries. */
num_sequences = 1;
last_high_pc = sequences[0].last_line->address;
for (n = 1; n < table->num_sequences; n++)
{
if (sequences[n].low_pc < last_high_pc)
{
if (sequences[n].last_line->address <= last_high_pc)
/* Skip nested entries. */
continue;
/* Trim overlapping entries. */
sequences[n].low_pc = last_high_pc;
}
last_high_pc = sequences[n].last_line->address;
if (n > num_sequences)
{
/* Close up the gap. */
sequences[num_sequences].low_pc = sequences[n].low_pc;
sequences[num_sequences].last_line = sequences[n].last_line;
}
num_sequences++;
}
table->sequences = sequences;
table->num_sequences = num_sequences;
return TRUE;
} | /* Sort the line sequences for quick lookup. */ | Sort the line sequences for quick lookup. | [
"Sort",
"the",
"line",
"sequences",
"for",
"quick",
"lookup",
"."
] | static bfd_boolean
sort_line_sequences (struct line_info_table* table)
{
bfd_size_type amt;
struct line_sequence* sequences;
struct line_sequence* seq;
unsigned int n = 0;
unsigned int num_sequences = table->num_sequences;
bfd_vma last_high_pc;
if (num_sequences == 0)
return TRUE;
amt = sizeof (struct line_sequence) * num_sequences;
sequences = (struct line_sequence *) bfd_alloc (table->abfd, amt);
if (sequences == NULL)
return FALSE;
seq = table->sequences;
for (n = 0; n < num_sequences; n++)
{
struct line_sequence* last_seq = seq;
BFD_ASSERT (seq);
sequences[n].low_pc = seq->low_pc;
sequences[n].prev_sequence = NULL;
sequences[n].last_line = seq->last_line;
seq = seq->prev_sequence;
free (last_seq);
}
BFD_ASSERT (seq == NULL);
qsort (sequences, n, sizeof (struct line_sequence), compare_sequences);
num_sequences = 1;
last_high_pc = sequences[0].last_line->address;
for (n = 1; n < table->num_sequences; n++)
{
if (sequences[n].low_pc < last_high_pc)
{
if (sequences[n].last_line->address <= last_high_pc)
continue;
sequences[n].low_pc = last_high_pc;
}
last_high_pc = sequences[n].last_line->address;
if (n > num_sequences)
{
sequences[num_sequences].low_pc = sequences[n].low_pc;
sequences[num_sequences].last_line = sequences[n].last_line;
}
num_sequences++;
}
table->sequences = sequences;
table->num_sequences = num_sequences;
return TRUE;
} | [
"static",
"bfd_boolean",
"sort_line_sequences",
"(",
"struct",
"line_info_table",
"*",
"table",
")",
"{",
"bfd_size_type",
"amt",
";",
"struct",
"line_sequence",
"*",
"sequences",
";",
"struct",
"line_sequence",
"*",
"seq",
";",
"unsigned",
"int",
"n",
"=",
"0",
";",
"unsigned",
"int",
"num_sequences",
"=",
"table",
"->",
"num_sequences",
";",
"bfd_vma",
"last_high_pc",
";",
"if",
"(",
"num_sequences",
"==",
"0",
")",
"return",
"TRUE",
";",
"amt",
"=",
"sizeof",
"(",
"struct",
"line_sequence",
")",
"*",
"num_sequences",
";",
"sequences",
"=",
"(",
"struct",
"line_sequence",
"*",
")",
"bfd_alloc",
"(",
"table",
"->",
"abfd",
",",
"amt",
")",
";",
"if",
"(",
"sequences",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"seq",
"=",
"table",
"->",
"sequences",
";",
"for",
"(",
"n",
"=",
"0",
";",
"n",
"<",
"num_sequences",
";",
"n",
"++",
")",
"{",
"struct",
"line_sequence",
"*",
"last_seq",
"=",
"seq",
";",
"BFD_ASSERT",
"(",
"seq",
")",
";",
"sequences",
"[",
"n",
"]",
".",
"low_pc",
"=",
"seq",
"->",
"low_pc",
";",
"sequences",
"[",
"n",
"]",
".",
"prev_sequence",
"=",
"NULL",
";",
"sequences",
"[",
"n",
"]",
".",
"last_line",
"=",
"seq",
"->",
"last_line",
";",
"seq",
"=",
"seq",
"->",
"prev_sequence",
";",
"free",
"(",
"last_seq",
")",
";",
"}",
"BFD_ASSERT",
"(",
"seq",
"==",
"NULL",
")",
";",
"qsort",
"(",
"sequences",
",",
"n",
",",
"sizeof",
"(",
"struct",
"line_sequence",
")",
",",
"compare_sequences",
")",
";",
"num_sequences",
"=",
"1",
";",
"last_high_pc",
"=",
"sequences",
"[",
"0",
"]",
".",
"last_line",
"->",
"address",
";",
"for",
"(",
"n",
"=",
"1",
";",
"n",
"<",
"table",
"->",
"num_sequences",
";",
"n",
"++",
")",
"{",
"if",
"(",
"sequences",
"[",
"n",
"]",
".",
"low_pc",
"<",
"last_high_pc",
")",
"{",
"if",
"(",
"sequences",
"[",
"n",
"]",
".",
"last_line",
"->",
"address",
"<=",
"last_high_pc",
")",
"continue",
";",
"sequences",
"[",
"n",
"]",
".",
"low_pc",
"=",
"last_high_pc",
";",
"}",
"last_high_pc",
"=",
"sequences",
"[",
"n",
"]",
".",
"last_line",
"->",
"address",
";",
"if",
"(",
"n",
">",
"num_sequences",
")",
"{",
"sequences",
"[",
"num_sequences",
"]",
".",
"low_pc",
"=",
"sequences",
"[",
"n",
"]",
".",
"low_pc",
";",
"sequences",
"[",
"num_sequences",
"]",
".",
"last_line",
"=",
"sequences",
"[",
"n",
"]",
".",
"last_line",
";",
"}",
"num_sequences",
"++",
";",
"}",
"table",
"->",
"sequences",
"=",
"sequences",
";",
"table",
"->",
"num_sequences",
"=",
"num_sequences",
";",
"return",
"TRUE",
";",
"}"
] | Sort the line sequences for quick lookup. | [
"Sort",
"the",
"line",
"sequences",
"for",
"quick",
"lookup",
"."
] | [
"/* Allocate space for an array of sequences. */",
"/* Copy the linked list into the array, freeing the original nodes. */",
"/* Make the list binary-searchable by trimming overlapping entries\n and removing nested entries. */",
"/* Skip nested entries. */",
"/* Trim overlapping entries. */",
"/* Close up the gap. */"
] | [
{
"param": "table",
"type": "struct line_info_table"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "struct line_info_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_address_in_line_info_table | bfd_vma | static bfd_vma
lookup_address_in_line_info_table (struct line_info_table *table,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr,
unsigned int *discriminator_ptr)
{
struct line_sequence *seq = NULL;
struct line_info *each_line;
int low, high, mid;
/* Binary search the array of sequences. */
low = 0;
high = table->num_sequences;
while (low < high)
{
mid = (low + high) / 2;
seq = &table->sequences[mid];
if (addr < seq->low_pc)
high = mid;
else if (addr >= seq->last_line->address)
low = mid + 1;
else
break;
}
if (seq && addr >= seq->low_pc && addr < seq->last_line->address)
{
/* Note: seq->last_line should be a descendingly sorted list. */
for (each_line = seq->last_line;
each_line;
each_line = each_line->prev_line)
if (addr >= each_line->address)
break;
if (each_line
&& !(each_line->end_sequence || each_line == seq->last_line))
{
*filename_ptr = each_line->filename;
*linenumber_ptr = each_line->line;
if (discriminator_ptr)
*discriminator_ptr = each_line->discriminator;
return seq->last_line->address - seq->low_pc;
}
}
*filename_ptr = NULL;
return 0;
} | /* If ADDR is within TABLE set the output parameters and return the
range of addresses covered by the entry used to fill them out.
Otherwise set * FILENAME_PTR to NULL and return 0.
The parameters FILENAME_PTR, LINENUMBER_PTR and DISCRIMINATOR_PTR
are pointers to the objects to be filled in. */ | If ADDR is within TABLE set the output parameters and return the
range of addresses covered by the entry used to fill them out.
Otherwise set * FILENAME_PTR to NULL and return 0.
The parameters FILENAME_PTR, LINENUMBER_PTR and DISCRIMINATOR_PTR
are pointers to the objects to be filled in. | [
"If",
"ADDR",
"is",
"within",
"TABLE",
"set",
"the",
"output",
"parameters",
"and",
"return",
"the",
"range",
"of",
"addresses",
"covered",
"by",
"the",
"entry",
"used",
"to",
"fill",
"them",
"out",
".",
"Otherwise",
"set",
"*",
"FILENAME_PTR",
"to",
"NULL",
"and",
"return",
"0",
".",
"The",
"parameters",
"FILENAME_PTR",
"LINENUMBER_PTR",
"and",
"DISCRIMINATOR_PTR",
"are",
"pointers",
"to",
"the",
"objects",
"to",
"be",
"filled",
"in",
"."
] | static bfd_vma
lookup_address_in_line_info_table (struct line_info_table *table,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr,
unsigned int *discriminator_ptr)
{
struct line_sequence *seq = NULL;
struct line_info *each_line;
int low, high, mid;
low = 0;
high = table->num_sequences;
while (low < high)
{
mid = (low + high) / 2;
seq = &table->sequences[mid];
if (addr < seq->low_pc)
high = mid;
else if (addr >= seq->last_line->address)
low = mid + 1;
else
break;
}
if (seq && addr >= seq->low_pc && addr < seq->last_line->address)
{
for (each_line = seq->last_line;
each_line;
each_line = each_line->prev_line)
if (addr >= each_line->address)
break;
if (each_line
&& !(each_line->end_sequence || each_line == seq->last_line))
{
*filename_ptr = each_line->filename;
*linenumber_ptr = each_line->line;
if (discriminator_ptr)
*discriminator_ptr = each_line->discriminator;
return seq->last_line->address - seq->low_pc;
}
}
*filename_ptr = NULL;
return 0;
} | [
"static",
"bfd_vma",
"lookup_address_in_line_info_table",
"(",
"struct",
"line_info_table",
"*",
"table",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
",",
"unsigned",
"int",
"*",
"discriminator_ptr",
")",
"{",
"struct",
"line_sequence",
"*",
"seq",
"=",
"NULL",
";",
"struct",
"line_info",
"*",
"each_line",
";",
"int",
"low",
",",
"high",
",",
"mid",
";",
"low",
"=",
"0",
";",
"high",
"=",
"table",
"->",
"num_sequences",
";",
"while",
"(",
"low",
"<",
"high",
")",
"{",
"mid",
"=",
"(",
"low",
"+",
"high",
")",
"/",
"2",
";",
"seq",
"=",
"&",
"table",
"->",
"sequences",
"[",
"mid",
"]",
";",
"if",
"(",
"addr",
"<",
"seq",
"->",
"low_pc",
")",
"high",
"=",
"mid",
";",
"else",
"if",
"(",
"addr",
">=",
"seq",
"->",
"last_line",
"->",
"address",
")",
"low",
"=",
"mid",
"+",
"1",
";",
"else",
"break",
";",
"}",
"if",
"(",
"seq",
"&&",
"addr",
">=",
"seq",
"->",
"low_pc",
"&&",
"addr",
"<",
"seq",
"->",
"last_line",
"->",
"address",
")",
"{",
"for",
"(",
"each_line",
"=",
"seq",
"->",
"last_line",
";",
"each_line",
";",
"each_line",
"=",
"each_line",
"->",
"prev_line",
")",
"if",
"(",
"addr",
">=",
"each_line",
"->",
"address",
")",
"break",
";",
"if",
"(",
"each_line",
"&&",
"!",
"(",
"each_line",
"->",
"end_sequence",
"||",
"each_line",
"==",
"seq",
"->",
"last_line",
")",
")",
"{",
"*",
"filename_ptr",
"=",
"each_line",
"->",
"filename",
";",
"*",
"linenumber_ptr",
"=",
"each_line",
"->",
"line",
";",
"if",
"(",
"discriminator_ptr",
")",
"*",
"discriminator_ptr",
"=",
"each_line",
"->",
"discriminator",
";",
"return",
"seq",
"->",
"last_line",
"->",
"address",
"-",
"seq",
"->",
"low_pc",
";",
"}",
"}",
"*",
"filename_ptr",
"=",
"NULL",
";",
"return",
"0",
";",
"}"
] | If ADDR is within TABLE set the output parameters and return the
range of addresses covered by the entry used to fill them out. | [
"If",
"ADDR",
"is",
"within",
"TABLE",
"set",
"the",
"output",
"parameters",
"and",
"return",
"the",
"range",
"of",
"addresses",
"covered",
"by",
"the",
"entry",
"used",
"to",
"fill",
"them",
"out",
"."
] | [
"/* Binary search the array of sequences. */",
"/* Note: seq->last_line should be a descendingly sorted list. */"
] | [
{
"param": "table",
"type": "struct line_info_table"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
},
{
"param": "discriminator_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": "struct line_info_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "discriminator_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | read_debug_ranges | bfd_boolean | static bfd_boolean
read_debug_ranges (struct comp_unit *unit)
{
struct dwarf2_debug *stash = unit->stash;
return read_section (unit->abfd, &stash->debug_sections[debug_ranges],
stash->syms, 0,
&stash->dwarf_ranges_buffer, &stash->dwarf_ranges_size);
} | /* Read in the .debug_ranges section for future reference. */ | Read in the .debug_ranges section for future reference. | [
"Read",
"in",
"the",
".",
"debug_ranges",
"section",
"for",
"future",
"reference",
"."
] | static bfd_boolean
read_debug_ranges (struct comp_unit *unit)
{
struct dwarf2_debug *stash = unit->stash;
return read_section (unit->abfd, &stash->debug_sections[debug_ranges],
stash->syms, 0,
&stash->dwarf_ranges_buffer, &stash->dwarf_ranges_size);
} | [
"static",
"bfd_boolean",
"read_debug_ranges",
"(",
"struct",
"comp_unit",
"*",
"unit",
")",
"{",
"struct",
"dwarf2_debug",
"*",
"stash",
"=",
"unit",
"->",
"stash",
";",
"return",
"read_section",
"(",
"unit",
"->",
"abfd",
",",
"&",
"stash",
"->",
"debug_sections",
"[",
"debug_ranges",
"]",
",",
"stash",
"->",
"syms",
",",
"0",
",",
"&",
"stash",
"->",
"dwarf_ranges_buffer",
",",
"&",
"stash",
"->",
"dwarf_ranges_size",
")",
";",
"}"
] | Read in the .debug_ranges section for future reference. | [
"Read",
"in",
"the",
".",
"debug_ranges",
"section",
"for",
"future",
"reference",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_address_in_function_table | bfd_boolean | static bfd_boolean
lookup_address_in_function_table (struct comp_unit *unit,
bfd_vma addr,
struct funcinfo **function_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct arange *arange;
for (each_func = unit->function_table;
each_func;
each_func = each_func->prev_func)
{
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if (addr >= arange->low && addr < arange->high)
{
if (!best_fit
|| arange->high - arange->low < best_fit_len)
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
}
if (best_fit)
{
*function_ptr = best_fit;
return TRUE;
}
return FALSE;
} | /* If ADDR is within UNIT's function tables, set FUNCTION_PTR, and return
TRUE. Note that we need to find the function that has the smallest range
that contains ADDR, to handle inlined functions without depending upon
them being ordered in TABLE by increasing range. */ | If ADDR is within UNIT's function tables, set FUNCTION_PTR, and return
TRUE. Note that we need to find the function that has the smallest range
that contains ADDR, to handle inlined functions without depending upon
them being ordered in TABLE by increasing range. | [
"If",
"ADDR",
"is",
"within",
"UNIT",
"'",
"s",
"function",
"tables",
"set",
"FUNCTION_PTR",
"and",
"return",
"TRUE",
".",
"Note",
"that",
"we",
"need",
"to",
"find",
"the",
"function",
"that",
"has",
"the",
"smallest",
"range",
"that",
"contains",
"ADDR",
"to",
"handle",
"inlined",
"functions",
"without",
"depending",
"upon",
"them",
"being",
"ordered",
"in",
"TABLE",
"by",
"increasing",
"range",
"."
] | static bfd_boolean
lookup_address_in_function_table (struct comp_unit *unit,
bfd_vma addr,
struct funcinfo **function_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct arange *arange;
for (each_func = unit->function_table;
each_func;
each_func = each_func->prev_func)
{
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if (addr >= arange->low && addr < arange->high)
{
if (!best_fit
|| arange->high - arange->low < best_fit_len)
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
}
if (best_fit)
{
*function_ptr = best_fit;
return TRUE;
}
return FALSE;
} | [
"static",
"bfd_boolean",
"lookup_address_in_function_table",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_vma",
"addr",
",",
"struct",
"funcinfo",
"*",
"*",
"function_ptr",
")",
"{",
"struct",
"funcinfo",
"*",
"each_func",
";",
"struct",
"funcinfo",
"*",
"best_fit",
"=",
"NULL",
";",
"bfd_vma",
"best_fit_len",
"=",
"0",
";",
"struct",
"arange",
"*",
"arange",
";",
"for",
"(",
"each_func",
"=",
"unit",
"->",
"function_table",
";",
"each_func",
";",
"each_func",
"=",
"each_func",
"->",
"prev_func",
")",
"{",
"for",
"(",
"arange",
"=",
"&",
"each_func",
"->",
"arange",
";",
"arange",
";",
"arange",
"=",
"arange",
"->",
"next",
")",
"{",
"if",
"(",
"addr",
">=",
"arange",
"->",
"low",
"&&",
"addr",
"<",
"arange",
"->",
"high",
")",
"{",
"if",
"(",
"!",
"best_fit",
"||",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
"<",
"best_fit_len",
")",
"{",
"best_fit",
"=",
"each_func",
";",
"best_fit_len",
"=",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"best_fit",
")",
"{",
"*",
"function_ptr",
"=",
"best_fit",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | If ADDR is within UNIT's function tables, set FUNCTION_PTR, and return
TRUE. | [
"If",
"ADDR",
"is",
"within",
"UNIT",
"'",
"s",
"function",
"tables",
"set",
"FUNCTION_PTR",
"and",
"return",
"TRUE",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "function_ptr",
"type": "struct funcinfo"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "function_ptr",
"type": "struct funcinfo",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_symbol_in_function_table | bfd_boolean | static bfd_boolean
lookup_symbol_in_function_table (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
for (each_func = unit->function_table;
each_func;
each_func = each_func->prev_func)
{
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if ((!each_func->sec || each_func->sec == sec)
&& addr >= arange->low
&& addr < arange->high
&& each_func->name
&& strcmp (name, each_func->name) == 0
&& (!best_fit
|| arange->high - arange->low < best_fit_len))
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
if (best_fit)
{
best_fit->sec = sec;
*filename_ptr = best_fit->file;
*linenumber_ptr = best_fit->line;
return TRUE;
}
else
return FALSE;
} | /* If SYM at ADDR is within function table of UNIT, set FILENAME_PTR
and LINENUMBER_PTR, and return TRUE. */ | If SYM at ADDR is within function table of UNIT, set FILENAME_PTR
and LINENUMBER_PTR, and return TRUE. | [
"If",
"SYM",
"at",
"ADDR",
"is",
"within",
"function",
"table",
"of",
"UNIT",
"set",
"FILENAME_PTR",
"and",
"LINENUMBER_PTR",
"and",
"return",
"TRUE",
"."
] | static bfd_boolean
lookup_symbol_in_function_table (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
for (each_func = unit->function_table;
each_func;
each_func = each_func->prev_func)
{
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if ((!each_func->sec || each_func->sec == sec)
&& addr >= arange->low
&& addr < arange->high
&& each_func->name
&& strcmp (name, each_func->name) == 0
&& (!best_fit
|| arange->high - arange->low < best_fit_len))
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
if (best_fit)
{
best_fit->sec = sec;
*filename_ptr = best_fit->file;
*linenumber_ptr = best_fit->line;
return TRUE;
}
else
return FALSE;
} | [
"static",
"bfd_boolean",
"lookup_symbol_in_function_table",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
")",
"{",
"struct",
"funcinfo",
"*",
"each_func",
";",
"struct",
"funcinfo",
"*",
"best_fit",
"=",
"NULL",
";",
"bfd_vma",
"best_fit_len",
"=",
"0",
";",
"struct",
"arange",
"*",
"arange",
";",
"const",
"char",
"*",
"name",
"=",
"bfd_asymbol_name",
"(",
"sym",
")",
";",
"asection",
"*",
"sec",
"=",
"bfd_get_section",
"(",
"sym",
")",
";",
"for",
"(",
"each_func",
"=",
"unit",
"->",
"function_table",
";",
"each_func",
";",
"each_func",
"=",
"each_func",
"->",
"prev_func",
")",
"{",
"for",
"(",
"arange",
"=",
"&",
"each_func",
"->",
"arange",
";",
"arange",
";",
"arange",
"=",
"arange",
"->",
"next",
")",
"{",
"if",
"(",
"(",
"!",
"each_func",
"->",
"sec",
"||",
"each_func",
"->",
"sec",
"==",
"sec",
")",
"&&",
"addr",
">=",
"arange",
"->",
"low",
"&&",
"addr",
"<",
"arange",
"->",
"high",
"&&",
"each_func",
"->",
"name",
"&&",
"strcmp",
"(",
"name",
",",
"each_func",
"->",
"name",
")",
"==",
"0",
"&&",
"(",
"!",
"best_fit",
"||",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
"<",
"best_fit_len",
")",
")",
"{",
"best_fit",
"=",
"each_func",
";",
"best_fit_len",
"=",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
";",
"}",
"}",
"}",
"if",
"(",
"best_fit",
")",
"{",
"best_fit",
"->",
"sec",
"=",
"sec",
";",
"*",
"filename_ptr",
"=",
"best_fit",
"->",
"file",
";",
"*",
"linenumber_ptr",
"=",
"best_fit",
"->",
"line",
";",
"return",
"TRUE",
";",
"}",
"else",
"return",
"FALSE",
";",
"}"
] | If SYM at ADDR is within function table of UNIT, set FILENAME_PTR
and LINENUMBER_PTR, and return TRUE. | [
"If",
"SYM",
"at",
"ADDR",
"is",
"within",
"function",
"table",
"of",
"UNIT",
"set",
"FILENAME_PTR",
"and",
"LINENUMBER_PTR",
"and",
"return",
"TRUE",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | lookup_symbol_in_variable_table | bfd_boolean | static bfd_boolean
lookup_symbol_in_variable_table (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
struct varinfo* each;
for (each = unit->variable_table; each; each = each->prev_var)
if (each->stack == 0
&& each->file != NULL
&& each->name != NULL
&& each->addr == addr
&& (!each->sec || each->sec == sec)
&& strcmp (name, each->name) == 0)
break;
if (each)
{
each->sec = sec;
*filename_ptr = each->file;
*linenumber_ptr = each->line;
return TRUE;
}
else
return FALSE;
} | /* If SYM is within variable table of UNIT, set FILENAME_PTR and
LINENUMBER_PTR, and return TRUE. */ | If SYM is within variable table of UNIT, set FILENAME_PTR and
LINENUMBER_PTR, and return TRUE. | [
"If",
"SYM",
"is",
"within",
"variable",
"table",
"of",
"UNIT",
"set",
"FILENAME_PTR",
"and",
"LINENUMBER_PTR",
"and",
"return",
"TRUE",
"."
] | static bfd_boolean
lookup_symbol_in_variable_table (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
struct varinfo* each;
for (each = unit->variable_table; each; each = each->prev_var)
if (each->stack == 0
&& each->file != NULL
&& each->name != NULL
&& each->addr == addr
&& (!each->sec || each->sec == sec)
&& strcmp (name, each->name) == 0)
break;
if (each)
{
each->sec = sec;
*filename_ptr = each->file;
*linenumber_ptr = each->line;
return TRUE;
}
else
return FALSE;
} | [
"static",
"bfd_boolean",
"lookup_symbol_in_variable_table",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
")",
"{",
"const",
"char",
"*",
"name",
"=",
"bfd_asymbol_name",
"(",
"sym",
")",
";",
"asection",
"*",
"sec",
"=",
"bfd_get_section",
"(",
"sym",
")",
";",
"struct",
"varinfo",
"*",
"each",
";",
"for",
"(",
"each",
"=",
"unit",
"->",
"variable_table",
";",
"each",
";",
"each",
"=",
"each",
"->",
"prev_var",
")",
"if",
"(",
"each",
"->",
"stack",
"==",
"0",
"&&",
"each",
"->",
"file",
"!=",
"NULL",
"&&",
"each",
"->",
"name",
"!=",
"NULL",
"&&",
"each",
"->",
"addr",
"==",
"addr",
"&&",
"(",
"!",
"each",
"->",
"sec",
"||",
"each",
"->",
"sec",
"==",
"sec",
")",
"&&",
"strcmp",
"(",
"name",
",",
"each",
"->",
"name",
")",
"==",
"0",
")",
"break",
";",
"if",
"(",
"each",
")",
"{",
"each",
"->",
"sec",
"=",
"sec",
";",
"*",
"filename_ptr",
"=",
"each",
"->",
"file",
";",
"*",
"linenumber_ptr",
"=",
"each",
"->",
"line",
";",
"return",
"TRUE",
";",
"}",
"else",
"return",
"FALSE",
";",
"}"
] | If SYM is within variable table of UNIT, set FILENAME_PTR and
LINENUMBER_PTR, and return TRUE. | [
"If",
"SYM",
"is",
"within",
"variable",
"table",
"of",
"UNIT",
"set",
"FILENAME_PTR",
"and",
"LINENUMBER_PTR",
"and",
"return",
"TRUE",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | parse_comp_unit | null | static struct comp_unit *
parse_comp_unit (struct dwarf2_debug *stash,
bfd_vma unit_length,
bfd_byte *info_ptr_unit,
unsigned int offset_size)
{
struct comp_unit* unit;
unsigned int version;
bfd_uint64_t abbrev_offset = 0;
unsigned int addr_size;
struct abbrev_info** abbrevs;
unsigned int abbrev_number, bytes_read, i;
struct abbrev_info *abbrev;
struct attribute attr;
bfd_byte *info_ptr = stash->info_ptr;
bfd_byte *end_ptr = info_ptr + unit_length;
bfd_size_type amt;
bfd_vma low_pc = 0;
bfd_vma high_pc = 0;
bfd *abfd = stash->bfd_ptr;
bfd_boolean high_pc_relative = FALSE;
version = read_2_bytes (abfd, info_ptr, end_ptr);
info_ptr += 2;
BFD_ASSERT (offset_size == 4 || offset_size == 8);
if (offset_size == 4)
abbrev_offset = read_4_bytes (abfd, info_ptr, end_ptr);
else
abbrev_offset = read_8_bytes (abfd, info_ptr, end_ptr);
info_ptr += offset_size;
addr_size = read_1_byte (abfd, info_ptr, end_ptr);
info_ptr += 1;
if (version != 2 && version != 3 && version != 4)
{
/* PR 19872: A version number of 0 probably means that there is padding
at the end of the .debug_info section. Gold puts it there when
performing an incremental link, for example. So do not generate
an error, just return a NULL. */
if (version)
{
(*_bfd_error_handler)
(_("Dwarf Error: found dwarf version '%u', this reader"
" only handles version 2, 3 and 4 information."), version);
bfd_set_error (bfd_error_bad_value);
}
return NULL;
}
if (addr_size > sizeof (bfd_vma))
{
(*_bfd_error_handler)
(_("Dwarf Error: found address size '%u', this reader"
" can not handle sizes greater than '%u'."),
addr_size,
(unsigned int) sizeof (bfd_vma));
bfd_set_error (bfd_error_bad_value);
return NULL;
}
if (addr_size != 2 && addr_size != 4 && addr_size != 8)
{
(*_bfd_error_handler)
("Dwarf Error: found address size '%u', this reader"
" can only handle address sizes '2', '4' and '8'.", addr_size);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
/* Read the abbrevs for this compilation unit into a table. */
abbrevs = read_abbrevs (abfd, abbrev_offset, stash);
if (! abbrevs)
return NULL;
abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, end_ptr);
info_ptr += bytes_read;
if (! abbrev_number)
{
/* PR 19872: An abbrev number of 0 probably means that there is padding
at the end of the .debug_abbrev section. Gold puts it there when
performing an incremental link, for example. So do not generate
an error, just return a NULL. */
return NULL;
}
abbrev = lookup_abbrev (abbrev_number, abbrevs);
if (! abbrev)
{
(*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
abbrev_number);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
amt = sizeof (struct comp_unit);
unit = (struct comp_unit *) bfd_zalloc (abfd, amt);
if (unit == NULL)
return NULL;
unit->abfd = abfd;
unit->version = version;
unit->addr_size = addr_size;
unit->offset_size = offset_size;
unit->abbrevs = abbrevs;
unit->end_ptr = end_ptr;
unit->stash = stash;
unit->info_ptr_unit = info_ptr_unit;
unit->sec_info_ptr = stash->sec_info_ptr;
for (i = 0; i < abbrev->num_attrs; ++i)
{
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr);
if (info_ptr == NULL)
return NULL;
/* Store the data if it is of an attribute we want to keep in a
partial symbol table. */
switch (attr.name)
{
case DW_AT_stmt_list:
unit->stmtlist = 1;
unit->line_offset = attr.u.val;
break;
case DW_AT_name:
unit->name = attr.u.str;
break;
case DW_AT_low_pc:
low_pc = attr.u.val;
/* If the compilation unit DIE has a DW_AT_low_pc attribute,
this is the base address to use when reading location
lists or range lists. */
if (abbrev->tag == DW_TAG_compile_unit)
unit->base_address = low_pc;
break;
case DW_AT_high_pc:
high_pc = attr.u.val;
high_pc_relative = attr.form != DW_FORM_addr;
break;
case DW_AT_ranges:
if (!read_rangelist (unit, &unit->arange, attr.u.val))
return NULL;
break;
case DW_AT_comp_dir:
{
char *comp_dir = attr.u.str;
/* PR 17512: file: 1fe726be. */
if (! is_str_attr (attr.form))
{
(*_bfd_error_handler)
(_("Dwarf Error: DW_AT_comp_dir attribute encountered with a non-string form."));
comp_dir = NULL;
}
if (comp_dir)
{
/* Irix 6.2 native cc prepends <machine>.: to the compilation
directory, get rid of it. */
char *cp = strchr (comp_dir, ':');
if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
comp_dir = cp + 1;
}
unit->comp_dir = comp_dir;
break;
}
case DW_AT_language:
unit->lang = attr.u.val;
break;
default:
break;
}
}
if (high_pc_relative)
high_pc += low_pc;
if (high_pc != 0)
{
if (!arange_add (unit, &unit->arange, low_pc, high_pc))
return NULL;
}
unit->first_child_die_ptr = info_ptr;
return unit;
} | /* Parse a DWARF2 compilation unit starting at INFO_PTR. This
includes the compilation unit header that proceeds the DIE's, but
does not include the length field that precedes each compilation
unit header. END_PTR points one past the end of this comp unit.
OFFSET_SIZE is the size of DWARF2 offsets (either 4 or 8 bytes).
This routine does not read the whole compilation unit; only enough
to get to the line number information for the compilation unit. */ | Parse a DWARF2 compilation unit starting at INFO_PTR. This
includes the compilation unit header that proceeds the DIE's, but
does not include the length field that precedes each compilation
unit header. END_PTR points one past the end of this comp unit.
OFFSET_SIZE is the size of DWARF2 offsets (either 4 or 8 bytes).
This routine does not read the whole compilation unit; only enough
to get to the line number information for the compilation unit. | [
"Parse",
"a",
"DWARF2",
"compilation",
"unit",
"starting",
"at",
"INFO_PTR",
".",
"This",
"includes",
"the",
"compilation",
"unit",
"header",
"that",
"proceeds",
"the",
"DIE",
"'",
"s",
"but",
"does",
"not",
"include",
"the",
"length",
"field",
"that",
"precedes",
"each",
"compilation",
"unit",
"header",
".",
"END_PTR",
"points",
"one",
"past",
"the",
"end",
"of",
"this",
"comp",
"unit",
".",
"OFFSET_SIZE",
"is",
"the",
"size",
"of",
"DWARF2",
"offsets",
"(",
"either",
"4",
"or",
"8",
"bytes",
")",
".",
"This",
"routine",
"does",
"not",
"read",
"the",
"whole",
"compilation",
"unit",
";",
"only",
"enough",
"to",
"get",
"to",
"the",
"line",
"number",
"information",
"for",
"the",
"compilation",
"unit",
"."
] | static struct comp_unit *
parse_comp_unit (struct dwarf2_debug *stash,
bfd_vma unit_length,
bfd_byte *info_ptr_unit,
unsigned int offset_size)
{
struct comp_unit* unit;
unsigned int version;
bfd_uint64_t abbrev_offset = 0;
unsigned int addr_size;
struct abbrev_info** abbrevs;
unsigned int abbrev_number, bytes_read, i;
struct abbrev_info *abbrev;
struct attribute attr;
bfd_byte *info_ptr = stash->info_ptr;
bfd_byte *end_ptr = info_ptr + unit_length;
bfd_size_type amt;
bfd_vma low_pc = 0;
bfd_vma high_pc = 0;
bfd *abfd = stash->bfd_ptr;
bfd_boolean high_pc_relative = FALSE;
version = read_2_bytes (abfd, info_ptr, end_ptr);
info_ptr += 2;
BFD_ASSERT (offset_size == 4 || offset_size == 8);
if (offset_size == 4)
abbrev_offset = read_4_bytes (abfd, info_ptr, end_ptr);
else
abbrev_offset = read_8_bytes (abfd, info_ptr, end_ptr);
info_ptr += offset_size;
addr_size = read_1_byte (abfd, info_ptr, end_ptr);
info_ptr += 1;
if (version != 2 && version != 3 && version != 4)
{
if (version)
{
(*_bfd_error_handler)
(_("Dwarf Error: found dwarf version '%u', this reader"
" only handles version 2, 3 and 4 information."), version);
bfd_set_error (bfd_error_bad_value);
}
return NULL;
}
if (addr_size > sizeof (bfd_vma))
{
(*_bfd_error_handler)
(_("Dwarf Error: found address size '%u', this reader"
" can not handle sizes greater than '%u'."),
addr_size,
(unsigned int) sizeof (bfd_vma));
bfd_set_error (bfd_error_bad_value);
return NULL;
}
if (addr_size != 2 && addr_size != 4 && addr_size != 8)
{
(*_bfd_error_handler)
("Dwarf Error: found address size '%u', this reader"
" can only handle address sizes '2', '4' and '8'.", addr_size);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
abbrevs = read_abbrevs (abfd, abbrev_offset, stash);
if (! abbrevs)
return NULL;
abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, end_ptr);
info_ptr += bytes_read;
if (! abbrev_number)
{
return NULL;
}
abbrev = lookup_abbrev (abbrev_number, abbrevs);
if (! abbrev)
{
(*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
abbrev_number);
bfd_set_error (bfd_error_bad_value);
return NULL;
}
amt = sizeof (struct comp_unit);
unit = (struct comp_unit *) bfd_zalloc (abfd, amt);
if (unit == NULL)
return NULL;
unit->abfd = abfd;
unit->version = version;
unit->addr_size = addr_size;
unit->offset_size = offset_size;
unit->abbrevs = abbrevs;
unit->end_ptr = end_ptr;
unit->stash = stash;
unit->info_ptr_unit = info_ptr_unit;
unit->sec_info_ptr = stash->sec_info_ptr;
for (i = 0; i < abbrev->num_attrs; ++i)
{
info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr);
if (info_ptr == NULL)
return NULL;
switch (attr.name)
{
case DW_AT_stmt_list:
unit->stmtlist = 1;
unit->line_offset = attr.u.val;
break;
case DW_AT_name:
unit->name = attr.u.str;
break;
case DW_AT_low_pc:
low_pc = attr.u.val;
if (abbrev->tag == DW_TAG_compile_unit)
unit->base_address = low_pc;
break;
case DW_AT_high_pc:
high_pc = attr.u.val;
high_pc_relative = attr.form != DW_FORM_addr;
break;
case DW_AT_ranges:
if (!read_rangelist (unit, &unit->arange, attr.u.val))
return NULL;
break;
case DW_AT_comp_dir:
{
char *comp_dir = attr.u.str;
if (! is_str_attr (attr.form))
{
(*_bfd_error_handler)
(_("Dwarf Error: DW_AT_comp_dir attribute encountered with a non-string form."));
comp_dir = NULL;
}
if (comp_dir)
{
char *cp = strchr (comp_dir, ':');
if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/')
comp_dir = cp + 1;
}
unit->comp_dir = comp_dir;
break;
}
case DW_AT_language:
unit->lang = attr.u.val;
break;
default:
break;
}
}
if (high_pc_relative)
high_pc += low_pc;
if (high_pc != 0)
{
if (!arange_add (unit, &unit->arange, low_pc, high_pc))
return NULL;
}
unit->first_child_die_ptr = info_ptr;
return unit;
} | [
"static",
"struct",
"comp_unit",
"*",
"parse_comp_unit",
"(",
"struct",
"dwarf2_debug",
"*",
"stash",
",",
"bfd_vma",
"unit_length",
",",
"bfd_byte",
"*",
"info_ptr_unit",
",",
"unsigned",
"int",
"offset_size",
")",
"{",
"struct",
"comp_unit",
"*",
"unit",
";",
"unsigned",
"int",
"version",
";",
"bfd_uint64_t",
"abbrev_offset",
"=",
"0",
";",
"unsigned",
"int",
"addr_size",
";",
"struct",
"abbrev_info",
"*",
"*",
"abbrevs",
";",
"unsigned",
"int",
"abbrev_number",
",",
"bytes_read",
",",
"i",
";",
"struct",
"abbrev_info",
"*",
"abbrev",
";",
"struct",
"attribute",
"attr",
";",
"bfd_byte",
"*",
"info_ptr",
"=",
"stash",
"->",
"info_ptr",
";",
"bfd_byte",
"*",
"end_ptr",
"=",
"info_ptr",
"+",
"unit_length",
";",
"bfd_size_type",
"amt",
";",
"bfd_vma",
"low_pc",
"=",
"0",
";",
"bfd_vma",
"high_pc",
"=",
"0",
";",
"bfd",
"*",
"abfd",
"=",
"stash",
"->",
"bfd_ptr",
";",
"bfd_boolean",
"high_pc_relative",
"=",
"FALSE",
";",
"version",
"=",
"read_2_bytes",
"(",
"abfd",
",",
"info_ptr",
",",
"end_ptr",
")",
";",
"info_ptr",
"+=",
"2",
";",
"BFD_ASSERT",
"(",
"offset_size",
"==",
"4",
"||",
"offset_size",
"==",
"8",
")",
";",
"if",
"(",
"offset_size",
"==",
"4",
")",
"abbrev_offset",
"=",
"read_4_bytes",
"(",
"abfd",
",",
"info_ptr",
",",
"end_ptr",
")",
";",
"else",
"abbrev_offset",
"=",
"read_8_bytes",
"(",
"abfd",
",",
"info_ptr",
",",
"end_ptr",
")",
";",
"info_ptr",
"+=",
"offset_size",
";",
"addr_size",
"=",
"read_1_byte",
"(",
"abfd",
",",
"info_ptr",
",",
"end_ptr",
")",
";",
"info_ptr",
"+=",
"1",
";",
"if",
"(",
"version",
"!=",
"2",
"&&",
"version",
"!=",
"3",
"&&",
"version",
"!=",
"4",
")",
"{",
"if",
"(",
"version",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"version",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"}",
"return",
"NULL",
";",
"}",
"if",
"(",
"addr_size",
">",
"sizeof",
"(",
"bfd_vma",
")",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
"\"",
"\"",
")",
",",
"addr_size",
",",
"(",
"unsigned",
"int",
")",
"sizeof",
"(",
"bfd_vma",
")",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"return",
"NULL",
";",
"}",
"if",
"(",
"addr_size",
"!=",
"2",
"&&",
"addr_size",
"!=",
"4",
"&&",
"addr_size",
"!=",
"8",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"\"",
"\"",
"\"",
"\"",
",",
"addr_size",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"return",
"NULL",
";",
"}",
"abbrevs",
"=",
"read_abbrevs",
"(",
"abfd",
",",
"abbrev_offset",
",",
"stash",
")",
";",
"if",
"(",
"!",
"abbrevs",
")",
"return",
"NULL",
";",
"abbrev_number",
"=",
"safe_read_leb128",
"(",
"abfd",
",",
"info_ptr",
",",
"&",
"bytes_read",
",",
"FALSE",
",",
"end_ptr",
")",
";",
"info_ptr",
"+=",
"bytes_read",
";",
"if",
"(",
"!",
"abbrev_number",
")",
"{",
"return",
"NULL",
";",
"}",
"abbrev",
"=",
"lookup_abbrev",
"(",
"abbrev_number",
",",
"abbrevs",
")",
";",
"if",
"(",
"!",
"abbrev",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
")",
",",
"abbrev_number",
")",
";",
"bfd_set_error",
"(",
"bfd_error_bad_value",
")",
";",
"return",
"NULL",
";",
"}",
"amt",
"=",
"sizeof",
"(",
"struct",
"comp_unit",
")",
";",
"unit",
"=",
"(",
"struct",
"comp_unit",
"*",
")",
"bfd_zalloc",
"(",
"abfd",
",",
"amt",
")",
";",
"if",
"(",
"unit",
"==",
"NULL",
")",
"return",
"NULL",
";",
"unit",
"->",
"abfd",
"=",
"abfd",
";",
"unit",
"->",
"version",
"=",
"version",
";",
"unit",
"->",
"addr_size",
"=",
"addr_size",
";",
"unit",
"->",
"offset_size",
"=",
"offset_size",
";",
"unit",
"->",
"abbrevs",
"=",
"abbrevs",
";",
"unit",
"->",
"end_ptr",
"=",
"end_ptr",
";",
"unit",
"->",
"stash",
"=",
"stash",
";",
"unit",
"->",
"info_ptr_unit",
"=",
"info_ptr_unit",
";",
"unit",
"->",
"sec_info_ptr",
"=",
"stash",
"->",
"sec_info_ptr",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"abbrev",
"->",
"num_attrs",
";",
"++",
"i",
")",
"{",
"info_ptr",
"=",
"read_attribute",
"(",
"&",
"attr",
",",
"&",
"abbrev",
"->",
"attrs",
"[",
"i",
"]",
",",
"unit",
",",
"info_ptr",
",",
"end_ptr",
")",
";",
"if",
"(",
"info_ptr",
"==",
"NULL",
")",
"return",
"NULL",
";",
"switch",
"(",
"attr",
".",
"name",
")",
"{",
"case",
"DW_AT_stmt_list",
":",
"unit",
"->",
"stmtlist",
"=",
"1",
";",
"unit",
"->",
"line_offset",
"=",
"attr",
".",
"u",
".",
"val",
";",
"break",
";",
"case",
"DW_AT_name",
":",
"unit",
"->",
"name",
"=",
"attr",
".",
"u",
".",
"str",
";",
"break",
";",
"case",
"DW_AT_low_pc",
":",
"low_pc",
"=",
"attr",
".",
"u",
".",
"val",
";",
"if",
"(",
"abbrev",
"->",
"tag",
"==",
"DW_TAG_compile_unit",
")",
"unit",
"->",
"base_address",
"=",
"low_pc",
";",
"break",
";",
"case",
"DW_AT_high_pc",
":",
"high_pc",
"=",
"attr",
".",
"u",
".",
"val",
";",
"high_pc_relative",
"=",
"attr",
".",
"form",
"!=",
"DW_FORM_addr",
";",
"break",
";",
"case",
"DW_AT_ranges",
":",
"if",
"(",
"!",
"read_rangelist",
"(",
"unit",
",",
"&",
"unit",
"->",
"arange",
",",
"attr",
".",
"u",
".",
"val",
")",
")",
"return",
"NULL",
";",
"break",
";",
"case",
"DW_AT_comp_dir",
":",
"{",
"char",
"*",
"comp_dir",
"=",
"attr",
".",
"u",
".",
"str",
";",
"if",
"(",
"!",
"is_str_attr",
"(",
"attr",
".",
"form",
")",
")",
"{",
"(",
"*",
"_bfd_error_handler",
")",
"(",
"_",
"(",
"\"",
"\"",
")",
")",
";",
"comp_dir",
"=",
"NULL",
";",
"}",
"if",
"(",
"comp_dir",
")",
"{",
"char",
"*",
"cp",
"=",
"strchr",
"(",
"comp_dir",
",",
"'",
"'",
")",
";",
"if",
"(",
"cp",
"&&",
"cp",
"!=",
"comp_dir",
"&&",
"cp",
"[",
"-1",
"]",
"==",
"'",
"'",
"&&",
"cp",
"[",
"1",
"]",
"==",
"'",
"'",
")",
"comp_dir",
"=",
"cp",
"+",
"1",
";",
"}",
"unit",
"->",
"comp_dir",
"=",
"comp_dir",
";",
"break",
";",
"}",
"case",
"DW_AT_language",
":",
"unit",
"->",
"lang",
"=",
"attr",
".",
"u",
".",
"val",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"if",
"(",
"high_pc_relative",
")",
"high_pc",
"+=",
"low_pc",
";",
"if",
"(",
"high_pc",
"!=",
"0",
")",
"{",
"if",
"(",
"!",
"arange_add",
"(",
"unit",
",",
"&",
"unit",
"->",
"arange",
",",
"low_pc",
",",
"high_pc",
")",
")",
"return",
"NULL",
";",
"}",
"unit",
"->",
"first_child_die_ptr",
"=",
"info_ptr",
";",
"return",
"unit",
";",
"}"
] | Parse a DWARF2 compilation unit starting at INFO_PTR. | [
"Parse",
"a",
"DWARF2",
"compilation",
"unit",
"starting",
"at",
"INFO_PTR",
"."
] | [
"/* PR 19872: A version number of 0 probably means that there is padding\n\t at the end of the .debug_info section. Gold puts it there when\n\t performing an incremental link, for example. So do not generate\n\t an error, just return a NULL. */",
"/* Read the abbrevs for this compilation unit into a table. */",
"/* PR 19872: An abbrev number of 0 probably means that there is padding\n\t at the end of the .debug_abbrev section. Gold puts it there when\n\t performing an incremental link, for example. So do not generate\n\t an error, just return a NULL. */",
"/* Store the data if it is of an attribute we want to keep in a\n\t partial symbol table. */",
"/* If the compilation unit DIE has a DW_AT_low_pc attribute,\n\t this is the base address to use when reading location\n\t lists or range lists. */",
"/* PR 17512: file: 1fe726be. */",
"/* Irix 6.2 native cc prepends <machine>.: to the compilation\n\t\t directory, get rid of it. */"
] | [
{
"param": "stash",
"type": "struct dwarf2_debug"
},
{
"param": "unit_length",
"type": "bfd_vma"
},
{
"param": "info_ptr_unit",
"type": "bfd_byte"
},
{
"param": "offset_size",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unit_length",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "info_ptr_unit",
"type": "bfd_byte",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset_size",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | comp_unit_contains_address | bfd_boolean | static bfd_boolean
comp_unit_contains_address (struct comp_unit *unit, bfd_vma addr)
{
struct arange *arange;
if (unit->error)
return FALSE;
arange = &unit->arange;
do
{
if (addr >= arange->low && addr < arange->high)
return TRUE;
arange = arange->next;
}
while (arange);
return FALSE;
} | /* Return TRUE if UNIT may contain the address given by ADDR. When
there are functions written entirely with inline asm statements, the
range info in the compilation unit header may not be correct. We
need to consult the line info table to see if a compilation unit
really contains the given address. */ | Return TRUE if UNIT may contain the address given by ADDR. When
there are functions written entirely with inline asm statements, the
range info in the compilation unit header may not be correct. We
need to consult the line info table to see if a compilation unit
really contains the given address. | [
"Return",
"TRUE",
"if",
"UNIT",
"may",
"contain",
"the",
"address",
"given",
"by",
"ADDR",
".",
"When",
"there",
"are",
"functions",
"written",
"entirely",
"with",
"inline",
"asm",
"statements",
"the",
"range",
"info",
"in",
"the",
"compilation",
"unit",
"header",
"may",
"not",
"be",
"correct",
".",
"We",
"need",
"to",
"consult",
"the",
"line",
"info",
"table",
"to",
"see",
"if",
"a",
"compilation",
"unit",
"really",
"contains",
"the",
"given",
"address",
"."
] | static bfd_boolean
comp_unit_contains_address (struct comp_unit *unit, bfd_vma addr)
{
struct arange *arange;
if (unit->error)
return FALSE;
arange = &unit->arange;
do
{
if (addr >= arange->low && addr < arange->high)
return TRUE;
arange = arange->next;
}
while (arange);
return FALSE;
} | [
"static",
"bfd_boolean",
"comp_unit_contains_address",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_vma",
"addr",
")",
"{",
"struct",
"arange",
"*",
"arange",
";",
"if",
"(",
"unit",
"->",
"error",
")",
"return",
"FALSE",
";",
"arange",
"=",
"&",
"unit",
"->",
"arange",
";",
"do",
"{",
"if",
"(",
"addr",
">=",
"arange",
"->",
"low",
"&&",
"addr",
"<",
"arange",
"->",
"high",
")",
"return",
"TRUE",
";",
"arange",
"=",
"arange",
"->",
"next",
";",
"}",
"while",
"(",
"arange",
")",
";",
"return",
"FALSE",
";",
"}"
] | Return TRUE if UNIT may contain the address given by ADDR. | [
"Return",
"TRUE",
"if",
"UNIT",
"may",
"contain",
"the",
"address",
"given",
"by",
"ADDR",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "addr",
"type": "bfd_vma"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | comp_unit_find_nearest_line | bfd_vma | static bfd_vma
comp_unit_find_nearest_line (struct comp_unit *unit,
bfd_vma addr,
const char **filename_ptr,
struct funcinfo **function_ptr,
unsigned int *linenumber_ptr,
unsigned int *discriminator_ptr,
struct dwarf2_debug *stash)
{
bfd_boolean func_p;
if (unit->error)
return FALSE;
if (! unit->line_table)
{
if (! unit->stmtlist)
{
unit->error = 1;
return FALSE;
}
unit->line_table = decode_line_info (unit, stash);
if (! unit->line_table)
{
unit->error = 1;
return FALSE;
}
if (unit->first_child_die_ptr < unit->end_ptr
&& ! scan_unit_for_symbols (unit))
{
unit->error = 1;
return FALSE;
}
}
*function_ptr = NULL;
func_p = lookup_address_in_function_table (unit, addr, function_ptr);
if (func_p && (*function_ptr)->tag == DW_TAG_inlined_subroutine)
stash->inliner_chain = *function_ptr;
return lookup_address_in_line_info_table (unit->line_table, addr,
filename_ptr,
linenumber_ptr,
discriminator_ptr);
} | /* If UNIT contains ADDR, set the output parameters to the values for
the line containing ADDR. The output parameters, FILENAME_PTR,
FUNCTION_PTR, and LINENUMBER_PTR, are pointers to the objects
to be filled in.
Returns the range of addresses covered by the entry that was used
to fill in *LINENUMBER_PTR or 0 if it was not filled in. */ | If UNIT contains ADDR, set the output parameters to the values for
the line containing ADDR. The output parameters, FILENAME_PTR,
FUNCTION_PTR, and LINENUMBER_PTR, are pointers to the objects
to be filled in.
Returns the range of addresses covered by the entry that was used
to fill in *LINENUMBER_PTR or 0 if it was not filled in. | [
"If",
"UNIT",
"contains",
"ADDR",
"set",
"the",
"output",
"parameters",
"to",
"the",
"values",
"for",
"the",
"line",
"containing",
"ADDR",
".",
"The",
"output",
"parameters",
"FILENAME_PTR",
"FUNCTION_PTR",
"and",
"LINENUMBER_PTR",
"are",
"pointers",
"to",
"the",
"objects",
"to",
"be",
"filled",
"in",
".",
"Returns",
"the",
"range",
"of",
"addresses",
"covered",
"by",
"the",
"entry",
"that",
"was",
"used",
"to",
"fill",
"in",
"*",
"LINENUMBER_PTR",
"or",
"0",
"if",
"it",
"was",
"not",
"filled",
"in",
"."
] | static bfd_vma
comp_unit_find_nearest_line (struct comp_unit *unit,
bfd_vma addr,
const char **filename_ptr,
struct funcinfo **function_ptr,
unsigned int *linenumber_ptr,
unsigned int *discriminator_ptr,
struct dwarf2_debug *stash)
{
bfd_boolean func_p;
if (unit->error)
return FALSE;
if (! unit->line_table)
{
if (! unit->stmtlist)
{
unit->error = 1;
return FALSE;
}
unit->line_table = decode_line_info (unit, stash);
if (! unit->line_table)
{
unit->error = 1;
return FALSE;
}
if (unit->first_child_die_ptr < unit->end_ptr
&& ! scan_unit_for_symbols (unit))
{
unit->error = 1;
return FALSE;
}
}
*function_ptr = NULL;
func_p = lookup_address_in_function_table (unit, addr, function_ptr);
if (func_p && (*function_ptr)->tag == DW_TAG_inlined_subroutine)
stash->inliner_chain = *function_ptr;
return lookup_address_in_line_info_table (unit->line_table, addr,
filename_ptr,
linenumber_ptr,
discriminator_ptr);
} | [
"static",
"bfd_vma",
"comp_unit_find_nearest_line",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"struct",
"funcinfo",
"*",
"*",
"function_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
",",
"unsigned",
"int",
"*",
"discriminator_ptr",
",",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"bfd_boolean",
"func_p",
";",
"if",
"(",
"unit",
"->",
"error",
")",
"return",
"FALSE",
";",
"if",
"(",
"!",
"unit",
"->",
"line_table",
")",
"{",
"if",
"(",
"!",
"unit",
"->",
"stmtlist",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"unit",
"->",
"line_table",
"=",
"decode_line_info",
"(",
"unit",
",",
"stash",
")",
";",
"if",
"(",
"!",
"unit",
"->",
"line_table",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"if",
"(",
"unit",
"->",
"first_child_die_ptr",
"<",
"unit",
"->",
"end_ptr",
"&&",
"!",
"scan_unit_for_symbols",
"(",
"unit",
")",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"}",
"*",
"function_ptr",
"=",
"NULL",
";",
"func_p",
"=",
"lookup_address_in_function_table",
"(",
"unit",
",",
"addr",
",",
"function_ptr",
")",
";",
"if",
"(",
"func_p",
"&&",
"(",
"*",
"function_ptr",
")",
"->",
"tag",
"==",
"DW_TAG_inlined_subroutine",
")",
"stash",
"->",
"inliner_chain",
"=",
"*",
"function_ptr",
";",
"return",
"lookup_address_in_line_info_table",
"(",
"unit",
"->",
"line_table",
",",
"addr",
",",
"filename_ptr",
",",
"linenumber_ptr",
",",
"discriminator_ptr",
")",
";",
"}"
] | If UNIT contains ADDR, set the output parameters to the values for
the line containing ADDR. | [
"If",
"UNIT",
"contains",
"ADDR",
"set",
"the",
"output",
"parameters",
"to",
"the",
"values",
"for",
"the",
"line",
"containing",
"ADDR",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "function_ptr",
"type": "struct funcinfo"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
},
{
"param": "discriminator_ptr",
"type": "unsigned int"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "function_ptr",
"type": "struct funcinfo",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "discriminator_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | comp_unit_maybe_decode_line_info | bfd_boolean | static bfd_boolean
comp_unit_maybe_decode_line_info (struct comp_unit *unit,
struct dwarf2_debug *stash)
{
if (unit->error)
return FALSE;
if (! unit->line_table)
{
if (! unit->stmtlist)
{
unit->error = 1;
return FALSE;
}
unit->line_table = decode_line_info (unit, stash);
if (! unit->line_table)
{
unit->error = 1;
return FALSE;
}
if (unit->first_child_die_ptr < unit->end_ptr
&& ! scan_unit_for_symbols (unit))
{
unit->error = 1;
return FALSE;
}
}
return TRUE;
} | /* Check to see if line info is already decoded in a comp_unit.
If not, decode it. Returns TRUE if no errors were encountered;
FALSE otherwise. */ | Check to see if line info is already decoded in a comp_unit.
If not, decode it. Returns TRUE if no errors were encountered;
FALSE otherwise. | [
"Check",
"to",
"see",
"if",
"line",
"info",
"is",
"already",
"decoded",
"in",
"a",
"comp_unit",
".",
"If",
"not",
"decode",
"it",
".",
"Returns",
"TRUE",
"if",
"no",
"errors",
"were",
"encountered",
";",
"FALSE",
"otherwise",
"."
] | static bfd_boolean
comp_unit_maybe_decode_line_info (struct comp_unit *unit,
struct dwarf2_debug *stash)
{
if (unit->error)
return FALSE;
if (! unit->line_table)
{
if (! unit->stmtlist)
{
unit->error = 1;
return FALSE;
}
unit->line_table = decode_line_info (unit, stash);
if (! unit->line_table)
{
unit->error = 1;
return FALSE;
}
if (unit->first_child_die_ptr < unit->end_ptr
&& ! scan_unit_for_symbols (unit))
{
unit->error = 1;
return FALSE;
}
}
return TRUE;
} | [
"static",
"bfd_boolean",
"comp_unit_maybe_decode_line_info",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"if",
"(",
"unit",
"->",
"error",
")",
"return",
"FALSE",
";",
"if",
"(",
"!",
"unit",
"->",
"line_table",
")",
"{",
"if",
"(",
"!",
"unit",
"->",
"stmtlist",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"unit",
"->",
"line_table",
"=",
"decode_line_info",
"(",
"unit",
",",
"stash",
")",
";",
"if",
"(",
"!",
"unit",
"->",
"line_table",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"if",
"(",
"unit",
"->",
"first_child_die_ptr",
"<",
"unit",
"->",
"end_ptr",
"&&",
"!",
"scan_unit_for_symbols",
"(",
"unit",
")",
")",
"{",
"unit",
"->",
"error",
"=",
"1",
";",
"return",
"FALSE",
";",
"}",
"}",
"return",
"TRUE",
";",
"}"
] | Check to see if line info is already decoded in a comp_unit. | [
"Check",
"to",
"see",
"if",
"line",
"info",
"is",
"already",
"decoded",
"in",
"a",
"comp_unit",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | comp_unit_find_line | bfd_boolean | static bfd_boolean
comp_unit_find_line (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr,
struct dwarf2_debug *stash)
{
if (!comp_unit_maybe_decode_line_info (unit, stash))
return FALSE;
if (sym->flags & BSF_FUNCTION)
return lookup_symbol_in_function_table (unit, sym, addr,
filename_ptr,
linenumber_ptr);
return lookup_symbol_in_variable_table (unit, sym, addr,
filename_ptr,
linenumber_ptr);
} | /* If UNIT contains SYM at ADDR, set the output parameters to the
values for the line containing SYM. The output parameters,
FILENAME_PTR, and LINENUMBER_PTR, are pointers to the objects to be
filled in.
Return TRUE if UNIT contains SYM, and no errors were encountered;
FALSE otherwise. */ | If UNIT contains SYM at ADDR, set the output parameters to the
values for the line containing SYM. The output parameters,
FILENAME_PTR, and LINENUMBER_PTR, are pointers to the objects to be
filled in.
| [
"If",
"UNIT",
"contains",
"SYM",
"at",
"ADDR",
"set",
"the",
"output",
"parameters",
"to",
"the",
"values",
"for",
"the",
"line",
"containing",
"SYM",
".",
"The",
"output",
"parameters",
"FILENAME_PTR",
"and",
"LINENUMBER_PTR",
"are",
"pointers",
"to",
"the",
"objects",
"to",
"be",
"filled",
"in",
"."
] | static bfd_boolean
comp_unit_find_line (struct comp_unit *unit,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr,
struct dwarf2_debug *stash)
{
if (!comp_unit_maybe_decode_line_info (unit, stash))
return FALSE;
if (sym->flags & BSF_FUNCTION)
return lookup_symbol_in_function_table (unit, sym, addr,
filename_ptr,
linenumber_ptr);
return lookup_symbol_in_variable_table (unit, sym, addr,
filename_ptr,
linenumber_ptr);
} | [
"static",
"bfd_boolean",
"comp_unit_find_line",
"(",
"struct",
"comp_unit",
"*",
"unit",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
",",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"if",
"(",
"!",
"comp_unit_maybe_decode_line_info",
"(",
"unit",
",",
"stash",
")",
")",
"return",
"FALSE",
";",
"if",
"(",
"sym",
"->",
"flags",
"&",
"BSF_FUNCTION",
")",
"return",
"lookup_symbol_in_function_table",
"(",
"unit",
",",
"sym",
",",
"addr",
",",
"filename_ptr",
",",
"linenumber_ptr",
")",
";",
"return",
"lookup_symbol_in_variable_table",
"(",
"unit",
",",
"sym",
",",
"addr",
",",
"filename_ptr",
",",
"linenumber_ptr",
")",
";",
"}"
] | If UNIT contains SYM at ADDR, set the output parameters to the
values for the line containing SYM. | [
"If",
"UNIT",
"contains",
"SYM",
"at",
"ADDR",
"set",
"the",
"output",
"parameters",
"to",
"the",
"values",
"for",
"the",
"line",
"containing",
"SYM",
"."
] | [] | [
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | comp_unit_hash_info | bfd_boolean | static bfd_boolean
comp_unit_hash_info (struct dwarf2_debug *stash,
struct comp_unit *unit,
struct info_hash_table *funcinfo_hash_table,
struct info_hash_table *varinfo_hash_table)
{
struct funcinfo* each_func;
struct varinfo* each_var;
bfd_boolean okay = TRUE;
BFD_ASSERT (stash->info_hash_status != STASH_INFO_HASH_DISABLED);
if (!comp_unit_maybe_decode_line_info (unit, stash))
return FALSE;
BFD_ASSERT (!unit->cached);
/* To preserve the original search order, we went to visit the function
infos in the reversed order of the list. However, making the list
bi-directional use quite a bit of extra memory. So we reverse
the list first, traverse the list in the now reversed order and
finally reverse the list again to get back the original order. */
unit->function_table = reverse_funcinfo_list (unit->function_table);
for (each_func = unit->function_table;
each_func && okay;
each_func = each_func->prev_func)
{
/* Skip nameless functions. */
if (each_func->name)
/* There is no need to copy name string into hash table as
name string is either in the dwarf string buffer or
info in the stash. */
okay = insert_info_hash_table (funcinfo_hash_table, each_func->name,
(void*) each_func, FALSE);
}
unit->function_table = reverse_funcinfo_list (unit->function_table);
if (!okay)
return FALSE;
/* We do the same for variable infos. */
unit->variable_table = reverse_varinfo_list (unit->variable_table);
for (each_var = unit->variable_table;
each_var && okay;
each_var = each_var->prev_var)
{
/* Skip stack vars and vars with no files or names. */
if (each_var->stack == 0
&& each_var->file != NULL
&& each_var->name != NULL)
/* There is no need to copy name string into hash table as
name string is either in the dwarf string buffer or
info in the stash. */
okay = insert_info_hash_table (varinfo_hash_table, each_var->name,
(void*) each_var, FALSE);
}
unit->variable_table = reverse_varinfo_list (unit->variable_table);
unit->cached = TRUE;
return okay;
} | /* Extract all interesting funcinfos and varinfos of a compilation
unit into hash tables for faster lookup. Returns TRUE if no
errors were enountered; FALSE otherwise. */ | Extract all interesting funcinfos and varinfos of a compilation
unit into hash tables for faster lookup. Returns TRUE if no
errors were enountered; FALSE otherwise. | [
"Extract",
"all",
"interesting",
"funcinfos",
"and",
"varinfos",
"of",
"a",
"compilation",
"unit",
"into",
"hash",
"tables",
"for",
"faster",
"lookup",
".",
"Returns",
"TRUE",
"if",
"no",
"errors",
"were",
"enountered",
";",
"FALSE",
"otherwise",
"."
] | static bfd_boolean
comp_unit_hash_info (struct dwarf2_debug *stash,
struct comp_unit *unit,
struct info_hash_table *funcinfo_hash_table,
struct info_hash_table *varinfo_hash_table)
{
struct funcinfo* each_func;
struct varinfo* each_var;
bfd_boolean okay = TRUE;
BFD_ASSERT (stash->info_hash_status != STASH_INFO_HASH_DISABLED);
if (!comp_unit_maybe_decode_line_info (unit, stash))
return FALSE;
BFD_ASSERT (!unit->cached);
unit->function_table = reverse_funcinfo_list (unit->function_table);
for (each_func = unit->function_table;
each_func && okay;
each_func = each_func->prev_func)
{
if (each_func->name)
okay = insert_info_hash_table (funcinfo_hash_table, each_func->name,
(void*) each_func, FALSE);
}
unit->function_table = reverse_funcinfo_list (unit->function_table);
if (!okay)
return FALSE;
unit->variable_table = reverse_varinfo_list (unit->variable_table);
for (each_var = unit->variable_table;
each_var && okay;
each_var = each_var->prev_var)
{
if (each_var->stack == 0
&& each_var->file != NULL
&& each_var->name != NULL)
okay = insert_info_hash_table (varinfo_hash_table, each_var->name,
(void*) each_var, FALSE);
}
unit->variable_table = reverse_varinfo_list (unit->variable_table);
unit->cached = TRUE;
return okay;
} | [
"static",
"bfd_boolean",
"comp_unit_hash_info",
"(",
"struct",
"dwarf2_debug",
"*",
"stash",
",",
"struct",
"comp_unit",
"*",
"unit",
",",
"struct",
"info_hash_table",
"*",
"funcinfo_hash_table",
",",
"struct",
"info_hash_table",
"*",
"varinfo_hash_table",
")",
"{",
"struct",
"funcinfo",
"*",
"each_func",
";",
"struct",
"varinfo",
"*",
"each_var",
";",
"bfd_boolean",
"okay",
"=",
"TRUE",
";",
"BFD_ASSERT",
"(",
"stash",
"->",
"info_hash_status",
"!=",
"STASH_INFO_HASH_DISABLED",
")",
";",
"if",
"(",
"!",
"comp_unit_maybe_decode_line_info",
"(",
"unit",
",",
"stash",
")",
")",
"return",
"FALSE",
";",
"BFD_ASSERT",
"(",
"!",
"unit",
"->",
"cached",
")",
";",
"unit",
"->",
"function_table",
"=",
"reverse_funcinfo_list",
"(",
"unit",
"->",
"function_table",
")",
";",
"for",
"(",
"each_func",
"=",
"unit",
"->",
"function_table",
";",
"each_func",
"&&",
"okay",
";",
"each_func",
"=",
"each_func",
"->",
"prev_func",
")",
"{",
"if",
"(",
"each_func",
"->",
"name",
")",
"okay",
"=",
"insert_info_hash_table",
"(",
"funcinfo_hash_table",
",",
"each_func",
"->",
"name",
",",
"(",
"void",
"*",
")",
"each_func",
",",
"FALSE",
")",
";",
"}",
"unit",
"->",
"function_table",
"=",
"reverse_funcinfo_list",
"(",
"unit",
"->",
"function_table",
")",
";",
"if",
"(",
"!",
"okay",
")",
"return",
"FALSE",
";",
"unit",
"->",
"variable_table",
"=",
"reverse_varinfo_list",
"(",
"unit",
"->",
"variable_table",
")",
";",
"for",
"(",
"each_var",
"=",
"unit",
"->",
"variable_table",
";",
"each_var",
"&&",
"okay",
";",
"each_var",
"=",
"each_var",
"->",
"prev_var",
")",
"{",
"if",
"(",
"each_var",
"->",
"stack",
"==",
"0",
"&&",
"each_var",
"->",
"file",
"!=",
"NULL",
"&&",
"each_var",
"->",
"name",
"!=",
"NULL",
")",
"okay",
"=",
"insert_info_hash_table",
"(",
"varinfo_hash_table",
",",
"each_var",
"->",
"name",
",",
"(",
"void",
"*",
")",
"each_var",
",",
"FALSE",
")",
";",
"}",
"unit",
"->",
"variable_table",
"=",
"reverse_varinfo_list",
"(",
"unit",
"->",
"variable_table",
")",
";",
"unit",
"->",
"cached",
"=",
"TRUE",
";",
"return",
"okay",
";",
"}"
] | Extract all interesting funcinfos and varinfos of a compilation
unit into hash tables for faster lookup. | [
"Extract",
"all",
"interesting",
"funcinfos",
"and",
"varinfos",
"of",
"a",
"compilation",
"unit",
"into",
"hash",
"tables",
"for",
"faster",
"lookup",
"."
] | [
"/* To preserve the original search order, we went to visit the function\n infos in the reversed order of the list. However, making the list\n bi-directional use quite a bit of extra memory. So we reverse\n the list first, traverse the list in the now reversed order and\n finally reverse the list again to get back the original order. */",
"/* Skip nameless functions. */",
"/* There is no need to copy name string into hash table as\n\t name string is either in the dwarf string buffer or\n\t info in the stash. */",
"/* We do the same for variable infos. */",
"/* Skip stack vars and vars with no files or names. */",
"/* There is no need to copy name string into hash table as\n\t name string is either in the dwarf string buffer or\n\t info in the stash. */"
] | [
{
"param": "stash",
"type": "struct dwarf2_debug"
},
{
"param": "unit",
"type": "struct comp_unit"
},
{
"param": "funcinfo_hash_table",
"type": "struct info_hash_table"
},
{
"param": "varinfo_hash_table",
"type": "struct info_hash_table"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unit",
"type": "struct comp_unit",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "funcinfo_hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "varinfo_hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | unset_sections | void | static void
unset_sections (struct dwarf2_debug *stash)
{
int i;
struct adjusted_section *p;
i = stash->adjusted_section_count;
p = stash->adjusted_sections;
for (; i > 0; i--, p++)
p->section->vma = 0;
} | /* Unset vmas for adjusted sections in STASH. */ | Unset vmas for adjusted sections in STASH. | [
"Unset",
"vmas",
"for",
"adjusted",
"sections",
"in",
"STASH",
"."
] | static void
unset_sections (struct dwarf2_debug *stash)
{
int i;
struct adjusted_section *p;
i = stash->adjusted_section_count;
p = stash->adjusted_sections;
for (; i > 0; i--, p++)
p->section->vma = 0;
} | [
"static",
"void",
"unset_sections",
"(",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"int",
"i",
";",
"struct",
"adjusted_section",
"*",
"p",
";",
"i",
"=",
"stash",
"->",
"adjusted_section_count",
";",
"p",
"=",
"stash",
"->",
"adjusted_sections",
";",
"for",
"(",
";",
"i",
">",
"0",
";",
"i",
"--",
",",
"p",
"++",
")",
"p",
"->",
"section",
"->",
"vma",
"=",
"0",
";",
"}"
] | Unset vmas for adjusted sections in STASH. | [
"Unset",
"vmas",
"for",
"adjusted",
"sections",
"in",
"STASH",
"."
] | [] | [
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | place_sections | bfd_boolean | static bfd_boolean
place_sections (bfd *orig_bfd, struct dwarf2_debug *stash)
{
bfd *abfd;
struct adjusted_section *p;
int i;
const char *debug_info_name;
if (stash->adjusted_section_count != 0)
{
i = stash->adjusted_section_count;
p = stash->adjusted_sections;
for (; i > 0; i--, p++)
p->section->vma = p->adj_vma;
return TRUE;
}
debug_info_name = stash->debug_sections[debug_info].uncompressed_name;
i = 0;
abfd = orig_bfd;
while (1)
{
asection *sect;
for (sect = abfd->sections; sect != NULL; sect = sect->next)
{
int is_debug_info;
if ((sect->output_section != NULL
&& sect->output_section != sect
&& (sect->flags & SEC_DEBUGGING) == 0)
|| sect->vma != 0)
continue;
is_debug_info = (strcmp (sect->name, debug_info_name) == 0
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO));
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd)
&& !is_debug_info)
continue;
i++;
}
if (abfd == stash->bfd_ptr)
break;
abfd = stash->bfd_ptr;
}
if (i <= 1)
stash->adjusted_section_count = -1;
else
{
bfd_vma last_vma = 0, last_dwarf = 0;
bfd_size_type amt = i * sizeof (struct adjusted_section);
p = (struct adjusted_section *) bfd_malloc (amt);
if (p == NULL)
return FALSE;
stash->adjusted_sections = p;
stash->adjusted_section_count = i;
abfd = orig_bfd;
while (1)
{
asection *sect;
for (sect = abfd->sections; sect != NULL; sect = sect->next)
{
bfd_size_type sz;
int is_debug_info;
if ((sect->output_section != NULL
&& sect->output_section != sect
&& (sect->flags & SEC_DEBUGGING) == 0)
|| sect->vma != 0)
continue;
is_debug_info = (strcmp (sect->name, debug_info_name) == 0
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO));
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd)
&& !is_debug_info)
continue;
sz = sect->rawsize ? sect->rawsize : sect->size;
if (is_debug_info)
{
BFD_ASSERT (sect->alignment_power == 0);
sect->vma = last_dwarf;
last_dwarf += sz;
}
else
{
/* Align the new address to the current section
alignment. */
last_vma = ((last_vma
+ ~(-((bfd_vma) 1 << sect->alignment_power)))
& (-((bfd_vma) 1 << sect->alignment_power)));
sect->vma = last_vma;
last_vma += sz;
}
p->section = sect;
p->adj_vma = sect->vma;
p++;
}
if (abfd == stash->bfd_ptr)
break;
abfd = stash->bfd_ptr;
}
}
if (orig_bfd != stash->bfd_ptr)
set_debug_vma (orig_bfd, stash->bfd_ptr);
return TRUE;
} | /* Set VMAs for allocated and .debug_info sections in ORIG_BFD, a
relocatable object file. VMAs are normally all zero in relocatable
object files, so if we want to distinguish locations in sections by
address we need to set VMAs so the sections do not overlap. We
also set VMA on .debug_info so that when we have multiple
.debug_info sections (or the linkonce variant) they also do not
overlap. The multiple .debug_info sections make up a single
logical section. ??? We should probably do the same for other
debug sections. */ | Set VMAs for allocated and .debug_info sections in ORIG_BFD, a
relocatable object file. VMAs are normally all zero in relocatable
object files, so if we want to distinguish locations in sections by
address we need to set VMAs so the sections do not overlap. We
also set VMA on .debug_info so that when we have multiple
.debug_info sections (or the linkonce variant) they also do not
overlap. The multiple .debug_info sections make up a single
logical section. | [
"Set",
"VMAs",
"for",
"allocated",
"and",
".",
"debug_info",
"sections",
"in",
"ORIG_BFD",
"a",
"relocatable",
"object",
"file",
".",
"VMAs",
"are",
"normally",
"all",
"zero",
"in",
"relocatable",
"object",
"files",
"so",
"if",
"we",
"want",
"to",
"distinguish",
"locations",
"in",
"sections",
"by",
"address",
"we",
"need",
"to",
"set",
"VMAs",
"so",
"the",
"sections",
"do",
"not",
"overlap",
".",
"We",
"also",
"set",
"VMA",
"on",
".",
"debug_info",
"so",
"that",
"when",
"we",
"have",
"multiple",
".",
"debug_info",
"sections",
"(",
"or",
"the",
"linkonce",
"variant",
")",
"they",
"also",
"do",
"not",
"overlap",
".",
"The",
"multiple",
".",
"debug_info",
"sections",
"make",
"up",
"a",
"single",
"logical",
"section",
"."
] | static bfd_boolean
place_sections (bfd *orig_bfd, struct dwarf2_debug *stash)
{
bfd *abfd;
struct adjusted_section *p;
int i;
const char *debug_info_name;
if (stash->adjusted_section_count != 0)
{
i = stash->adjusted_section_count;
p = stash->adjusted_sections;
for (; i > 0; i--, p++)
p->section->vma = p->adj_vma;
return TRUE;
}
debug_info_name = stash->debug_sections[debug_info].uncompressed_name;
i = 0;
abfd = orig_bfd;
while (1)
{
asection *sect;
for (sect = abfd->sections; sect != NULL; sect = sect->next)
{
int is_debug_info;
if ((sect->output_section != NULL
&& sect->output_section != sect
&& (sect->flags & SEC_DEBUGGING) == 0)
|| sect->vma != 0)
continue;
is_debug_info = (strcmp (sect->name, debug_info_name) == 0
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO));
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd)
&& !is_debug_info)
continue;
i++;
}
if (abfd == stash->bfd_ptr)
break;
abfd = stash->bfd_ptr;
}
if (i <= 1)
stash->adjusted_section_count = -1;
else
{
bfd_vma last_vma = 0, last_dwarf = 0;
bfd_size_type amt = i * sizeof (struct adjusted_section);
p = (struct adjusted_section *) bfd_malloc (amt);
if (p == NULL)
return FALSE;
stash->adjusted_sections = p;
stash->adjusted_section_count = i;
abfd = orig_bfd;
while (1)
{
asection *sect;
for (sect = abfd->sections; sect != NULL; sect = sect->next)
{
bfd_size_type sz;
int is_debug_info;
if ((sect->output_section != NULL
&& sect->output_section != sect
&& (sect->flags & SEC_DEBUGGING) == 0)
|| sect->vma != 0)
continue;
is_debug_info = (strcmp (sect->name, debug_info_name) == 0
|| CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO));
if (!((sect->flags & SEC_ALLOC) != 0 && abfd == orig_bfd)
&& !is_debug_info)
continue;
sz = sect->rawsize ? sect->rawsize : sect->size;
if (is_debug_info)
{
BFD_ASSERT (sect->alignment_power == 0);
sect->vma = last_dwarf;
last_dwarf += sz;
}
else
{
last_vma = ((last_vma
+ ~(-((bfd_vma) 1 << sect->alignment_power)))
& (-((bfd_vma) 1 << sect->alignment_power)));
sect->vma = last_vma;
last_vma += sz;
}
p->section = sect;
p->adj_vma = sect->vma;
p++;
}
if (abfd == stash->bfd_ptr)
break;
abfd = stash->bfd_ptr;
}
}
if (orig_bfd != stash->bfd_ptr)
set_debug_vma (orig_bfd, stash->bfd_ptr);
return TRUE;
} | [
"static",
"bfd_boolean",
"place_sections",
"(",
"bfd",
"*",
"orig_bfd",
",",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"bfd",
"*",
"abfd",
";",
"struct",
"adjusted_section",
"*",
"p",
";",
"int",
"i",
";",
"const",
"char",
"*",
"debug_info_name",
";",
"if",
"(",
"stash",
"->",
"adjusted_section_count",
"!=",
"0",
")",
"{",
"i",
"=",
"stash",
"->",
"adjusted_section_count",
";",
"p",
"=",
"stash",
"->",
"adjusted_sections",
";",
"for",
"(",
";",
"i",
">",
"0",
";",
"i",
"--",
",",
"p",
"++",
")",
"p",
"->",
"section",
"->",
"vma",
"=",
"p",
"->",
"adj_vma",
";",
"return",
"TRUE",
";",
"}",
"debug_info_name",
"=",
"stash",
"->",
"debug_sections",
"[",
"debug_info",
"]",
".",
"uncompressed_name",
";",
"i",
"=",
"0",
";",
"abfd",
"=",
"orig_bfd",
";",
"while",
"(",
"1",
")",
"{",
"asection",
"*",
"sect",
";",
"for",
"(",
"sect",
"=",
"abfd",
"->",
"sections",
";",
"sect",
"!=",
"NULL",
";",
"sect",
"=",
"sect",
"->",
"next",
")",
"{",
"int",
"is_debug_info",
";",
"if",
"(",
"(",
"sect",
"->",
"output_section",
"!=",
"NULL",
"&&",
"sect",
"->",
"output_section",
"!=",
"sect",
"&&",
"(",
"sect",
"->",
"flags",
"&",
"SEC_DEBUGGING",
")",
"==",
"0",
")",
"||",
"sect",
"->",
"vma",
"!=",
"0",
")",
"continue",
";",
"is_debug_info",
"=",
"(",
"strcmp",
"(",
"sect",
"->",
"name",
",",
"debug_info_name",
")",
"==",
"0",
"||",
"CONST_STRNEQ",
"(",
"sect",
"->",
"name",
",",
"GNU_LINKONCE_INFO",
")",
")",
";",
"if",
"(",
"!",
"(",
"(",
"sect",
"->",
"flags",
"&",
"SEC_ALLOC",
")",
"!=",
"0",
"&&",
"abfd",
"==",
"orig_bfd",
")",
"&&",
"!",
"is_debug_info",
")",
"continue",
";",
"i",
"++",
";",
"}",
"if",
"(",
"abfd",
"==",
"stash",
"->",
"bfd_ptr",
")",
"break",
";",
"abfd",
"=",
"stash",
"->",
"bfd_ptr",
";",
"}",
"if",
"(",
"i",
"<=",
"1",
")",
"stash",
"->",
"adjusted_section_count",
"=",
"-1",
";",
"else",
"{",
"bfd_vma",
"last_vma",
"=",
"0",
",",
"last_dwarf",
"=",
"0",
";",
"bfd_size_type",
"amt",
"=",
"i",
"*",
"sizeof",
"(",
"struct",
"adjusted_section",
")",
";",
"p",
"=",
"(",
"struct",
"adjusted_section",
"*",
")",
"bfd_malloc",
"(",
"amt",
")",
";",
"if",
"(",
"p",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"stash",
"->",
"adjusted_sections",
"=",
"p",
";",
"stash",
"->",
"adjusted_section_count",
"=",
"i",
";",
"abfd",
"=",
"orig_bfd",
";",
"while",
"(",
"1",
")",
"{",
"asection",
"*",
"sect",
";",
"for",
"(",
"sect",
"=",
"abfd",
"->",
"sections",
";",
"sect",
"!=",
"NULL",
";",
"sect",
"=",
"sect",
"->",
"next",
")",
"{",
"bfd_size_type",
"sz",
";",
"int",
"is_debug_info",
";",
"if",
"(",
"(",
"sect",
"->",
"output_section",
"!=",
"NULL",
"&&",
"sect",
"->",
"output_section",
"!=",
"sect",
"&&",
"(",
"sect",
"->",
"flags",
"&",
"SEC_DEBUGGING",
")",
"==",
"0",
")",
"||",
"sect",
"->",
"vma",
"!=",
"0",
")",
"continue",
";",
"is_debug_info",
"=",
"(",
"strcmp",
"(",
"sect",
"->",
"name",
",",
"debug_info_name",
")",
"==",
"0",
"||",
"CONST_STRNEQ",
"(",
"sect",
"->",
"name",
",",
"GNU_LINKONCE_INFO",
")",
")",
";",
"if",
"(",
"!",
"(",
"(",
"sect",
"->",
"flags",
"&",
"SEC_ALLOC",
")",
"!=",
"0",
"&&",
"abfd",
"==",
"orig_bfd",
")",
"&&",
"!",
"is_debug_info",
")",
"continue",
";",
"sz",
"=",
"sect",
"->",
"rawsize",
"?",
"sect",
"->",
"rawsize",
":",
"sect",
"->",
"size",
";",
"if",
"(",
"is_debug_info",
")",
"{",
"BFD_ASSERT",
"(",
"sect",
"->",
"alignment_power",
"==",
"0",
")",
";",
"sect",
"->",
"vma",
"=",
"last_dwarf",
";",
"last_dwarf",
"+=",
"sz",
";",
"}",
"else",
"{",
"last_vma",
"=",
"(",
"(",
"last_vma",
"+",
"~",
"(",
"-",
"(",
"(",
"bfd_vma",
")",
"1",
"<<",
"sect",
"->",
"alignment_power",
")",
")",
")",
"&",
"(",
"-",
"(",
"(",
"bfd_vma",
")",
"1",
"<<",
"sect",
"->",
"alignment_power",
")",
")",
")",
";",
"sect",
"->",
"vma",
"=",
"last_vma",
";",
"last_vma",
"+=",
"sz",
";",
"}",
"p",
"->",
"section",
"=",
"sect",
";",
"p",
"->",
"adj_vma",
"=",
"sect",
"->",
"vma",
";",
"p",
"++",
";",
"}",
"if",
"(",
"abfd",
"==",
"stash",
"->",
"bfd_ptr",
")",
"break",
";",
"abfd",
"=",
"stash",
"->",
"bfd_ptr",
";",
"}",
"}",
"if",
"(",
"orig_bfd",
"!=",
"stash",
"->",
"bfd_ptr",
")",
"set_debug_vma",
"(",
"orig_bfd",
",",
"stash",
"->",
"bfd_ptr",
")",
";",
"return",
"TRUE",
";",
"}"
] | Set VMAs for allocated and .debug_info sections in ORIG_BFD, a
relocatable object file. | [
"Set",
"VMAs",
"for",
"allocated",
"and",
".",
"debug_info",
"sections",
"in",
"ORIG_BFD",
"a",
"relocatable",
"object",
"file",
"."
] | [
"/* Align the new address to the current section\n\t\t alignment. */"
] | [
{
"param": "orig_bfd",
"type": "bfd"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "orig_bfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | info_hash_lookup_funcinfo | bfd_boolean | static bfd_boolean
info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct info_list_node *node;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
for (node = lookup_info_hash_table (hash_table, name);
node;
node = node->next)
{
each_func = (struct funcinfo *) node->info;
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if ((!each_func->sec || each_func->sec == sec)
&& addr >= arange->low
&& addr < arange->high
&& (!best_fit
|| arange->high - arange->low < best_fit_len))
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
if (best_fit)
{
best_fit->sec = sec;
*filename_ptr = best_fit->file;
*linenumber_ptr = best_fit->line;
return TRUE;
}
return FALSE;
} | /* Look up a funcinfo by name using the given info hash table. If found,
also update the locations pointed to by filename_ptr and linenumber_ptr.
This function returns TRUE if a funcinfo that matches the given symbol
and address is found with any error; otherwise it returns FALSE. */ | Look up a funcinfo by name using the given info hash table. If found,
also update the locations pointed to by filename_ptr and linenumber_ptr.
This function returns TRUE if a funcinfo that matches the given symbol
and address is found with any error; otherwise it returns FALSE. | [
"Look",
"up",
"a",
"funcinfo",
"by",
"name",
"using",
"the",
"given",
"info",
"hash",
"table",
".",
"If",
"found",
"also",
"update",
"the",
"locations",
"pointed",
"to",
"by",
"filename_ptr",
"and",
"linenumber_ptr",
".",
"This",
"function",
"returns",
"TRUE",
"if",
"a",
"funcinfo",
"that",
"matches",
"the",
"given",
"symbol",
"and",
"address",
"is",
"found",
"with",
"any",
"error",
";",
"otherwise",
"it",
"returns",
"FALSE",
"."
] | static bfd_boolean
info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
struct funcinfo* each_func;
struct funcinfo* best_fit = NULL;
bfd_vma best_fit_len = 0;
struct info_list_node *node;
struct arange *arange;
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
for (node = lookup_info_hash_table (hash_table, name);
node;
node = node->next)
{
each_func = (struct funcinfo *) node->info;
for (arange = &each_func->arange;
arange;
arange = arange->next)
{
if ((!each_func->sec || each_func->sec == sec)
&& addr >= arange->low
&& addr < arange->high
&& (!best_fit
|| arange->high - arange->low < best_fit_len))
{
best_fit = each_func;
best_fit_len = arange->high - arange->low;
}
}
}
if (best_fit)
{
best_fit->sec = sec;
*filename_ptr = best_fit->file;
*linenumber_ptr = best_fit->line;
return TRUE;
}
return FALSE;
} | [
"static",
"bfd_boolean",
"info_hash_lookup_funcinfo",
"(",
"struct",
"info_hash_table",
"*",
"hash_table",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
")",
"{",
"struct",
"funcinfo",
"*",
"each_func",
";",
"struct",
"funcinfo",
"*",
"best_fit",
"=",
"NULL",
";",
"bfd_vma",
"best_fit_len",
"=",
"0",
";",
"struct",
"info_list_node",
"*",
"node",
";",
"struct",
"arange",
"*",
"arange",
";",
"const",
"char",
"*",
"name",
"=",
"bfd_asymbol_name",
"(",
"sym",
")",
";",
"asection",
"*",
"sec",
"=",
"bfd_get_section",
"(",
"sym",
")",
";",
"for",
"(",
"node",
"=",
"lookup_info_hash_table",
"(",
"hash_table",
",",
"name",
")",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"{",
"each_func",
"=",
"(",
"struct",
"funcinfo",
"*",
")",
"node",
"->",
"info",
";",
"for",
"(",
"arange",
"=",
"&",
"each_func",
"->",
"arange",
";",
"arange",
";",
"arange",
"=",
"arange",
"->",
"next",
")",
"{",
"if",
"(",
"(",
"!",
"each_func",
"->",
"sec",
"||",
"each_func",
"->",
"sec",
"==",
"sec",
")",
"&&",
"addr",
">=",
"arange",
"->",
"low",
"&&",
"addr",
"<",
"arange",
"->",
"high",
"&&",
"(",
"!",
"best_fit",
"||",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
"<",
"best_fit_len",
")",
")",
"{",
"best_fit",
"=",
"each_func",
";",
"best_fit_len",
"=",
"arange",
"->",
"high",
"-",
"arange",
"->",
"low",
";",
"}",
"}",
"}",
"if",
"(",
"best_fit",
")",
"{",
"best_fit",
"->",
"sec",
"=",
"sec",
";",
"*",
"filename_ptr",
"=",
"best_fit",
"->",
"file",
";",
"*",
"linenumber_ptr",
"=",
"best_fit",
"->",
"line",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Look up a funcinfo by name using the given info hash table. | [
"Look",
"up",
"a",
"funcinfo",
"by",
"name",
"using",
"the",
"given",
"info",
"hash",
"table",
"."
] | [] | [
{
"param": "hash_table",
"type": "struct info_hash_table"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | info_hash_lookup_varinfo | bfd_boolean | static bfd_boolean
info_hash_lookup_varinfo (struct info_hash_table *hash_table,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
struct varinfo* each;
struct info_list_node *node;
for (node = lookup_info_hash_table (hash_table, name);
node;
node = node->next)
{
each = (struct varinfo *) node->info;
if (each->addr == addr
&& (!each->sec || each->sec == sec))
{
each->sec = sec;
*filename_ptr = each->file;
*linenumber_ptr = each->line;
return TRUE;
}
}
return FALSE;
} | /* Look up a varinfo by name using the given info hash table. If found,
also update the locations pointed to by filename_ptr and linenumber_ptr.
This function returns TRUE if a varinfo that matches the given symbol
and address is found with any error; otherwise it returns FALSE. */ | Look up a varinfo by name using the given info hash table. If found,
also update the locations pointed to by filename_ptr and linenumber_ptr.
This function returns TRUE if a varinfo that matches the given symbol
and address is found with any error; otherwise it returns FALSE. | [
"Look",
"up",
"a",
"varinfo",
"by",
"name",
"using",
"the",
"given",
"info",
"hash",
"table",
".",
"If",
"found",
"also",
"update",
"the",
"locations",
"pointed",
"to",
"by",
"filename_ptr",
"and",
"linenumber_ptr",
".",
"This",
"function",
"returns",
"TRUE",
"if",
"a",
"varinfo",
"that",
"matches",
"the",
"given",
"symbol",
"and",
"address",
"is",
"found",
"with",
"any",
"error",
";",
"otherwise",
"it",
"returns",
"FALSE",
"."
] | static bfd_boolean
info_hash_lookup_varinfo (struct info_hash_table *hash_table,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
const char *name = bfd_asymbol_name (sym);
asection *sec = bfd_get_section (sym);
struct varinfo* each;
struct info_list_node *node;
for (node = lookup_info_hash_table (hash_table, name);
node;
node = node->next)
{
each = (struct varinfo *) node->info;
if (each->addr == addr
&& (!each->sec || each->sec == sec))
{
each->sec = sec;
*filename_ptr = each->file;
*linenumber_ptr = each->line;
return TRUE;
}
}
return FALSE;
} | [
"static",
"bfd_boolean",
"info_hash_lookup_varinfo",
"(",
"struct",
"info_hash_table",
"*",
"hash_table",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
")",
"{",
"const",
"char",
"*",
"name",
"=",
"bfd_asymbol_name",
"(",
"sym",
")",
";",
"asection",
"*",
"sec",
"=",
"bfd_get_section",
"(",
"sym",
")",
";",
"struct",
"varinfo",
"*",
"each",
";",
"struct",
"info_list_node",
"*",
"node",
";",
"for",
"(",
"node",
"=",
"lookup_info_hash_table",
"(",
"hash_table",
",",
"name",
")",
";",
"node",
";",
"node",
"=",
"node",
"->",
"next",
")",
"{",
"each",
"=",
"(",
"struct",
"varinfo",
"*",
")",
"node",
"->",
"info",
";",
"if",
"(",
"each",
"->",
"addr",
"==",
"addr",
"&&",
"(",
"!",
"each",
"->",
"sec",
"||",
"each",
"->",
"sec",
"==",
"sec",
")",
")",
"{",
"each",
"->",
"sec",
"=",
"sec",
";",
"*",
"filename_ptr",
"=",
"each",
"->",
"file",
";",
"*",
"linenumber_ptr",
"=",
"each",
"->",
"line",
";",
"return",
"TRUE",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Look up a varinfo by name using the given info hash table. | [
"Look",
"up",
"a",
"varinfo",
"by",
"name",
"using",
"the",
"given",
"info",
"hash",
"table",
"."
] | [] | [
{
"param": "hash_table",
"type": "struct info_hash_table"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hash_table",
"type": "struct info_hash_table",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | stash_maybe_update_info_hash_tables | bfd_boolean | static bfd_boolean
stash_maybe_update_info_hash_tables (struct dwarf2_debug *stash)
{
struct comp_unit *each;
/* Exit if hash tables are up-to-date. */
if (stash->all_comp_units == stash->hash_units_head)
return TRUE;
if (stash->hash_units_head)
each = stash->hash_units_head->prev_unit;
else
each = stash->last_comp_unit;
while (each)
{
if (!comp_unit_hash_info (stash, each, stash->funcinfo_hash_table,
stash->varinfo_hash_table))
{
stash->info_hash_status = STASH_INFO_HASH_DISABLED;
return FALSE;
}
each = each->prev_unit;
}
stash->hash_units_head = stash->all_comp_units;
return TRUE;
} | /* Update the funcinfo and varinfo info hash tables if they are
not up to date. Returns TRUE if there is no error; otherwise
returns FALSE and disable the info hash tables. */ | Update the funcinfo and varinfo info hash tables if they are
not up to date. Returns TRUE if there is no error; otherwise
returns FALSE and disable the info hash tables. | [
"Update",
"the",
"funcinfo",
"and",
"varinfo",
"info",
"hash",
"tables",
"if",
"they",
"are",
"not",
"up",
"to",
"date",
".",
"Returns",
"TRUE",
"if",
"there",
"is",
"no",
"error",
";",
"otherwise",
"returns",
"FALSE",
"and",
"disable",
"the",
"info",
"hash",
"tables",
"."
] | static bfd_boolean
stash_maybe_update_info_hash_tables (struct dwarf2_debug *stash)
{
struct comp_unit *each;
if (stash->all_comp_units == stash->hash_units_head)
return TRUE;
if (stash->hash_units_head)
each = stash->hash_units_head->prev_unit;
else
each = stash->last_comp_unit;
while (each)
{
if (!comp_unit_hash_info (stash, each, stash->funcinfo_hash_table,
stash->varinfo_hash_table))
{
stash->info_hash_status = STASH_INFO_HASH_DISABLED;
return FALSE;
}
each = each->prev_unit;
}
stash->hash_units_head = stash->all_comp_units;
return TRUE;
} | [
"static",
"bfd_boolean",
"stash_maybe_update_info_hash_tables",
"(",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"struct",
"comp_unit",
"*",
"each",
";",
"if",
"(",
"stash",
"->",
"all_comp_units",
"==",
"stash",
"->",
"hash_units_head",
")",
"return",
"TRUE",
";",
"if",
"(",
"stash",
"->",
"hash_units_head",
")",
"each",
"=",
"stash",
"->",
"hash_units_head",
"->",
"prev_unit",
";",
"else",
"each",
"=",
"stash",
"->",
"last_comp_unit",
";",
"while",
"(",
"each",
")",
"{",
"if",
"(",
"!",
"comp_unit_hash_info",
"(",
"stash",
",",
"each",
",",
"stash",
"->",
"funcinfo_hash_table",
",",
"stash",
"->",
"varinfo_hash_table",
")",
")",
"{",
"stash",
"->",
"info_hash_status",
"=",
"STASH_INFO_HASH_DISABLED",
";",
"return",
"FALSE",
";",
"}",
"each",
"=",
"each",
"->",
"prev_unit",
";",
"}",
"stash",
"->",
"hash_units_head",
"=",
"stash",
"->",
"all_comp_units",
";",
"return",
"TRUE",
";",
"}"
] | Update the funcinfo and varinfo info hash tables if they are
not up to date. | [
"Update",
"the",
"funcinfo",
"and",
"varinfo",
"info",
"hash",
"tables",
"if",
"they",
"are",
"not",
"up",
"to",
"date",
"."
] | [
"/* Exit if hash tables are up-to-date. */"
] | [
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | stash_maybe_enable_info_hash_tables | void | static void
stash_maybe_enable_info_hash_tables (bfd *abfd, struct dwarf2_debug *stash)
{
BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_OFF);
if (stash->info_hash_count++ < STASH_INFO_HASH_TRIGGER)
return;
/* FIXME: Maybe we should check the reduce_memory_overheads
and optimize fields in the bfd_link_info structure ? */
/* Create hash tables. */
stash->funcinfo_hash_table = create_info_hash_table (abfd);
stash->varinfo_hash_table = create_info_hash_table (abfd);
if (!stash->funcinfo_hash_table || !stash->varinfo_hash_table)
{
/* Turn off info hashes if any allocation above fails. */
stash->info_hash_status = STASH_INFO_HASH_DISABLED;
return;
}
/* We need a forced update so that the info hash tables will
be created even though there is no compilation unit. That
happens if STASH_INFO_HASH_TRIGGER is 0. */
stash_maybe_update_info_hash_tables (stash);
stash->info_hash_status = STASH_INFO_HASH_ON;
} | /* Check to see if we want to enable the info hash tables, which consume
quite a bit of memory. Currently we only check the number times
bfd_dwarf2_find_line is called. In the future, we may also want to
take the number of symbols into account. */ | Check to see if we want to enable the info hash tables, which consume
quite a bit of memory. Currently we only check the number times
bfd_dwarf2_find_line is called. In the future, we may also want to
take the number of symbols into account. | [
"Check",
"to",
"see",
"if",
"we",
"want",
"to",
"enable",
"the",
"info",
"hash",
"tables",
"which",
"consume",
"quite",
"a",
"bit",
"of",
"memory",
".",
"Currently",
"we",
"only",
"check",
"the",
"number",
"times",
"bfd_dwarf2_find_line",
"is",
"called",
".",
"In",
"the",
"future",
"we",
"may",
"also",
"want",
"to",
"take",
"the",
"number",
"of",
"symbols",
"into",
"account",
"."
] | static void
stash_maybe_enable_info_hash_tables (bfd *abfd, struct dwarf2_debug *stash)
{
BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_OFF);
if (stash->info_hash_count++ < STASH_INFO_HASH_TRIGGER)
return;
stash->funcinfo_hash_table = create_info_hash_table (abfd);
stash->varinfo_hash_table = create_info_hash_table (abfd);
if (!stash->funcinfo_hash_table || !stash->varinfo_hash_table)
{
stash->info_hash_status = STASH_INFO_HASH_DISABLED;
return;
}
stash_maybe_update_info_hash_tables (stash);
stash->info_hash_status = STASH_INFO_HASH_ON;
} | [
"static",
"void",
"stash_maybe_enable_info_hash_tables",
"(",
"bfd",
"*",
"abfd",
",",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"BFD_ASSERT",
"(",
"stash",
"->",
"info_hash_status",
"==",
"STASH_INFO_HASH_OFF",
")",
";",
"if",
"(",
"stash",
"->",
"info_hash_count",
"++",
"<",
"STASH_INFO_HASH_TRIGGER",
")",
"return",
";",
"stash",
"->",
"funcinfo_hash_table",
"=",
"create_info_hash_table",
"(",
"abfd",
")",
";",
"stash",
"->",
"varinfo_hash_table",
"=",
"create_info_hash_table",
"(",
"abfd",
")",
";",
"if",
"(",
"!",
"stash",
"->",
"funcinfo_hash_table",
"||",
"!",
"stash",
"->",
"varinfo_hash_table",
")",
"{",
"stash",
"->",
"info_hash_status",
"=",
"STASH_INFO_HASH_DISABLED",
";",
"return",
";",
"}",
"stash_maybe_update_info_hash_tables",
"(",
"stash",
")",
";",
"stash",
"->",
"info_hash_status",
"=",
"STASH_INFO_HASH_ON",
";",
"}"
] | Check to see if we want to enable the info hash tables, which consume
quite a bit of memory. | [
"Check",
"to",
"see",
"if",
"we",
"want",
"to",
"enable",
"the",
"info",
"hash",
"tables",
"which",
"consume",
"quite",
"a",
"bit",
"of",
"memory",
"."
] | [
"/* FIXME: Maybe we should check the reduce_memory_overheads\n and optimize fields in the bfd_link_info structure ? */",
"/* Create hash tables. */",
"/* Turn off info hashes if any allocation above fails. */",
"/* We need a forced update so that the info hash tables will\n be created even though there is no compilation unit. That\n happens if STASH_INFO_HASH_TRIGGER is 0. */"
] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | stash_find_line_fast | bfd_boolean | static bfd_boolean
stash_find_line_fast (struct dwarf2_debug *stash,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_ON);
if (sym->flags & BSF_FUNCTION)
return info_hash_lookup_funcinfo (stash->funcinfo_hash_table, sym, addr,
filename_ptr, linenumber_ptr);
return info_hash_lookup_varinfo (stash->varinfo_hash_table, sym, addr,
filename_ptr, linenumber_ptr);
} | /* Find the file and line associated with a symbol and address using the
info hash tables of a stash. If there is a match, the function returns
TRUE and update the locations pointed to by filename_ptr and linenumber_ptr;
otherwise it returns FALSE. */ | Find the file and line associated with a symbol and address using the
info hash tables of a stash. If there is a match, the function returns
TRUE and update the locations pointed to by filename_ptr and linenumber_ptr;
otherwise it returns FALSE. | [
"Find",
"the",
"file",
"and",
"line",
"associated",
"with",
"a",
"symbol",
"and",
"address",
"using",
"the",
"info",
"hash",
"tables",
"of",
"a",
"stash",
".",
"If",
"there",
"is",
"a",
"match",
"the",
"function",
"returns",
"TRUE",
"and",
"update",
"the",
"locations",
"pointed",
"to",
"by",
"filename_ptr",
"and",
"linenumber_ptr",
";",
"otherwise",
"it",
"returns",
"FALSE",
"."
] | static bfd_boolean
stash_find_line_fast (struct dwarf2_debug *stash,
asymbol *sym,
bfd_vma addr,
const char **filename_ptr,
unsigned int *linenumber_ptr)
{
BFD_ASSERT (stash->info_hash_status == STASH_INFO_HASH_ON);
if (sym->flags & BSF_FUNCTION)
return info_hash_lookup_funcinfo (stash->funcinfo_hash_table, sym, addr,
filename_ptr, linenumber_ptr);
return info_hash_lookup_varinfo (stash->varinfo_hash_table, sym, addr,
filename_ptr, linenumber_ptr);
} | [
"static",
"bfd_boolean",
"stash_find_line_fast",
"(",
"struct",
"dwarf2_debug",
"*",
"stash",
",",
"asymbol",
"*",
"sym",
",",
"bfd_vma",
"addr",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"unsigned",
"int",
"*",
"linenumber_ptr",
")",
"{",
"BFD_ASSERT",
"(",
"stash",
"->",
"info_hash_status",
"==",
"STASH_INFO_HASH_ON",
")",
";",
"if",
"(",
"sym",
"->",
"flags",
"&",
"BSF_FUNCTION",
")",
"return",
"info_hash_lookup_funcinfo",
"(",
"stash",
"->",
"funcinfo_hash_table",
",",
"sym",
",",
"addr",
",",
"filename_ptr",
",",
"linenumber_ptr",
")",
";",
"return",
"info_hash_lookup_varinfo",
"(",
"stash",
"->",
"varinfo_hash_table",
",",
"sym",
",",
"addr",
",",
"filename_ptr",
",",
"linenumber_ptr",
")",
";",
"}"
] | Find the file and line associated with a symbol and address using the
info hash tables of a stash. | [
"Find",
"the",
"file",
"and",
"line",
"associated",
"with",
"a",
"symbol",
"and",
"address",
"using",
"the",
"info",
"hash",
"tables",
"of",
"a",
"stash",
"."
] | [] | [
{
"param": "stash",
"type": "struct dwarf2_debug"
},
{
"param": "sym",
"type": "asymbol"
},
{
"param": "addr",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "linenumber_ptr",
"type": "unsigned int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sym",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linenumber_ptr",
"type": "unsigned int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | section_vma_same | bfd_boolean | static bfd_boolean
section_vma_same (const bfd *abfd, const struct dwarf2_debug *stash)
{
asection *s;
unsigned int i;
for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
{
bfd_vma vma;
if (s->output_section != NULL)
vma = s->output_section->vma + s->output_offset;
else
vma = s->vma;
if (vma != stash->sec_vma[i])
return FALSE;
}
return TRUE;
} | /* Compare current section VMAs against those at the time the stash
was created. If find_nearest_line is used in linker warnings or
errors early in the link process, the debug info stash will be
invalid for later calls. This is because we relocate debug info
sections, so the stashed section contents depend on symbol values,
which in turn depend on section VMAs. */ | Compare current section VMAs against those at the time the stash
was created. If find_nearest_line is used in linker warnings or
errors early in the link process, the debug info stash will be
invalid for later calls. This is because we relocate debug info
sections, so the stashed section contents depend on symbol values,
which in turn depend on section VMAs. | [
"Compare",
"current",
"section",
"VMAs",
"against",
"those",
"at",
"the",
"time",
"the",
"stash",
"was",
"created",
".",
"If",
"find_nearest_line",
"is",
"used",
"in",
"linker",
"warnings",
"or",
"errors",
"early",
"in",
"the",
"link",
"process",
"the",
"debug",
"info",
"stash",
"will",
"be",
"invalid",
"for",
"later",
"calls",
".",
"This",
"is",
"because",
"we",
"relocate",
"debug",
"info",
"sections",
"so",
"the",
"stashed",
"section",
"contents",
"depend",
"on",
"symbol",
"values",
"which",
"in",
"turn",
"depend",
"on",
"section",
"VMAs",
"."
] | static bfd_boolean
section_vma_same (const bfd *abfd, const struct dwarf2_debug *stash)
{
asection *s;
unsigned int i;
for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
{
bfd_vma vma;
if (s->output_section != NULL)
vma = s->output_section->vma + s->output_offset;
else
vma = s->vma;
if (vma != stash->sec_vma[i])
return FALSE;
}
return TRUE;
} | [
"static",
"bfd_boolean",
"section_vma_same",
"(",
"const",
"bfd",
"*",
"abfd",
",",
"const",
"struct",
"dwarf2_debug",
"*",
"stash",
")",
"{",
"asection",
"*",
"s",
";",
"unsigned",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
",",
"s",
"=",
"abfd",
"->",
"sections",
";",
"i",
"<",
"abfd",
"->",
"section_count",
";",
"i",
"++",
",",
"s",
"=",
"s",
"->",
"next",
")",
"{",
"bfd_vma",
"vma",
";",
"if",
"(",
"s",
"->",
"output_section",
"!=",
"NULL",
")",
"vma",
"=",
"s",
"->",
"output_section",
"->",
"vma",
"+",
"s",
"->",
"output_offset",
";",
"else",
"vma",
"=",
"s",
"->",
"vma",
";",
"if",
"(",
"vma",
"!=",
"stash",
"->",
"sec_vma",
"[",
"i",
"]",
")",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Compare current section VMAs against those at the time the stash
was created. | [
"Compare",
"current",
"section",
"VMAs",
"against",
"those",
"at",
"the",
"time",
"the",
"stash",
"was",
"created",
"."
] | [] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "stash",
"type": "struct dwarf2_debug"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stash",
"type": "struct dwarf2_debug",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | _bfd_dwarf2_slurp_debug_info | bfd_boolean | bfd_boolean
_bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
const struct dwarf_debug_section *debug_sections,
asymbol **symbols,
void **pinfo,
bfd_boolean do_place)
{
bfd_size_type amt = sizeof (struct dwarf2_debug);
bfd_size_type total_size;
asection *msec;
struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;
if (stash != NULL)
{
if (section_vma_same (abfd, stash))
return TRUE;
_bfd_dwarf2_cleanup_debug_info (abfd, pinfo);
memset (stash, 0, amt);
}
else
{
stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt);
if (! stash)
return FALSE;
}
stash->debug_sections = debug_sections;
stash->syms = symbols;
if (!save_section_vma (abfd, stash))
return FALSE;
*pinfo = stash;
if (debug_bfd == NULL)
debug_bfd = abfd;
msec = find_debug_info (debug_bfd, debug_sections, NULL);
if (msec == NULL && abfd == debug_bfd)
{
char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR);
if (debug_filename == NULL)
/* No dwarf2 info, and no gnu_debuglink to follow.
Note that at this point the stash has been allocated, but
contains zeros. This lets future calls to this function
fail more quickly. */
return FALSE;
/* Set BFD_DECOMPRESS to decompress debug sections. */
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| !(debug_bfd->flags |= BFD_DECOMPRESS,
bfd_check_format (debug_bfd, bfd_object))
|| (msec = find_debug_info (debug_bfd,
debug_sections, NULL)) == NULL
|| !bfd_generic_link_read_symbols (debug_bfd))
{
if (debug_bfd)
bfd_close (debug_bfd);
/* FIXME: Should we report our failure to follow the debuglink ? */
free (debug_filename);
return FALSE;
}
symbols = bfd_get_outsymbols (debug_bfd);
stash->syms = symbols;
stash->close_on_cleanup = TRUE;
}
stash->bfd_ptr = debug_bfd;
if (do_place
&& !place_sections (abfd, stash))
return FALSE;
/* There can be more than one DWARF2 info section in a BFD these
days. First handle the easy case when there's only one. If
there's more than one, try case two: none of the sections is
compressed. In that case, read them all in and produce one
large stash. We do this in two passes - in the first pass we
just accumulate the section sizes, and in the second pass we
read in the section's contents. (The allows us to avoid
reallocing the data as we add sections to the stash.) If
some or all sections are compressed, then do things the slow
way, with a bunch of reallocs. */
if (! find_debug_info (debug_bfd, debug_sections, msec))
{
/* Case 1: only one info section. */
total_size = msec->size;
if (! read_section (debug_bfd, &stash->debug_sections[debug_info],
symbols, 0,
&stash->info_ptr_memory, &total_size))
return FALSE;
}
else
{
/* Case 2: multiple sections. */
for (total_size = 0;
msec;
msec = find_debug_info (debug_bfd, debug_sections, msec))
total_size += msec->size;
stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size);
if (stash->info_ptr_memory == NULL)
return FALSE;
total_size = 0;
for (msec = find_debug_info (debug_bfd, debug_sections, NULL);
msec;
msec = find_debug_info (debug_bfd, debug_sections, msec))
{
bfd_size_type size;
size = msec->size;
if (size == 0)
continue;
if (!(bfd_simple_get_relocated_section_contents
(debug_bfd, msec, stash->info_ptr_memory + total_size,
symbols)))
return FALSE;
total_size += size;
}
}
stash->info_ptr = stash->info_ptr_memory;
stash->info_ptr_end = stash->info_ptr + total_size;
stash->sec = find_debug_info (debug_bfd, debug_sections, NULL);
stash->sec_info_ptr = stash->info_ptr;
return TRUE;
} | /* Read debug information from DEBUG_BFD when DEBUG_BFD is specified.
If DEBUG_BFD is not specified, we read debug information from ABFD
or its gnu_debuglink. The results will be stored in PINFO.
The function returns TRUE iff debug information is ready. */ | Read debug information from DEBUG_BFD when DEBUG_BFD is specified.
If DEBUG_BFD is not specified, we read debug information from ABFD
or its gnu_debuglink. The results will be stored in PINFO.
The function returns TRUE iff debug information is ready. | [
"Read",
"debug",
"information",
"from",
"DEBUG_BFD",
"when",
"DEBUG_BFD",
"is",
"specified",
".",
"If",
"DEBUG_BFD",
"is",
"not",
"specified",
"we",
"read",
"debug",
"information",
"from",
"ABFD",
"or",
"its",
"gnu_debuglink",
".",
"The",
"results",
"will",
"be",
"stored",
"in",
"PINFO",
".",
"The",
"function",
"returns",
"TRUE",
"iff",
"debug",
"information",
"is",
"ready",
"."
] | bfd_boolean
_bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
const struct dwarf_debug_section *debug_sections,
asymbol **symbols,
void **pinfo,
bfd_boolean do_place)
{
bfd_size_type amt = sizeof (struct dwarf2_debug);
bfd_size_type total_size;
asection *msec;
struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;
if (stash != NULL)
{
if (section_vma_same (abfd, stash))
return TRUE;
_bfd_dwarf2_cleanup_debug_info (abfd, pinfo);
memset (stash, 0, amt);
}
else
{
stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt);
if (! stash)
return FALSE;
}
stash->debug_sections = debug_sections;
stash->syms = symbols;
if (!save_section_vma (abfd, stash))
return FALSE;
*pinfo = stash;
if (debug_bfd == NULL)
debug_bfd = abfd;
msec = find_debug_info (debug_bfd, debug_sections, NULL);
if (msec == NULL && abfd == debug_bfd)
{
char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR);
if (debug_filename == NULL)
return FALSE;
if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
|| !(debug_bfd->flags |= BFD_DECOMPRESS,
bfd_check_format (debug_bfd, bfd_object))
|| (msec = find_debug_info (debug_bfd,
debug_sections, NULL)) == NULL
|| !bfd_generic_link_read_symbols (debug_bfd))
{
if (debug_bfd)
bfd_close (debug_bfd);
free (debug_filename);
return FALSE;
}
symbols = bfd_get_outsymbols (debug_bfd);
stash->syms = symbols;
stash->close_on_cleanup = TRUE;
}
stash->bfd_ptr = debug_bfd;
if (do_place
&& !place_sections (abfd, stash))
return FALSE;
if (! find_debug_info (debug_bfd, debug_sections, msec))
{
total_size = msec->size;
if (! read_section (debug_bfd, &stash->debug_sections[debug_info],
symbols, 0,
&stash->info_ptr_memory, &total_size))
return FALSE;
}
else
{
for (total_size = 0;
msec;
msec = find_debug_info (debug_bfd, debug_sections, msec))
total_size += msec->size;
stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size);
if (stash->info_ptr_memory == NULL)
return FALSE;
total_size = 0;
for (msec = find_debug_info (debug_bfd, debug_sections, NULL);
msec;
msec = find_debug_info (debug_bfd, debug_sections, msec))
{
bfd_size_type size;
size = msec->size;
if (size == 0)
continue;
if (!(bfd_simple_get_relocated_section_contents
(debug_bfd, msec, stash->info_ptr_memory + total_size,
symbols)))
return FALSE;
total_size += size;
}
}
stash->info_ptr = stash->info_ptr_memory;
stash->info_ptr_end = stash->info_ptr + total_size;
stash->sec = find_debug_info (debug_bfd, debug_sections, NULL);
stash->sec_info_ptr = stash->info_ptr;
return TRUE;
} | [
"bfd_boolean",
"_bfd_dwarf2_slurp_debug_info",
"(",
"bfd",
"*",
"abfd",
",",
"bfd",
"*",
"debug_bfd",
",",
"const",
"struct",
"dwarf_debug_section",
"*",
"debug_sections",
",",
"asymbol",
"*",
"*",
"symbols",
",",
"void",
"*",
"*",
"pinfo",
",",
"bfd_boolean",
"do_place",
")",
"{",
"bfd_size_type",
"amt",
"=",
"sizeof",
"(",
"struct",
"dwarf2_debug",
")",
";",
"bfd_size_type",
"total_size",
";",
"asection",
"*",
"msec",
";",
"struct",
"dwarf2_debug",
"*",
"stash",
"=",
"(",
"struct",
"dwarf2_debug",
"*",
")",
"*",
"pinfo",
";",
"if",
"(",
"stash",
"!=",
"NULL",
")",
"{",
"if",
"(",
"section_vma_same",
"(",
"abfd",
",",
"stash",
")",
")",
"return",
"TRUE",
";",
"_bfd_dwarf2_cleanup_debug_info",
"(",
"abfd",
",",
"pinfo",
")",
";",
"memset",
"(",
"stash",
",",
"0",
",",
"amt",
")",
";",
"}",
"else",
"{",
"stash",
"=",
"(",
"struct",
"dwarf2_debug",
"*",
")",
"bfd_zalloc",
"(",
"abfd",
",",
"amt",
")",
";",
"if",
"(",
"!",
"stash",
")",
"return",
"FALSE",
";",
"}",
"stash",
"->",
"debug_sections",
"=",
"debug_sections",
";",
"stash",
"->",
"syms",
"=",
"symbols",
";",
"if",
"(",
"!",
"save_section_vma",
"(",
"abfd",
",",
"stash",
")",
")",
"return",
"FALSE",
";",
"*",
"pinfo",
"=",
"stash",
";",
"if",
"(",
"debug_bfd",
"==",
"NULL",
")",
"debug_bfd",
"=",
"abfd",
";",
"msec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"NULL",
")",
";",
"if",
"(",
"msec",
"==",
"NULL",
"&&",
"abfd",
"==",
"debug_bfd",
")",
"{",
"char",
"*",
"debug_filename",
"=",
"bfd_follow_gnu_debuglink",
"(",
"abfd",
",",
"DEBUGDIR",
")",
";",
"if",
"(",
"debug_filename",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"if",
"(",
"(",
"debug_bfd",
"=",
"bfd_openr",
"(",
"debug_filename",
",",
"NULL",
")",
")",
"==",
"NULL",
"||",
"!",
"(",
"debug_bfd",
"->",
"flags",
"|=",
"BFD_DECOMPRESS",
",",
"bfd_check_format",
"(",
"debug_bfd",
",",
"bfd_object",
")",
")",
"||",
"(",
"msec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"NULL",
")",
")",
"==",
"NULL",
"||",
"!",
"bfd_generic_link_read_symbols",
"(",
"debug_bfd",
")",
")",
"{",
"if",
"(",
"debug_bfd",
")",
"bfd_close",
"(",
"debug_bfd",
")",
";",
"free",
"(",
"debug_filename",
")",
";",
"return",
"FALSE",
";",
"}",
"symbols",
"=",
"bfd_get_outsymbols",
"(",
"debug_bfd",
")",
";",
"stash",
"->",
"syms",
"=",
"symbols",
";",
"stash",
"->",
"close_on_cleanup",
"=",
"TRUE",
";",
"}",
"stash",
"->",
"bfd_ptr",
"=",
"debug_bfd",
";",
"if",
"(",
"do_place",
"&&",
"!",
"place_sections",
"(",
"abfd",
",",
"stash",
")",
")",
"return",
"FALSE",
";",
"if",
"(",
"!",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"msec",
")",
")",
"{",
"total_size",
"=",
"msec",
"->",
"size",
";",
"if",
"(",
"!",
"read_section",
"(",
"debug_bfd",
",",
"&",
"stash",
"->",
"debug_sections",
"[",
"debug_info",
"]",
",",
"symbols",
",",
"0",
",",
"&",
"stash",
"->",
"info_ptr_memory",
",",
"&",
"total_size",
")",
")",
"return",
"FALSE",
";",
"}",
"else",
"{",
"for",
"(",
"total_size",
"=",
"0",
";",
"msec",
";",
"msec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"msec",
")",
")",
"total_size",
"+=",
"msec",
"->",
"size",
";",
"stash",
"->",
"info_ptr_memory",
"=",
"(",
"bfd_byte",
"*",
")",
"bfd_malloc",
"(",
"total_size",
")",
";",
"if",
"(",
"stash",
"->",
"info_ptr_memory",
"==",
"NULL",
")",
"return",
"FALSE",
";",
"total_size",
"=",
"0",
";",
"for",
"(",
"msec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"NULL",
")",
";",
"msec",
";",
"msec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"msec",
")",
")",
"{",
"bfd_size_type",
"size",
";",
"size",
"=",
"msec",
"->",
"size",
";",
"if",
"(",
"size",
"==",
"0",
")",
"continue",
";",
"if",
"(",
"!",
"(",
"bfd_simple_get_relocated_section_contents",
"(",
"debug_bfd",
",",
"msec",
",",
"stash",
"->",
"info_ptr_memory",
"+",
"total_size",
",",
"symbols",
")",
")",
")",
"return",
"FALSE",
";",
"total_size",
"+=",
"size",
";",
"}",
"}",
"stash",
"->",
"info_ptr",
"=",
"stash",
"->",
"info_ptr_memory",
";",
"stash",
"->",
"info_ptr_end",
"=",
"stash",
"->",
"info_ptr",
"+",
"total_size",
";",
"stash",
"->",
"sec",
"=",
"find_debug_info",
"(",
"debug_bfd",
",",
"debug_sections",
",",
"NULL",
")",
";",
"stash",
"->",
"sec_info_ptr",
"=",
"stash",
"->",
"info_ptr",
";",
"return",
"TRUE",
";",
"}"
] | Read debug information from DEBUG_BFD when DEBUG_BFD is specified. | [
"Read",
"debug",
"information",
"from",
"DEBUG_BFD",
"when",
"DEBUG_BFD",
"is",
"specified",
"."
] | [
"/* No dwarf2 info, and no gnu_debuglink to follow.\n\t Note that at this point the stash has been allocated, but\n\t contains zeros. This lets future calls to this function\n\t fail more quickly. */",
"/* Set BFD_DECOMPRESS to decompress debug sections. */",
"/* FIXME: Should we report our failure to follow the debuglink ? */",
"/* There can be more than one DWARF2 info section in a BFD these\n days. First handle the easy case when there's only one. If\n there's more than one, try case two: none of the sections is\n compressed. In that case, read them all in and produce one\n large stash. We do this in two passes - in the first pass we\n just accumulate the section sizes, and in the second pass we\n read in the section's contents. (The allows us to avoid\n reallocing the data as we add sections to the stash.) If\n some or all sections are compressed, then do things the slow\n way, with a bunch of reallocs. */",
"/* Case 1: only one info section. */",
"/* Case 2: multiple sections. */"
] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "debug_bfd",
"type": "bfd"
},
{
"param": "debug_sections",
"type": "struct dwarf_debug_section"
},
{
"param": "symbols",
"type": "asymbol"
},
{
"param": "pinfo",
"type": "void"
},
{
"param": "do_place",
"type": "bfd_boolean"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "debug_bfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "debug_sections",
"type": "struct dwarf_debug_section",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "symbols",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pinfo",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "do_place",
"type": "bfd_boolean",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | _bfd_dwarf2_find_symbol_bias | bfd_signed_vma | bfd_signed_vma
_bfd_dwarf2_find_symbol_bias (asymbol ** symbols, void ** pinfo)
{
struct dwarf2_debug *stash;
struct comp_unit * unit;
stash = (struct dwarf2_debug *) *pinfo;
if (stash == NULL)
return 0;
for (unit = stash->all_comp_units; unit; unit = unit->next_unit)
{
struct funcinfo * func;
if (unit->function_table == NULL)
{
if (unit->line_table == NULL)
unit->line_table = decode_line_info (unit, stash);
if (unit->line_table != NULL)
scan_unit_for_symbols (unit);
}
for (func = unit->function_table; func != NULL; func = func->prev_func)
if (func->name && func->arange.low)
{
asymbol ** psym;
/* FIXME: Do we need to scan the aranges looking for the lowest pc value ? */
for (psym = symbols; * psym != NULL; psym++)
{
asymbol * sym = * psym;
if (sym->flags & BSF_FUNCTION
&& sym->section != NULL
&& strcmp (sym->name, func->name) == 0)
return ((bfd_signed_vma) func->arange.low) -
((bfd_signed_vma) (sym->value + sym->section->vma));
}
}
}
return 0;
} | /* Scan the debug information in PINFO looking for a DW_TAG_subprogram
abbrev with a DW_AT_low_pc attached to it. Then lookup that same
symbol in SYMBOLS and return the difference between the low_pc and
the symbol's address. Returns 0 if no suitable symbol could be found. */ | Scan the debug information in PINFO looking for a DW_TAG_subprogram
abbrev with a DW_AT_low_pc attached to it. Then lookup that same
symbol in SYMBOLS and return the difference between the low_pc and
the symbol's address. Returns 0 if no suitable symbol could be found. | [
"Scan",
"the",
"debug",
"information",
"in",
"PINFO",
"looking",
"for",
"a",
"DW_TAG_subprogram",
"abbrev",
"with",
"a",
"DW_AT_low_pc",
"attached",
"to",
"it",
".",
"Then",
"lookup",
"that",
"same",
"symbol",
"in",
"SYMBOLS",
"and",
"return",
"the",
"difference",
"between",
"the",
"low_pc",
"and",
"the",
"symbol",
"'",
"s",
"address",
".",
"Returns",
"0",
"if",
"no",
"suitable",
"symbol",
"could",
"be",
"found",
"."
] | bfd_signed_vma
_bfd_dwarf2_find_symbol_bias (asymbol ** symbols, void ** pinfo)
{
struct dwarf2_debug *stash;
struct comp_unit * unit;
stash = (struct dwarf2_debug *) *pinfo;
if (stash == NULL)
return 0;
for (unit = stash->all_comp_units; unit; unit = unit->next_unit)
{
struct funcinfo * func;
if (unit->function_table == NULL)
{
if (unit->line_table == NULL)
unit->line_table = decode_line_info (unit, stash);
if (unit->line_table != NULL)
scan_unit_for_symbols (unit);
}
for (func = unit->function_table; func != NULL; func = func->prev_func)
if (func->name && func->arange.low)
{
asymbol ** psym;
for (psym = symbols; * psym != NULL; psym++)
{
asymbol * sym = * psym;
if (sym->flags & BSF_FUNCTION
&& sym->section != NULL
&& strcmp (sym->name, func->name) == 0)
return ((bfd_signed_vma) func->arange.low) -
((bfd_signed_vma) (sym->value + sym->section->vma));
}
}
}
return 0;
} | [
"bfd_signed_vma",
"_bfd_dwarf2_find_symbol_bias",
"(",
"asymbol",
"*",
"*",
"symbols",
",",
"void",
"*",
"*",
"pinfo",
")",
"{",
"struct",
"dwarf2_debug",
"*",
"stash",
";",
"struct",
"comp_unit",
"*",
"unit",
";",
"stash",
"=",
"(",
"struct",
"dwarf2_debug",
"*",
")",
"*",
"pinfo",
";",
"if",
"(",
"stash",
"==",
"NULL",
")",
"return",
"0",
";",
"for",
"(",
"unit",
"=",
"stash",
"->",
"all_comp_units",
";",
"unit",
";",
"unit",
"=",
"unit",
"->",
"next_unit",
")",
"{",
"struct",
"funcinfo",
"*",
"func",
";",
"if",
"(",
"unit",
"->",
"function_table",
"==",
"NULL",
")",
"{",
"if",
"(",
"unit",
"->",
"line_table",
"==",
"NULL",
")",
"unit",
"->",
"line_table",
"=",
"decode_line_info",
"(",
"unit",
",",
"stash",
")",
";",
"if",
"(",
"unit",
"->",
"line_table",
"!=",
"NULL",
")",
"scan_unit_for_symbols",
"(",
"unit",
")",
";",
"}",
"for",
"(",
"func",
"=",
"unit",
"->",
"function_table",
";",
"func",
"!=",
"NULL",
";",
"func",
"=",
"func",
"->",
"prev_func",
")",
"if",
"(",
"func",
"->",
"name",
"&&",
"func",
"->",
"arange",
".",
"low",
")",
"{",
"asymbol",
"*",
"*",
"psym",
";",
"for",
"(",
"psym",
"=",
"symbols",
";",
"*",
"psym",
"!=",
"NULL",
";",
"psym",
"++",
")",
"{",
"asymbol",
"*",
"sym",
"=",
"*",
"psym",
";",
"if",
"(",
"sym",
"->",
"flags",
"&",
"BSF_FUNCTION",
"&&",
"sym",
"->",
"section",
"!=",
"NULL",
"&&",
"strcmp",
"(",
"sym",
"->",
"name",
",",
"func",
"->",
"name",
")",
"==",
"0",
")",
"return",
"(",
"(",
"bfd_signed_vma",
")",
"func",
"->",
"arange",
".",
"low",
")",
"-",
"(",
"(",
"bfd_signed_vma",
")",
"(",
"sym",
"->",
"value",
"+",
"sym",
"->",
"section",
"->",
"vma",
")",
")",
";",
"}",
"}",
"}",
"return",
"0",
";",
"}"
] | Scan the debug information in PINFO looking for a DW_TAG_subprogram
abbrev with a DW_AT_low_pc attached to it. | [
"Scan",
"the",
"debug",
"information",
"in",
"PINFO",
"looking",
"for",
"a",
"DW_TAG_subprogram",
"abbrev",
"with",
"a",
"DW_AT_low_pc",
"attached",
"to",
"it",
"."
] | [
"/* FIXME: Do we need to scan the aranges looking for the lowest pc value ? */"
] | [
{
"param": "symbols",
"type": "asymbol"
},
{
"param": "pinfo",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "symbols",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pinfo",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33370aca7d357a51e4e33502a245eef10fefd3ae | atrens/DragonFlyBSD-src | contrib/binutils-2.27/bfd/dwarf2.c | [
"BSD-3-Clause"
] | C | _bfd_elf_find_function | asymbol | asymbol *
_bfd_elf_find_function (bfd *abfd,
asymbol **symbols,
asection *section,
bfd_vma offset,
const char **filename_ptr,
const char **functionname_ptr)
{
struct elf_find_function_cache
{
asection *last_section;
asymbol *func;
const char *filename;
bfd_size_type func_size;
} *cache;
if (symbols == NULL)
return NULL;
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
return NULL;
cache = elf_tdata (abfd)->elf_find_function_cache;
if (cache == NULL)
{
cache = bfd_zalloc (abfd, sizeof (*cache));
elf_tdata (abfd)->elf_find_function_cache = cache;
if (cache == NULL)
return NULL;
}
if (cache->last_section != section
|| cache->func == NULL
|| offset < cache->func->value
|| offset >= cache->func->value + cache->func_size)
{
asymbol *file;
bfd_vma low_func;
asymbol **p;
/* ??? Given multiple file symbols, it is impossible to reliably
choose the right file name for global symbols. File symbols are
local symbols, and thus all file symbols must sort before any
global symbols. The ELF spec may be interpreted to say that a
file symbol must sort before other local symbols, but currently
ld -r doesn't do this. So, for ld -r output, it is possible to
make a better choice of file name for local symbols by ignoring
file symbols appearing after a given local symbol. */
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
file = NULL;
low_func = 0;
state = nothing_seen;
cache->filename = NULL;
cache->func = NULL;
cache->func_size = 0;
cache->last_section = section;
for (p = symbols; *p != NULL; p++)
{
asymbol *sym = *p;
bfd_vma code_off;
bfd_size_type size;
if ((sym->flags & BSF_FILE) != 0)
{
file = sym;
if (state == symbol_seen)
state = file_after_symbol_seen;
continue;
}
size = bed->maybe_function_sym (sym, section, &code_off);
if (size != 0
&& code_off <= offset
&& (code_off > low_func
|| (code_off == low_func
&& size > cache->func_size)))
{
cache->func = sym;
cache->func_size = size;
cache->filename = NULL;
low_func = code_off;
if (file != NULL
&& ((sym->flags & BSF_LOCAL) != 0
|| state != file_after_symbol_seen))
cache->filename = bfd_asymbol_name (file);
}
if (state == nothing_seen)
state = symbol_seen;
}
}
if (cache->func == NULL)
return NULL;
if (filename_ptr)
*filename_ptr = cache->filename;
if (functionname_ptr)
*functionname_ptr = bfd_asymbol_name (cache->func);
return cache->func;
} | /* Find the function to a particular section and offset,
for error reporting. */ | Find the function to a particular section and offset,
for error reporting. | [
"Find",
"the",
"function",
"to",
"a",
"particular",
"section",
"and",
"offset",
"for",
"error",
"reporting",
"."
] | asymbol *
_bfd_elf_find_function (bfd *abfd,
asymbol **symbols,
asection *section,
bfd_vma offset,
const char **filename_ptr,
const char **functionname_ptr)
{
struct elf_find_function_cache
{
asection *last_section;
asymbol *func;
const char *filename;
bfd_size_type func_size;
} *cache;
if (symbols == NULL)
return NULL;
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
return NULL;
cache = elf_tdata (abfd)->elf_find_function_cache;
if (cache == NULL)
{
cache = bfd_zalloc (abfd, sizeof (*cache));
elf_tdata (abfd)->elf_find_function_cache = cache;
if (cache == NULL)
return NULL;
}
if (cache->last_section != section
|| cache->func == NULL
|| offset < cache->func->value
|| offset >= cache->func->value + cache->func_size)
{
asymbol *file;
bfd_vma low_func;
asymbol **p;
enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
file = NULL;
low_func = 0;
state = nothing_seen;
cache->filename = NULL;
cache->func = NULL;
cache->func_size = 0;
cache->last_section = section;
for (p = symbols; *p != NULL; p++)
{
asymbol *sym = *p;
bfd_vma code_off;
bfd_size_type size;
if ((sym->flags & BSF_FILE) != 0)
{
file = sym;
if (state == symbol_seen)
state = file_after_symbol_seen;
continue;
}
size = bed->maybe_function_sym (sym, section, &code_off);
if (size != 0
&& code_off <= offset
&& (code_off > low_func
|| (code_off == low_func
&& size > cache->func_size)))
{
cache->func = sym;
cache->func_size = size;
cache->filename = NULL;
low_func = code_off;
if (file != NULL
&& ((sym->flags & BSF_LOCAL) != 0
|| state != file_after_symbol_seen))
cache->filename = bfd_asymbol_name (file);
}
if (state == nothing_seen)
state = symbol_seen;
}
}
if (cache->func == NULL)
return NULL;
if (filename_ptr)
*filename_ptr = cache->filename;
if (functionname_ptr)
*functionname_ptr = bfd_asymbol_name (cache->func);
return cache->func;
} | [
"asymbol",
"*",
"_bfd_elf_find_function",
"(",
"bfd",
"*",
"abfd",
",",
"asymbol",
"*",
"*",
"symbols",
",",
"asection",
"*",
"section",
",",
"bfd_vma",
"offset",
",",
"const",
"char",
"*",
"*",
"filename_ptr",
",",
"const",
"char",
"*",
"*",
"functionname_ptr",
")",
"{",
"struct",
"elf_find_function_cache",
"{",
"asection",
"*",
"last_section",
";",
"asymbol",
"*",
"func",
";",
"const",
"char",
"*",
"filename",
";",
"bfd_size_type",
"func_size",
";",
"}",
"*",
"cache",
";",
"if",
"(",
"symbols",
"==",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"bfd_get_flavour",
"(",
"abfd",
")",
"!=",
"bfd_target_elf_flavour",
")",
"return",
"NULL",
";",
"cache",
"=",
"elf_tdata",
"(",
"abfd",
")",
"->",
"elf_find_function_cache",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"{",
"cache",
"=",
"bfd_zalloc",
"(",
"abfd",
",",
"sizeof",
"(",
"*",
"cache",
")",
")",
";",
"elf_tdata",
"(",
"abfd",
")",
"->",
"elf_find_function_cache",
"=",
"cache",
";",
"if",
"(",
"cache",
"==",
"NULL",
")",
"return",
"NULL",
";",
"}",
"if",
"(",
"cache",
"->",
"last_section",
"!=",
"section",
"||",
"cache",
"->",
"func",
"==",
"NULL",
"||",
"offset",
"<",
"cache",
"->",
"func",
"->",
"value",
"||",
"offset",
">=",
"cache",
"->",
"func",
"->",
"value",
"+",
"cache",
"->",
"func_size",
")",
"{",
"asymbol",
"*",
"file",
";",
"bfd_vma",
"low_func",
";",
"asymbol",
"*",
"*",
"p",
";",
"enum",
"{",
"nothing_seen",
",",
"symbol_seen",
",",
"file_after_symbol_seen",
"}",
"state",
";",
"const",
"struct",
"elf_backend_data",
"*",
"bed",
"=",
"get_elf_backend_data",
"(",
"abfd",
")",
";",
"file",
"=",
"NULL",
";",
"low_func",
"=",
"0",
";",
"state",
"=",
"nothing_seen",
";",
"cache",
"->",
"filename",
"=",
"NULL",
";",
"cache",
"->",
"func",
"=",
"NULL",
";",
"cache",
"->",
"func_size",
"=",
"0",
";",
"cache",
"->",
"last_section",
"=",
"section",
";",
"for",
"(",
"p",
"=",
"symbols",
";",
"*",
"p",
"!=",
"NULL",
";",
"p",
"++",
")",
"{",
"asymbol",
"*",
"sym",
"=",
"*",
"p",
";",
"bfd_vma",
"code_off",
";",
"bfd_size_type",
"size",
";",
"if",
"(",
"(",
"sym",
"->",
"flags",
"&",
"BSF_FILE",
")",
"!=",
"0",
")",
"{",
"file",
"=",
"sym",
";",
"if",
"(",
"state",
"==",
"symbol_seen",
")",
"state",
"=",
"file_after_symbol_seen",
";",
"continue",
";",
"}",
"size",
"=",
"bed",
"->",
"maybe_function_sym",
"(",
"sym",
",",
"section",
",",
"&",
"code_off",
")",
";",
"if",
"(",
"size",
"!=",
"0",
"&&",
"code_off",
"<=",
"offset",
"&&",
"(",
"code_off",
">",
"low_func",
"||",
"(",
"code_off",
"==",
"low_func",
"&&",
"size",
">",
"cache",
"->",
"func_size",
")",
")",
")",
"{",
"cache",
"->",
"func",
"=",
"sym",
";",
"cache",
"->",
"func_size",
"=",
"size",
";",
"cache",
"->",
"filename",
"=",
"NULL",
";",
"low_func",
"=",
"code_off",
";",
"if",
"(",
"file",
"!=",
"NULL",
"&&",
"(",
"(",
"sym",
"->",
"flags",
"&",
"BSF_LOCAL",
")",
"!=",
"0",
"||",
"state",
"!=",
"file_after_symbol_seen",
")",
")",
"cache",
"->",
"filename",
"=",
"bfd_asymbol_name",
"(",
"file",
")",
";",
"}",
"if",
"(",
"state",
"==",
"nothing_seen",
")",
"state",
"=",
"symbol_seen",
";",
"}",
"}",
"if",
"(",
"cache",
"->",
"func",
"==",
"NULL",
")",
"return",
"NULL",
";",
"if",
"(",
"filename_ptr",
")",
"*",
"filename_ptr",
"=",
"cache",
"->",
"filename",
";",
"if",
"(",
"functionname_ptr",
")",
"*",
"functionname_ptr",
"=",
"bfd_asymbol_name",
"(",
"cache",
"->",
"func",
")",
";",
"return",
"cache",
"->",
"func",
";",
"}"
] | Find the function to a particular section and offset,
for error reporting. | [
"Find",
"the",
"function",
"to",
"a",
"particular",
"section",
"and",
"offset",
"for",
"error",
"reporting",
"."
] | [
"/* ??? Given multiple file symbols, it is impossible to reliably\n\t choose the right file name for global symbols. File symbols are\n\t local symbols, and thus all file symbols must sort before any\n\t global symbols. The ELF spec may be interpreted to say that a\n\t file symbol must sort before other local symbols, but currently\n\t ld -r doesn't do this. So, for ld -r output, it is possible to\n\t make a better choice of file name for local symbols by ignoring\n\t file symbols appearing after a given local symbol. */"
] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "symbols",
"type": "asymbol"
},
{
"param": "section",
"type": "asection"
},
{
"param": "offset",
"type": "bfd_vma"
},
{
"param": "filename_ptr",
"type": "char"
},
{
"param": "functionname_ptr",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "symbols",
"type": "asymbol",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "section",
"type": "asection",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "offset",
"type": "bfd_vma",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "functionname_ptr",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f2aafde42f27307aadd02d4a9877bc4ee34bab9d | atrens/DragonFlyBSD-src | lib/libposix1e/acl_to_text.c | [
"BSD-3-Clause"
] | C | acl_to_text | char | char *
acl_to_text(acl_t acl, ssize_t *len_p)
{
char *buf, *tmpbuf;
char name_buf[MAXLOGNAME];
char perm_buf[ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1];
int i, error, len;
uid_t ae_id;
acl_tag_t ae_tag;
acl_perm_t ae_perm, effective_perm, mask_perm;
buf = strdup("");
mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */
for (i = 0; i < acl->acl_cnt; i++)
if (acl->acl_entry[i].ae_tag == ACL_MASK)
mask_perm = acl->acl_entry[i].ae_perm;
for (i = 0; i < acl->acl_cnt; i++) {
ae_tag = acl->acl_entry[i].ae_tag;
ae_id = acl->acl_entry[i].ae_id;
ae_perm = acl->acl_entry[i].ae_perm;
switch(ae_tag) {
case ACL_USER_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_USER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, MAXLOGNAME,
name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser:%s:%s\t\t# "
"effective: %s\n",
buf, name_buf, perm_buf,
effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%suser:%s:%s\n", buf,
name_buf, perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_GROUP_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
"effective: %s\n",
buf, perm_buf, effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%sgroup::%s\n", buf,
perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_GROUP:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, MAXLOGNAME,
name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
"effective: %s\n",
buf, perm_buf, effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%sgroup:%s:%s\n", buf,
name_buf, perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_MASK:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%smask::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_OTHER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sother::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
default:
free(buf);
errno = EINVAL;
return (0);
}
}
if (len_p) {
*len_p = strlen(buf);
}
return (buf);
error_label:
/* jump to here sets errno already, we just clean up */
if (buf) free(buf);
return (0);
} | /*
* acl_to_text - generate a text form of an acl
* spec says nothing about output ordering, so leave in acl order
*
* This function will not produce nice results if it is called with
* a non-POSIX.1e semantics ACL.
*/ | generate a text form of an acl
spec says nothing about output ordering, so leave in acl order
This function will not produce nice results if it is called with
a non-POSIX.1e semantics ACL. | [
"generate",
"a",
"text",
"form",
"of",
"an",
"acl",
"spec",
"says",
"nothing",
"about",
"output",
"ordering",
"so",
"leave",
"in",
"acl",
"order",
"This",
"function",
"will",
"not",
"produce",
"nice",
"results",
"if",
"it",
"is",
"called",
"with",
"a",
"non",
"-",
"POSIX",
".",
"1e",
"semantics",
"ACL",
"."
] | char *
acl_to_text(acl_t acl, ssize_t *len_p)
{
char *buf, *tmpbuf;
char name_buf[MAXLOGNAME];
char perm_buf[ACL_STRING_PERM_MAXSIZE+1],
effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1];
int i, error, len;
uid_t ae_id;
acl_tag_t ae_tag;
acl_perm_t ae_perm, effective_perm, mask_perm;
buf = strdup("");
mask_perm = ACL_PERM_BITS;
for (i = 0; i < acl->acl_cnt; i++)
if (acl->acl_entry[i].ae_tag == ACL_MASK)
mask_perm = acl->acl_entry[i].ae_perm;
for (i = 0; i < acl->acl_cnt; i++) {
ae_tag = acl->acl_entry[i].ae_tag;
ae_id = acl->acl_entry[i].ae_id;
ae_perm = acl->acl_entry[i].ae_perm;
switch(ae_tag) {
case ACL_USER_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_USER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, MAXLOGNAME,
name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%suser:%s:%s\t\t# "
"effective: %s\n",
buf, name_buf, perm_buf,
effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%suser:%s:%s\n", buf,
name_buf, perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_GROUP_OBJ:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
"effective: %s\n",
buf, perm_buf, effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%sgroup::%s\n", buf,
perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_GROUP:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
error = acl_id_to_name(ae_tag, ae_id, MAXLOGNAME,
name_buf);
if (error)
goto error_label;
effective_perm = ae_perm & mask_perm;
if (effective_perm != ae_perm) {
error = acl_perm_to_string(effective_perm,
ACL_STRING_PERM_MAXSIZE+1,
effective_perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
"effective: %s\n",
buf, perm_buf, effective_perm_buf);
} else {
len = asprintf(&tmpbuf, "%sgroup:%s:%s\n", buf,
name_buf, perm_buf);
}
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_MASK:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%smask::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
case ACL_OTHER:
error = acl_perm_to_string(ae_perm,
ACL_STRING_PERM_MAXSIZE+1, perm_buf);
if (error)
goto error_label;
len = asprintf(&tmpbuf, "%sother::%s\n", buf,
perm_buf);
if (len == -1) {
errno = ENOMEM;
goto error_label;
}
free(buf);
buf = tmpbuf;
break;
default:
free(buf);
errno = EINVAL;
return (0);
}
}
if (len_p) {
*len_p = strlen(buf);
}
return (buf);
error_label:
if (buf) free(buf);
return (0);
} | [
"char",
"*",
"acl_to_text",
"(",
"acl_t",
"acl",
",",
"ssize_t",
"*",
"len_p",
")",
"{",
"char",
"*",
"buf",
",",
"*",
"tmpbuf",
";",
"char",
"name_buf",
"[",
"MAXLOGNAME",
"]",
";",
"char",
"perm_buf",
"[",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
"]",
",",
"effective_perm_buf",
"[",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
"]",
";",
"int",
"i",
",",
"error",
",",
"len",
";",
"uid_t",
"ae_id",
";",
"acl_tag_t",
"ae_tag",
";",
"acl_perm_t",
"ae_perm",
",",
"effective_perm",
",",
"mask_perm",
";",
"buf",
"=",
"strdup",
"(",
"\"",
"\"",
")",
";",
"mask_perm",
"=",
"ACL_PERM_BITS",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"acl",
"->",
"acl_cnt",
";",
"i",
"++",
")",
"if",
"(",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
".",
"ae_tag",
"==",
"ACL_MASK",
")",
"mask_perm",
"=",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
".",
"ae_perm",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"acl",
"->",
"acl_cnt",
";",
"i",
"++",
")",
"{",
"ae_tag",
"=",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
".",
"ae_tag",
";",
"ae_id",
"=",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
".",
"ae_id",
";",
"ae_perm",
"=",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
".",
"ae_perm",
";",
"switch",
"(",
"ae_tag",
")",
"{",
"case",
"ACL_USER_OBJ",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
")",
";",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"case",
"ACL_USER",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"error",
"=",
"acl_id_to_name",
"(",
"ae_tag",
",",
"ae_id",
",",
"MAXLOGNAME",
",",
"name_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"effective_perm",
"=",
"ae_perm",
"&",
"mask_perm",
";",
"if",
"(",
"effective_perm",
"!=",
"ae_perm",
")",
"{",
"error",
"=",
"acl_perm_to_string",
"(",
"effective_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"effective_perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\t",
"\\t",
"\"",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"name_buf",
",",
"perm_buf",
",",
"effective_perm_buf",
")",
";",
"}",
"else",
"{",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"name_buf",
",",
"perm_buf",
")",
";",
"}",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"case",
"ACL_GROUP_OBJ",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"effective_perm",
"=",
"ae_perm",
"&",
"mask_perm",
";",
"if",
"(",
"effective_perm",
"!=",
"ae_perm",
")",
"{",
"error",
"=",
"acl_perm_to_string",
"(",
"effective_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"effective_perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\t",
"\\t",
"\"",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
",",
"effective_perm_buf",
")",
";",
"}",
"else",
"{",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
")",
";",
"}",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"case",
"ACL_GROUP",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"error",
"=",
"acl_id_to_name",
"(",
"ae_tag",
",",
"ae_id",
",",
"MAXLOGNAME",
",",
"name_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"effective_perm",
"=",
"ae_perm",
"&",
"mask_perm",
";",
"if",
"(",
"effective_perm",
"!=",
"ae_perm",
")",
"{",
"error",
"=",
"acl_perm_to_string",
"(",
"effective_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"effective_perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\t",
"\\t",
"\"",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
",",
"effective_perm_buf",
")",
";",
"}",
"else",
"{",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"name_buf",
",",
"perm_buf",
")",
";",
"}",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"case",
"ACL_MASK",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
")",
";",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"case",
"ACL_OTHER",
":",
"error",
"=",
"acl_perm_to_string",
"(",
"ae_perm",
",",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
",",
"perm_buf",
")",
";",
"if",
"(",
"error",
")",
"goto",
"error_label",
";",
"len",
"=",
"asprintf",
"(",
"&",
"tmpbuf",
",",
"\"",
"\\n",
"\"",
",",
"buf",
",",
"perm_buf",
")",
";",
"if",
"(",
"len",
"==",
"-1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"goto",
"error_label",
";",
"}",
"free",
"(",
"buf",
")",
";",
"buf",
"=",
"tmpbuf",
";",
"break",
";",
"default",
":",
"free",
"(",
"buf",
")",
";",
"errno",
"=",
"EINVAL",
";",
"return",
"(",
"0",
")",
";",
"}",
"}",
"if",
"(",
"len_p",
")",
"{",
"*",
"len_p",
"=",
"strlen",
"(",
"buf",
")",
";",
"}",
"return",
"(",
"buf",
")",
";",
"error_label",
":",
"if",
"(",
"buf",
")",
"free",
"(",
"buf",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | acl_to_text - generate a text form of an acl
spec says nothing about output ordering, so leave in acl order | [
"acl_to_text",
"-",
"generate",
"a",
"text",
"form",
"of",
"an",
"acl",
"spec",
"says",
"nothing",
"about",
"output",
"ordering",
"so",
"leave",
"in",
"acl",
"order"
] | [
"/* effective is regular if no mask */",
"/* jump to here sets errno already, we just clean up */"
] | [
{
"param": "acl",
"type": "acl_t"
},
{
"param": "len_p",
"type": "ssize_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acl",
"type": "acl_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "len_p",
"type": "ssize_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | is_valid_response | int | static int
is_valid_response(struct rad_handle *h, int srv,
const struct sockaddr_in *from)
{
MD5_CTX ctx;
unsigned char md5[MD5_DIGEST_LENGTH];
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
#endif
srvp = &h->servers[srv];
/* Check the source address */
if (from->sin_family != srvp->addr.sin_family ||
from->sin_addr.s_addr != srvp->addr.sin_addr.s_addr ||
from->sin_port != srvp->addr.sin_port)
return 0;
/* Check the message length */
if (h->in_len < POS_ATTRS)
return 0;
len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
if (len > h->in_len)
return 0;
/* Check the response authenticator */
MD5Init(&ctx);
MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
MD5Final(md5, &ctx);
if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
return 0;
#ifdef WITH_SSL
/*
* For non accounting responses check the message authenticator,
* if any.
*/
if (h->in[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
memcpy(resp, h->in, MSGSIZE);
pos = POS_ATTRS;
/* Search and verify the Message-Authenticator */
hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
/* zero fill the Message-Authenticator */
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
HMAC_Init_ex(hctx, srvp->secret,
strlen(srvp->secret), EVP_md5(), NULL);
HMAC_Update(hctx, &h->in[POS_CODE],
POS_AUTH - POS_CODE);
HMAC_Update(hctx, &h->out[POS_AUTH],
LEN_AUTH);
HMAC_Update(hctx, &resp[POS_ATTRS],
h->in_len - POS_ATTRS);
HMAC_Final(hctx, md, &md_len);
HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
MD5_DIGEST_LENGTH) != 0) {
HMAC_CTX_free(hctx);
return 0;
}
break;
}
pos += h->in[pos + 1];
}
HMAC_CTX_free(hctx);
}
#endif
return 1;
} | /*
* Return true if the current response is valid for a request to the
* specified server.
*/ | Return true if the current response is valid for a request to the
specified server. | [
"Return",
"true",
"if",
"the",
"current",
"response",
"is",
"valid",
"for",
"a",
"request",
"to",
"the",
"specified",
"server",
"."
] | static int
is_valid_response(struct rad_handle *h, int srv,
const struct sockaddr_in *from)
{
MD5_CTX ctx;
unsigned char md5[MD5_DIGEST_LENGTH];
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
#endif
srvp = &h->servers[srv];
if (from->sin_family != srvp->addr.sin_family ||
from->sin_addr.s_addr != srvp->addr.sin_addr.s_addr ||
from->sin_port != srvp->addr.sin_port)
return 0;
if (h->in_len < POS_ATTRS)
return 0;
len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
if (len > h->in_len)
return 0;
MD5Init(&ctx);
MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
MD5Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
MD5Final(md5, &ctx);
if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
return 0;
#ifdef WITH_SSL
if (h->in[POS_CODE] != RAD_ACCOUNTING_RESPONSE) {
memcpy(resp, h->in, MSGSIZE);
pos = POS_ATTRS;
hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
HMAC_Init_ex(hctx, srvp->secret,
strlen(srvp->secret), EVP_md5(), NULL);
HMAC_Update(hctx, &h->in[POS_CODE],
POS_AUTH - POS_CODE);
HMAC_Update(hctx, &h->out[POS_AUTH],
LEN_AUTH);
HMAC_Update(hctx, &resp[POS_ATTRS],
h->in_len - POS_ATTRS);
HMAC_Final(hctx, md, &md_len);
HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
MD5_DIGEST_LENGTH) != 0) {
HMAC_CTX_free(hctx);
return 0;
}
break;
}
pos += h->in[pos + 1];
}
HMAC_CTX_free(hctx);
}
#endif
return 1;
} | [
"static",
"int",
"is_valid_response",
"(",
"struct",
"rad_handle",
"*",
"h",
",",
"int",
"srv",
",",
"const",
"struct",
"sockaddr_in",
"*",
"from",
")",
"{",
"MD5_CTX",
"ctx",
";",
"unsigned",
"char",
"md5",
"[",
"MD5_DIGEST_LENGTH",
"]",
";",
"const",
"struct",
"rad_server",
"*",
"srvp",
";",
"int",
"len",
";",
"#ifdef",
"WITH_SSL",
"HMAC_CTX",
"*",
"hctx",
";",
"u_char",
"resp",
"[",
"MSGSIZE",
"]",
",",
"md",
"[",
"EVP_MAX_MD_SIZE",
"]",
";",
"u_int",
"md_len",
";",
"int",
"pos",
";",
"#endif",
"srvp",
"=",
"&",
"h",
"->",
"servers",
"[",
"srv",
"]",
";",
"if",
"(",
"from",
"->",
"sin_family",
"!=",
"srvp",
"->",
"addr",
".",
"sin_family",
"||",
"from",
"->",
"sin_addr",
".",
"s_addr",
"!=",
"srvp",
"->",
"addr",
".",
"sin_addr",
".",
"s_addr",
"||",
"from",
"->",
"sin_port",
"!=",
"srvp",
"->",
"addr",
".",
"sin_port",
")",
"return",
"0",
";",
"if",
"(",
"h",
"->",
"in_len",
"<",
"POS_ATTRS",
")",
"return",
"0",
";",
"len",
"=",
"h",
"->",
"in",
"[",
"POS_LENGTH",
"]",
"<<",
"8",
"|",
"h",
"->",
"in",
"[",
"POS_LENGTH",
"+",
"1",
"]",
";",
"if",
"(",
"len",
">",
"h",
"->",
"in_len",
")",
"return",
"0",
";",
"MD5Init",
"(",
"&",
"ctx",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"&",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
",",
"POS_AUTH",
"-",
"POS_CODE",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"&",
"h",
"->",
"out",
"[",
"POS_AUTH",
"]",
",",
"LEN_AUTH",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"&",
"h",
"->",
"in",
"[",
"POS_ATTRS",
"]",
",",
"len",
"-",
"POS_ATTRS",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"srvp",
"->",
"secret",
",",
"strlen",
"(",
"srvp",
"->",
"secret",
")",
")",
";",
"MD5Final",
"(",
"md5",
",",
"&",
"ctx",
")",
";",
"if",
"(",
"memcmp",
"(",
"&",
"h",
"->",
"in",
"[",
"POS_AUTH",
"]",
",",
"md5",
",",
"sizeof",
"md5",
")",
"!=",
"0",
")",
"return",
"0",
";",
"#ifdef",
"WITH_SSL",
"if",
"(",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
"!=",
"RAD_ACCOUNTING_RESPONSE",
")",
"{",
"memcpy",
"(",
"resp",
",",
"h",
"->",
"in",
",",
"MSGSIZE",
")",
";",
"pos",
"=",
"POS_ATTRS",
";",
"hctx",
"=",
"HMAC_CTX_new",
"(",
")",
";",
"while",
"(",
"pos",
"<",
"len",
"-",
"2",
")",
"{",
"if",
"(",
"h",
"->",
"in",
"[",
"pos",
"]",
"==",
"RAD_MESSAGE_AUTHENTIC",
")",
"{",
"memset",
"(",
"&",
"resp",
"[",
"pos",
"+",
"2",
"]",
",",
"0",
",",
"MD5_DIGEST_LENGTH",
")",
";",
"HMAC_Init_ex",
"(",
"hctx",
",",
"srvp",
"->",
"secret",
",",
"strlen",
"(",
"srvp",
"->",
"secret",
")",
",",
"EVP_md5",
"(",
")",
",",
"NULL",
")",
";",
"HMAC_Update",
"(",
"hctx",
",",
"&",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
",",
"POS_AUTH",
"-",
"POS_CODE",
")",
";",
"HMAC_Update",
"(",
"hctx",
",",
"&",
"h",
"->",
"out",
"[",
"POS_AUTH",
"]",
",",
"LEN_AUTH",
")",
";",
"HMAC_Update",
"(",
"hctx",
",",
"&",
"resp",
"[",
"POS_ATTRS",
"]",
",",
"h",
"->",
"in_len",
"-",
"POS_ATTRS",
")",
";",
"HMAC_Final",
"(",
"hctx",
",",
"md",
",",
"&",
"md_len",
")",
";",
"HMAC_CTX_reset",
"(",
"hctx",
")",
";",
"if",
"(",
"memcmp",
"(",
"md",
",",
"&",
"h",
"->",
"in",
"[",
"pos",
"+",
"2",
"]",
",",
"MD5_DIGEST_LENGTH",
")",
"!=",
"0",
")",
"{",
"HMAC_CTX_free",
"(",
"hctx",
")",
";",
"return",
"0",
";",
"}",
"break",
";",
"}",
"pos",
"+=",
"h",
"->",
"in",
"[",
"pos",
"+",
"1",
"]",
";",
"}",
"HMAC_CTX_free",
"(",
"hctx",
")",
";",
"}",
"#endif",
"return",
"1",
";",
"}"
] | Return true if the current response is valid for a request to the
specified server. | [
"Return",
"true",
"if",
"the",
"current",
"response",
"is",
"valid",
"for",
"a",
"request",
"to",
"the",
"specified",
"server",
"."
] | [
"/* Check the source address */",
"/* Check the message length */",
"/* Check the response authenticator */",
"/*\n\t * For non accounting responses check the message authenticator,\n\t * if any.\n\t */",
"/* Search and verify the Message-Authenticator */",
"/* zero fill the Message-Authenticator */"
] | [
{
"param": "h",
"type": "struct rad_handle"
},
{
"param": "srv",
"type": "int"
},
{
"param": "from",
"type": "struct sockaddr_in"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h",
"type": "struct rad_handle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "srv",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "from",
"type": "struct sockaddr_in",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | is_valid_request | int | static int
is_valid_request(struct rad_handle *h)
{
MD5_CTX ctx;
unsigned char md5[MD5_DIGEST_LENGTH];
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
#endif
srvp = &h->servers[h->srv];
/* Check the message length */
if (h->in_len < POS_ATTRS)
return (0);
len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
if (len > h->in_len)
return (0);
if (h->in[POS_CODE] != RAD_ACCESS_REQUEST) {
uint32_t zeroes[4] = { 0, 0, 0, 0 };
/* Check the request authenticator */
MD5Init(&ctx);
MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
MD5Update(&ctx, zeroes, LEN_AUTH);
MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
MD5Final(md5, &ctx);
if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
return (0);
}
#ifdef WITH_SSL
/* Search and verify the Message-Authenticator */
pos = POS_ATTRS;
hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
memcpy(resp, h->in, MSGSIZE);
/* zero fill the Request-Authenticator */
if (h->in[POS_CODE] != RAD_ACCESS_REQUEST)
memset(&resp[POS_AUTH], 0, LEN_AUTH);
/* zero fill the Message-Authenticator */
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
HMAC_Init_ex(hctx, srvp->secret,
strlen(srvp->secret), EVP_md5(), NULL);
HMAC_Update(hctx, resp, h->in_len);
HMAC_Final(hctx, md, &md_len);
HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
MD5_DIGEST_LENGTH) != 0) {
HMAC_CTX_free(hctx);
return (0);
}
break;
}
pos += h->in[pos + 1];
}
HMAC_CTX_free(hctx);
#endif
return (1);
} | /*
* Return true if the current request is valid for the specified server.
*/ | Return true if the current request is valid for the specified server. | [
"Return",
"true",
"if",
"the",
"current",
"request",
"is",
"valid",
"for",
"the",
"specified",
"server",
"."
] | static int
is_valid_request(struct rad_handle *h)
{
MD5_CTX ctx;
unsigned char md5[MD5_DIGEST_LENGTH];
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
#endif
srvp = &h->servers[h->srv];
if (h->in_len < POS_ATTRS)
return (0);
len = h->in[POS_LENGTH] << 8 | h->in[POS_LENGTH+1];
if (len > h->in_len)
return (0);
if (h->in[POS_CODE] != RAD_ACCESS_REQUEST) {
uint32_t zeroes[4] = { 0, 0, 0, 0 };
MD5Init(&ctx);
MD5Update(&ctx, &h->in[POS_CODE], POS_AUTH - POS_CODE);
MD5Update(&ctx, zeroes, LEN_AUTH);
MD5Update(&ctx, &h->in[POS_ATTRS], len - POS_ATTRS);
MD5Update(&ctx, srvp->secret, strlen(srvp->secret));
MD5Final(md5, &ctx);
if (memcmp(&h->in[POS_AUTH], md5, sizeof md5) != 0)
return (0);
}
#ifdef WITH_SSL
pos = POS_ATTRS;
hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
memcpy(resp, h->in, MSGSIZE);
if (h->in[POS_CODE] != RAD_ACCESS_REQUEST)
memset(&resp[POS_AUTH], 0, LEN_AUTH);
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
HMAC_Init_ex(hctx, srvp->secret,
strlen(srvp->secret), EVP_md5(), NULL);
HMAC_Update(hctx, resp, h->in_len);
HMAC_Final(hctx, md, &md_len);
HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
MD5_DIGEST_LENGTH) != 0) {
HMAC_CTX_free(hctx);
return (0);
}
break;
}
pos += h->in[pos + 1];
}
HMAC_CTX_free(hctx);
#endif
return (1);
} | [
"static",
"int",
"is_valid_request",
"(",
"struct",
"rad_handle",
"*",
"h",
")",
"{",
"MD5_CTX",
"ctx",
";",
"unsigned",
"char",
"md5",
"[",
"MD5_DIGEST_LENGTH",
"]",
";",
"const",
"struct",
"rad_server",
"*",
"srvp",
";",
"int",
"len",
";",
"#ifdef",
"WITH_SSL",
"HMAC_CTX",
"*",
"hctx",
";",
"u_char",
"resp",
"[",
"MSGSIZE",
"]",
",",
"md",
"[",
"EVP_MAX_MD_SIZE",
"]",
";",
"u_int",
"md_len",
";",
"int",
"pos",
";",
"#endif",
"srvp",
"=",
"&",
"h",
"->",
"servers",
"[",
"h",
"->",
"srv",
"]",
";",
"if",
"(",
"h",
"->",
"in_len",
"<",
"POS_ATTRS",
")",
"return",
"(",
"0",
")",
";",
"len",
"=",
"h",
"->",
"in",
"[",
"POS_LENGTH",
"]",
"<<",
"8",
"|",
"h",
"->",
"in",
"[",
"POS_LENGTH",
"+",
"1",
"]",
";",
"if",
"(",
"len",
">",
"h",
"->",
"in_len",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
"!=",
"RAD_ACCESS_REQUEST",
")",
"{",
"uint32_t",
"zeroes",
"[",
"4",
"]",
"=",
"{",
"0",
",",
"0",
",",
"0",
",",
"0",
"}",
";",
"MD5Init",
"(",
"&",
"ctx",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"&",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
",",
"POS_AUTH",
"-",
"POS_CODE",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"zeroes",
",",
"LEN_AUTH",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"&",
"h",
"->",
"in",
"[",
"POS_ATTRS",
"]",
",",
"len",
"-",
"POS_ATTRS",
")",
";",
"MD5Update",
"(",
"&",
"ctx",
",",
"srvp",
"->",
"secret",
",",
"strlen",
"(",
"srvp",
"->",
"secret",
")",
")",
";",
"MD5Final",
"(",
"md5",
",",
"&",
"ctx",
")",
";",
"if",
"(",
"memcmp",
"(",
"&",
"h",
"->",
"in",
"[",
"POS_AUTH",
"]",
",",
"md5",
",",
"sizeof",
"md5",
")",
"!=",
"0",
")",
"return",
"(",
"0",
")",
";",
"}",
"#ifdef",
"WITH_SSL",
"pos",
"=",
"POS_ATTRS",
";",
"hctx",
"=",
"HMAC_CTX_new",
"(",
")",
";",
"while",
"(",
"pos",
"<",
"len",
"-",
"2",
")",
"{",
"if",
"(",
"h",
"->",
"in",
"[",
"pos",
"]",
"==",
"RAD_MESSAGE_AUTHENTIC",
")",
"{",
"memcpy",
"(",
"resp",
",",
"h",
"->",
"in",
",",
"MSGSIZE",
")",
";",
"if",
"(",
"h",
"->",
"in",
"[",
"POS_CODE",
"]",
"!=",
"RAD_ACCESS_REQUEST",
")",
"memset",
"(",
"&",
"resp",
"[",
"POS_AUTH",
"]",
",",
"0",
",",
"LEN_AUTH",
")",
";",
"memset",
"(",
"&",
"resp",
"[",
"pos",
"+",
"2",
"]",
",",
"0",
",",
"MD5_DIGEST_LENGTH",
")",
";",
"HMAC_Init_ex",
"(",
"hctx",
",",
"srvp",
"->",
"secret",
",",
"strlen",
"(",
"srvp",
"->",
"secret",
")",
",",
"EVP_md5",
"(",
")",
",",
"NULL",
")",
";",
"HMAC_Update",
"(",
"hctx",
",",
"resp",
",",
"h",
"->",
"in_len",
")",
";",
"HMAC_Final",
"(",
"hctx",
",",
"md",
",",
"&",
"md_len",
")",
";",
"HMAC_CTX_reset",
"(",
"hctx",
")",
";",
"if",
"(",
"memcmp",
"(",
"md",
",",
"&",
"h",
"->",
"in",
"[",
"pos",
"+",
"2",
"]",
",",
"MD5_DIGEST_LENGTH",
")",
"!=",
"0",
")",
"{",
"HMAC_CTX_free",
"(",
"hctx",
")",
";",
"return",
"(",
"0",
")",
";",
"}",
"break",
";",
"}",
"pos",
"+=",
"h",
"->",
"in",
"[",
"pos",
"+",
"1",
"]",
";",
"}",
"HMAC_CTX_free",
"(",
"hctx",
")",
";",
"#endif",
"return",
"(",
"1",
")",
";",
"}"
] | Return true if the current request is valid for the specified server. | [
"Return",
"true",
"if",
"the",
"current",
"request",
"is",
"valid",
"for",
"the",
"specified",
"server",
"."
] | [
"/* Check the message length */",
"/* Check the request authenticator */",
"/* Search and verify the Message-Authenticator */",
"/* zero fill the Request-Authenticator */",
"/* zero fill the Message-Authenticator */"
] | [
{
"param": "h",
"type": "struct rad_handle"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h",
"type": "struct rad_handle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | rad_init_send_request | int | int
rad_init_send_request(struct rad_handle *h, int *fd, struct timeval *tv)
{
int srv;
time_t now;
struct sockaddr_in sin;
if (h->type == RADIUS_SERVER) {
generr(h, "denied function call");
return (-1);
}
/* Make sure we have a socket to use */
if (h->fd == -1) {
if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
generr(h, "Cannot create socket: %s", strerror(errno));
return -1;
}
memset(&sin, 0, sizeof sin);
sin.sin_len = sizeof sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = h->bindto;
sin.sin_port = htons(0);
if (bind(h->fd, (const struct sockaddr *)&sin,
sizeof sin) == -1) {
generr(h, "bind: %s", strerror(errno));
close(h->fd);
h->fd = -1;
return -1;
}
}
if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
/* Make sure no password given */
if (h->pass_pos || h->chap_pass) {
generr(h, "User or Chap Password"
" in accounting request");
return -1;
}
} else {
if (h->eap_msg == 0) {
/* Make sure the user gave us a password */
if (h->pass_pos == 0 && !h->chap_pass) {
generr(h, "No User or Chap Password"
" attributes given");
return -1;
}
if (h->pass_pos != 0 && h->chap_pass) {
generr(h, "Both User and Chap Password"
" attributes given");
return -1;
}
}
}
/* Fill in the length field in the message */
h->out[POS_LENGTH] = h->out_len >> 8;
h->out[POS_LENGTH+1] = h->out_len;
h->srv = 0;
now = time(NULL);
for (srv = 0; srv < h->num_servers; srv++)
h->servers[srv].num_tries = 0;
/* Find a first good server. */
for (srv = 0; srv < h->num_servers; srv++) {
if (h->servers[srv].is_dead == 0)
break;
if (h->servers[srv].dead_time &&
h->servers[srv].next_probe <= now) {
h->servers[srv].is_dead = 0;
break;
}
h->srv++;
}
/* If all servers was dead on the last probe, try from beginning */
if (h->srv == h->num_servers) {
for (srv = 0; srv < h->num_servers; srv++) {
h->servers[srv].is_dead = 0;
h->servers[srv].next_probe = 0;
}
h->srv = 0;
}
return rad_continue_send_request(h, 0, fd, tv);
} | /*
* Returns -1 on error, 0 to indicate no event and >0 for success
*/ | 1 on error, 0 to indicate no event and >0 for success | [
"1",
"on",
"error",
"0",
"to",
"indicate",
"no",
"event",
"and",
">",
"0",
"for",
"success"
] | int
rad_init_send_request(struct rad_handle *h, int *fd, struct timeval *tv)
{
int srv;
time_t now;
struct sockaddr_in sin;
if (h->type == RADIUS_SERVER) {
generr(h, "denied function call");
return (-1);
}
if (h->fd == -1) {
if ((h->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
generr(h, "Cannot create socket: %s", strerror(errno));
return -1;
}
memset(&sin, 0, sizeof sin);
sin.sin_len = sizeof sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = h->bindto;
sin.sin_port = htons(0);
if (bind(h->fd, (const struct sockaddr *)&sin,
sizeof sin) == -1) {
generr(h, "bind: %s", strerror(errno));
close(h->fd);
h->fd = -1;
return -1;
}
}
if (h->out[POS_CODE] != RAD_ACCESS_REQUEST) {
if (h->pass_pos || h->chap_pass) {
generr(h, "User or Chap Password"
" in accounting request");
return -1;
}
} else {
if (h->eap_msg == 0) {
if (h->pass_pos == 0 && !h->chap_pass) {
generr(h, "No User or Chap Password"
" attributes given");
return -1;
}
if (h->pass_pos != 0 && h->chap_pass) {
generr(h, "Both User and Chap Password"
" attributes given");
return -1;
}
}
}
h->out[POS_LENGTH] = h->out_len >> 8;
h->out[POS_LENGTH+1] = h->out_len;
h->srv = 0;
now = time(NULL);
for (srv = 0; srv < h->num_servers; srv++)
h->servers[srv].num_tries = 0;
for (srv = 0; srv < h->num_servers; srv++) {
if (h->servers[srv].is_dead == 0)
break;
if (h->servers[srv].dead_time &&
h->servers[srv].next_probe <= now) {
h->servers[srv].is_dead = 0;
break;
}
h->srv++;
}
if (h->srv == h->num_servers) {
for (srv = 0; srv < h->num_servers; srv++) {
h->servers[srv].is_dead = 0;
h->servers[srv].next_probe = 0;
}
h->srv = 0;
}
return rad_continue_send_request(h, 0, fd, tv);
} | [
"int",
"rad_init_send_request",
"(",
"struct",
"rad_handle",
"*",
"h",
",",
"int",
"*",
"fd",
",",
"struct",
"timeval",
"*",
"tv",
")",
"{",
"int",
"srv",
";",
"time_t",
"now",
";",
"struct",
"sockaddr_in",
"sin",
";",
"if",
"(",
"h",
"->",
"type",
"==",
"RADIUS_SERVER",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
")",
";",
"return",
"(",
"-1",
")",
";",
"}",
"if",
"(",
"h",
"->",
"fd",
"==",
"-1",
")",
"{",
"if",
"(",
"(",
"h",
"->",
"fd",
"=",
"socket",
"(",
"PF_INET",
",",
"SOCK_DGRAM",
",",
"IPPROTO_UDP",
")",
")",
"==",
"-1",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"return",
"-1",
";",
"}",
"memset",
"(",
"&",
"sin",
",",
"0",
",",
"sizeof",
"sin",
")",
";",
"sin",
".",
"sin_len",
"=",
"sizeof",
"sin",
";",
"sin",
".",
"sin_family",
"=",
"AF_INET",
";",
"sin",
".",
"sin_addr",
".",
"s_addr",
"=",
"h",
"->",
"bindto",
";",
"sin",
".",
"sin_port",
"=",
"htons",
"(",
"0",
")",
";",
"if",
"(",
"bind",
"(",
"h",
"->",
"fd",
",",
"(",
"const",
"struct",
"sockaddr",
"*",
")",
"&",
"sin",
",",
"sizeof",
"sin",
")",
"==",
"-1",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"close",
"(",
"h",
"->",
"fd",
")",
";",
"h",
"->",
"fd",
"=",
"-1",
";",
"return",
"-1",
";",
"}",
"}",
"if",
"(",
"h",
"->",
"out",
"[",
"POS_CODE",
"]",
"!=",
"RAD_ACCESS_REQUEST",
")",
"{",
"if",
"(",
"h",
"->",
"pass_pos",
"||",
"h",
"->",
"chap_pass",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"h",
"->",
"eap_msg",
"==",
"0",
")",
"{",
"if",
"(",
"h",
"->",
"pass_pos",
"==",
"0",
"&&",
"!",
"h",
"->",
"chap_pass",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"h",
"->",
"pass_pos",
"!=",
"0",
"&&",
"h",
"->",
"chap_pass",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"}",
"}",
"h",
"->",
"out",
"[",
"POS_LENGTH",
"]",
"=",
"h",
"->",
"out_len",
">>",
"8",
";",
"h",
"->",
"out",
"[",
"POS_LENGTH",
"+",
"1",
"]",
"=",
"h",
"->",
"out_len",
";",
"h",
"->",
"srv",
"=",
"0",
";",
"now",
"=",
"time",
"(",
"NULL",
")",
";",
"for",
"(",
"srv",
"=",
"0",
";",
"srv",
"<",
"h",
"->",
"num_servers",
";",
"srv",
"++",
")",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"num_tries",
"=",
"0",
";",
"for",
"(",
"srv",
"=",
"0",
";",
"srv",
"<",
"h",
"->",
"num_servers",
";",
"srv",
"++",
")",
"{",
"if",
"(",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"is_dead",
"==",
"0",
")",
"break",
";",
"if",
"(",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"dead_time",
"&&",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"next_probe",
"<=",
"now",
")",
"{",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"is_dead",
"=",
"0",
";",
"break",
";",
"}",
"h",
"->",
"srv",
"++",
";",
"}",
"if",
"(",
"h",
"->",
"srv",
"==",
"h",
"->",
"num_servers",
")",
"{",
"for",
"(",
"srv",
"=",
"0",
";",
"srv",
"<",
"h",
"->",
"num_servers",
";",
"srv",
"++",
")",
"{",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"is_dead",
"=",
"0",
";",
"h",
"->",
"servers",
"[",
"srv",
"]",
".",
"next_probe",
"=",
"0",
";",
"}",
"h",
"->",
"srv",
"=",
"0",
";",
"}",
"return",
"rad_continue_send_request",
"(",
"h",
",",
"0",
",",
"fd",
",",
"tv",
")",
";",
"}"
] | Returns -1 on error, 0 to indicate no event and >0 for success | [
"Returns",
"-",
"1",
"on",
"error",
"0",
"to",
"indicate",
"no",
"event",
"and",
">",
"0",
"for",
"success"
] | [
"/* Make sure we have a socket to use */",
"/* Make sure no password given */",
"/* Make sure the user gave us a password */",
"/* Fill in the length field in the message */",
"/* Find a first good server. */",
"/* If all servers was dead on the last probe, try from beginning */"
] | [
{
"param": "h",
"type": "struct rad_handle"
},
{
"param": "fd",
"type": "int"
},
{
"param": "tv",
"type": "struct timeval"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h",
"type": "struct rad_handle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fd",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tv",
"type": "struct timeval",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | rad_auth_open | null | struct rad_handle *
rad_auth_open(void)
{
struct rad_handle *h;
h = (struct rad_handle *)malloc(sizeof(struct rad_handle));
if (h != NULL) {
srandomdev();
h->fd = -1;
h->num_servers = 0;
h->ident = random();
h->errmsg[0] = '\0';
memset(h->pass, 0, sizeof h->pass);
h->pass_len = 0;
h->pass_pos = 0;
h->chap_pass = 0;
h->authentic_pos = 0;
h->type = RADIUS_AUTH;
h->out_created = 0;
h->eap_msg = 0;
h->bindto = INADDR_ANY;
}
return h;
} | /*
* Create and initialize a rad_handle structure, and return it to the
* caller. Can fail only if the necessary memory cannot be allocated.
* In that case, it returns NULL.
*/ | Create and initialize a rad_handle structure, and return it to the
caller. Can fail only if the necessary memory cannot be allocated.
In that case, it returns NULL. | [
"Create",
"and",
"initialize",
"a",
"rad_handle",
"structure",
"and",
"return",
"it",
"to",
"the",
"caller",
".",
"Can",
"fail",
"only",
"if",
"the",
"necessary",
"memory",
"cannot",
"be",
"allocated",
".",
"In",
"that",
"case",
"it",
"returns",
"NULL",
"."
] | struct rad_handle *
rad_auth_open(void)
{
struct rad_handle *h;
h = (struct rad_handle *)malloc(sizeof(struct rad_handle));
if (h != NULL) {
srandomdev();
h->fd = -1;
h->num_servers = 0;
h->ident = random();
h->errmsg[0] = '\0';
memset(h->pass, 0, sizeof h->pass);
h->pass_len = 0;
h->pass_pos = 0;
h->chap_pass = 0;
h->authentic_pos = 0;
h->type = RADIUS_AUTH;
h->out_created = 0;
h->eap_msg = 0;
h->bindto = INADDR_ANY;
}
return h;
} | [
"struct",
"rad_handle",
"*",
"rad_auth_open",
"(",
"void",
")",
"{",
"struct",
"rad_handle",
"*",
"h",
";",
"h",
"=",
"(",
"struct",
"rad_handle",
"*",
")",
"malloc",
"(",
"sizeof",
"(",
"struct",
"rad_handle",
")",
")",
";",
"if",
"(",
"h",
"!=",
"NULL",
")",
"{",
"srandomdev",
"(",
")",
";",
"h",
"->",
"fd",
"=",
"-1",
";",
"h",
"->",
"num_servers",
"=",
"0",
";",
"h",
"->",
"ident",
"=",
"random",
"(",
")",
";",
"h",
"->",
"errmsg",
"[",
"0",
"]",
"=",
"'",
"\\0",
"'",
";",
"memset",
"(",
"h",
"->",
"pass",
",",
"0",
",",
"sizeof",
"h",
"->",
"pass",
")",
";",
"h",
"->",
"pass_len",
"=",
"0",
";",
"h",
"->",
"pass_pos",
"=",
"0",
";",
"h",
"->",
"chap_pass",
"=",
"0",
";",
"h",
"->",
"authentic_pos",
"=",
"0",
";",
"h",
"->",
"type",
"=",
"RADIUS_AUTH",
";",
"h",
"->",
"out_created",
"=",
"0",
";",
"h",
"->",
"eap_msg",
"=",
"0",
";",
"h",
"->",
"bindto",
"=",
"INADDR_ANY",
";",
"}",
"return",
"h",
";",
"}"
] | Create and initialize a rad_handle structure, and return it to the
caller. | [
"Create",
"and",
"initialize",
"a",
"rad_handle",
"structure",
"and",
"return",
"it",
"to",
"the",
"caller",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | rad_send_request | int | int
rad_send_request(struct rad_handle *h)
{
struct timeval timelimit;
struct timeval tv;
int fd;
int n;
n = rad_init_send_request(h, &fd, &tv);
if (n != 0)
return n;
gettimeofday(&timelimit, NULL);
timeradd(&tv, &timelimit, &timelimit);
for ( ; ; ) {
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
n = select(fd + 1, &readfds, NULL, NULL, &tv);
if (n == -1) {
generr(h, "select: %s", strerror(errno));
return -1;
}
if (!FD_ISSET(fd, &readfds)) {
/* Compute a new timeout */
gettimeofday(&tv, NULL);
timersub(&timelimit, &tv, &tv);
if (tv.tv_sec > 0 || (tv.tv_sec == 0 && tv.tv_usec > 0))
/* Continue the select */
continue;
}
n = rad_continue_send_request(h, n, &fd, &tv);
if (n != 0)
return n;
gettimeofday(&timelimit, NULL);
timeradd(&tv, &timelimit, &timelimit);
}
} | /*
* Returns the response type code on success, or -1 on failure.
*/ | Returns the response type code on success, or -1 on failure. | [
"Returns",
"the",
"response",
"type",
"code",
"on",
"success",
"or",
"-",
"1",
"on",
"failure",
"."
] | int
rad_send_request(struct rad_handle *h)
{
struct timeval timelimit;
struct timeval tv;
int fd;
int n;
n = rad_init_send_request(h, &fd, &tv);
if (n != 0)
return n;
gettimeofday(&timelimit, NULL);
timeradd(&tv, &timelimit, &timelimit);
for ( ; ; ) {
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
n = select(fd + 1, &readfds, NULL, NULL, &tv);
if (n == -1) {
generr(h, "select: %s", strerror(errno));
return -1;
}
if (!FD_ISSET(fd, &readfds)) {
gettimeofday(&tv, NULL);
timersub(&timelimit, &tv, &tv);
if (tv.tv_sec > 0 || (tv.tv_sec == 0 && tv.tv_usec > 0))
continue;
}
n = rad_continue_send_request(h, n, &fd, &tv);
if (n != 0)
return n;
gettimeofday(&timelimit, NULL);
timeradd(&tv, &timelimit, &timelimit);
}
} | [
"int",
"rad_send_request",
"(",
"struct",
"rad_handle",
"*",
"h",
")",
"{",
"struct",
"timeval",
"timelimit",
";",
"struct",
"timeval",
"tv",
";",
"int",
"fd",
";",
"int",
"n",
";",
"n",
"=",
"rad_init_send_request",
"(",
"h",
",",
"&",
"fd",
",",
"&",
"tv",
")",
";",
"if",
"(",
"n",
"!=",
"0",
")",
"return",
"n",
";",
"gettimeofday",
"(",
"&",
"timelimit",
",",
"NULL",
")",
";",
"timeradd",
"(",
"&",
"tv",
",",
"&",
"timelimit",
",",
"&",
"timelimit",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"fd_set",
"readfds",
";",
"FD_ZERO",
"(",
"&",
"readfds",
")",
";",
"FD_SET",
"(",
"fd",
",",
"&",
"readfds",
")",
";",
"n",
"=",
"select",
"(",
"fd",
"+",
"1",
",",
"&",
"readfds",
",",
"NULL",
",",
"NULL",
",",
"&",
"tv",
")",
";",
"if",
"(",
"n",
"==",
"-1",
")",
"{",
"generr",
"(",
"h",
",",
"\"",
"\"",
",",
"strerror",
"(",
"errno",
")",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"!",
"FD_ISSET",
"(",
"fd",
",",
"&",
"readfds",
")",
")",
"{",
"gettimeofday",
"(",
"&",
"tv",
",",
"NULL",
")",
";",
"timersub",
"(",
"&",
"timelimit",
",",
"&",
"tv",
",",
"&",
"tv",
")",
";",
"if",
"(",
"tv",
".",
"tv_sec",
">",
"0",
"||",
"(",
"tv",
".",
"tv_sec",
"==",
"0",
"&&",
"tv",
".",
"tv_usec",
">",
"0",
")",
")",
"continue",
";",
"}",
"n",
"=",
"rad_continue_send_request",
"(",
"h",
",",
"n",
",",
"&",
"fd",
",",
"&",
"tv",
")",
";",
"if",
"(",
"n",
"!=",
"0",
")",
"return",
"n",
";",
"gettimeofday",
"(",
"&",
"timelimit",
",",
"NULL",
")",
";",
"timeradd",
"(",
"&",
"tv",
",",
"&",
"timelimit",
",",
"&",
"timelimit",
")",
";",
"}",
"}"
] | Returns the response type code on success, or -1 on failure. | [
"Returns",
"the",
"response",
"type",
"code",
"on",
"success",
"or",
"-",
"1",
"on",
"failure",
"."
] | [
"/* Compute a new timeout */",
"/* Continue the select */"
] | [
{
"param": "h",
"type": "struct rad_handle"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "h",
"type": "struct rad_handle",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f00eeb029e4acd82c975fd9b067db22cb39c7e3 | atrens/DragonFlyBSD-src | usr.sbin/ppp/libradius/radlib.c | [
"BSD-3-Clause"
] | C | split | int | static int
split(char *str, const char *fields[], int maxfields, char *msg, size_t msglen)
{
char *p;
int i;
static const char ws[] = " \t";
for (i = 0; i < maxfields; i++)
fields[i] = NULL;
p = str;
i = 0;
while (*p != '\0') {
p += strspn(p, ws);
if (*p == '#' || *p == '\0')
break;
if (i >= maxfields) {
snprintf(msg, msglen, "line has too many fields");
return -1;
}
if (*p == '"') {
char *dst;
dst = ++p;
fields[i] = dst;
while (*p != '"') {
if (*p == '\\') {
p++;
if (*p != '"' && *p != '\\' &&
*p != '\0') {
snprintf(msg, msglen,
"invalid `\\' escape");
return -1;
}
}
if (*p == '\0') {
snprintf(msg, msglen,
"unterminated quoted string");
return -1;
}
*dst++ = *p++;
}
*dst = '\0';
p++;
if (*fields[i] == '\0') {
snprintf(msg, msglen,
"empty quoted string not permitted");
return -1;
}
if (*p != '\0' && strspn(p, ws) == 0) {
snprintf(msg, msglen, "quoted string not"
" followed by white space");
return -1;
}
} else {
fields[i] = p;
p += strcspn(p, ws);
if (*p != '\0')
*p++ = '\0';
}
i++;
}
return i;
} | /*
* Destructively split a string into fields separated by white space.
* `#' at the beginning of a field begins a comment that extends to the
* end of the string. Fields may be quoted with `"'. Inside quoted
* strings, the backslash escapes `\"' and `\\' are honored.
*
* Pointers to up to the first maxfields fields are stored in the fields
* array. Missing fields get NULL pointers.
*
* The return value is the actual number of fields parsed, and is always
* <= maxfields.
*
* On a syntax error, places a message in the msg string, and returns -1.
*/ | Destructively split a string into fields separated by white space.
`#' at the beginning of a field begins a comment that extends to the
end of the string. Fields may be quoted with `"'. Inside quoted
strings, the backslash escapes `\"' and `\\' are honored.
Pointers to up to the first maxfields fields are stored in the fields
array. Missing fields get NULL pointers.
The return value is the actual number of fields parsed, and is always
<= maxfields.
On a syntax error, places a message in the msg string, and returns -1. | [
"Destructively",
"split",
"a",
"string",
"into",
"fields",
"separated",
"by",
"white",
"space",
".",
"`",
"#",
"'",
"at",
"the",
"beginning",
"of",
"a",
"field",
"begins",
"a",
"comment",
"that",
"extends",
"to",
"the",
"end",
"of",
"the",
"string",
".",
"Fields",
"may",
"be",
"quoted",
"with",
"`",
"\"",
"'",
".",
"Inside",
"quoted",
"strings",
"the",
"backslash",
"escapes",
"`",
"\\",
"\"",
"'",
"and",
"`",
"\\\\",
"'",
"are",
"honored",
".",
"Pointers",
"to",
"up",
"to",
"the",
"first",
"maxfields",
"fields",
"are",
"stored",
"in",
"the",
"fields",
"array",
".",
"Missing",
"fields",
"get",
"NULL",
"pointers",
".",
"The",
"return",
"value",
"is",
"the",
"actual",
"number",
"of",
"fields",
"parsed",
"and",
"is",
"always",
"<",
"=",
"maxfields",
".",
"On",
"a",
"syntax",
"error",
"places",
"a",
"message",
"in",
"the",
"msg",
"string",
"and",
"returns",
"-",
"1",
"."
] | static int
split(char *str, const char *fields[], int maxfields, char *msg, size_t msglen)
{
char *p;
int i;
static const char ws[] = " \t";
for (i = 0; i < maxfields; i++)
fields[i] = NULL;
p = str;
i = 0;
while (*p != '\0') {
p += strspn(p, ws);
if (*p == '#' || *p == '\0')
break;
if (i >= maxfields) {
snprintf(msg, msglen, "line has too many fields");
return -1;
}
if (*p == '"') {
char *dst;
dst = ++p;
fields[i] = dst;
while (*p != '"') {
if (*p == '\\') {
p++;
if (*p != '"' && *p != '\\' &&
*p != '\0') {
snprintf(msg, msglen,
"invalid `\\' escape");
return -1;
}
}
if (*p == '\0') {
snprintf(msg, msglen,
"unterminated quoted string");
return -1;
}
*dst++ = *p++;
}
*dst = '\0';
p++;
if (*fields[i] == '\0') {
snprintf(msg, msglen,
"empty quoted string not permitted");
return -1;
}
if (*p != '\0' && strspn(p, ws) == 0) {
snprintf(msg, msglen, "quoted string not"
" followed by white space");
return -1;
}
} else {
fields[i] = p;
p += strcspn(p, ws);
if (*p != '\0')
*p++ = '\0';
}
i++;
}
return i;
} | [
"static",
"int",
"split",
"(",
"char",
"*",
"str",
",",
"const",
"char",
"*",
"fields",
"[",
"]",
",",
"int",
"maxfields",
",",
"char",
"*",
"msg",
",",
"size_t",
"msglen",
")",
"{",
"char",
"*",
"p",
";",
"int",
"i",
";",
"static",
"const",
"char",
"ws",
"[",
"]",
"=",
"\"",
"\\t",
"\"",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"maxfields",
";",
"i",
"++",
")",
"fields",
"[",
"i",
"]",
"=",
"NULL",
";",
"p",
"=",
"str",
";",
"i",
"=",
"0",
";",
"while",
"(",
"*",
"p",
"!=",
"'",
"\\0",
"'",
")",
"{",
"p",
"+=",
"strspn",
"(",
"p",
",",
"ws",
")",
";",
"if",
"(",
"*",
"p",
"==",
"'",
"'",
"||",
"*",
"p",
"==",
"'",
"\\0",
"'",
")",
"break",
";",
"if",
"(",
"i",
">=",
"maxfields",
")",
"{",
"snprintf",
"(",
"msg",
",",
"msglen",
",",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"*",
"p",
"==",
"'",
"'",
")",
"{",
"char",
"*",
"dst",
";",
"dst",
"=",
"++",
"p",
";",
"fields",
"[",
"i",
"]",
"=",
"dst",
";",
"while",
"(",
"*",
"p",
"!=",
"'",
"'",
")",
"{",
"if",
"(",
"*",
"p",
"==",
"'",
"\\\\",
"'",
")",
"{",
"p",
"++",
";",
"if",
"(",
"*",
"p",
"!=",
"'",
"'",
"&&",
"*",
"p",
"!=",
"'",
"\\\\",
"'",
"&&",
"*",
"p",
"!=",
"'",
"\\0",
"'",
")",
"{",
"snprintf",
"(",
"msg",
",",
"msglen",
",",
"\"",
"\\\\",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"}",
"if",
"(",
"*",
"p",
"==",
"'",
"\\0",
"'",
")",
"{",
"snprintf",
"(",
"msg",
",",
"msglen",
",",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"*",
"dst",
"++",
"=",
"*",
"p",
"++",
";",
"}",
"*",
"dst",
"=",
"'",
"\\0",
"'",
";",
"p",
"++",
";",
"if",
"(",
"*",
"fields",
"[",
"i",
"]",
"==",
"'",
"\\0",
"'",
")",
"{",
"snprintf",
"(",
"msg",
",",
"msglen",
",",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"if",
"(",
"*",
"p",
"!=",
"'",
"\\0",
"'",
"&&",
"strspn",
"(",
"p",
",",
"ws",
")",
"==",
"0",
")",
"{",
"snprintf",
"(",
"msg",
",",
"msglen",
",",
"\"",
"\"",
"\"",
"\"",
")",
";",
"return",
"-1",
";",
"}",
"}",
"else",
"{",
"fields",
"[",
"i",
"]",
"=",
"p",
";",
"p",
"+=",
"strcspn",
"(",
"p",
",",
"ws",
")",
";",
"if",
"(",
"*",
"p",
"!=",
"'",
"\\0",
"'",
")",
"*",
"p",
"++",
"=",
"'",
"\\0",
"'",
";",
"}",
"i",
"++",
";",
"}",
"return",
"i",
";",
"}"
] | Destructively split a string into fields separated by white space. | [
"Destructively",
"split",
"a",
"string",
"into",
"fields",
"separated",
"by",
"white",
"space",
"."
] | [] | [
{
"param": "str",
"type": "char"
},
{
"param": "fields",
"type": "char"
},
{
"param": "maxfields",
"type": "int"
},
{
"param": "msg",
"type": "char"
},
{
"param": "msglen",
"type": "size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "str",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fields",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "maxfields",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msg",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msglen",
"type": "size_t",
"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_newhook | int | static int
ng_ppp_newhook(node_p node, hook_p hook, const char *name)
{
const priv_p priv = node->private;
int linkNum = -1;
hook_p *hookPtr = NULL;
int hookIndex = -1;
/* Figure out which hook it is */
if (strncmp(name, NG_PPP_HOOK_LINK_PREFIX, /* a link hook? */
strlen(NG_PPP_HOOK_LINK_PREFIX)) == 0) {
const char *cp;
char *eptr;
cp = name + strlen(NG_PPP_HOOK_LINK_PREFIX);
if (!isdigit(*cp) || (cp[0] == '0' && cp[1] != '\0'))
return (EINVAL);
linkNum = (int)strtoul(cp, &eptr, 10);
if (*eptr != '\0' || linkNum < 0 || linkNum >= NG_PPP_MAX_LINKS)
return (EINVAL);
hookPtr = &priv->links[linkNum].hook;
hookIndex = ~linkNum;
} else { /* must be a non-link hook */
int i;
for (i = 0; ng_ppp_hook_names[i] != NULL; i++) {
if (strcmp(name, ng_ppp_hook_names[i]) == 0) {
hookPtr = &priv->hooks[i];
hookIndex = i;
break;
}
}
if (ng_ppp_hook_names[i] == NULL)
return (EINVAL); /* no such hook */
}
/* See if hook is already connected */
if (*hookPtr != NULL)
return (EISCONN);
/* Disallow more than one link unless multilink is enabled */
if (linkNum != -1 && priv->links[linkNum].conf.enableLink
&& !priv->conf.enableMultilink && priv->numActiveLinks >= 1)
return (ENODEV);
/* OK */
*hookPtr = hook;
HOOK_INDEX(hook) = hookIndex;
ng_ppp_update(node, 0);
return (0);
} | /*
* Give our OK for a hook to be added
*/ | Give our OK for a hook to be added | [
"Give",
"our",
"OK",
"for",
"a",
"hook",
"to",
"be",
"added"
] | static int
ng_ppp_newhook(node_p node, hook_p hook, const char *name)
{
const priv_p priv = node->private;
int linkNum = -1;
hook_p *hookPtr = NULL;
int hookIndex = -1;
if (strncmp(name, NG_PPP_HOOK_LINK_PREFIX,
strlen(NG_PPP_HOOK_LINK_PREFIX)) == 0) {
const char *cp;
char *eptr;
cp = name + strlen(NG_PPP_HOOK_LINK_PREFIX);
if (!isdigit(*cp) || (cp[0] == '0' && cp[1] != '\0'))
return (EINVAL);
linkNum = (int)strtoul(cp, &eptr, 10);
if (*eptr != '\0' || linkNum < 0 || linkNum >= NG_PPP_MAX_LINKS)
return (EINVAL);
hookPtr = &priv->links[linkNum].hook;
hookIndex = ~linkNum;
} else {
int i;
for (i = 0; ng_ppp_hook_names[i] != NULL; i++) {
if (strcmp(name, ng_ppp_hook_names[i]) == 0) {
hookPtr = &priv->hooks[i];
hookIndex = i;
break;
}
}
if (ng_ppp_hook_names[i] == NULL)
return (EINVAL);
}
if (*hookPtr != NULL)
return (EISCONN);
if (linkNum != -1 && priv->links[linkNum].conf.enableLink
&& !priv->conf.enableMultilink && priv->numActiveLinks >= 1)
return (ENODEV);
*hookPtr = hook;
HOOK_INDEX(hook) = hookIndex;
ng_ppp_update(node, 0);
return (0);
} | [
"static",
"int",
"ng_ppp_newhook",
"(",
"node_p",
"node",
",",
"hook_p",
"hook",
",",
"const",
"char",
"*",
"name",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"int",
"linkNum",
"=",
"-1",
";",
"hook_p",
"*",
"hookPtr",
"=",
"NULL",
";",
"int",
"hookIndex",
"=",
"-1",
";",
"if",
"(",
"strncmp",
"(",
"name",
",",
"NG_PPP_HOOK_LINK_PREFIX",
",",
"strlen",
"(",
"NG_PPP_HOOK_LINK_PREFIX",
")",
")",
"==",
"0",
")",
"{",
"const",
"char",
"*",
"cp",
";",
"char",
"*",
"eptr",
";",
"cp",
"=",
"name",
"+",
"strlen",
"(",
"NG_PPP_HOOK_LINK_PREFIX",
")",
";",
"if",
"(",
"!",
"isdigit",
"(",
"*",
"cp",
")",
"||",
"(",
"cp",
"[",
"0",
"]",
"==",
"'",
"'",
"&&",
"cp",
"[",
"1",
"]",
"!=",
"'",
"\\0",
"'",
")",
")",
"return",
"(",
"EINVAL",
")",
";",
"linkNum",
"=",
"(",
"int",
")",
"strtoul",
"(",
"cp",
",",
"&",
"eptr",
",",
"10",
")",
";",
"if",
"(",
"*",
"eptr",
"!=",
"'",
"\\0",
"'",
"||",
"linkNum",
"<",
"0",
"||",
"linkNum",
">=",
"NG_PPP_MAX_LINKS",
")",
"return",
"(",
"EINVAL",
")",
";",
"hookPtr",
"=",
"&",
"priv",
"->",
"links",
"[",
"linkNum",
"]",
".",
"hook",
";",
"hookIndex",
"=",
"~",
"linkNum",
";",
"}",
"else",
"{",
"int",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"ng_ppp_hook_names",
"[",
"i",
"]",
"!=",
"NULL",
";",
"i",
"++",
")",
"{",
"if",
"(",
"strcmp",
"(",
"name",
",",
"ng_ppp_hook_names",
"[",
"i",
"]",
")",
"==",
"0",
")",
"{",
"hookPtr",
"=",
"&",
"priv",
"->",
"hooks",
"[",
"i",
"]",
";",
"hookIndex",
"=",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"ng_ppp_hook_names",
"[",
"i",
"]",
"==",
"NULL",
")",
"return",
"(",
"EINVAL",
")",
";",
"}",
"if",
"(",
"*",
"hookPtr",
"!=",
"NULL",
")",
"return",
"(",
"EISCONN",
")",
";",
"if",
"(",
"linkNum",
"!=",
"-1",
"&&",
"priv",
"->",
"links",
"[",
"linkNum",
"]",
".",
"conf",
".",
"enableLink",
"&&",
"!",
"priv",
"->",
"conf",
".",
"enableMultilink",
"&&",
"priv",
"->",
"numActiveLinks",
">=",
"1",
")",
"return",
"(",
"ENODEV",
")",
";",
"*",
"hookPtr",
"=",
"hook",
";",
"HOOK_INDEX",
"(",
"hook",
")",
"=",
"hookIndex",
";",
"ng_ppp_update",
"(",
"node",
",",
"0",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Give our OK for a hook to be added | [
"Give",
"our",
"OK",
"for",
"a",
"hook",
"to",
"be",
"added"
] | [
"/* Figure out which hook it is */",
"/* a link hook? */",
"/* must be a non-link hook */",
"/* no such hook */",
"/* See if hook is already connected */",
"/* Disallow more than one link unless multilink is enabled */",
"/* OK */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "hook",
"type": "hook_p"
},
{
"param": "name",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"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_output | int | static int
ng_ppp_output(node_p node, int bypass,
int proto, int linkNum, struct mbuf *m, meta_p meta)
{
const priv_p priv = node->private;
struct ng_ppp_link *link;
int len, error;
u_int16_t mru;
/* If not doing MP, map bundle virtual link to (the only) link */
if (linkNum == NG_PPP_BUNDLE_LINKNUM && !priv->conf.enableMultilink)
linkNum = priv->activeLinks[0];
/* Get link pointer (optimization) */
link = (linkNum != NG_PPP_BUNDLE_LINKNUM) ?
&priv->links[linkNum] : NULL;
/* Check link status (if real) */
if (linkNum != NG_PPP_BUNDLE_LINKNUM) {
if (!bypass && !link->conf.enableLink) {
NG_FREE_DATA(m, meta);
return (ENXIO);
}
if (link->hook == NULL) {
NG_FREE_DATA(m, meta);
return (ENETDOWN);
}
}
/* Check peer's MRU for this link */
mru = (link != NULL) ? link->conf.mru : priv->conf.mrru;
if (mru != 0 && m->m_pkthdr.len > mru) {
NG_FREE_DATA(m, meta);
return (EMSGSIZE);
}
/* Prepend protocol number, possibly compressed */
if ((m = ng_ppp_addproto(m, proto,
linkNum == NG_PPP_BUNDLE_LINKNUM
|| link->conf.enableProtoComp)) == NULL) {
NG_FREE_META(meta);
return (ENOBUFS);
}
/* Special handling for the MP virtual link */
if (linkNum == NG_PPP_BUNDLE_LINKNUM)
return ng_ppp_mp_output(node, m, meta);
/* Prepend address and control field (unless compressed) */
if (proto == PROT_LCP || !link->conf.enableACFComp) {
if ((m = ng_ppp_prepend(m, &ng_ppp_acf, 2)) == NULL) {
NG_FREE_META(meta);
return (ENOBUFS);
}
}
/* Deliver frame */
len = m->m_pkthdr.len;
NG_SEND_DATA(error, link->hook, m, meta);
/* Update stats and 'bytes in queue' counter */
if (error == 0) {
link->stats.xmitFrames++;
link->stats.xmitOctets += len;
link->bytesInQueue += len;
getmicrouptime(&link->lastWrite);
}
return error;
} | /*
* Deliver a frame out a link, either a real one or NG_PPP_BUNDLE_LINKNUM.
* If the link is not enabled then ENXIO is returned, unless "bypass" is != 0.
*
* If the frame is too big for the particular link, return EMSGSIZE.
*/ | Deliver a frame out a link, either a real one or NG_PPP_BUNDLE_LINKNUM.
If the link is not enabled then ENXIO is returned, unless "bypass" is != 0.
If the frame is too big for the particular link, return EMSGSIZE. | [
"Deliver",
"a",
"frame",
"out",
"a",
"link",
"either",
"a",
"real",
"one",
"or",
"NG_PPP_BUNDLE_LINKNUM",
".",
"If",
"the",
"link",
"is",
"not",
"enabled",
"then",
"ENXIO",
"is",
"returned",
"unless",
"\"",
"bypass",
"\"",
"is",
"!",
"=",
"0",
".",
"If",
"the",
"frame",
"is",
"too",
"big",
"for",
"the",
"particular",
"link",
"return",
"EMSGSIZE",
"."
] | static int
ng_ppp_output(node_p node, int bypass,
int proto, int linkNum, struct mbuf *m, meta_p meta)
{
const priv_p priv = node->private;
struct ng_ppp_link *link;
int len, error;
u_int16_t mru;
if (linkNum == NG_PPP_BUNDLE_LINKNUM && !priv->conf.enableMultilink)
linkNum = priv->activeLinks[0];
link = (linkNum != NG_PPP_BUNDLE_LINKNUM) ?
&priv->links[linkNum] : NULL;
if (linkNum != NG_PPP_BUNDLE_LINKNUM) {
if (!bypass && !link->conf.enableLink) {
NG_FREE_DATA(m, meta);
return (ENXIO);
}
if (link->hook == NULL) {
NG_FREE_DATA(m, meta);
return (ENETDOWN);
}
}
mru = (link != NULL) ? link->conf.mru : priv->conf.mrru;
if (mru != 0 && m->m_pkthdr.len > mru) {
NG_FREE_DATA(m, meta);
return (EMSGSIZE);
}
if ((m = ng_ppp_addproto(m, proto,
linkNum == NG_PPP_BUNDLE_LINKNUM
|| link->conf.enableProtoComp)) == NULL) {
NG_FREE_META(meta);
return (ENOBUFS);
}
if (linkNum == NG_PPP_BUNDLE_LINKNUM)
return ng_ppp_mp_output(node, m, meta);
if (proto == PROT_LCP || !link->conf.enableACFComp) {
if ((m = ng_ppp_prepend(m, &ng_ppp_acf, 2)) == NULL) {
NG_FREE_META(meta);
return (ENOBUFS);
}
}
len = m->m_pkthdr.len;
NG_SEND_DATA(error, link->hook, m, meta);
if (error == 0) {
link->stats.xmitFrames++;
link->stats.xmitOctets += len;
link->bytesInQueue += len;
getmicrouptime(&link->lastWrite);
}
return error;
} | [
"static",
"int",
"ng_ppp_output",
"(",
"node_p",
"node",
",",
"int",
"bypass",
",",
"int",
"proto",
",",
"int",
"linkNum",
",",
"struct",
"mbuf",
"*",
"m",
",",
"meta_p",
"meta",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"struct",
"ng_ppp_link",
"*",
"link",
";",
"int",
"len",
",",
"error",
";",
"u_int16_t",
"mru",
";",
"if",
"(",
"linkNum",
"==",
"NG_PPP_BUNDLE_LINKNUM",
"&&",
"!",
"priv",
"->",
"conf",
".",
"enableMultilink",
")",
"linkNum",
"=",
"priv",
"->",
"activeLinks",
"[",
"0",
"]",
";",
"link",
"=",
"(",
"linkNum",
"!=",
"NG_PPP_BUNDLE_LINKNUM",
")",
"?",
"&",
"priv",
"->",
"links",
"[",
"linkNum",
"]",
":",
"NULL",
";",
"if",
"(",
"linkNum",
"!=",
"NG_PPP_BUNDLE_LINKNUM",
")",
"{",
"if",
"(",
"!",
"bypass",
"&&",
"!",
"link",
"->",
"conf",
".",
"enableLink",
")",
"{",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"ENXIO",
")",
";",
"}",
"if",
"(",
"link",
"->",
"hook",
"==",
"NULL",
")",
"{",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"ENETDOWN",
")",
";",
"}",
"}",
"mru",
"=",
"(",
"link",
"!=",
"NULL",
")",
"?",
"link",
"->",
"conf",
".",
"mru",
":",
"priv",
"->",
"conf",
".",
"mrru",
";",
"if",
"(",
"mru",
"!=",
"0",
"&&",
"m",
"->",
"m_pkthdr",
".",
"len",
">",
"mru",
")",
"{",
"NG_FREE_DATA",
"(",
"m",
",",
"meta",
")",
";",
"return",
"(",
"EMSGSIZE",
")",
";",
"}",
"if",
"(",
"(",
"m",
"=",
"ng_ppp_addproto",
"(",
"m",
",",
"proto",
",",
"linkNum",
"==",
"NG_PPP_BUNDLE_LINKNUM",
"||",
"link",
"->",
"conf",
".",
"enableProtoComp",
")",
")",
"==",
"NULL",
")",
"{",
"NG_FREE_META",
"(",
"meta",
")",
";",
"return",
"(",
"ENOBUFS",
")",
";",
"}",
"if",
"(",
"linkNum",
"==",
"NG_PPP_BUNDLE_LINKNUM",
")",
"return",
"ng_ppp_mp_output",
"(",
"node",
",",
"m",
",",
"meta",
")",
";",
"if",
"(",
"proto",
"==",
"PROT_LCP",
"||",
"!",
"link",
"->",
"conf",
".",
"enableACFComp",
")",
"{",
"if",
"(",
"(",
"m",
"=",
"ng_ppp_prepend",
"(",
"m",
",",
"&",
"ng_ppp_acf",
",",
"2",
")",
")",
"==",
"NULL",
")",
"{",
"NG_FREE_META",
"(",
"meta",
")",
";",
"return",
"(",
"ENOBUFS",
")",
";",
"}",
"}",
"len",
"=",
"m",
"->",
"m_pkthdr",
".",
"len",
";",
"NG_SEND_DATA",
"(",
"error",
",",
"link",
"->",
"hook",
",",
"m",
",",
"meta",
")",
";",
"if",
"(",
"error",
"==",
"0",
")",
"{",
"link",
"->",
"stats",
".",
"xmitFrames",
"++",
";",
"link",
"->",
"stats",
".",
"xmitOctets",
"+=",
"len",
";",
"link",
"->",
"bytesInQueue",
"+=",
"len",
";",
"getmicrouptime",
"(",
"&",
"link",
"->",
"lastWrite",
")",
";",
"}",
"return",
"error",
";",
"}"
] | Deliver a frame out a link, either a real one or NG_PPP_BUNDLE_LINKNUM. | [
"Deliver",
"a",
"frame",
"out",
"a",
"link",
"either",
"a",
"real",
"one",
"or",
"NG_PPP_BUNDLE_LINKNUM",
"."
] | [
"/* If not doing MP, map bundle virtual link to (the only) link */",
"/* Get link pointer (optimization) */",
"/* Check link status (if real) */",
"/* Check peer's MRU for this link */",
"/* Prepend protocol number, possibly compressed */",
"/* Special handling for the MP virtual link */",
"/* Prepend address and control field (unless compressed) */",
"/* Deliver frame */",
"/* Update stats and 'bytes in queue' counter */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "bypass",
"type": "int"
},
{
"param": "proto",
"type": "int"
},
{
"param": "linkNum",
"type": "int"
},
{
"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": "bypass",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "proto",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "linkNum",
"type": "int",
"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_check_packet | int | static int
ng_ppp_check_packet(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
/* Check for empty queue */
if (TAILQ_EMPTY(&priv->frags))
return (0);
/* Check first fragment is the start of a deliverable packet */
qent = TAILQ_FIRST(&priv->frags);
if (!qent->first || MP_RECV_SEQ_DIFF(priv, qent->seq, priv->mseq) > 1)
return (0);
/* Check that all the fragments are there */
while (!qent->last) {
qnext = TAILQ_NEXT(qent, f_qent);
if (qnext == NULL) /* end of queue */
return (0);
if (qnext->seq != MP_NEXT_RECV_SEQ(priv, qent->seq))
return (0);
qent = qnext;
}
/* Got one */
return (1);
} | /*
* Examine our list of fragments, and determine if there is a
* complete and deliverable packet at the head of the list.
* Return 1 if so, zero otherwise.
*/ | Examine our list of fragments, and determine if there is a
complete and deliverable packet at the head of the list.
Return 1 if so, zero otherwise. | [
"Examine",
"our",
"list",
"of",
"fragments",
"and",
"determine",
"if",
"there",
"is",
"a",
"complete",
"and",
"deliverable",
"packet",
"at",
"the",
"head",
"of",
"the",
"list",
".",
"Return",
"1",
"if",
"so",
"zero",
"otherwise",
"."
] | static int
ng_ppp_check_packet(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
if (TAILQ_EMPTY(&priv->frags))
return (0);
qent = TAILQ_FIRST(&priv->frags);
if (!qent->first || MP_RECV_SEQ_DIFF(priv, qent->seq, priv->mseq) > 1)
return (0);
while (!qent->last) {
qnext = TAILQ_NEXT(qent, f_qent);
if (qnext == NULL)
return (0);
if (qnext->seq != MP_NEXT_RECV_SEQ(priv, qent->seq))
return (0);
qent = qnext;
}
return (1);
} | [
"static",
"int",
"ng_ppp_check_packet",
"(",
"node_p",
"node",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"struct",
"ng_ppp_frag",
"*",
"qent",
",",
"*",
"qnext",
";",
"if",
"(",
"TAILQ_EMPTY",
"(",
"&",
"priv",
"->",
"frags",
")",
")",
"return",
"(",
"0",
")",
";",
"qent",
"=",
"TAILQ_FIRST",
"(",
"&",
"priv",
"->",
"frags",
")",
";",
"if",
"(",
"!",
"qent",
"->",
"first",
"||",
"MP_RECV_SEQ_DIFF",
"(",
"priv",
",",
"qent",
"->",
"seq",
",",
"priv",
"->",
"mseq",
")",
">",
"1",
")",
"return",
"(",
"0",
")",
";",
"while",
"(",
"!",
"qent",
"->",
"last",
")",
"{",
"qnext",
"=",
"TAILQ_NEXT",
"(",
"qent",
",",
"f_qent",
")",
";",
"if",
"(",
"qnext",
"==",
"NULL",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"qnext",
"->",
"seq",
"!=",
"MP_NEXT_RECV_SEQ",
"(",
"priv",
",",
"qent",
"->",
"seq",
")",
")",
"return",
"(",
"0",
")",
";",
"qent",
"=",
"qnext",
";",
"}",
"return",
"(",
"1",
")",
";",
"}"
] | Examine our list of fragments, and determine if there is a
complete and deliverable packet at the head of the list. | [
"Examine",
"our",
"list",
"of",
"fragments",
"and",
"determine",
"if",
"there",
"is",
"a",
"complete",
"and",
"deliverable",
"packet",
"at",
"the",
"head",
"of",
"the",
"list",
"."
] | [
"/* Check for empty queue */",
"/* Check first fragment is the start of a deliverable packet */",
"/* Check that all the fragments are there */",
"/* end of queue */",
"/* Got one */"
] | [
{
"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": []
} |
24425625e822973bcdf1290f1e34fd00dafa96cd | atrens/DragonFlyBSD-src | sys/netgraph/ppp/ng_ppp.c | [
"BSD-3-Clause"
] | C | ng_ppp_get_packet | void | static void
ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
struct mbuf *m = NULL, *tail;
qent = TAILQ_FIRST(&priv->frags);
KASSERT(!TAILQ_EMPTY(&priv->frags) && qent->first,
("%s: no packet", __func__));
for (tail = NULL; qent != NULL; qent = qnext) {
qnext = TAILQ_NEXT(qent, f_qent);
KASSERT(!TAILQ_EMPTY(&priv->frags),
("%s: empty q", __func__));
TAILQ_REMOVE(&priv->frags, qent, f_qent);
if (tail == NULL) {
tail = m = qent->data;
*metap = qent->meta; /* inherit first frag's meta */
} else {
m->m_pkthdr.len += qent->data->m_pkthdr.len;
tail->m_next = qent->data;
NG_FREE_META(qent->meta); /* drop other frags' metas */
}
while (tail->m_next != NULL)
tail = tail->m_next;
if (qent->last)
qnext = NULL;
kfree(qent, M_NETGRAPH);
priv->qlen--;
}
*mp = m;
} | /*
* Pull a completed packet off the head of the incoming fragment queue.
* This assumes there is a completed packet there to pull off.
*/ | Pull a completed packet off the head of the incoming fragment queue.
This assumes there is a completed packet there to pull off. | [
"Pull",
"a",
"completed",
"packet",
"off",
"the",
"head",
"of",
"the",
"incoming",
"fragment",
"queue",
".",
"This",
"assumes",
"there",
"is",
"a",
"completed",
"packet",
"there",
"to",
"pull",
"off",
"."
] | static void
ng_ppp_get_packet(node_p node, struct mbuf **mp, meta_p *metap)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext;
struct mbuf *m = NULL, *tail;
qent = TAILQ_FIRST(&priv->frags);
KASSERT(!TAILQ_EMPTY(&priv->frags) && qent->first,
("%s: no packet", __func__));
for (tail = NULL; qent != NULL; qent = qnext) {
qnext = TAILQ_NEXT(qent, f_qent);
KASSERT(!TAILQ_EMPTY(&priv->frags),
("%s: empty q", __func__));
TAILQ_REMOVE(&priv->frags, qent, f_qent);
if (tail == NULL) {
tail = m = qent->data;
*metap = qent->meta;
} else {
m->m_pkthdr.len += qent->data->m_pkthdr.len;
tail->m_next = qent->data;
NG_FREE_META(qent->meta);
}
while (tail->m_next != NULL)
tail = tail->m_next;
if (qent->last)
qnext = NULL;
kfree(qent, M_NETGRAPH);
priv->qlen--;
}
*mp = m;
} | [
"static",
"void",
"ng_ppp_get_packet",
"(",
"node_p",
"node",
",",
"struct",
"mbuf",
"*",
"*",
"mp",
",",
"meta_p",
"*",
"metap",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"struct",
"ng_ppp_frag",
"*",
"qent",
",",
"*",
"qnext",
";",
"struct",
"mbuf",
"*",
"m",
"=",
"NULL",
",",
"*",
"tail",
";",
"qent",
"=",
"TAILQ_FIRST",
"(",
"&",
"priv",
"->",
"frags",
")",
";",
"KASSERT",
"(",
"!",
"TAILQ_EMPTY",
"(",
"&",
"priv",
"->",
"frags",
")",
"&&",
"qent",
"->",
"first",
",",
"(",
"\"",
"\"",
",",
"__func__",
")",
")",
";",
"for",
"(",
"tail",
"=",
"NULL",
";",
"qent",
"!=",
"NULL",
";",
"qent",
"=",
"qnext",
")",
"{",
"qnext",
"=",
"TAILQ_NEXT",
"(",
"qent",
",",
"f_qent",
")",
";",
"KASSERT",
"(",
"!",
"TAILQ_EMPTY",
"(",
"&",
"priv",
"->",
"frags",
")",
",",
"(",
"\"",
"\"",
",",
"__func__",
")",
")",
";",
"TAILQ_REMOVE",
"(",
"&",
"priv",
"->",
"frags",
",",
"qent",
",",
"f_qent",
")",
";",
"if",
"(",
"tail",
"==",
"NULL",
")",
"{",
"tail",
"=",
"m",
"=",
"qent",
"->",
"data",
";",
"*",
"metap",
"=",
"qent",
"->",
"meta",
";",
"}",
"else",
"{",
"m",
"->",
"m_pkthdr",
".",
"len",
"+=",
"qent",
"->",
"data",
"->",
"m_pkthdr",
".",
"len",
";",
"tail",
"->",
"m_next",
"=",
"qent",
"->",
"data",
";",
"NG_FREE_META",
"(",
"qent",
"->",
"meta",
")",
";",
"}",
"while",
"(",
"tail",
"->",
"m_next",
"!=",
"NULL",
")",
"tail",
"=",
"tail",
"->",
"m_next",
";",
"if",
"(",
"qent",
"->",
"last",
")",
"qnext",
"=",
"NULL",
";",
"kfree",
"(",
"qent",
",",
"M_NETGRAPH",
")",
";",
"priv",
"->",
"qlen",
"--",
";",
"}",
"*",
"mp",
"=",
"m",
";",
"}"
] | Pull a completed packet off the head of the incoming fragment queue. | [
"Pull",
"a",
"completed",
"packet",
"off",
"the",
"head",
"of",
"the",
"incoming",
"fragment",
"queue",
"."
] | [
"/* inherit first frag's meta */",
"/* drop other frags' metas */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "mp",
"type": "struct mbuf"
},
{
"param": "metap",
"type": "meta_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mp",
"type": "struct mbuf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "metap",
"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_frag_trim | int | static int
ng_ppp_frag_trim(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext = NULL;
int removed = 0;
/* Scan for "dead" fragments and remove them */
while (1) {
int dead = 0;
/* If queue is empty, we're done */
if (TAILQ_EMPTY(&priv->frags))
break;
/* Determine whether first fragment can ever be completed */
TAILQ_FOREACH(qent, &priv->frags, f_qent) {
if (MP_RECV_SEQ_DIFF(priv, qent->seq, priv->mseq) >= 0)
break;
qnext = TAILQ_NEXT(qent, f_qent);
KASSERT(qnext != NULL,
("%s: last frag < MSEQ?", __func__));
if (qnext->seq != MP_NEXT_RECV_SEQ(priv, qent->seq)
|| qent->last || qnext->first) {
dead = 1;
break;
}
}
if (!dead)
break;
/* Remove fragment and all others in the same packet */
while ((qent = TAILQ_FIRST(&priv->frags)) != qnext) {
KASSERT(!TAILQ_EMPTY(&priv->frags),
("%s: empty q", __func__));
priv->bundleStats.dropFragments++;
TAILQ_REMOVE(&priv->frags, qent, f_qent);
NG_FREE_DATA(qent->data, qent->meta);
kfree(qent, M_NETGRAPH);
priv->qlen--;
removed = 1;
}
}
return (removed);
} | /*
* Trim fragments from the queue whose packets can never be completed.
* This assumes a complete packet is NOT at the beginning of the queue.
* Returns 1 if fragments were removed, zero otherwise.
*/ | Trim fragments from the queue whose packets can never be completed.
This assumes a complete packet is NOT at the beginning of the queue.
Returns 1 if fragments were removed, zero otherwise. | [
"Trim",
"fragments",
"from",
"the",
"queue",
"whose",
"packets",
"can",
"never",
"be",
"completed",
".",
"This",
"assumes",
"a",
"complete",
"packet",
"is",
"NOT",
"at",
"the",
"beginning",
"of",
"the",
"queue",
".",
"Returns",
"1",
"if",
"fragments",
"were",
"removed",
"zero",
"otherwise",
"."
] | static int
ng_ppp_frag_trim(node_p node)
{
const priv_p priv = node->private;
struct ng_ppp_frag *qent, *qnext = NULL;
int removed = 0;
while (1) {
int dead = 0;
if (TAILQ_EMPTY(&priv->frags))
break;
TAILQ_FOREACH(qent, &priv->frags, f_qent) {
if (MP_RECV_SEQ_DIFF(priv, qent->seq, priv->mseq) >= 0)
break;
qnext = TAILQ_NEXT(qent, f_qent);
KASSERT(qnext != NULL,
("%s: last frag < MSEQ?", __func__));
if (qnext->seq != MP_NEXT_RECV_SEQ(priv, qent->seq)
|| qent->last || qnext->first) {
dead = 1;
break;
}
}
if (!dead)
break;
while ((qent = TAILQ_FIRST(&priv->frags)) != qnext) {
KASSERT(!TAILQ_EMPTY(&priv->frags),
("%s: empty q", __func__));
priv->bundleStats.dropFragments++;
TAILQ_REMOVE(&priv->frags, qent, f_qent);
NG_FREE_DATA(qent->data, qent->meta);
kfree(qent, M_NETGRAPH);
priv->qlen--;
removed = 1;
}
}
return (removed);
} | [
"static",
"int",
"ng_ppp_frag_trim",
"(",
"node_p",
"node",
")",
"{",
"const",
"priv_p",
"priv",
"=",
"node",
"->",
"private",
";",
"struct",
"ng_ppp_frag",
"*",
"qent",
",",
"*",
"qnext",
"=",
"NULL",
";",
"int",
"removed",
"=",
"0",
";",
"while",
"(",
"1",
")",
"{",
"int",
"dead",
"=",
"0",
";",
"if",
"(",
"TAILQ_EMPTY",
"(",
"&",
"priv",
"->",
"frags",
")",
")",
"break",
";",
"TAILQ_FOREACH",
"(",
"qent",
",",
"&",
"priv",
"->",
"frags",
",",
"f_qent",
")",
"",
"{",
"if",
"(",
"MP_RECV_SEQ_DIFF",
"(",
"priv",
",",
"qent",
"->",
"seq",
",",
"priv",
"->",
"mseq",
")",
">=",
"0",
")",
"break",
";",
"qnext",
"=",
"TAILQ_NEXT",
"(",
"qent",
",",
"f_qent",
")",
";",
"KASSERT",
"(",
"qnext",
"!=",
"NULL",
",",
"(",
"\"",
"\"",
",",
"__func__",
")",
")",
";",
"if",
"(",
"qnext",
"->",
"seq",
"!=",
"MP_NEXT_RECV_SEQ",
"(",
"priv",
",",
"qent",
"->",
"seq",
")",
"||",
"qent",
"->",
"last",
"||",
"qnext",
"->",
"first",
")",
"{",
"dead",
"=",
"1",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"dead",
")",
"break",
";",
"while",
"(",
"(",
"qent",
"=",
"TAILQ_FIRST",
"(",
"&",
"priv",
"->",
"frags",
")",
")",
"!=",
"qnext",
")",
"{",
"KASSERT",
"(",
"!",
"TAILQ_EMPTY",
"(",
"&",
"priv",
"->",
"frags",
")",
",",
"(",
"\"",
"\"",
",",
"__func__",
")",
")",
";",
"priv",
"->",
"bundleStats",
".",
"dropFragments",
"++",
";",
"TAILQ_REMOVE",
"(",
"&",
"priv",
"->",
"frags",
",",
"qent",
",",
"f_qent",
")",
";",
"NG_FREE_DATA",
"(",
"qent",
"->",
"data",
",",
"qent",
"->",
"meta",
")",
";",
"kfree",
"(",
"qent",
",",
"M_NETGRAPH",
")",
";",
"priv",
"->",
"qlen",
"--",
";",
"removed",
"=",
"1",
";",
"}",
"}",
"return",
"(",
"removed",
")",
";",
"}"
] | Trim fragments from the queue whose packets can never be completed. | [
"Trim",
"fragments",
"from",
"the",
"queue",
"whose",
"packets",
"can",
"never",
"be",
"completed",
"."
] | [
"/* Scan for \"dead\" fragments and remove them */",
"/* If queue is empty, we're done */",
"/* Determine whether first fragment can ever be completed */",
"/* Remove fragment and all others in the same packet */"
] | [
{
"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": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.