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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a489058904b799df8d5e0b9de34de67f4179b0cb | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldcref.c | [
"BSD-3-Clause"
] | C | check_local_sym_xref | void | static void
check_local_sym_xref (lang_input_statement_type *statement)
{
bfd *abfd;
asymbol **syms;
abfd = statement->the_bfd;
if (abfd == NULL)
return;
if (!bfd_generic_link_read_symbols (abfd))
einfo (_("%B%F: could not read symbols: %E\n"), abfd);
for (syms = bfd_get_outsymbols (abfd); *syms; ++syms)
{
asymbol *sym = *syms;
if (sym->flags & (BSF_GLOBAL | BSF_WARNING | BSF_INDIRECT | BSF_FILE))
continue;
if ((sym->flags & (BSF_LOCAL | BSF_SECTION_SYM)) != 0
&& sym->section->output_section != NULL)
{
const char *outsecname, *symname;
struct lang_nocrossrefs *ncrs;
struct lang_nocrossref *ncr;
outsecname = sym->section->output_section->name;
symname = NULL;
if ((sym->flags & BSF_SECTION_SYM) == 0)
symname = sym->name;
for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
{
if (strcmp (ncr->name, outsecname) == 0)
check_refs (symname, FALSE, sym->section, abfd, ncrs);
/* The NOCROSSREFS_TO command only checks symbols defined in
the first section in the list. */
if (ncrs->onlyfirst)
break;
}
}
}
} | /* Check for prohibited cross references to local and section symbols. */ | Check for prohibited cross references to local and section symbols. | [
"Check",
"for",
"prohibited",
"cross",
"references",
"to",
"local",
"and",
"section",
"symbols",
"."
] | static void
check_local_sym_xref (lang_input_statement_type *statement)
{
bfd *abfd;
asymbol **syms;
abfd = statement->the_bfd;
if (abfd == NULL)
return;
if (!bfd_generic_link_read_symbols (abfd))
einfo (_("%B%F: could not read symbols: %E\n"), abfd);
for (syms = bfd_get_outsymbols (abfd); *syms; ++syms)
{
asymbol *sym = *syms;
if (sym->flags & (BSF_GLOBAL | BSF_WARNING | BSF_INDIRECT | BSF_FILE))
continue;
if ((sym->flags & (BSF_LOCAL | BSF_SECTION_SYM)) != 0
&& sym->section->output_section != NULL)
{
const char *outsecname, *symname;
struct lang_nocrossrefs *ncrs;
struct lang_nocrossref *ncr;
outsecname = sym->section->output_section->name;
symname = NULL;
if ((sym->flags & BSF_SECTION_SYM) == 0)
symname = sym->name;
for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
{
if (strcmp (ncr->name, outsecname) == 0)
check_refs (symname, FALSE, sym->section, abfd, ncrs);
if (ncrs->onlyfirst)
break;
}
}
}
} | [
"static",
"void",
"check_local_sym_xref",
"(",
"lang_input_statement_type",
"*",
"statement",
")",
"{",
"bfd",
"*",
"abfd",
";",
"asymbol",
"*",
"*",
"syms",
";",
"abfd",
"=",
"statement",
"->",
"the_bfd",
";",
"if",
"(",
"abfd",
"==",
"NULL",
")",
"return",
";",
"if",
"(",
"!",
"bfd_generic_link_read_symbols",
"(",
"abfd",
")",
")",
"einfo",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"abfd",
")",
";",
"for",
"(",
"syms",
"=",
"bfd_get_outsymbols",
"(",
"abfd",
")",
";",
"*",
"syms",
";",
"++",
"syms",
")",
"{",
"asymbol",
"*",
"sym",
"=",
"*",
"syms",
";",
"if",
"(",
"sym",
"->",
"flags",
"&",
"(",
"BSF_GLOBAL",
"|",
"BSF_WARNING",
"|",
"BSF_INDIRECT",
"|",
"BSF_FILE",
")",
")",
"continue",
";",
"if",
"(",
"(",
"sym",
"->",
"flags",
"&",
"(",
"BSF_LOCAL",
"|",
"BSF_SECTION_SYM",
")",
")",
"!=",
"0",
"&&",
"sym",
"->",
"section",
"->",
"output_section",
"!=",
"NULL",
")",
"{",
"const",
"char",
"*",
"outsecname",
",",
"*",
"symname",
";",
"struct",
"lang_nocrossrefs",
"*",
"ncrs",
";",
"struct",
"lang_nocrossref",
"*",
"ncr",
";",
"outsecname",
"=",
"sym",
"->",
"section",
"->",
"output_section",
"->",
"name",
";",
"symname",
"=",
"NULL",
";",
"if",
"(",
"(",
"sym",
"->",
"flags",
"&",
"BSF_SECTION_SYM",
")",
"==",
"0",
")",
"symname",
"=",
"sym",
"->",
"name",
";",
"for",
"(",
"ncrs",
"=",
"nocrossref_list",
";",
"ncrs",
"!=",
"NULL",
";",
"ncrs",
"=",
"ncrs",
"->",
"next",
")",
"for",
"(",
"ncr",
"=",
"ncrs",
"->",
"list",
";",
"ncr",
"!=",
"NULL",
";",
"ncr",
"=",
"ncr",
"->",
"next",
")",
"{",
"if",
"(",
"strcmp",
"(",
"ncr",
"->",
"name",
",",
"outsecname",
")",
"==",
"0",
")",
"check_refs",
"(",
"symname",
",",
"FALSE",
",",
"sym",
"->",
"section",
",",
"abfd",
",",
"ncrs",
")",
";",
"if",
"(",
"ncrs",
"->",
"onlyfirst",
")",
"break",
";",
"}",
"}",
"}",
"}"
] | Check for prohibited cross references to local and section symbols. | [
"Check",
"for",
"prohibited",
"cross",
"references",
"to",
"local",
"and",
"section",
"symbols",
"."
] | [
"/* The NOCROSSREFS_TO command only checks symbols defined in\n\t\t the first section in the list. */"
] | [
{
"param": "statement",
"type": "lang_input_statement_type"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "statement",
"type": "lang_input_statement_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a489058904b799df8d5e0b9de34de67f4179b0cb | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldcref.c | [
"BSD-3-Clause"
] | C | check_refs | void | static void
check_refs (const char *name,
bfd_boolean global,
asection *sec,
bfd *abfd,
struct lang_nocrossrefs *ncrs)
{
struct check_refs_info info;
/* We need to look through the relocations for this BFD, to see
if any of the relocations which refer to this symbol are from
a prohibited section. Note that we need to do this even for
the BFD in which the symbol is defined, since even a single
BFD might contain a prohibited cross reference. */
if (!bfd_generic_link_read_symbols (abfd))
einfo (_("%B%F: could not read symbols: %E\n"), abfd);
info.sym_name = name;
info.global = global;
info.defsec = sec;
info.ncrs = ncrs;
info.asymbols = bfd_get_outsymbols (abfd);
bfd_map_over_sections (abfd, check_reloc_refs, &info);
} | /* This function is called for each symbol defined in a section which
prohibits cross references. We need to look through all references
to this symbol, and ensure that the references are not from
prohibited sections. */ | This function is called for each symbol defined in a section which
prohibits cross references. We need to look through all references
to this symbol, and ensure that the references are not from
prohibited sections. | [
"This",
"function",
"is",
"called",
"for",
"each",
"symbol",
"defined",
"in",
"a",
"section",
"which",
"prohibits",
"cross",
"references",
".",
"We",
"need",
"to",
"look",
"through",
"all",
"references",
"to",
"this",
"symbol",
"and",
"ensure",
"that",
"the",
"references",
"are",
"not",
"from",
"prohibited",
"sections",
"."
] | static void
check_refs (const char *name,
bfd_boolean global,
asection *sec,
bfd *abfd,
struct lang_nocrossrefs *ncrs)
{
struct check_refs_info info;
if (!bfd_generic_link_read_symbols (abfd))
einfo (_("%B%F: could not read symbols: %E\n"), abfd);
info.sym_name = name;
info.global = global;
info.defsec = sec;
info.ncrs = ncrs;
info.asymbols = bfd_get_outsymbols (abfd);
bfd_map_over_sections (abfd, check_reloc_refs, &info);
} | [
"static",
"void",
"check_refs",
"(",
"const",
"char",
"*",
"name",
",",
"bfd_boolean",
"global",
",",
"asection",
"*",
"sec",
",",
"bfd",
"*",
"abfd",
",",
"struct",
"lang_nocrossrefs",
"*",
"ncrs",
")",
"{",
"struct",
"check_refs_info",
"info",
";",
"if",
"(",
"!",
"bfd_generic_link_read_symbols",
"(",
"abfd",
")",
")",
"einfo",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"abfd",
")",
";",
"info",
".",
"sym_name",
"=",
"name",
";",
"info",
".",
"global",
"=",
"global",
";",
"info",
".",
"defsec",
"=",
"sec",
";",
"info",
".",
"ncrs",
"=",
"ncrs",
";",
"info",
".",
"asymbols",
"=",
"bfd_get_outsymbols",
"(",
"abfd",
")",
";",
"bfd_map_over_sections",
"(",
"abfd",
",",
"check_reloc_refs",
",",
"&",
"info",
")",
";",
"}"
] | This function is called for each symbol defined in a section which
prohibits cross references. | [
"This",
"function",
"is",
"called",
"for",
"each",
"symbol",
"defined",
"in",
"a",
"section",
"which",
"prohibits",
"cross",
"references",
"."
] | [
"/* We need to look through the relocations for this BFD, to see\n if any of the relocations which refer to this symbol are from\n a prohibited section. Note that we need to do this even for\n the BFD in which the symbol is defined, since even a single\n BFD might contain a prohibited cross reference. */"
] | [
{
"param": "name",
"type": "char"
},
{
"param": "global",
"type": "bfd_boolean"
},
{
"param": "sec",
"type": "asection"
},
{
"param": "abfd",
"type": "bfd"
},
{
"param": "ncrs",
"type": "struct lang_nocrossrefs"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "global",
"type": "bfd_boolean",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sec",
"type": "asection",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ncrs",
"type": "struct lang_nocrossrefs",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a489058904b799df8d5e0b9de34de67f4179b0cb | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldcref.c | [
"BSD-3-Clause"
] | C | check_reloc_refs | void | static void
check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
{
struct check_refs_info *info = (struct check_refs_info *) iarg;
asection *outsec;
const char *outsecname;
asection *outdefsec;
const char *outdefsecname;
struct lang_nocrossref *ncr;
const char *symname;
bfd_boolean global;
long relsize;
arelent **relpp;
long relcount;
arelent **p, **pend;
outsec = sec->output_section;
outsecname = bfd_get_section_name (outsec->owner, outsec);
outdefsec = info->defsec->output_section;
outdefsecname = bfd_get_section_name (outdefsec->owner, outdefsec);
/* The section where the symbol is defined is permitted. */
if (strcmp (outsecname, outdefsecname) == 0)
return;
for (ncr = info->ncrs->list; ncr != NULL; ncr = ncr->next)
if (strcmp (outsecname, ncr->name) == 0)
break;
if (ncr == NULL)
return;
/* This section is one for which cross references are prohibited.
Look through the relocations, and see if any of them are to
INFO->SYM_NAME. If INFO->SYMNAME is NULL, check for relocations
against the section symbol. If INFO->GLOBAL is TRUE, the
definition is global, check for relocations against the global
symbols. Otherwise check for relocations against the local and
section symbols. */
symname = info->sym_name;
global = info->global;
relsize = bfd_get_reloc_upper_bound (abfd, sec);
if (relsize < 0)
einfo (_("%B%F: could not read relocs: %E\n"), abfd);
if (relsize == 0)
return;
relpp = (arelent **) xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
if (relcount < 0)
einfo (_("%B%F: could not read relocs: %E\n"), abfd);
p = relpp;
pend = p + relcount;
for (; p < pend && *p != NULL; p++)
{
arelent *q = *p;
if (q->sym_ptr_ptr != NULL
&& *q->sym_ptr_ptr != NULL
&& ((global
&& (bfd_is_und_section (bfd_get_section (*q->sym_ptr_ptr))
|| bfd_is_com_section (bfd_get_section (*q->sym_ptr_ptr))
|| ((*q->sym_ptr_ptr)->flags & (BSF_GLOBAL
| BSF_WEAK)) != 0))
|| (!global
&& ((*q->sym_ptr_ptr)->flags & (BSF_LOCAL
| BSF_SECTION_SYM)) != 0
&& bfd_get_section (*q->sym_ptr_ptr) == info->defsec))
&& (symname != NULL
? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0
: ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0))
{
/* We found a reloc for the symbol. The symbol is defined
in OUTSECNAME. This reloc is from a section which is
mapped into a section from which references to OUTSECNAME
are prohibited. We must report an error. */
einfo (_("%X%C: prohibited cross reference from %s to `%T' in %s\n"),
abfd, sec, q->address, outsecname,
bfd_asymbol_name (*q->sym_ptr_ptr), outdefsecname);
}
}
free (relpp);
} | /* This is called via bfd_map_over_sections. INFO->SYM_NAME is a symbol
defined in INFO->DEFSECNAME. If this section maps into any of the
sections listed in INFO->NCRS, other than INFO->DEFSECNAME, then we
look through the relocations. If any of the relocations are to
INFO->SYM_NAME, then we report a prohibited cross reference error. */ | This is called via bfd_map_over_sections. INFO->SYM_NAME is a symbol
defined in INFO->DEFSECNAME. If this section maps into any of the
sections listed in INFO->NCRS, other than INFO->DEFSECNAME, then we
look through the relocations. If any of the relocations are to
INFO->SYM_NAME, then we report a prohibited cross reference error. | [
"This",
"is",
"called",
"via",
"bfd_map_over_sections",
".",
"INFO",
"-",
">",
"SYM_NAME",
"is",
"a",
"symbol",
"defined",
"in",
"INFO",
"-",
">",
"DEFSECNAME",
".",
"If",
"this",
"section",
"maps",
"into",
"any",
"of",
"the",
"sections",
"listed",
"in",
"INFO",
"-",
">",
"NCRS",
"other",
"than",
"INFO",
"-",
">",
"DEFSECNAME",
"then",
"we",
"look",
"through",
"the",
"relocations",
".",
"If",
"any",
"of",
"the",
"relocations",
"are",
"to",
"INFO",
"-",
">",
"SYM_NAME",
"then",
"we",
"report",
"a",
"prohibited",
"cross",
"reference",
"error",
"."
] | static void
check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
{
struct check_refs_info *info = (struct check_refs_info *) iarg;
asection *outsec;
const char *outsecname;
asection *outdefsec;
const char *outdefsecname;
struct lang_nocrossref *ncr;
const char *symname;
bfd_boolean global;
long relsize;
arelent **relpp;
long relcount;
arelent **p, **pend;
outsec = sec->output_section;
outsecname = bfd_get_section_name (outsec->owner, outsec);
outdefsec = info->defsec->output_section;
outdefsecname = bfd_get_section_name (outdefsec->owner, outdefsec);
if (strcmp (outsecname, outdefsecname) == 0)
return;
for (ncr = info->ncrs->list; ncr != NULL; ncr = ncr->next)
if (strcmp (outsecname, ncr->name) == 0)
break;
if (ncr == NULL)
return;
symname = info->sym_name;
global = info->global;
relsize = bfd_get_reloc_upper_bound (abfd, sec);
if (relsize < 0)
einfo (_("%B%F: could not read relocs: %E\n"), abfd);
if (relsize == 0)
return;
relpp = (arelent **) xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols);
if (relcount < 0)
einfo (_("%B%F: could not read relocs: %E\n"), abfd);
p = relpp;
pend = p + relcount;
for (; p < pend && *p != NULL; p++)
{
arelent *q = *p;
if (q->sym_ptr_ptr != NULL
&& *q->sym_ptr_ptr != NULL
&& ((global
&& (bfd_is_und_section (bfd_get_section (*q->sym_ptr_ptr))
|| bfd_is_com_section (bfd_get_section (*q->sym_ptr_ptr))
|| ((*q->sym_ptr_ptr)->flags & (BSF_GLOBAL
| BSF_WEAK)) != 0))
|| (!global
&& ((*q->sym_ptr_ptr)->flags & (BSF_LOCAL
| BSF_SECTION_SYM)) != 0
&& bfd_get_section (*q->sym_ptr_ptr) == info->defsec))
&& (symname != NULL
? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0
: ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0))
{
einfo (_("%X%C: prohibited cross reference from %s to `%T' in %s\n"),
abfd, sec, q->address, outsecname,
bfd_asymbol_name (*q->sym_ptr_ptr), outdefsecname);
}
}
free (relpp);
} | [
"static",
"void",
"check_reloc_refs",
"(",
"bfd",
"*",
"abfd",
",",
"asection",
"*",
"sec",
",",
"void",
"*",
"iarg",
")",
"{",
"struct",
"check_refs_info",
"*",
"info",
"=",
"(",
"struct",
"check_refs_info",
"*",
")",
"iarg",
";",
"asection",
"*",
"outsec",
";",
"const",
"char",
"*",
"outsecname",
";",
"asection",
"*",
"outdefsec",
";",
"const",
"char",
"*",
"outdefsecname",
";",
"struct",
"lang_nocrossref",
"*",
"ncr",
";",
"const",
"char",
"*",
"symname",
";",
"bfd_boolean",
"global",
";",
"long",
"relsize",
";",
"arelent",
"*",
"*",
"relpp",
";",
"long",
"relcount",
";",
"arelent",
"*",
"*",
"p",
",",
"*",
"*",
"pend",
";",
"outsec",
"=",
"sec",
"->",
"output_section",
";",
"outsecname",
"=",
"bfd_get_section_name",
"(",
"outsec",
"->",
"owner",
",",
"outsec",
")",
";",
"outdefsec",
"=",
"info",
"->",
"defsec",
"->",
"output_section",
";",
"outdefsecname",
"=",
"bfd_get_section_name",
"(",
"outdefsec",
"->",
"owner",
",",
"outdefsec",
")",
";",
"if",
"(",
"strcmp",
"(",
"outsecname",
",",
"outdefsecname",
")",
"==",
"0",
")",
"return",
";",
"for",
"(",
"ncr",
"=",
"info",
"->",
"ncrs",
"->",
"list",
";",
"ncr",
"!=",
"NULL",
";",
"ncr",
"=",
"ncr",
"->",
"next",
")",
"if",
"(",
"strcmp",
"(",
"outsecname",
",",
"ncr",
"->",
"name",
")",
"==",
"0",
")",
"break",
";",
"if",
"(",
"ncr",
"==",
"NULL",
")",
"return",
";",
"symname",
"=",
"info",
"->",
"sym_name",
";",
"global",
"=",
"info",
"->",
"global",
";",
"relsize",
"=",
"bfd_get_reloc_upper_bound",
"(",
"abfd",
",",
"sec",
")",
";",
"if",
"(",
"relsize",
"<",
"0",
")",
"einfo",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"abfd",
")",
";",
"if",
"(",
"relsize",
"==",
"0",
")",
"return",
";",
"relpp",
"=",
"(",
"arelent",
"*",
"*",
")",
"xmalloc",
"(",
"relsize",
")",
";",
"relcount",
"=",
"bfd_canonicalize_reloc",
"(",
"abfd",
",",
"sec",
",",
"relpp",
",",
"info",
"->",
"asymbols",
")",
";",
"if",
"(",
"relcount",
"<",
"0",
")",
"einfo",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"abfd",
")",
";",
"p",
"=",
"relpp",
";",
"pend",
"=",
"p",
"+",
"relcount",
";",
"for",
"(",
";",
"p",
"<",
"pend",
"&&",
"*",
"p",
"!=",
"NULL",
";",
"p",
"++",
")",
"{",
"arelent",
"*",
"q",
"=",
"*",
"p",
";",
"if",
"(",
"q",
"->",
"sym_ptr_ptr",
"!=",
"NULL",
"&&",
"*",
"q",
"->",
"sym_ptr_ptr",
"!=",
"NULL",
"&&",
"(",
"(",
"global",
"&&",
"(",
"bfd_is_und_section",
"(",
"bfd_get_section",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
")",
"||",
"bfd_is_com_section",
"(",
"bfd_get_section",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
")",
"||",
"(",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
"->",
"flags",
"&",
"(",
"BSF_GLOBAL",
"|",
"BSF_WEAK",
")",
")",
"!=",
"0",
")",
")",
"||",
"(",
"!",
"global",
"&&",
"(",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
"->",
"flags",
"&",
"(",
"BSF_LOCAL",
"|",
"BSF_SECTION_SYM",
")",
")",
"!=",
"0",
"&&",
"bfd_get_section",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
"==",
"info",
"->",
"defsec",
")",
")",
"&&",
"(",
"symname",
"!=",
"NULL",
"?",
"strcmp",
"(",
"bfd_asymbol_name",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
",",
"symname",
")",
"==",
"0",
":",
"(",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
"->",
"flags",
"&",
"BSF_SECTION_SYM",
")",
"!=",
"0",
")",
")",
"{",
"einfo",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
",",
"abfd",
",",
"sec",
",",
"q",
"->",
"address",
",",
"outsecname",
",",
"bfd_asymbol_name",
"(",
"*",
"q",
"->",
"sym_ptr_ptr",
")",
",",
"outdefsecname",
")",
";",
"}",
"}",
"free",
"(",
"relpp",
")",
";",
"}"
] | This is called via bfd_map_over_sections. | [
"This",
"is",
"called",
"via",
"bfd_map_over_sections",
"."
] | [
"/* The section where the symbol is defined is permitted. */",
"/* This section is one for which cross references are prohibited.\n Look through the relocations, and see if any of them are to\n INFO->SYM_NAME. If INFO->SYMNAME is NULL, check for relocations\n against the section symbol. If INFO->GLOBAL is TRUE, the\n definition is global, check for relocations against the global\n symbols. Otherwise check for relocations against the local and\n section symbols. */",
"/* We found a reloc for the symbol. The symbol is defined\n\t in OUTSECNAME. This reloc is from a section which is\n\t mapped into a section from which references to OUTSECNAME\n\t are prohibited. We must report an error. */"
] | [
{
"param": "abfd",
"type": "bfd"
},
{
"param": "sec",
"type": "asection"
},
{
"param": "iarg",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "abfd",
"type": "bfd",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sec",
"type": "asection",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "iarg",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6ffef29bf1f80e37e9ca15cb407d8e4df66807d9 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/gimple-streamer-in.c | [
"BSD-3-Clause"
] | C | input_phi | gphi | static gphi *
input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
struct function *fn)
{
unsigned HOST_WIDE_INT ix;
tree phi_result;
int i, len;
gphi *result;
ix = streamer_read_uhwi (ib);
phi_result = (*SSANAMES (fn))[ix];
len = EDGE_COUNT (bb->preds);
result = create_phi_node (phi_result, bb);
/* We have to go through a lookup process here because the preds in the
reconstructed graph are generally in a different order than they
were in the original program. */
for (i = 0; i < len; i++)
{
tree def = stream_read_tree (ib, data_in);
int src_index = streamer_read_uhwi (ib);
bitpack_d bp = streamer_read_bitpack (ib);
/* Do not cache a location - we do not have API to get pointer to the
location in PHI statement and we may trigger reallocation. */
location_t arg_loc = stream_input_location_now (&bp, data_in);
basic_block sbb = BASIC_BLOCK_FOR_FN (fn, src_index);
edge e = NULL;
int j;
for (j = 0; j < len; j++)
if (EDGE_PRED (bb, j)->src == sbb)
{
e = EDGE_PRED (bb, j);
break;
}
add_phi_arg (result, def, e, arg_loc);
}
return result;
} | /* Read a PHI function for basic block BB in function FN. DATA_IN is
the file being read. IB is the input block to use for reading. */ | Read a PHI function for basic block BB in function FN. DATA_IN is
the file being read. IB is the input block to use for reading. | [
"Read",
"a",
"PHI",
"function",
"for",
"basic",
"block",
"BB",
"in",
"function",
"FN",
".",
"DATA_IN",
"is",
"the",
"file",
"being",
"read",
".",
"IB",
"is",
"the",
"input",
"block",
"to",
"use",
"for",
"reading",
"."
] | static gphi *
input_phi (struct lto_input_block *ib, basic_block bb, struct data_in *data_in,
struct function *fn)
{
unsigned HOST_WIDE_INT ix;
tree phi_result;
int i, len;
gphi *result;
ix = streamer_read_uhwi (ib);
phi_result = (*SSANAMES (fn))[ix];
len = EDGE_COUNT (bb->preds);
result = create_phi_node (phi_result, bb);
for (i = 0; i < len; i++)
{
tree def = stream_read_tree (ib, data_in);
int src_index = streamer_read_uhwi (ib);
bitpack_d bp = streamer_read_bitpack (ib);
location_t arg_loc = stream_input_location_now (&bp, data_in);
basic_block sbb = BASIC_BLOCK_FOR_FN (fn, src_index);
edge e = NULL;
int j;
for (j = 0; j < len; j++)
if (EDGE_PRED (bb, j)->src == sbb)
{
e = EDGE_PRED (bb, j);
break;
}
add_phi_arg (result, def, e, arg_loc);
}
return result;
} | [
"static",
"gphi",
"*",
"input_phi",
"(",
"struct",
"lto_input_block",
"*",
"ib",
",",
"basic_block",
"bb",
",",
"struct",
"data_in",
"*",
"data_in",
",",
"struct",
"function",
"*",
"fn",
")",
"{",
"unsigned",
"HOST_WIDE_INT",
"ix",
";",
"tree",
"phi_result",
";",
"int",
"i",
",",
"len",
";",
"gphi",
"*",
"result",
";",
"ix",
"=",
"streamer_read_uhwi",
"(",
"ib",
")",
";",
"phi_result",
"=",
"(",
"*",
"SSANAMES",
"(",
"fn",
")",
")",
"[",
"ix",
"]",
";",
"len",
"=",
"EDGE_COUNT",
"(",
"bb",
"->",
"preds",
")",
";",
"result",
"=",
"create_phi_node",
"(",
"phi_result",
",",
"bb",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"tree",
"def",
"=",
"stream_read_tree",
"(",
"ib",
",",
"data_in",
")",
";",
"int",
"src_index",
"=",
"streamer_read_uhwi",
"(",
"ib",
")",
";",
"bitpack_d",
"bp",
"=",
"streamer_read_bitpack",
"(",
"ib",
")",
";",
"location_t",
"arg_loc",
"=",
"stream_input_location_now",
"(",
"&",
"bp",
",",
"data_in",
")",
";",
"basic_block",
"sbb",
"=",
"BASIC_BLOCK_FOR_FN",
"(",
"fn",
",",
"src_index",
")",
";",
"edge",
"e",
"=",
"NULL",
";",
"int",
"j",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"len",
";",
"j",
"++",
")",
"if",
"(",
"EDGE_PRED",
"(",
"bb",
",",
"j",
")",
"->",
"src",
"==",
"sbb",
")",
"{",
"e",
"=",
"EDGE_PRED",
"(",
"bb",
",",
"j",
")",
";",
"break",
";",
"}",
"add_phi_arg",
"(",
"result",
",",
"def",
",",
"e",
",",
"arg_loc",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Read a PHI function for basic block BB in function FN. | [
"Read",
"a",
"PHI",
"function",
"for",
"basic",
"block",
"BB",
"in",
"function",
"FN",
"."
] | [
"/* We have to go through a lookup process here because the preds in the\n reconstructed graph are generally in a different order than they\n were in the original program. */",
"/* Do not cache a location - we do not have API to get pointer to the\n\t location in PHI statement and we may trigger reallocation. */"
] | [
{
"param": "ib",
"type": "struct lto_input_block"
},
{
"param": "bb",
"type": "basic_block"
},
{
"param": "data_in",
"type": "struct data_in"
},
{
"param": "fn",
"type": "struct function"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ib",
"type": "struct lto_input_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bb",
"type": "basic_block",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_in",
"type": "struct data_in",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fn",
"type": "struct function",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
249c0ae52c6d18be7cf8f14c34703f4601843b50 | atrens/DragonFlyBSD-src | sys/dev/drm/drm_plane.c | [
"BSD-3-Clause"
] | C | drm_num_planes | null | static unsigned int drm_num_planes(struct drm_device *dev)
{
unsigned int num = 0;
struct drm_plane *tmp;
drm_for_each_plane(tmp, dev) {
num++;
}
return num;
} | /**
* DOC: overview
*
* A plane represents an image source that can be blended with or overlayed on
* top of a CRTC during the scanout process. Planes take their input data from a
* &drm_framebuffer object. The plane itself specifies the cropping and scaling
* of that image, and where it is placed on the visible are of a display
* pipeline, represented by &drm_crtc. A plane can also have additional
* properties that specify how the pixels are positioned and blended, like
* rotation or Z-position. All these properties are stored in &drm_plane_state.
*
* To create a plane, a KMS drivers allocates and zeroes an instances of
* struct &drm_plane (possibly as part of a larger structure) and registers it
* with a call to drm_universal_plane_init().
*
* Cursor and overlay planes are optional. All drivers should provide one
* primary plane per CRTC to avoid surprising userspace too much. See enum
* &drm_plane_type for a more in-depth discussion of these special uapi-relevant
* plane types. Special planes are associated with their CRTC by calling
* drm_crtc_init_with_planes().
*
* The type of a plane is exposed in the immutable "type" enumeration property,
* which has one of the following values: "Overlay", "Primary", "Cursor".
*/ | overview
A plane represents an image source that can be blended with or overlayed on
top of a CRTC during the scanout process. Planes take their input data from a
&drm_framebuffer object. The plane itself specifies the cropping and scaling
of that image, and where it is placed on the visible are of a display
pipeline, represented by &drm_crtc. A plane can also have additional
properties that specify how the pixels are positioned and blended, like
rotation or Z-position. All these properties are stored in &drm_plane_state.
To create a plane, a KMS drivers allocates and zeroes an instances of
struct &drm_plane (possibly as part of a larger structure) and registers it
with a call to drm_universal_plane_init().
Cursor and overlay planes are optional. All drivers should provide one
primary plane per CRTC to avoid surprising userspace too much. See enum
&drm_plane_type for a more in-depth discussion of these special uapi-relevant
plane types. Special planes are associated with their CRTC by calling
drm_crtc_init_with_planes().
| [
"overview",
"A",
"plane",
"represents",
"an",
"image",
"source",
"that",
"can",
"be",
"blended",
"with",
"or",
"overlayed",
"on",
"top",
"of",
"a",
"CRTC",
"during",
"the",
"scanout",
"process",
".",
"Planes",
"take",
"their",
"input",
"data",
"from",
"a",
"&drm_framebuffer",
"object",
".",
"The",
"plane",
"itself",
"specifies",
"the",
"cropping",
"and",
"scaling",
"of",
"that",
"image",
"and",
"where",
"it",
"is",
"placed",
"on",
"the",
"visible",
"are",
"of",
"a",
"display",
"pipeline",
"represented",
"by",
"&drm_crtc",
".",
"A",
"plane",
"can",
"also",
"have",
"additional",
"properties",
"that",
"specify",
"how",
"the",
"pixels",
"are",
"positioned",
"and",
"blended",
"like",
"rotation",
"or",
"Z",
"-",
"position",
".",
"All",
"these",
"properties",
"are",
"stored",
"in",
"&drm_plane_state",
".",
"To",
"create",
"a",
"plane",
"a",
"KMS",
"drivers",
"allocates",
"and",
"zeroes",
"an",
"instances",
"of",
"struct",
"&drm_plane",
"(",
"possibly",
"as",
"part",
"of",
"a",
"larger",
"structure",
")",
"and",
"registers",
"it",
"with",
"a",
"call",
"to",
"drm_universal_plane_init",
"()",
".",
"Cursor",
"and",
"overlay",
"planes",
"are",
"optional",
".",
"All",
"drivers",
"should",
"provide",
"one",
"primary",
"plane",
"per",
"CRTC",
"to",
"avoid",
"surprising",
"userspace",
"too",
"much",
".",
"See",
"enum",
"&drm_plane_type",
"for",
"a",
"more",
"in",
"-",
"depth",
"discussion",
"of",
"these",
"special",
"uapi",
"-",
"relevant",
"plane",
"types",
".",
"Special",
"planes",
"are",
"associated",
"with",
"their",
"CRTC",
"by",
"calling",
"drm_crtc_init_with_planes",
"()",
"."
] | static unsigned int drm_num_planes(struct drm_device *dev)
{
unsigned int num = 0;
struct drm_plane *tmp;
drm_for_each_plane(tmp, dev) {
num++;
}
return num;
} | [
"static",
"unsigned",
"int",
"drm_num_planes",
"(",
"struct",
"drm_device",
"*",
"dev",
")",
"{",
"unsigned",
"int",
"num",
"=",
"0",
";",
"struct",
"drm_plane",
"*",
"tmp",
";",
"drm_for_each_plane",
"(",
"tmp",
",",
"dev",
")",
"",
"{",
"num",
"++",
";",
"}",
"return",
"num",
";",
"}"
] | DOC: overview
A plane represents an image source that can be blended with or overlayed on
top of a CRTC during the scanout process. | [
"DOC",
":",
"overview",
"A",
"plane",
"represents",
"an",
"image",
"source",
"that",
"can",
"be",
"blended",
"with",
"or",
"overlayed",
"on",
"top",
"of",
"a",
"CRTC",
"during",
"the",
"scanout",
"process",
"."
] | [] | [
{
"param": "dev",
"type": "struct drm_device"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "struct drm_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
249c0ae52c6d18be7cf8f14c34703f4601843b50 | atrens/DragonFlyBSD-src | sys/dev/drm/drm_plane.c | [
"BSD-3-Clause"
] | C | drm_plane_cleanup | void | void drm_plane_cleanup(struct drm_plane *plane)
{
struct drm_device *dev = plane->dev;
drm_modeset_lock_all(dev);
kfree(plane->format_types);
drm_mode_object_unregister(dev, &plane->base);
BUG_ON(list_empty(&plane->head));
/* Note that the plane_list is considered to be static; should we
* remove the drm_plane at runtime we would have to decrement all
* the indices on the drm_plane after us in the plane_list.
*/
list_del(&plane->head);
dev->mode_config.num_total_plane--;
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
dev->mode_config.num_overlay_plane--;
drm_modeset_unlock_all(dev);
WARN_ON(plane->state && !plane->funcs->atomic_destroy_state);
if (plane->state && plane->funcs->atomic_destroy_state)
plane->funcs->atomic_destroy_state(plane, plane->state);
kfree(plane->name);
memset(plane, 0, sizeof(*plane));
} | /**
* drm_plane_cleanup - Clean up the core plane usage
* @plane: plane to cleanup
*
* This function cleans up @plane and removes it from the DRM mode setting
* core. Note that the function does *not* free the plane structure itself,
* this is the responsibility of the caller.
*/ | Clean up the core plane usage
@plane: plane to cleanup
This function cleans up @plane and removes it from the DRM mode setting
core. Note that the function does *not* free the plane structure itself,
this is the responsibility of the caller. | [
"Clean",
"up",
"the",
"core",
"plane",
"usage",
"@plane",
":",
"plane",
"to",
"cleanup",
"This",
"function",
"cleans",
"up",
"@plane",
"and",
"removes",
"it",
"from",
"the",
"DRM",
"mode",
"setting",
"core",
".",
"Note",
"that",
"the",
"function",
"does",
"*",
"not",
"*",
"free",
"the",
"plane",
"structure",
"itself",
"this",
"is",
"the",
"responsibility",
"of",
"the",
"caller",
"."
] | void drm_plane_cleanup(struct drm_plane *plane)
{
struct drm_device *dev = plane->dev;
drm_modeset_lock_all(dev);
kfree(plane->format_types);
drm_mode_object_unregister(dev, &plane->base);
BUG_ON(list_empty(&plane->head));
list_del(&plane->head);
dev->mode_config.num_total_plane--;
if (plane->type == DRM_PLANE_TYPE_OVERLAY)
dev->mode_config.num_overlay_plane--;
drm_modeset_unlock_all(dev);
WARN_ON(plane->state && !plane->funcs->atomic_destroy_state);
if (plane->state && plane->funcs->atomic_destroy_state)
plane->funcs->atomic_destroy_state(plane, plane->state);
kfree(plane->name);
memset(plane, 0, sizeof(*plane));
} | [
"void",
"drm_plane_cleanup",
"(",
"struct",
"drm_plane",
"*",
"plane",
")",
"{",
"struct",
"drm_device",
"*",
"dev",
"=",
"plane",
"->",
"dev",
";",
"drm_modeset_lock_all",
"(",
"dev",
")",
";",
"kfree",
"(",
"plane",
"->",
"format_types",
")",
";",
"drm_mode_object_unregister",
"(",
"dev",
",",
"&",
"plane",
"->",
"base",
")",
";",
"BUG_ON",
"(",
"list_empty",
"(",
"&",
"plane",
"->",
"head",
")",
")",
";",
"list_del",
"(",
"&",
"plane",
"->",
"head",
")",
";",
"dev",
"->",
"mode_config",
".",
"num_total_plane",
"--",
";",
"if",
"(",
"plane",
"->",
"type",
"==",
"DRM_PLANE_TYPE_OVERLAY",
")",
"dev",
"->",
"mode_config",
".",
"num_overlay_plane",
"--",
";",
"drm_modeset_unlock_all",
"(",
"dev",
")",
";",
"WARN_ON",
"(",
"plane",
"->",
"state",
"&&",
"!",
"plane",
"->",
"funcs",
"->",
"atomic_destroy_state",
")",
";",
"if",
"(",
"plane",
"->",
"state",
"&&",
"plane",
"->",
"funcs",
"->",
"atomic_destroy_state",
")",
"plane",
"->",
"funcs",
"->",
"atomic_destroy_state",
"(",
"plane",
",",
"plane",
"->",
"state",
")",
";",
"kfree",
"(",
"plane",
"->",
"name",
")",
";",
"memset",
"(",
"plane",
",",
"0",
",",
"sizeof",
"(",
"*",
"plane",
")",
")",
";",
"}"
] | drm_plane_cleanup - Clean up the core plane usage
@plane: plane to cleanup | [
"drm_plane_cleanup",
"-",
"Clean",
"up",
"the",
"core",
"plane",
"usage",
"@plane",
":",
"plane",
"to",
"cleanup"
] | [
"/* Note that the plane_list is considered to be static; should we\n\t * remove the drm_plane at runtime we would have to decrement all\n\t * the indices on the drm_plane after us in the plane_list.\n\t */"
] | [
{
"param": "plane",
"type": "struct drm_plane"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plane",
"type": "struct drm_plane",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
249c0ae52c6d18be7cf8f14c34703f4601843b50 | atrens/DragonFlyBSD-src | sys/dev/drm/drm_plane.c | [
"BSD-3-Clause"
] | C | drm_plane_from_index | null | struct drm_plane *
drm_plane_from_index(struct drm_device *dev, int idx)
{
struct drm_plane *plane;
drm_for_each_plane(plane, dev)
if (idx == plane->index)
return plane;
return NULL;
} | /**
* drm_plane_from_index - find the registered plane at an index
* @dev: DRM device
* @idx: index of registered plane to find for
*
* Given a plane index, return the registered plane from DRM device's
* list of planes with matching index.
*/ | find the registered plane at an index
@dev: DRM device
@idx: index of registered plane to find for
Given a plane index, return the registered plane from DRM device's
list of planes with matching index. | [
"find",
"the",
"registered",
"plane",
"at",
"an",
"index",
"@dev",
":",
"DRM",
"device",
"@idx",
":",
"index",
"of",
"registered",
"plane",
"to",
"find",
"for",
"Given",
"a",
"plane",
"index",
"return",
"the",
"registered",
"plane",
"from",
"DRM",
"device",
"'",
"s",
"list",
"of",
"planes",
"with",
"matching",
"index",
"."
] | struct drm_plane *
drm_plane_from_index(struct drm_device *dev, int idx)
{
struct drm_plane *plane;
drm_for_each_plane(plane, dev)
if (idx == plane->index)
return plane;
return NULL;
} | [
"struct",
"drm_plane",
"*",
"drm_plane_from_index",
"(",
"struct",
"drm_device",
"*",
"dev",
",",
"int",
"idx",
")",
"{",
"struct",
"drm_plane",
"*",
"plane",
";",
"drm_for_each_plane",
"(",
"plane",
",",
"dev",
")",
"",
"if",
"(",
"idx",
"==",
"plane",
"->",
"index",
")",
"return",
"plane",
";",
"return",
"NULL",
";",
"}"
] | drm_plane_from_index - find the registered plane at an index
@dev: DRM device
@idx: index of registered plane to find for | [
"drm_plane_from_index",
"-",
"find",
"the",
"registered",
"plane",
"at",
"an",
"index",
"@dev",
":",
"DRM",
"device",
"@idx",
":",
"index",
"of",
"registered",
"plane",
"to",
"find",
"for"
] | [] | [
{
"param": "dev",
"type": "struct drm_device"
},
{
"param": "idx",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "struct drm_device",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "idx",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
249c0ae52c6d18be7cf8f14c34703f4601843b50 | atrens/DragonFlyBSD-src | sys/dev/drm/drm_plane.c | [
"BSD-3-Clause"
] | C | __setplane_internal | int | static int __setplane_internal(struct drm_plane *plane,
struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int32_t crtc_x, int32_t crtc_y,
uint32_t crtc_w, uint32_t crtc_h,
/* src_{x,y,w,h} values are 16.16 fixed point */
uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h)
{
int ret = 0;
/* No fb means shut it down */
if (!fb) {
plane->old_fb = plane->fb;
ret = plane->funcs->disable_plane(plane);
if (!ret) {
plane->crtc = NULL;
plane->fb = NULL;
} else {
plane->old_fb = NULL;
}
goto out;
}
/* Check whether this plane is usable on this CRTC */
if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) {
DRM_DEBUG_KMS("Invalid crtc for plane\n");
ret = -EINVAL;
goto out;
}
/* Check whether this plane supports the fb pixel format. */
ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
if (ret) {
char *format_name = drm_get_format_name(fb->pixel_format);
DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name);
kfree(format_name);
goto out;
}
/* Give drivers some help against integer overflows */
if (crtc_w > INT_MAX ||
crtc_x > INT_MAX - (int32_t) crtc_w ||
crtc_h > INT_MAX ||
crtc_y > INT_MAX - (int32_t) crtc_h) {
DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
crtc_w, crtc_h, crtc_x, crtc_y);
ret = -ERANGE;
goto out;
}
ret = drm_framebuffer_check_src_coords(src_x, src_y, src_w, src_h, fb);
if (ret)
goto out;
plane->old_fb = plane->fb;
ret = plane->funcs->update_plane(plane, crtc, fb,
crtc_x, crtc_y, crtc_w, crtc_h,
src_x, src_y, src_w, src_h);
if (!ret) {
plane->crtc = crtc;
plane->fb = fb;
fb = NULL;
} else {
plane->old_fb = NULL;
}
out:
if (fb)
drm_framebuffer_unreference(fb);
if (plane->old_fb)
drm_framebuffer_unreference(plane->old_fb);
plane->old_fb = NULL;
return ret;
} | /*
* setplane_internal - setplane handler for internal callers
*
* Note that we assume an extra reference has already been taken on fb. If the
* update fails, this reference will be dropped before return; if it succeeds,
* the previous framebuffer (if any) will be unreferenced instead.
*
* src_{x,y,w,h} are provided in 16.16 fixed point format
*/ | setplane handler for internal callers
Note that we assume an extra reference has already been taken on fb. If the
update fails, this reference will be dropped before return; if it succeeds,
the previous framebuffer (if any) will be unreferenced instead.
src_{x,y,w,h} are provided in 16.16 fixed point format | [
"setplane",
"handler",
"for",
"internal",
"callers",
"Note",
"that",
"we",
"assume",
"an",
"extra",
"reference",
"has",
"already",
"been",
"taken",
"on",
"fb",
".",
"If",
"the",
"update",
"fails",
"this",
"reference",
"will",
"be",
"dropped",
"before",
"return",
";",
"if",
"it",
"succeeds",
"the",
"previous",
"framebuffer",
"(",
"if",
"any",
")",
"will",
"be",
"unreferenced",
"instead",
".",
"src_",
"{",
"x",
"y",
"w",
"h",
"}",
"are",
"provided",
"in",
"16",
".",
"16",
"fixed",
"point",
"format"
] | static int __setplane_internal(struct drm_plane *plane,
struct drm_crtc *crtc,
struct drm_framebuffer *fb,
int32_t crtc_x, int32_t crtc_y,
uint32_t crtc_w, uint32_t crtc_h,
uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h)
{
int ret = 0;
if (!fb) {
plane->old_fb = plane->fb;
ret = plane->funcs->disable_plane(plane);
if (!ret) {
plane->crtc = NULL;
plane->fb = NULL;
} else {
plane->old_fb = NULL;
}
goto out;
}
if (!(plane->possible_crtcs & drm_crtc_mask(crtc))) {
DRM_DEBUG_KMS("Invalid crtc for plane\n");
ret = -EINVAL;
goto out;
}
ret = drm_plane_check_pixel_format(plane, fb->pixel_format);
if (ret) {
char *format_name = drm_get_format_name(fb->pixel_format);
DRM_DEBUG_KMS("Invalid pixel format %s\n", format_name);
kfree(format_name);
goto out;
}
if (crtc_w > INT_MAX ||
crtc_x > INT_MAX - (int32_t) crtc_w ||
crtc_h > INT_MAX ||
crtc_y > INT_MAX - (int32_t) crtc_h) {
DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
crtc_w, crtc_h, crtc_x, crtc_y);
ret = -ERANGE;
goto out;
}
ret = drm_framebuffer_check_src_coords(src_x, src_y, src_w, src_h, fb);
if (ret)
goto out;
plane->old_fb = plane->fb;
ret = plane->funcs->update_plane(plane, crtc, fb,
crtc_x, crtc_y, crtc_w, crtc_h,
src_x, src_y, src_w, src_h);
if (!ret) {
plane->crtc = crtc;
plane->fb = fb;
fb = NULL;
} else {
plane->old_fb = NULL;
}
out:
if (fb)
drm_framebuffer_unreference(fb);
if (plane->old_fb)
drm_framebuffer_unreference(plane->old_fb);
plane->old_fb = NULL;
return ret;
} | [
"static",
"int",
"__setplane_internal",
"(",
"struct",
"drm_plane",
"*",
"plane",
",",
"struct",
"drm_crtc",
"*",
"crtc",
",",
"struct",
"drm_framebuffer",
"*",
"fb",
",",
"int32_t",
"crtc_x",
",",
"int32_t",
"crtc_y",
",",
"uint32_t",
"crtc_w",
",",
"uint32_t",
"crtc_h",
",",
"uint32_t",
"src_x",
",",
"uint32_t",
"src_y",
",",
"uint32_t",
"src_w",
",",
"uint32_t",
"src_h",
")",
"{",
"int",
"ret",
"=",
"0",
";",
"if",
"(",
"!",
"fb",
")",
"{",
"plane",
"->",
"old_fb",
"=",
"plane",
"->",
"fb",
";",
"ret",
"=",
"plane",
"->",
"funcs",
"->",
"disable_plane",
"(",
"plane",
")",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"plane",
"->",
"crtc",
"=",
"NULL",
";",
"plane",
"->",
"fb",
"=",
"NULL",
";",
"}",
"else",
"{",
"plane",
"->",
"old_fb",
"=",
"NULL",
";",
"}",
"goto",
"out",
";",
"}",
"if",
"(",
"!",
"(",
"plane",
"->",
"possible_crtcs",
"&",
"drm_crtc_mask",
"(",
"crtc",
")",
")",
")",
"{",
"DRM_DEBUG_KMS",
"(",
"\"",
"\\n",
"\"",
")",
";",
"ret",
"=",
"-",
"EINVAL",
";",
"goto",
"out",
";",
"}",
"ret",
"=",
"drm_plane_check_pixel_format",
"(",
"plane",
",",
"fb",
"->",
"pixel_format",
")",
";",
"if",
"(",
"ret",
")",
"{",
"char",
"*",
"format_name",
"=",
"drm_get_format_name",
"(",
"fb",
"->",
"pixel_format",
")",
";",
"DRM_DEBUG_KMS",
"(",
"\"",
"\\n",
"\"",
",",
"format_name",
")",
";",
"kfree",
"(",
"format_name",
")",
";",
"goto",
"out",
";",
"}",
"if",
"(",
"crtc_w",
">",
"INT_MAX",
"||",
"crtc_x",
">",
"INT_MAX",
"-",
"(",
"int32_t",
")",
"crtc_w",
"||",
"crtc_h",
">",
"INT_MAX",
"||",
"crtc_y",
">",
"INT_MAX",
"-",
"(",
"int32_t",
")",
"crtc_h",
")",
"{",
"DRM_DEBUG_KMS",
"(",
"\"",
"\\n",
"\"",
",",
"crtc_w",
",",
"crtc_h",
",",
"crtc_x",
",",
"crtc_y",
")",
";",
"ret",
"=",
"-",
"ERANGE",
";",
"goto",
"out",
";",
"}",
"ret",
"=",
"drm_framebuffer_check_src_coords",
"(",
"src_x",
",",
"src_y",
",",
"src_w",
",",
"src_h",
",",
"fb",
")",
";",
"if",
"(",
"ret",
")",
"goto",
"out",
";",
"plane",
"->",
"old_fb",
"=",
"plane",
"->",
"fb",
";",
"ret",
"=",
"plane",
"->",
"funcs",
"->",
"update_plane",
"(",
"plane",
",",
"crtc",
",",
"fb",
",",
"crtc_x",
",",
"crtc_y",
",",
"crtc_w",
",",
"crtc_h",
",",
"src_x",
",",
"src_y",
",",
"src_w",
",",
"src_h",
")",
";",
"if",
"(",
"!",
"ret",
")",
"{",
"plane",
"->",
"crtc",
"=",
"crtc",
";",
"plane",
"->",
"fb",
"=",
"fb",
";",
"fb",
"=",
"NULL",
";",
"}",
"else",
"{",
"plane",
"->",
"old_fb",
"=",
"NULL",
";",
"}",
"out",
":",
"if",
"(",
"fb",
")",
"drm_framebuffer_unreference",
"(",
"fb",
")",
";",
"if",
"(",
"plane",
"->",
"old_fb",
")",
"drm_framebuffer_unreference",
"(",
"plane",
"->",
"old_fb",
")",
";",
"plane",
"->",
"old_fb",
"=",
"NULL",
";",
"return",
"ret",
";",
"}"
] | setplane_internal - setplane handler for internal callers
Note that we assume an extra reference has already been taken on fb. | [
"setplane_internal",
"-",
"setplane",
"handler",
"for",
"internal",
"callers",
"Note",
"that",
"we",
"assume",
"an",
"extra",
"reference",
"has",
"already",
"been",
"taken",
"on",
"fb",
"."
] | [
"/* src_{x,y,w,h} values are 16.16 fixed point */",
"/* No fb means shut it down */",
"/* Check whether this plane is usable on this CRTC */",
"/* Check whether this plane supports the fb pixel format. */",
"/* Give drivers some help against integer overflows */"
] | [
{
"param": "plane",
"type": "struct drm_plane"
},
{
"param": "crtc",
"type": "struct drm_crtc"
},
{
"param": "fb",
"type": "struct drm_framebuffer"
},
{
"param": "crtc_x",
"type": "int32_t"
},
{
"param": "crtc_y",
"type": "int32_t"
},
{
"param": "crtc_w",
"type": "uint32_t"
},
{
"param": "crtc_h",
"type": "uint32_t"
},
{
"param": "src_x",
"type": "uint32_t"
},
{
"param": "src_y",
"type": "uint32_t"
},
{
"param": "src_w",
"type": "uint32_t"
},
{
"param": "src_h",
"type": "uint32_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plane",
"type": "struct drm_plane",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crtc",
"type": "struct drm_crtc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fb",
"type": "struct drm_framebuffer",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crtc_x",
"type": "int32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crtc_y",
"type": "int32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crtc_w",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "crtc_h",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src_x",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src_y",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src_w",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "src_h",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_sort | int | int
acl_sort(acl_t acl)
{
qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
(compare) acl_entry_compare);
return (0);
} | /*
* acl_sort -- sort ACL entries.
* Give the opportunity to fail, althouh we don't currently have a way
* to fail.
*/ | - sort ACL entries.
Give the opportunity to fail, althouh we don't currently have a way
to fail. | [
"-",
"sort",
"ACL",
"entries",
".",
"Give",
"the",
"opportunity",
"to",
"fail",
"althouh",
"we",
"don",
"'",
"t",
"currently",
"have",
"a",
"way",
"to",
"fail",
"."
] | int
acl_sort(acl_t acl)
{
qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
(compare) acl_entry_compare);
return (0);
} | [
"int",
"acl_sort",
"(",
"acl_t",
"acl",
")",
"{",
"qsort",
"(",
"&",
"acl",
"->",
"acl_entry",
"[",
"0",
"]",
",",
"acl",
"->",
"acl_cnt",
",",
"sizeof",
"(",
"struct",
"acl_entry",
")",
",",
"(",
"compare",
")",
"acl_entry_compare",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | acl_sort -- sort ACL entries. | [
"acl_sort",
"--",
"sort",
"ACL",
"entries",
"."
] | [] | [
{
"param": "acl",
"type": "acl_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acl",
"type": "acl_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_posix1e | int | int
acl_posix1e(acl_t acl, acl_type_t type)
{
return ((type == ACL_TYPE_ACCESS) || (type == ACL_TYPE_DEFAULT));
} | /*
* acl_posix1e -- in what situations should we acl_sort before submission?
* We apply posix1e ACL semantics for any ACL of type ACL_TYPE_ACCESS or
* ACL_TYPE_DEFAULT
*/ | - in what situations should we acl_sort before submission.
We apply posix1e ACL semantics for any ACL of type ACL_TYPE_ACCESS or
ACL_TYPE_DEFAULT | [
"-",
"in",
"what",
"situations",
"should",
"we",
"acl_sort",
"before",
"submission",
".",
"We",
"apply",
"posix1e",
"ACL",
"semantics",
"for",
"any",
"ACL",
"of",
"type",
"ACL_TYPE_ACCESS",
"or",
"ACL_TYPE_DEFAULT"
] | int
acl_posix1e(acl_t acl, acl_type_t type)
{
return ((type == ACL_TYPE_ACCESS) || (type == ACL_TYPE_DEFAULT));
} | [
"int",
"acl_posix1e",
"(",
"acl_t",
"acl",
",",
"acl_type_t",
"type",
")",
"{",
"return",
"(",
"(",
"type",
"==",
"ACL_TYPE_ACCESS",
")",
"||",
"(",
"type",
"==",
"ACL_TYPE_DEFAULT",
")",
")",
";",
"}"
] | acl_posix1e -- in what situations should we acl_sort before submission? | [
"acl_posix1e",
"--",
"in",
"what",
"situations",
"should",
"we",
"acl_sort",
"before",
"submission?"
] | [] | [
{
"param": "acl",
"type": "acl_t"
},
{
"param": "type",
"type": "acl_type_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acl",
"type": "acl_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "type",
"type": "acl_type_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_check | int | int
acl_check(struct acl *acl)
{
struct acl_entry *entry; /* current entry */
uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
int stage = ACL_USER_OBJ;
int i = 0;
int count_user_obj=0, count_user=0, count_group_obj=0,
count_group=0, count_mask=0, count_other=0;
/* printf("acl_check: checking acl with %d entries\n", acl->acl_cnt); */
while (i < acl->acl_cnt) {
entry = &acl->acl_entry[i];
if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
return (EINVAL);
switch(entry->ae_tag) {
case ACL_USER_OBJ:
/* printf("acl_check: %d: ACL_USER_OBJ\n", i); */
if (stage > ACL_USER_OBJ)
return (EINVAL);
stage = ACL_USER;
count_user_obj++;
obj_uid = entry->ae_id;
break;
case ACL_USER:
/* printf("acl_check: %d: ACL_USER\n", i); */
if (stage > ACL_USER)
return (EINVAL);
stage = ACL_USER;
if (entry->ae_id == obj_uid)
return (EINVAL);
if (count_user && (entry->ae_id <= highest_uid))
return (EINVAL);
highest_uid = entry->ae_id;
count_user++;
break;
case ACL_GROUP_OBJ:
/* printf("acl_check: %d: ACL_GROUP_OBJ\n", i); */
if (stage > ACL_GROUP_OBJ)
return (EINVAL);
stage = ACL_GROUP;
count_group_obj++;
obj_gid = entry->ae_id;
break;
case ACL_GROUP:
/* printf("acl_check: %d: ACL_GROUP\n", i); */
if (stage > ACL_GROUP)
return (EINVAL);
stage = ACL_GROUP;
if (entry->ae_id == obj_gid)
return (EINVAL);
if (count_group && (entry->ae_id <= highest_gid))
return (EINVAL);
highest_gid = entry->ae_id;
count_group++;
break;
case ACL_MASK:
/* printf("acl_check: %d: ACL_MASK\n", i); */
if (stage > ACL_MASK)
return (EINVAL);
stage = ACL_MASK;
count_mask++;
break;
case ACL_OTHER:
/* printf("acl_check: %d: ACL_OTHER\n", i); */
if (stage > ACL_OTHER)
return (EINVAL);
stage = ACL_OTHER;
count_other++;
break;
default:
/* printf("acl_check: %d: INVALID\n", i); */
return (EINVAL);
}
i++;
}
if (count_user_obj != 1)
return (EINVAL);
if (count_group_obj != 1)
return (EINVAL);
if (count_mask != 0 && count_mask != 1)
return (EINVAL);
if (count_other != 1)
return (EINVAL);
return (0);
} | /*
* acl_check -- given an ACL, check its validity. This is mirrored from
* code in sys/kern/kern_acl.c, and if changes are made in one, they should
* be made in the other also. This copy of acl_check is made available
* in userland for the benefit of processes wanting to check ACLs for
* validity before submitting them to the kernel, or for performing
* in userland file system checking. Needless to say, the kernel makes
* the real checks on calls to get/setacl.
*
* See the comments in kernel for explanation -- just briefly, it assumes
* an already sorted ACL, and checks based on that assumption. The
* POSIX.1e interface, acl_valid(), will perform the sort before calling
* this. Returns 0 on success, EINVAL on failure.
*/ | - given an ACL, check its validity. This is mirrored from
code in sys/kern/kern_acl.c, and if changes are made in one, they should
be made in the other also. This copy of acl_check is made available
in userland for the benefit of processes wanting to check ACLs for
validity before submitting them to the kernel, or for performing
in userland file system checking. Needless to say, the kernel makes
the real checks on calls to get/setacl.
See the comments in kernel for explanation -- just briefly, it assumes
an already sorted ACL, and checks based on that assumption. The
POSIX.1e interface, acl_valid(), will perform the sort before calling
this. Returns 0 on success, EINVAL on failure. | [
"-",
"given",
"an",
"ACL",
"check",
"its",
"validity",
".",
"This",
"is",
"mirrored",
"from",
"code",
"in",
"sys",
"/",
"kern",
"/",
"kern_acl",
".",
"c",
"and",
"if",
"changes",
"are",
"made",
"in",
"one",
"they",
"should",
"be",
"made",
"in",
"the",
"other",
"also",
".",
"This",
"copy",
"of",
"acl_check",
"is",
"made",
"available",
"in",
"userland",
"for",
"the",
"benefit",
"of",
"processes",
"wanting",
"to",
"check",
"ACLs",
"for",
"validity",
"before",
"submitting",
"them",
"to",
"the",
"kernel",
"or",
"for",
"performing",
"in",
"userland",
"file",
"system",
"checking",
".",
"Needless",
"to",
"say",
"the",
"kernel",
"makes",
"the",
"real",
"checks",
"on",
"calls",
"to",
"get",
"/",
"setacl",
".",
"See",
"the",
"comments",
"in",
"kernel",
"for",
"explanation",
"--",
"just",
"briefly",
"it",
"assumes",
"an",
"already",
"sorted",
"ACL",
"and",
"checks",
"based",
"on",
"that",
"assumption",
".",
"The",
"POSIX",
".",
"1e",
"interface",
"acl_valid",
"()",
"will",
"perform",
"the",
"sort",
"before",
"calling",
"this",
".",
"Returns",
"0",
"on",
"success",
"EINVAL",
"on",
"failure",
"."
] | int
acl_check(struct acl *acl)
{
struct acl_entry *entry;
uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
int stage = ACL_USER_OBJ;
int i = 0;
int count_user_obj=0, count_user=0, count_group_obj=0,
count_group=0, count_mask=0, count_other=0;
while (i < acl->acl_cnt) {
entry = &acl->acl_entry[i];
if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
return (EINVAL);
switch(entry->ae_tag) {
case ACL_USER_OBJ:
if (stage > ACL_USER_OBJ)
return (EINVAL);
stage = ACL_USER;
count_user_obj++;
obj_uid = entry->ae_id;
break;
case ACL_USER:
if (stage > ACL_USER)
return (EINVAL);
stage = ACL_USER;
if (entry->ae_id == obj_uid)
return (EINVAL);
if (count_user && (entry->ae_id <= highest_uid))
return (EINVAL);
highest_uid = entry->ae_id;
count_user++;
break;
case ACL_GROUP_OBJ:
if (stage > ACL_GROUP_OBJ)
return (EINVAL);
stage = ACL_GROUP;
count_group_obj++;
obj_gid = entry->ae_id;
break;
case ACL_GROUP:
if (stage > ACL_GROUP)
return (EINVAL);
stage = ACL_GROUP;
if (entry->ae_id == obj_gid)
return (EINVAL);
if (count_group && (entry->ae_id <= highest_gid))
return (EINVAL);
highest_gid = entry->ae_id;
count_group++;
break;
case ACL_MASK:
if (stage > ACL_MASK)
return (EINVAL);
stage = ACL_MASK;
count_mask++;
break;
case ACL_OTHER:
if (stage > ACL_OTHER)
return (EINVAL);
stage = ACL_OTHER;
count_other++;
break;
default:
return (EINVAL);
}
i++;
}
if (count_user_obj != 1)
return (EINVAL);
if (count_group_obj != 1)
return (EINVAL);
if (count_mask != 0 && count_mask != 1)
return (EINVAL);
if (count_other != 1)
return (EINVAL);
return (0);
} | [
"int",
"acl_check",
"(",
"struct",
"acl",
"*",
"acl",
")",
"{",
"struct",
"acl_entry",
"*",
"entry",
";",
"uid_t",
"obj_uid",
"=",
"-1",
",",
"obj_gid",
"=",
"-1",
",",
"highest_uid",
"=",
"0",
",",
"highest_gid",
"=",
"0",
";",
"int",
"stage",
"=",
"ACL_USER_OBJ",
";",
"int",
"i",
"=",
"0",
";",
"int",
"count_user_obj",
"=",
"0",
",",
"count_user",
"=",
"0",
",",
"count_group_obj",
"=",
"0",
",",
"count_group",
"=",
"0",
",",
"count_mask",
"=",
"0",
",",
"count_other",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"acl",
"->",
"acl_cnt",
")",
"{",
"entry",
"=",
"&",
"acl",
"->",
"acl_entry",
"[",
"i",
"]",
";",
"if",
"(",
"(",
"entry",
"->",
"ae_perm",
"|",
"ACL_PERM_BITS",
")",
"!=",
"ACL_PERM_BITS",
")",
"return",
"(",
"EINVAL",
")",
";",
"switch",
"(",
"entry",
"->",
"ae_tag",
")",
"{",
"case",
"ACL_USER_OBJ",
":",
"if",
"(",
"stage",
">",
"ACL_USER_OBJ",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_USER",
";",
"count_user_obj",
"++",
";",
"obj_uid",
"=",
"entry",
"->",
"ae_id",
";",
"break",
";",
"case",
"ACL_USER",
":",
"if",
"(",
"stage",
">",
"ACL_USER",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_USER",
";",
"if",
"(",
"entry",
"->",
"ae_id",
"==",
"obj_uid",
")",
"return",
"(",
"EINVAL",
")",
";",
"if",
"(",
"count_user",
"&&",
"(",
"entry",
"->",
"ae_id",
"<=",
"highest_uid",
")",
")",
"return",
"(",
"EINVAL",
")",
";",
"highest_uid",
"=",
"entry",
"->",
"ae_id",
";",
"count_user",
"++",
";",
"break",
";",
"case",
"ACL_GROUP_OBJ",
":",
"if",
"(",
"stage",
">",
"ACL_GROUP_OBJ",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_GROUP",
";",
"count_group_obj",
"++",
";",
"obj_gid",
"=",
"entry",
"->",
"ae_id",
";",
"break",
";",
"case",
"ACL_GROUP",
":",
"if",
"(",
"stage",
">",
"ACL_GROUP",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_GROUP",
";",
"if",
"(",
"entry",
"->",
"ae_id",
"==",
"obj_gid",
")",
"return",
"(",
"EINVAL",
")",
";",
"if",
"(",
"count_group",
"&&",
"(",
"entry",
"->",
"ae_id",
"<=",
"highest_gid",
")",
")",
"return",
"(",
"EINVAL",
")",
";",
"highest_gid",
"=",
"entry",
"->",
"ae_id",
";",
"count_group",
"++",
";",
"break",
";",
"case",
"ACL_MASK",
":",
"if",
"(",
"stage",
">",
"ACL_MASK",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_MASK",
";",
"count_mask",
"++",
";",
"break",
";",
"case",
"ACL_OTHER",
":",
"if",
"(",
"stage",
">",
"ACL_OTHER",
")",
"return",
"(",
"EINVAL",
")",
";",
"stage",
"=",
"ACL_OTHER",
";",
"count_other",
"++",
";",
"break",
";",
"default",
":",
"return",
"(",
"EINVAL",
")",
";",
"}",
"i",
"++",
";",
"}",
"if",
"(",
"count_user_obj",
"!=",
"1",
")",
"return",
"(",
"EINVAL",
")",
";",
"if",
"(",
"count_group_obj",
"!=",
"1",
")",
"return",
"(",
"EINVAL",
")",
";",
"if",
"(",
"count_mask",
"!=",
"0",
"&&",
"count_mask",
"!=",
"1",
")",
"return",
"(",
"EINVAL",
")",
";",
"if",
"(",
"count_other",
"!=",
"1",
")",
"return",
"(",
"EINVAL",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | acl_check -- given an ACL, check its validity. | [
"acl_check",
"--",
"given",
"an",
"ACL",
"check",
"its",
"validity",
"."
] | [
"/* current entry */",
"/* printf(\"acl_check: checking acl with %d entries\\n\", acl->acl_cnt); */",
"/* printf(\"acl_check: %d: ACL_USER_OBJ\\n\", i); */",
"/* printf(\"acl_check: %d: ACL_USER\\n\", i); */",
"/* printf(\"acl_check: %d: ACL_GROUP_OBJ\\n\", i); */",
"/* printf(\"acl_check: %d: ACL_GROUP\\n\", i); */",
"/* printf(\"acl_check: %d: ACL_MASK\\n\", i); */",
"/* printf(\"acl_check: %d: ACL_OTHER\\n\", i); */",
"/* printf(\"acl_check: %d: INVALID\\n\", i); */"
] | [
{
"param": "acl",
"type": "struct acl"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acl",
"type": "struct acl",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_name_to_id | int | int
acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
{
struct group *g;
struct passwd *p;
switch(tag) {
case ACL_USER:
p = getpwnam(name);
if (!p) {
errno = EINVAL;
return (-1);
}
*id = p->pw_uid;
return (0);
case ACL_GROUP:
g = getgrnam(name);
if (g) {
errno = EINVAL;
return (-1);
}
*id = g->gr_gid;
return (0);
default:
return (EINVAL);
}
} | /*
* Given a username/groupname from a text form of an ACL, return the uid/gid
* XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM
* XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
* MAY HAVE SIDE-EFFECTS
*
* XXX currently doesn't deal correctly with a numeric uid being passed
* instead of a username. What is correct behavior here? Check chown.
*/ |
XXX currently doesn't deal correctly with a numeric uid being passed
instead of a username. What is correct behavior here. Check chown. | [
"XXX",
"currently",
"doesn",
"'",
"t",
"deal",
"correctly",
"with",
"a",
"numeric",
"uid",
"being",
"passed",
"instead",
"of",
"a",
"username",
".",
"What",
"is",
"correct",
"behavior",
"here",
".",
"Check",
"chown",
"."
] | int
acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
{
struct group *g;
struct passwd *p;
switch(tag) {
case ACL_USER:
p = getpwnam(name);
if (!p) {
errno = EINVAL;
return (-1);
}
*id = p->pw_uid;
return (0);
case ACL_GROUP:
g = getgrnam(name);
if (g) {
errno = EINVAL;
return (-1);
}
*id = g->gr_gid;
return (0);
default:
return (EINVAL);
}
} | [
"int",
"acl_name_to_id",
"(",
"acl_tag_t",
"tag",
",",
"char",
"*",
"name",
",",
"uid_t",
"*",
"id",
")",
"{",
"struct",
"group",
"*",
"g",
";",
"struct",
"passwd",
"*",
"p",
";",
"switch",
"(",
"tag",
")",
"{",
"case",
"ACL_USER",
":",
"p",
"=",
"getpwnam",
"(",
"name",
")",
";",
"if",
"(",
"!",
"p",
")",
"{",
"errno",
"=",
"EINVAL",
";",
"return",
"(",
"-1",
")",
";",
"}",
"*",
"id",
"=",
"p",
"->",
"pw_uid",
";",
"return",
"(",
"0",
")",
";",
"case",
"ACL_GROUP",
":",
"g",
"=",
"getgrnam",
"(",
"name",
")",
";",
"if",
"(",
"g",
")",
"{",
"errno",
"=",
"EINVAL",
";",
"return",
"(",
"-1",
")",
";",
"}",
"*",
"id",
"=",
"g",
"->",
"gr_gid",
";",
"return",
"(",
"0",
")",
";",
"default",
":",
"return",
"(",
"EINVAL",
")",
";",
"}",
"}"
] | Given a username/groupname from a text form of an ACL, return the uid/gid
XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM
XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
MAY HAVE SIDE-EFFECTS | [
"Given",
"a",
"username",
"/",
"groupname",
"from",
"a",
"text",
"form",
"of",
"an",
"ACL",
"return",
"the",
"uid",
"/",
"gid",
"XXX",
"NOT",
"THREAD",
"SAFE",
"RELIES",
"ON",
"GETPWNAM",
"GETGRNAM",
"XXX",
"USES",
"*",
"PW",
"*",
"AND",
"*",
"GR",
"*",
"WHICH",
"ARE",
"STATEFUL",
"AND",
"THEREFORE",
"THIS",
"ROUTINE",
"MAY",
"HAVE",
"SIDE",
"-",
"EFFECTS"
] | [] | [
{
"param": "tag",
"type": "acl_tag_t"
},
{
"param": "name",
"type": "char"
},
{
"param": "id",
"type": "uid_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tag",
"type": "acl_tag_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": "uid_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_perm_to_string | int | int
acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
{
if (buf_len < ACL_STRING_PERM_MAXSIZE + 1) {
errno = ENOMEM;
return (-1);
}
if ((perm | ACL_PERM_BITS) != ACL_PERM_BITS) {
errno = EINVAL;
return (-1);
}
buf[3] = 0; /* null terminate */
if (perm & ACL_PERM_READ)
buf[0] = ACL_STRING_PERM_READ;
else
buf[0] = ACL_STRING_PERM_NONE;
if (perm & ACL_PERM_WRITE)
buf[1] = ACL_STRING_PERM_WRITE;
else
buf[1] = ACL_STRING_PERM_NONE;
if (perm & ACL_PERM_EXEC)
buf[2] = ACL_STRING_PERM_EXEC;
else
buf[2] = ACL_STRING_PERM_NONE;
return (0);
} | /*
* Given a right-shifted permission (i.e., direct ACL_PERM_* mask), fill
* in a string describing the permissions.
*/ | Given a right-shifted permission , fill
in a string describing the permissions. | [
"Given",
"a",
"right",
"-",
"shifted",
"permission",
"fill",
"in",
"a",
"string",
"describing",
"the",
"permissions",
"."
] | int
acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
{
if (buf_len < ACL_STRING_PERM_MAXSIZE + 1) {
errno = ENOMEM;
return (-1);
}
if ((perm | ACL_PERM_BITS) != ACL_PERM_BITS) {
errno = EINVAL;
return (-1);
}
buf[3] = 0;
if (perm & ACL_PERM_READ)
buf[0] = ACL_STRING_PERM_READ;
else
buf[0] = ACL_STRING_PERM_NONE;
if (perm & ACL_PERM_WRITE)
buf[1] = ACL_STRING_PERM_WRITE;
else
buf[1] = ACL_STRING_PERM_NONE;
if (perm & ACL_PERM_EXEC)
buf[2] = ACL_STRING_PERM_EXEC;
else
buf[2] = ACL_STRING_PERM_NONE;
return (0);
} | [
"int",
"acl_perm_to_string",
"(",
"acl_perm_t",
"perm",
",",
"ssize_t",
"buf_len",
",",
"char",
"*",
"buf",
")",
"{",
"if",
"(",
"buf_len",
"<",
"ACL_STRING_PERM_MAXSIZE",
"+",
"1",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"return",
"(",
"-1",
")",
";",
"}",
"if",
"(",
"(",
"perm",
"|",
"ACL_PERM_BITS",
")",
"!=",
"ACL_PERM_BITS",
")",
"{",
"errno",
"=",
"EINVAL",
";",
"return",
"(",
"-1",
")",
";",
"}",
"buf",
"[",
"3",
"]",
"=",
"0",
";",
"if",
"(",
"perm",
"&",
"ACL_PERM_READ",
")",
"buf",
"[",
"0",
"]",
"=",
"ACL_STRING_PERM_READ",
";",
"else",
"buf",
"[",
"0",
"]",
"=",
"ACL_STRING_PERM_NONE",
";",
"if",
"(",
"perm",
"&",
"ACL_PERM_WRITE",
")",
"buf",
"[",
"1",
"]",
"=",
"ACL_STRING_PERM_WRITE",
";",
"else",
"buf",
"[",
"1",
"]",
"=",
"ACL_STRING_PERM_NONE",
";",
"if",
"(",
"perm",
"&",
"ACL_PERM_EXEC",
")",
"buf",
"[",
"2",
"]",
"=",
"ACL_STRING_PERM_EXEC",
";",
"else",
"buf",
"[",
"2",
"]",
"=",
"ACL_STRING_PERM_NONE",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Given a right-shifted permission (i.e., direct ACL_PERM_* mask), fill
in a string describing the permissions. | [
"Given",
"a",
"right",
"-",
"shifted",
"permission",
"(",
"i",
".",
"e",
".",
"direct",
"ACL_PERM_",
"*",
"mask",
")",
"fill",
"in",
"a",
"string",
"describing",
"the",
"permissions",
"."
] | [
"/* null terminate */"
] | [
{
"param": "perm",
"type": "acl_perm_t"
},
{
"param": "buf_len",
"type": "ssize_t"
},
{
"param": "buf",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "perm",
"type": "acl_perm_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf_len",
"type": "ssize_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "buf",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_string_to_perm | int | int
acl_string_to_perm(char *string, acl_perm_t *perm)
{
acl_perm_t myperm = ACL_PERM_NONE;
char *ch;
ch = string;
while (*ch) {
switch(*ch) {
case ACL_STRING_PERM_READ:
myperm |= ACL_PERM_READ;
break;
case ACL_STRING_PERM_WRITE:
myperm |= ACL_PERM_WRITE;
break;
case ACL_STRING_PERM_EXEC:
myperm |= ACL_PERM_EXEC;
break;
case ACL_STRING_PERM_NONE:
break;
default:
return (EINVAL);
}
ch++;
}
*perm = myperm;
return (0);
} | /*
* given a string, return a permission describing it
*/ | given a string, return a permission describing it | [
"given",
"a",
"string",
"return",
"a",
"permission",
"describing",
"it"
] | int
acl_string_to_perm(char *string, acl_perm_t *perm)
{
acl_perm_t myperm = ACL_PERM_NONE;
char *ch;
ch = string;
while (*ch) {
switch(*ch) {
case ACL_STRING_PERM_READ:
myperm |= ACL_PERM_READ;
break;
case ACL_STRING_PERM_WRITE:
myperm |= ACL_PERM_WRITE;
break;
case ACL_STRING_PERM_EXEC:
myperm |= ACL_PERM_EXEC;
break;
case ACL_STRING_PERM_NONE:
break;
default:
return (EINVAL);
}
ch++;
}
*perm = myperm;
return (0);
} | [
"int",
"acl_string_to_perm",
"(",
"char",
"*",
"string",
",",
"acl_perm_t",
"*",
"perm",
")",
"{",
"acl_perm_t",
"myperm",
"=",
"ACL_PERM_NONE",
";",
"char",
"*",
"ch",
";",
"ch",
"=",
"string",
";",
"while",
"(",
"*",
"ch",
")",
"{",
"switch",
"(",
"*",
"ch",
")",
"{",
"case",
"ACL_STRING_PERM_READ",
":",
"myperm",
"|=",
"ACL_PERM_READ",
";",
"break",
";",
"case",
"ACL_STRING_PERM_WRITE",
":",
"myperm",
"|=",
"ACL_PERM_WRITE",
";",
"break",
";",
"case",
"ACL_STRING_PERM_EXEC",
":",
"myperm",
"|=",
"ACL_PERM_EXEC",
";",
"break",
";",
"case",
"ACL_STRING_PERM_NONE",
":",
"break",
";",
"default",
":",
"return",
"(",
"EINVAL",
")",
";",
"}",
"ch",
"++",
";",
"}",
"*",
"perm",
"=",
"myperm",
";",
"return",
"(",
"0",
")",
";",
"}"
] | given a string, return a permission describing it | [
"given",
"a",
"string",
"return",
"a",
"permission",
"describing",
"it"
] | [] | [
{
"param": "string",
"type": "char"
},
{
"param": "perm",
"type": "acl_perm_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "perm",
"type": "acl_perm_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f20bc2d5471fd2db5514d9089f44c4f42423012 | atrens/DragonFlyBSD-src | lib/libposix1e/acl_support.c | [
"BSD-3-Clause"
] | C | acl_add_entry | int | int
acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
{
struct acl_entry *e;
if (acl->acl_cnt >= ACL_MAX_ENTRIES) {
errno = ENOMEM;
return (-1);
}
e = &(acl->acl_entry[acl->acl_cnt]);
e->ae_perm = perm;
e->ae_tag = tag;
e->ae_id = id;
acl->acl_cnt++;
return (0);
} | /*
* Add an ACL entry without doing much checking, et al
*/ | Add an ACL entry without doing much checking, et al | [
"Add",
"an",
"ACL",
"entry",
"without",
"doing",
"much",
"checking",
"et",
"al"
] | int
acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
{
struct acl_entry *e;
if (acl->acl_cnt >= ACL_MAX_ENTRIES) {
errno = ENOMEM;
return (-1);
}
e = &(acl->acl_entry[acl->acl_cnt]);
e->ae_perm = perm;
e->ae_tag = tag;
e->ae_id = id;
acl->acl_cnt++;
return (0);
} | [
"int",
"acl_add_entry",
"(",
"acl_t",
"acl",
",",
"acl_tag_t",
"tag",
",",
"uid_t",
"id",
",",
"acl_perm_t",
"perm",
")",
"{",
"struct",
"acl_entry",
"*",
"e",
";",
"if",
"(",
"acl",
"->",
"acl_cnt",
">=",
"ACL_MAX_ENTRIES",
")",
"{",
"errno",
"=",
"ENOMEM",
";",
"return",
"(",
"-1",
")",
";",
"}",
"e",
"=",
"&",
"(",
"acl",
"->",
"acl_entry",
"[",
"acl",
"->",
"acl_cnt",
"]",
")",
";",
"e",
"->",
"ae_perm",
"=",
"perm",
";",
"e",
"->",
"ae_tag",
"=",
"tag",
";",
"e",
"->",
"ae_id",
"=",
"id",
";",
"acl",
"->",
"acl_cnt",
"++",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Add an ACL entry without doing much checking, et al | [
"Add",
"an",
"ACL",
"entry",
"without",
"doing",
"much",
"checking",
"et",
"al"
] | [] | [
{
"param": "acl",
"type": "acl_t"
},
{
"param": "tag",
"type": "acl_tag_t"
},
{
"param": "id",
"type": "uid_t"
},
{
"param": "perm",
"type": "acl_perm_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "acl",
"type": "acl_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "acl_tag_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id",
"type": "uid_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "perm",
"type": "acl_perm_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f2d476fa539d9c1c9a08b493ad111a58b4724737 | atrens/DragonFlyBSD-src | sys/netgraph/pppoe/ng_pppoe.c | [
"BSD-3-Clause"
] | C | ng_pppoe_connect | int | static int
ng_pppoe_connect(hook_p hook)
{
/* be really amiable and just say "YUP that's OK by me! " */
return (0);
} | /*
* This is called once we've already connected a new hook to the other node.
* It gives us a chance to balk at the last minute.
*/ | This is called once we've already connected a new hook to the other node.
It gives us a chance to balk at the last minute. | [
"This",
"is",
"called",
"once",
"we",
"'",
"ve",
"already",
"connected",
"a",
"new",
"hook",
"to",
"the",
"other",
"node",
".",
"It",
"gives",
"us",
"a",
"chance",
"to",
"balk",
"at",
"the",
"last",
"minute",
"."
] | static int
ng_pppoe_connect(hook_p hook)
{
return (0);
} | [
"static",
"int",
"ng_pppoe_connect",
"(",
"hook_p",
"hook",
")",
"{",
"return",
"(",
"0",
")",
";",
"}"
] | This is called once we've already connected a new hook to the other node. | [
"This",
"is",
"called",
"once",
"we",
"'",
"ve",
"already",
"connected",
"a",
"new",
"hook",
"to",
"the",
"other",
"node",
"."
] | [
"/* be really amiable and just say \"YUP that's OK by me! \" */"
] | [
{
"param": "hook",
"type": "hook_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb15f16458b91a08cac3e431e9ca6f1af02fa677 | atrens/DragonFlyBSD-src | sys/bus/u4b/storage/ustorage_fs.c | [
"BSD-3-Clause"
] | C | ustorage_fs_probe | int | static int
ustorage_fs_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
struct usb_interface_descriptor *id;
if (uaa->usb_mode != USB_MODE_DEVICE) {
return (ENXIO);
}
/* Check for a standards compliant device */
id = usbd_get_interface_descriptor(uaa->iface);
if ((id == NULL) ||
(id->bInterfaceClass != UICLASS_MASS) ||
(id->bInterfaceSubClass != UISUBCLASS_SCSI) ||
(id->bInterfaceProtocol != UIPROTO_MASS_BBB)) {
return (ENXIO);
}
return (BUS_PROBE_GENERIC);
} | /*
* USB device probe/attach/detach
*/ | USB device probe/attach/detach | [
"USB",
"device",
"probe",
"/",
"attach",
"/",
"detach"
] | static int
ustorage_fs_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
struct usb_interface_descriptor *id;
if (uaa->usb_mode != USB_MODE_DEVICE) {
return (ENXIO);
}
id = usbd_get_interface_descriptor(uaa->iface);
if ((id == NULL) ||
(id->bInterfaceClass != UICLASS_MASS) ||
(id->bInterfaceSubClass != UISUBCLASS_SCSI) ||
(id->bInterfaceProtocol != UIPROTO_MASS_BBB)) {
return (ENXIO);
}
return (BUS_PROBE_GENERIC);
} | [
"static",
"int",
"ustorage_fs_probe",
"(",
"device_t",
"dev",
")",
"{",
"struct",
"usb_attach_arg",
"*",
"uaa",
"=",
"device_get_ivars",
"(",
"dev",
")",
";",
"struct",
"usb_interface_descriptor",
"*",
"id",
";",
"if",
"(",
"uaa",
"->",
"usb_mode",
"!=",
"USB_MODE_DEVICE",
")",
"{",
"return",
"(",
"ENXIO",
")",
";",
"}",
"id",
"=",
"usbd_get_interface_descriptor",
"(",
"uaa",
"->",
"iface",
")",
";",
"if",
"(",
"(",
"id",
"==",
"NULL",
")",
"||",
"(",
"id",
"->",
"bInterfaceClass",
"!=",
"UICLASS_MASS",
")",
"||",
"(",
"id",
"->",
"bInterfaceSubClass",
"!=",
"UISUBCLASS_SCSI",
")",
"||",
"(",
"id",
"->",
"bInterfaceProtocol",
"!=",
"UIPROTO_MASS_BBB",
")",
")",
"{",
"return",
"(",
"ENXIO",
")",
";",
"}",
"return",
"(",
"BUS_PROBE_GENERIC",
")",
";",
"}"
] | USB device probe/attach/detach | [
"USB",
"device",
"probe",
"/",
"attach",
"/",
"detach"
] | [
"/* Check for a standards compliant device */"
] | [
{
"param": "dev",
"type": "device_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb15f16458b91a08cac3e431e9ca6f1af02fa677 | atrens/DragonFlyBSD-src | sys/bus/u4b/storage/ustorage_fs.c | [
"BSD-3-Clause"
] | C | ustorage_fs_check_cmd | uint8_t | static uint8_t
ustorage_fs_check_cmd(struct ustorage_fs_softc *sc, uint8_t min_cmd_size,
uint16_t mask, uint8_t needs_medium)
{
struct ustorage_fs_lun *currlun;
uint8_t lun = (sc->sc_cbw->CBWCDB[1] >> 5);
uint8_t i;
/* Verify the length of the command itself */
if (min_cmd_size > sc->sc_transfer.cmd_len) {
DPRINTF("%u > %u\n",
min_cmd_size, sc->sc_transfer.cmd_len);
sc->sc_csw->bCSWStatus = CSWSTATUS_PHASE;
return (1);
}
/* Mask away the LUN */
sc->sc_cbw->CBWCDB[1] &= 0x1f;
/* Check if LUN is correct */
if (lun != sc->sc_transfer.lun) {
}
/* Check the LUN */
if (sc->sc_transfer.lun <= sc->sc_last_lun) {
sc->sc_transfer.currlun = currlun =
sc->sc_lun + sc->sc_transfer.lun;
if (sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE) {
currlun->sense_data = SS_NO_SENSE;
currlun->sense_data_info = 0;
currlun->info_valid = 0;
}
/*
* If a unit attention condition exists, only INQUIRY
* and REQUEST SENSE commands are allowed. Anything
* else must fail!
*/
if ((currlun->unit_attention_data != SS_NO_SENSE) &&
(sc->sc_cbw->CBWCDB[0] != SC_INQUIRY) &&
(sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE)) {
currlun->sense_data = currlun->unit_attention_data;
currlun->unit_attention_data = SS_NO_SENSE;
return (1);
}
} else {
sc->sc_transfer.currlun = currlun = NULL;
/*
* INQUIRY and REQUEST SENSE commands are explicitly allowed
* to use unsupported LUNs; all others may not.
*/
if ((sc->sc_cbw->CBWCDB[0] != SC_INQUIRY) &&
(sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE)) {
return (1);
}
}
/*
* Check that only command bytes listed in the mask are
* non-zero.
*/
for (i = 0; i != min_cmd_size; i++) {
if (sc->sc_cbw->CBWCDB[i] && !(mask & (1UL << i))) {
if (currlun) {
currlun->sense_data = SS_INVALID_FIELD_IN_CDB;
}
return (1);
}
}
/*
* If the medium isn't mounted and the command needs to access
* it, return an error.
*/
if (currlun && (!currlun->memory_image) && needs_medium) {
currlun->sense_data = SS_MEDIUM_NOT_PRESENT;
return (1);
}
return (0);
} | /*------------------------------------------------------------------------*
* ustorage_fs_check_cmd - check command routine
*
* Check whether the command is properly formed and whether its data
* size and direction agree with the values we already have.
*
* Return values:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/ | check command routine
Check whether the command is properly formed and whether its data
size and direction agree with the values we already have.
Return values:
0: Success
Else: Failure | [
"check",
"command",
"routine",
"Check",
"whether",
"the",
"command",
"is",
"properly",
"formed",
"and",
"whether",
"its",
"data",
"size",
"and",
"direction",
"agree",
"with",
"the",
"values",
"we",
"already",
"have",
".",
"Return",
"values",
":",
"0",
":",
"Success",
"Else",
":",
"Failure"
] | static uint8_t
ustorage_fs_check_cmd(struct ustorage_fs_softc *sc, uint8_t min_cmd_size,
uint16_t mask, uint8_t needs_medium)
{
struct ustorage_fs_lun *currlun;
uint8_t lun = (sc->sc_cbw->CBWCDB[1] >> 5);
uint8_t i;
if (min_cmd_size > sc->sc_transfer.cmd_len) {
DPRINTF("%u > %u\n",
min_cmd_size, sc->sc_transfer.cmd_len);
sc->sc_csw->bCSWStatus = CSWSTATUS_PHASE;
return (1);
}
sc->sc_cbw->CBWCDB[1] &= 0x1f;
if (lun != sc->sc_transfer.lun) {
}
if (sc->sc_transfer.lun <= sc->sc_last_lun) {
sc->sc_transfer.currlun = currlun =
sc->sc_lun + sc->sc_transfer.lun;
if (sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE) {
currlun->sense_data = SS_NO_SENSE;
currlun->sense_data_info = 0;
currlun->info_valid = 0;
}
if ((currlun->unit_attention_data != SS_NO_SENSE) &&
(sc->sc_cbw->CBWCDB[0] != SC_INQUIRY) &&
(sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE)) {
currlun->sense_data = currlun->unit_attention_data;
currlun->unit_attention_data = SS_NO_SENSE;
return (1);
}
} else {
sc->sc_transfer.currlun = currlun = NULL;
if ((sc->sc_cbw->CBWCDB[0] != SC_INQUIRY) &&
(sc->sc_cbw->CBWCDB[0] != SC_REQUEST_SENSE)) {
return (1);
}
}
for (i = 0; i != min_cmd_size; i++) {
if (sc->sc_cbw->CBWCDB[i] && !(mask & (1UL << i))) {
if (currlun) {
currlun->sense_data = SS_INVALID_FIELD_IN_CDB;
}
return (1);
}
}
if (currlun && (!currlun->memory_image) && needs_medium) {
currlun->sense_data = SS_MEDIUM_NOT_PRESENT;
return (1);
}
return (0);
} | [
"static",
"uint8_t",
"ustorage_fs_check_cmd",
"(",
"struct",
"ustorage_fs_softc",
"*",
"sc",
",",
"uint8_t",
"min_cmd_size",
",",
"uint16_t",
"mask",
",",
"uint8_t",
"needs_medium",
")",
"{",
"struct",
"ustorage_fs_lun",
"*",
"currlun",
";",
"uint8_t",
"lun",
"=",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"1",
"]",
">>",
"5",
")",
";",
"uint8_t",
"i",
";",
"if",
"(",
"min_cmd_size",
">",
"sc",
"->",
"sc_transfer",
".",
"cmd_len",
")",
"{",
"DPRINTF",
"(",
"\"",
"\\n",
"\"",
",",
"min_cmd_size",
",",
"sc",
"->",
"sc_transfer",
".",
"cmd_len",
")",
";",
"sc",
"->",
"sc_csw",
"->",
"bCSWStatus",
"=",
"CSWSTATUS_PHASE",
";",
"return",
"(",
"1",
")",
";",
"}",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"1",
"]",
"&=",
"0x1f",
";",
"if",
"(",
"lun",
"!=",
"sc",
"->",
"sc_transfer",
".",
"lun",
")",
"{",
"}",
"if",
"(",
"sc",
"->",
"sc_transfer",
".",
"lun",
"<=",
"sc",
"->",
"sc_last_lun",
")",
"{",
"sc",
"->",
"sc_transfer",
".",
"currlun",
"=",
"currlun",
"=",
"sc",
"->",
"sc_lun",
"+",
"sc",
"->",
"sc_transfer",
".",
"lun",
";",
"if",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"0",
"]",
"!=",
"SC_REQUEST_SENSE",
")",
"{",
"currlun",
"->",
"sense_data",
"=",
"SS_NO_SENSE",
";",
"currlun",
"->",
"sense_data_info",
"=",
"0",
";",
"currlun",
"->",
"info_valid",
"=",
"0",
";",
"}",
"if",
"(",
"(",
"currlun",
"->",
"unit_attention_data",
"!=",
"SS_NO_SENSE",
")",
"&&",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"0",
"]",
"!=",
"SC_INQUIRY",
")",
"&&",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"0",
"]",
"!=",
"SC_REQUEST_SENSE",
")",
")",
"{",
"currlun",
"->",
"sense_data",
"=",
"currlun",
"->",
"unit_attention_data",
";",
"currlun",
"->",
"unit_attention_data",
"=",
"SS_NO_SENSE",
";",
"return",
"(",
"1",
")",
";",
"}",
"}",
"else",
"{",
"sc",
"->",
"sc_transfer",
".",
"currlun",
"=",
"currlun",
"=",
"NULL",
";",
"if",
"(",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"0",
"]",
"!=",
"SC_INQUIRY",
")",
"&&",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"0",
"]",
"!=",
"SC_REQUEST_SENSE",
")",
")",
"{",
"return",
"(",
"1",
")",
";",
"}",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"!=",
"min_cmd_size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sc",
"->",
"sc_cbw",
"->",
"CBWCDB",
"[",
"i",
"]",
"&&",
"!",
"(",
"mask",
"&",
"(",
"1UL",
"<<",
"i",
")",
")",
")",
"{",
"if",
"(",
"currlun",
")",
"{",
"currlun",
"->",
"sense_data",
"=",
"SS_INVALID_FIELD_IN_CDB",
";",
"}",
"return",
"(",
"1",
")",
";",
"}",
"}",
"if",
"(",
"currlun",
"&&",
"(",
"!",
"currlun",
"->",
"memory_image",
")",
"&&",
"needs_medium",
")",
"{",
"currlun",
"->",
"sense_data",
"=",
"SS_MEDIUM_NOT_PRESENT",
";",
"return",
"(",
"1",
")",
";",
"}",
"return",
"(",
"0",
")",
";",
"}"
] | ustorage_fs_check_cmd - check command routine
Check whether the command is properly formed and whether its data
size and direction agree with the values we already have. | [
"ustorage_fs_check_cmd",
"-",
"check",
"command",
"routine",
"Check",
"whether",
"the",
"command",
"is",
"properly",
"formed",
"and",
"whether",
"its",
"data",
"size",
"and",
"direction",
"agree",
"with",
"the",
"values",
"we",
"already",
"have",
"."
] | [
"/* Verify the length of the command itself */",
"/* Mask away the LUN */",
"/* Check if LUN is correct */",
"/* Check the LUN */",
"/*\n\t\t * If a unit attention condition exists, only INQUIRY\n\t\t * and REQUEST SENSE commands are allowed. Anything\n\t\t * else must fail!\n\t\t */",
"/*\n\t\t * INQUIRY and REQUEST SENSE commands are explicitly allowed\n\t\t * to use unsupported LUNs; all others may not.\n\t\t */",
"/*\n\t * Check that only command bytes listed in the mask are\n\t * non-zero.\n\t */",
"/*\n\t * If the medium isn't mounted and the command needs to access\n\t * it, return an error.\n\t */"
] | [
{
"param": "sc",
"type": "struct ustorage_fs_softc"
},
{
"param": "min_cmd_size",
"type": "uint8_t"
},
{
"param": "mask",
"type": "uint16_t"
},
{
"param": "needs_medium",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sc",
"type": "struct ustorage_fs_softc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "min_cmd_size",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mask",
"type": "uint16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "needs_medium",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_init | int | static int
ext2_init(struct vfsconf *vfsp)
{
static int done;
if (done)
return (0);
done = 1;
ext2_ihashinit();
#ifdef QUOTA
ext2_dqinit();
#endif
return (0);
} | /*
* Initial UFS filesystems, done only once.
*/ | Initial UFS filesystems, done only once. | [
"Initial",
"UFS",
"filesystems",
"done",
"only",
"once",
"."
] | static int
ext2_init(struct vfsconf *vfsp)
{
static int done;
if (done)
return (0);
done = 1;
ext2_ihashinit();
#ifdef QUOTA
ext2_dqinit();
#endif
return (0);
} | [
"static",
"int",
"ext2_init",
"(",
"struct",
"vfsconf",
"*",
"vfsp",
")",
"{",
"static",
"int",
"done",
";",
"if",
"(",
"done",
")",
"return",
"(",
"0",
")",
";",
"done",
"=",
"1",
";",
"ext2_ihashinit",
"(",
")",
";",
"#ifdef",
"QUOTA",
"ext2_dqinit",
"(",
")",
";",
"#endif",
"return",
"(",
"0",
")",
";",
"}"
] | Initial UFS filesystems, done only once. | [
"Initial",
"UFS",
"filesystems",
"done",
"only",
"once",
"."
] | [] | [
{
"param": "vfsp",
"type": "struct vfsconf"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vfsp",
"type": "struct vfsconf",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_mountfs | int | static int
ext2_mountfs(struct vnode *devvp, struct mount *mp, struct ucred *cred)
{
struct ext2_mount *ump;
struct buf *bp;
struct ext2_sb_info *fs;
struct ext2_super_block *es;
cdev_t dev;
int error, i;
int ronly;
/*
* Disallow multiple mounts of the same device.
* Disallow mounting of a device that is currently in use
* (except for root, which might share swap device for miniroot).
* Flush out any old buffers remaining from a previous use.
*/
if ((error = vfs_mountedon(devvp)) != 0)
return (error);
if (vcount(devvp) > 0)
return (EBUSY);
if ((error = vinvalbuf(devvp, V_SAVE, 0, 0)) != 0)
return (error);
#ifdef READONLY
/* turn on this to force it to be read-only */
mp->mnt_flag |= MNT_RDONLY;
#endif
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, NULL);
vn_unlock(devvp);
if (error)
return (error);
dev = devvp->v_rdev;
if (dev->si_iosize_max != 0)
mp->mnt_iosize_max = dev->si_iosize_max;
if (mp->mnt_iosize_max > MAXPHYS)
mp->mnt_iosize_max = MAXPHYS;
bp = NULL;
ump = NULL;
if ((error = bread(devvp, SBOFF, SBSIZE, &bp)) != 0)
goto out;
es = (struct ext2_super_block *)bp->b_data;
if (ext2_check_sb_compat(es, dev, ronly) != 0) {
error = EINVAL; /* XXX needs translation */
goto out;
}
if ((es->s_state & EXT2_VALID_FS) == 0 ||
(es->s_state & EXT2_ERROR_FS)) {
if (ronly || (mp->mnt_flag & MNT_FORCE)) {
kprintf(
"WARNING: Filesystem was not properly dismounted\n");
} else {
kprintf(
"WARNING: R/W mount denied. Filesystem is not clean - run fsck\n");
error = EPERM;
goto out;
}
}
ump = kmalloc(sizeof *ump, M_EXT2MNT, M_WAITOK | M_ZERO);
ump->um_malloctype = M_EXT2NODE;
ump->um_blkatoff = ext2_blkatoff;
ump->um_truncate = ext2_truncate;
ump->um_update = ext2_update;
ump->um_valloc = ext2_valloc;
ump->um_vfree = ext2_vfree;
/* I don't know whether this is the right strategy. Note that
we dynamically allocate both a ext2_sb_info and a ext2_super_block
while Linux keeps the super block in a locked buffer
*/
ump->um_e2fs = kmalloc(sizeof(struct ext2_sb_info),
M_EXT2MNT, M_WAITOK);
ump->um_e2fs->s_es = kmalloc(sizeof(struct ext2_super_block),
M_EXT2MNT, M_WAITOK);
bcopy(es, ump->um_e2fs->s_es, (u_int)sizeof(struct ext2_super_block));
if ((error = compute_sb_data(devvp, ump->um_e2fs->s_es, ump->um_e2fs)))
goto out;
/*
* We don't free the group descriptors allocated by compute_sb_data()
* until ext2_unmount(). This is OK since the mount will succeed.
*/
brelse(bp);
bp = NULL;
fs = ump->um_e2fs;
fs->s_rd_only = ronly; /* ronly is set according to mnt_flags */
/* if the fs is not mounted read-only, make sure the super block is
always written back on a sync()
*/
fs->s_wasvalid = fs->s_es->s_state & EXT2_VALID_FS ? 1 : 0;
if (ronly == 0) {
fs->s_dirt = 1; /* mark it modified */
fs->s_es->s_state &= ~EXT2_VALID_FS; /* set fs invalid */
}
mp->mnt_data = (qaddr_t)ump;
mp->mnt_stat.f_fsid.val[0] = devid_from_dev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN;
mp->mnt_flag |= MNT_LOCAL;
ump->um_mountp = mp;
ump->um_dev = dev;
ump->um_devvp = devvp;
/* setting those two parameters allows us to use
ext2_bmap w/o changse !
*/
ump->um_nindir = EXT2_ADDR_PER_BLOCK(fs);
ump->um_bptrtodb = fs->s_es->s_log_block_size + 1;
ump->um_seqinc = EXT2_FRAGS_PER_BLOCK(fs);
for (i = 0; i < MAXQUOTAS; i++)
ump->um_quotas[i] = NULLVP;
dev->si_mountpoint = mp;
vfs_add_vnodeops(mp, &ext2_vnode_vops, &mp->mnt_vn_norm_ops);
vfs_add_vnodeops(mp, &ext2_spec_vops, &mp->mnt_vn_spec_ops);
vfs_add_vnodeops(mp, &ext2_fifo_vops, &mp->mnt_vn_fifo_ops);
if (ronly == 0)
ext2_sbupdate(ump, MNT_WAIT);
return (0);
out:
if (bp)
brelse(bp);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NULL);
vn_unlock(devvp);
if (ump) {
kfree(ump->um_e2fs->s_es, M_EXT2MNT);
kfree(ump->um_e2fs, M_EXT2MNT);
kfree(ump, M_EXT2MNT);
mp->mnt_data = (qaddr_t)0;
}
return (error);
} | /*
* Common code for mount and mountroot
*/ | Common code for mount and mountroot | [
"Common",
"code",
"for",
"mount",
"and",
"mountroot"
] | static int
ext2_mountfs(struct vnode *devvp, struct mount *mp, struct ucred *cred)
{
struct ext2_mount *ump;
struct buf *bp;
struct ext2_sb_info *fs;
struct ext2_super_block *es;
cdev_t dev;
int error, i;
int ronly;
if ((error = vfs_mountedon(devvp)) != 0)
return (error);
if (vcount(devvp) > 0)
return (EBUSY);
if ((error = vinvalbuf(devvp, V_SAVE, 0, 0)) != 0)
return (error);
#ifdef READONLY
mp->mnt_flag |= MNT_RDONLY;
#endif
ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, NULL);
vn_unlock(devvp);
if (error)
return (error);
dev = devvp->v_rdev;
if (dev->si_iosize_max != 0)
mp->mnt_iosize_max = dev->si_iosize_max;
if (mp->mnt_iosize_max > MAXPHYS)
mp->mnt_iosize_max = MAXPHYS;
bp = NULL;
ump = NULL;
if ((error = bread(devvp, SBOFF, SBSIZE, &bp)) != 0)
goto out;
es = (struct ext2_super_block *)bp->b_data;
if (ext2_check_sb_compat(es, dev, ronly) != 0) {
error = EINVAL;
goto out;
}
if ((es->s_state & EXT2_VALID_FS) == 0 ||
(es->s_state & EXT2_ERROR_FS)) {
if (ronly || (mp->mnt_flag & MNT_FORCE)) {
kprintf(
"WARNING: Filesystem was not properly dismounted\n");
} else {
kprintf(
"WARNING: R/W mount denied. Filesystem is not clean - run fsck\n");
error = EPERM;
goto out;
}
}
ump = kmalloc(sizeof *ump, M_EXT2MNT, M_WAITOK | M_ZERO);
ump->um_malloctype = M_EXT2NODE;
ump->um_blkatoff = ext2_blkatoff;
ump->um_truncate = ext2_truncate;
ump->um_update = ext2_update;
ump->um_valloc = ext2_valloc;
ump->um_vfree = ext2_vfree;
ump->um_e2fs = kmalloc(sizeof(struct ext2_sb_info),
M_EXT2MNT, M_WAITOK);
ump->um_e2fs->s_es = kmalloc(sizeof(struct ext2_super_block),
M_EXT2MNT, M_WAITOK);
bcopy(es, ump->um_e2fs->s_es, (u_int)sizeof(struct ext2_super_block));
if ((error = compute_sb_data(devvp, ump->um_e2fs->s_es, ump->um_e2fs)))
goto out;
brelse(bp);
bp = NULL;
fs = ump->um_e2fs;
fs->s_rd_only = ronly;
fs->s_wasvalid = fs->s_es->s_state & EXT2_VALID_FS ? 1 : 0;
if (ronly == 0) {
fs->s_dirt = 1;
fs->s_es->s_state &= ~EXT2_VALID_FS;
}
mp->mnt_data = (qaddr_t)ump;
mp->mnt_stat.f_fsid.val[0] = devid_from_dev(dev);
mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN;
mp->mnt_flag |= MNT_LOCAL;
ump->um_mountp = mp;
ump->um_dev = dev;
ump->um_devvp = devvp;
ump->um_nindir = EXT2_ADDR_PER_BLOCK(fs);
ump->um_bptrtodb = fs->s_es->s_log_block_size + 1;
ump->um_seqinc = EXT2_FRAGS_PER_BLOCK(fs);
for (i = 0; i < MAXQUOTAS; i++)
ump->um_quotas[i] = NULLVP;
dev->si_mountpoint = mp;
vfs_add_vnodeops(mp, &ext2_vnode_vops, &mp->mnt_vn_norm_ops);
vfs_add_vnodeops(mp, &ext2_spec_vops, &mp->mnt_vn_spec_ops);
vfs_add_vnodeops(mp, &ext2_fifo_vops, &mp->mnt_vn_fifo_ops);
if (ronly == 0)
ext2_sbupdate(ump, MNT_WAIT);
return (0);
out:
if (bp)
brelse(bp);
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NULL);
vn_unlock(devvp);
if (ump) {
kfree(ump->um_e2fs->s_es, M_EXT2MNT);
kfree(ump->um_e2fs, M_EXT2MNT);
kfree(ump, M_EXT2MNT);
mp->mnt_data = (qaddr_t)0;
}
return (error);
} | [
"static",
"int",
"ext2_mountfs",
"(",
"struct",
"vnode",
"*",
"devvp",
",",
"struct",
"mount",
"*",
"mp",
",",
"struct",
"ucred",
"*",
"cred",
")",
"{",
"struct",
"ext2_mount",
"*",
"ump",
";",
"struct",
"buf",
"*",
"bp",
";",
"struct",
"ext2_sb_info",
"*",
"fs",
";",
"struct",
"ext2_super_block",
"*",
"es",
";",
"cdev_t",
"dev",
";",
"int",
"error",
",",
"i",
";",
"int",
"ronly",
";",
"if",
"(",
"(",
"error",
"=",
"vfs_mountedon",
"(",
"devvp",
")",
")",
"!=",
"0",
")",
"return",
"(",
"error",
")",
";",
"if",
"(",
"vcount",
"(",
"devvp",
")",
">",
"0",
")",
"return",
"(",
"EBUSY",
")",
";",
"if",
"(",
"(",
"error",
"=",
"vinvalbuf",
"(",
"devvp",
",",
"V_SAVE",
",",
"0",
",",
"0",
")",
")",
"!=",
"0",
")",
"return",
"(",
"error",
")",
";",
"#ifdef",
"READONLY",
"mp",
"->",
"mnt_flag",
"|=",
"MNT_RDONLY",
";",
"#endif",
"ronly",
"=",
"(",
"mp",
"->",
"mnt_flag",
"&",
"MNT_RDONLY",
")",
"!=",
"0",
";",
"vn_lock",
"(",
"devvp",
",",
"LK_EXCLUSIVE",
"|",
"LK_RETRY",
")",
";",
"error",
"=",
"VOP_OPEN",
"(",
"devvp",
",",
"ronly",
"?",
"FREAD",
":",
"FREAD",
"|",
"FWRITE",
",",
"FSCRED",
",",
"NULL",
")",
";",
"vn_unlock",
"(",
"devvp",
")",
";",
"if",
"(",
"error",
")",
"return",
"(",
"error",
")",
";",
"dev",
"=",
"devvp",
"->",
"v_rdev",
";",
"if",
"(",
"dev",
"->",
"si_iosize_max",
"!=",
"0",
")",
"mp",
"->",
"mnt_iosize_max",
"=",
"dev",
"->",
"si_iosize_max",
";",
"if",
"(",
"mp",
"->",
"mnt_iosize_max",
">",
"MAXPHYS",
")",
"mp",
"->",
"mnt_iosize_max",
"=",
"MAXPHYS",
";",
"bp",
"=",
"NULL",
";",
"ump",
"=",
"NULL",
";",
"if",
"(",
"(",
"error",
"=",
"bread",
"(",
"devvp",
",",
"SBOFF",
",",
"SBSIZE",
",",
"&",
"bp",
")",
")",
"!=",
"0",
")",
"goto",
"out",
";",
"es",
"=",
"(",
"struct",
"ext2_super_block",
"*",
")",
"bp",
"->",
"b_data",
";",
"if",
"(",
"ext2_check_sb_compat",
"(",
"es",
",",
"dev",
",",
"ronly",
")",
"!=",
"0",
")",
"{",
"error",
"=",
"EINVAL",
";",
"goto",
"out",
";",
"}",
"if",
"(",
"(",
"es",
"->",
"s_state",
"&",
"EXT2_VALID_FS",
")",
"==",
"0",
"||",
"(",
"es",
"->",
"s_state",
"&",
"EXT2_ERROR_FS",
")",
")",
"{",
"if",
"(",
"ronly",
"||",
"(",
"mp",
"->",
"mnt_flag",
"&",
"MNT_FORCE",
")",
")",
"{",
"kprintf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"kprintf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"error",
"=",
"EPERM",
";",
"goto",
"out",
";",
"}",
"}",
"ump",
"=",
"kmalloc",
"(",
"sizeof",
"*",
"ump",
",",
"M_EXT2MNT",
",",
"M_WAITOK",
"|",
"M_ZERO",
")",
";",
"ump",
"->",
"um_malloctype",
"=",
"M_EXT2NODE",
";",
"ump",
"->",
"um_blkatoff",
"=",
"ext2_blkatoff",
";",
"ump",
"->",
"um_truncate",
"=",
"ext2_truncate",
";",
"ump",
"->",
"um_update",
"=",
"ext2_update",
";",
"ump",
"->",
"um_valloc",
"=",
"ext2_valloc",
";",
"ump",
"->",
"um_vfree",
"=",
"ext2_vfree",
";",
"ump",
"->",
"um_e2fs",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"ext2_sb_info",
")",
",",
"M_EXT2MNT",
",",
"M_WAITOK",
")",
";",
"ump",
"->",
"um_e2fs",
"->",
"s_es",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"ext2_super_block",
")",
",",
"M_EXT2MNT",
",",
"M_WAITOK",
")",
";",
"bcopy",
"(",
"es",
",",
"ump",
"->",
"um_e2fs",
"->",
"s_es",
",",
"(",
"u_int",
")",
"sizeof",
"(",
"struct",
"ext2_super_block",
")",
")",
";",
"if",
"(",
"(",
"error",
"=",
"compute_sb_data",
"(",
"devvp",
",",
"ump",
"->",
"um_e2fs",
"->",
"s_es",
",",
"ump",
"->",
"um_e2fs",
")",
")",
")",
"goto",
"out",
";",
"brelse",
"(",
"bp",
")",
";",
"bp",
"=",
"NULL",
";",
"fs",
"=",
"ump",
"->",
"um_e2fs",
";",
"fs",
"->",
"s_rd_only",
"=",
"ronly",
";",
"fs",
"->",
"s_wasvalid",
"=",
"fs",
"->",
"s_es",
"->",
"s_state",
"&",
"EXT2_VALID_FS",
"?",
"1",
":",
"0",
";",
"if",
"(",
"ronly",
"==",
"0",
")",
"{",
"fs",
"->",
"s_dirt",
"=",
"1",
";",
"fs",
"->",
"s_es",
"->",
"s_state",
"&=",
"~",
"EXT2_VALID_FS",
";",
"}",
"mp",
"->",
"mnt_data",
"=",
"(",
"qaddr_t",
")",
"ump",
";",
"mp",
"->",
"mnt_stat",
".",
"f_fsid",
".",
"val",
"[",
"0",
"]",
"=",
"devid_from_dev",
"(",
"dev",
")",
";",
"mp",
"->",
"mnt_stat",
".",
"f_fsid",
".",
"val",
"[",
"1",
"]",
"=",
"mp",
"->",
"mnt_vfc",
"->",
"vfc_typenum",
";",
"mp",
"->",
"mnt_maxsymlinklen",
"=",
"EXT2_MAXSYMLINKLEN",
";",
"mp",
"->",
"mnt_flag",
"|=",
"MNT_LOCAL",
";",
"ump",
"->",
"um_mountp",
"=",
"mp",
";",
"ump",
"->",
"um_dev",
"=",
"dev",
";",
"ump",
"->",
"um_devvp",
"=",
"devvp",
";",
"ump",
"->",
"um_nindir",
"=",
"EXT2_ADDR_PER_BLOCK",
"(",
"fs",
")",
";",
"ump",
"->",
"um_bptrtodb",
"=",
"fs",
"->",
"s_es",
"->",
"s_log_block_size",
"+",
"1",
";",
"ump",
"->",
"um_seqinc",
"=",
"EXT2_FRAGS_PER_BLOCK",
"(",
"fs",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAXQUOTAS",
";",
"i",
"++",
")",
"ump",
"->",
"um_quotas",
"[",
"i",
"]",
"=",
"NULLVP",
";",
"dev",
"->",
"si_mountpoint",
"=",
"mp",
";",
"vfs_add_vnodeops",
"(",
"mp",
",",
"&",
"ext2_vnode_vops",
",",
"&",
"mp",
"->",
"mnt_vn_norm_ops",
")",
";",
"vfs_add_vnodeops",
"(",
"mp",
",",
"&",
"ext2_spec_vops",
",",
"&",
"mp",
"->",
"mnt_vn_spec_ops",
")",
";",
"vfs_add_vnodeops",
"(",
"mp",
",",
"&",
"ext2_fifo_vops",
",",
"&",
"mp",
"->",
"mnt_vn_fifo_ops",
")",
";",
"if",
"(",
"ronly",
"==",
"0",
")",
"ext2_sbupdate",
"(",
"ump",
",",
"MNT_WAIT",
")",
";",
"return",
"(",
"0",
")",
";",
"out",
":",
"if",
"(",
"bp",
")",
"brelse",
"(",
"bp",
")",
";",
"vn_lock",
"(",
"devvp",
",",
"LK_EXCLUSIVE",
"|",
"LK_RETRY",
")",
";",
"VOP_CLOSE",
"(",
"devvp",
",",
"ronly",
"?",
"FREAD",
":",
"FREAD",
"|",
"FWRITE",
",",
"NULL",
")",
";",
"vn_unlock",
"(",
"devvp",
")",
";",
"if",
"(",
"ump",
")",
"{",
"kfree",
"(",
"ump",
"->",
"um_e2fs",
"->",
"s_es",
",",
"M_EXT2MNT",
")",
";",
"kfree",
"(",
"ump",
"->",
"um_e2fs",
",",
"M_EXT2MNT",
")",
";",
"kfree",
"(",
"ump",
",",
"M_EXT2MNT",
")",
";",
"mp",
"->",
"mnt_data",
"=",
"(",
"qaddr_t",
")",
"0",
";",
"}",
"return",
"(",
"error",
")",
";",
"}"
] | Common code for mount and mountroot | [
"Common",
"code",
"for",
"mount",
"and",
"mountroot"
] | [
"/*\n\t * Disallow multiple mounts of the same device.\n\t * Disallow mounting of a device that is currently in use\n\t * (except for root, which might share swap device for miniroot).\n\t * Flush out any old buffers remaining from a previous use.\n\t */",
"/* turn on this to force it to be read-only */",
"/* XXX needs translation */",
"/* I don't know whether this is the right strategy. Note that\n\t we dynamically allocate both a ext2_sb_info and a ext2_super_block\n\t while Linux keeps the super block in a locked buffer\n\t */",
"/*\n\t * We don't free the group descriptors allocated by compute_sb_data()\n\t * until ext2_unmount(). This is OK since the mount will succeed.\n\t */",
"/* ronly is set according to mnt_flags */",
"/* if the fs is not mounted read-only, make sure the super block is\n\t always written back on a sync()\n\t */",
"/* mark it modified */",
"/* set fs invalid */",
"/* setting those two parameters allows us to use\n\t ext2_bmap w/o changse !\n\t*/"
] | [
{
"param": "devvp",
"type": "struct vnode"
},
{
"param": "mp",
"type": "struct mount"
},
{
"param": "cred",
"type": "struct ucred"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "devvp",
"type": "struct vnode",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mp",
"type": "struct mount",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cred",
"type": "struct ucred",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_flushfiles | int | static int
ext2_flushfiles(struct mount *mp, int flags)
{
struct ext2_mount *ump;
int error;
#ifdef QUOTA
int i;
#endif
ump = VFSTOEXT2(mp);
#ifdef QUOTA
if (mp->mnt_flag & MNT_QUOTA) {
if ((error = vflush(mp, 0, SKIPSYSTEM|flags)) != 0)
return (error);
for (i = 0; i < MAXQUOTAS; i++) {
if (ump->um_quotas[i] == NULLVP)
continue;
ext2_quotaoff(mp, i);
}
/*
* Here we fall through to vflush again to ensure
* that we have gotten rid of all the system vnodes.
*/
}
#endif
error = vflush(mp, 0, flags);
return (error);
} | /*
* Flush out all the files in a filesystem.
*/ | Flush out all the files in a filesystem. | [
"Flush",
"out",
"all",
"the",
"files",
"in",
"a",
"filesystem",
"."
] | static int
ext2_flushfiles(struct mount *mp, int flags)
{
struct ext2_mount *ump;
int error;
#ifdef QUOTA
int i;
#endif
ump = VFSTOEXT2(mp);
#ifdef QUOTA
if (mp->mnt_flag & MNT_QUOTA) {
if ((error = vflush(mp, 0, SKIPSYSTEM|flags)) != 0)
return (error);
for (i = 0; i < MAXQUOTAS; i++) {
if (ump->um_quotas[i] == NULLVP)
continue;
ext2_quotaoff(mp, i);
}
}
#endif
error = vflush(mp, 0, flags);
return (error);
} | [
"static",
"int",
"ext2_flushfiles",
"(",
"struct",
"mount",
"*",
"mp",
",",
"int",
"flags",
")",
"{",
"struct",
"ext2_mount",
"*",
"ump",
";",
"int",
"error",
";",
"#ifdef",
"QUOTA",
"int",
"i",
";",
"#endif",
"ump",
"=",
"VFSTOEXT2",
"(",
"mp",
")",
";",
"#ifdef",
"QUOTA",
"if",
"(",
"mp",
"->",
"mnt_flag",
"&",
"MNT_QUOTA",
")",
"{",
"if",
"(",
"(",
"error",
"=",
"vflush",
"(",
"mp",
",",
"0",
",",
"SKIPSYSTEM",
"|",
"flags",
")",
")",
"!=",
"0",
")",
"return",
"(",
"error",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAXQUOTAS",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ump",
"->",
"um_quotas",
"[",
"i",
"]",
"==",
"NULLVP",
")",
"continue",
";",
"ext2_quotaoff",
"(",
"mp",
",",
"i",
")",
";",
"}",
"}",
"#endif",
"error",
"=",
"vflush",
"(",
"mp",
",",
"0",
",",
"flags",
")",
";",
"return",
"(",
"error",
")",
";",
"}"
] | Flush out all the files in a filesystem. | [
"Flush",
"out",
"all",
"the",
"files",
"in",
"a",
"filesystem",
"."
] | [
"/*\n\t\t * Here we fall through to vflush again to ensure\n\t\t * that we have gotten rid of all the system vnodes.\n\t\t */"
] | [
{
"param": "mp",
"type": "struct mount"
},
{
"param": "flags",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mp",
"type": "struct mount",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_vget | int | static int
ext2_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp)
{
struct ext2_sb_info *fs;
struct inode *ip;
struct ext2_mount *ump;
struct buf *bp;
struct vnode *vp;
cdev_t dev;
int i, error;
int used_blocks;
ump = VFSTOEXT2(mp);
dev = ump->um_dev;
restart:
if ((*vpp = ext2_ihashget(dev, ino)) != NULL)
return (0);
/*
* Lock out the creation of new entries in the FFS hash table in
* case getnewvnode() or MALLOC() blocks, otherwise a duplicate
* may occur!
*/
if (ext2fs_inode_hash_lock) {
while (ext2fs_inode_hash_lock) {
ext2fs_inode_hash_lock = -1;
tsleep(&ext2fs_inode_hash_lock, 0, "e2vget", 0);
}
goto restart;
}
ext2fs_inode_hash_lock = 1;
/*
* If this MALLOC() is performed after the getnewvnode()
* it might block, leaving a vnode with a NULL v_data to be
* found by ext2_sync() if a sync happens to fire right then,
* which will cause a panic because ext2_sync() blindly
* dereferences vp->v_data (as well it should).
*/
ip = kmalloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK);
/* Allocate a new vnode/inode. */
if ((error = getnewvnode(VT_EXT2FS, mp, &vp, 0, LK_CANRECURSE)) != 0) {
if (ext2fs_inode_hash_lock < 0)
wakeup(&ext2fs_inode_hash_lock);
ext2fs_inode_hash_lock = 0;
*vpp = NULL;
kfree(ip, M_EXT2NODE);
return (error);
}
bzero((caddr_t)ip, sizeof(struct inode));
vp->v_data = ip;
ip->i_vnode = vp;
ip->i_e2fs = fs = ump->um_e2fs;
ip->i_dev = dev;
ip->i_number = ino;
#ifdef QUOTA
for (i = 0; i < MAXQUOTAS; i++)
ip->i_dquot[i] = NODQUOT;
#endif
/*
* Put it onto its hash chain. Since our vnode is locked, other
* requests for this inode will block if they arrive while we are
* sleeping waiting for old data structures to be purged or for the
* contents of the disk portion of this inode to be read.
*/
ext2_ihashins(ip);
if (ext2fs_inode_hash_lock < 0)
wakeup(&ext2fs_inode_hash_lock);
ext2fs_inode_hash_lock = 0;
/* Read in the disk contents for the inode, copy into the inode. */
#if 0
kprintf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
#endif
error = bread(ump->um_devvp, fsbtodoff(fs, ino_to_fsba(fs, ino)),
(int)fs->s_blocksize, &bp);
if (error) {
/*
* The inode does not contain anything useful, so it would
* be misleading to leave it on its hash chain. With mode
* still zero, it will be unlinked and returned to the free
* list by vput().
*/
brelse(bp);
vx_put(vp);
*vpp = NULL;
return (error);
}
/* convert ext2 inode to dinode */
ext2_ei2di((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE(fs) *
ino_to_fsbo(fs, ino)), &ip->i_din);
ip->i_block_group = ino_to_cg(fs, ino);
ip->i_next_alloc_block = 0;
ip->i_next_alloc_goal = 0;
ip->i_prealloc_count = 0;
ip->i_prealloc_block = 0;
/* now we want to make sure that block pointers for unused
blocks are zeroed out - ext2_balloc depends on this
although for regular files and directories only
*/
if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) {
used_blocks = (ip->i_size+fs->s_blocksize-1) / fs->s_blocksize;
for(i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
ip->i_db[i] = 0;
}
#if 0
ext2_print_inode(ip);
#endif
bqrelse(bp);
/*
* Initialize the vnode from the inode, check for aliases.
* Note that the underlying vnode may have changed.
*/
if ((error = ext2_vinit(mp, &vp)) != 0) {
vx_put(vp);
*vpp = NULL;
return (error);
}
/*
* Finish inode initialization now that aliasing has been resolved.
*/
ip->i_devvp = ump->um_devvp;
vref(ip->i_devvp);
/*
* Set up a generation number for this inode if it does not
* already have one. This should only happen on old filesystems.
*/
if (ip->i_gen == 0) {
ip->i_gen = krandom() / 2 + 1;
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IN_MODIFIED;
}
/*
* Return the locked and refd vnode.
*/
vx_downgrade(vp); /* downgrade VX lock to VN lock */
*vpp = vp;
return (0);
} | /*
* Look up a EXT2FS dinode number to find its incore vnode, otherwise read it
* in from disk. If it is in core, wait for the lock bit to clear, then
* return the inode locked. Detection and handling of mount points must be
* done by the calling routine.
*/ | Look up a EXT2FS dinode number to find its incore vnode, otherwise read it
in from disk. If it is in core, wait for the lock bit to clear, then
return the inode locked. Detection and handling of mount points must be
done by the calling routine. | [
"Look",
"up",
"a",
"EXT2FS",
"dinode",
"number",
"to",
"find",
"its",
"incore",
"vnode",
"otherwise",
"read",
"it",
"in",
"from",
"disk",
".",
"If",
"it",
"is",
"in",
"core",
"wait",
"for",
"the",
"lock",
"bit",
"to",
"clear",
"then",
"return",
"the",
"inode",
"locked",
".",
"Detection",
"and",
"handling",
"of",
"mount",
"points",
"must",
"be",
"done",
"by",
"the",
"calling",
"routine",
"."
] | static int
ext2_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp)
{
struct ext2_sb_info *fs;
struct inode *ip;
struct ext2_mount *ump;
struct buf *bp;
struct vnode *vp;
cdev_t dev;
int i, error;
int used_blocks;
ump = VFSTOEXT2(mp);
dev = ump->um_dev;
restart:
if ((*vpp = ext2_ihashget(dev, ino)) != NULL)
return (0);
if (ext2fs_inode_hash_lock) {
while (ext2fs_inode_hash_lock) {
ext2fs_inode_hash_lock = -1;
tsleep(&ext2fs_inode_hash_lock, 0, "e2vget", 0);
}
goto restart;
}
ext2fs_inode_hash_lock = 1;
ip = kmalloc(sizeof(struct inode), M_EXT2NODE, M_WAITOK);
if ((error = getnewvnode(VT_EXT2FS, mp, &vp, 0, LK_CANRECURSE)) != 0) {
if (ext2fs_inode_hash_lock < 0)
wakeup(&ext2fs_inode_hash_lock);
ext2fs_inode_hash_lock = 0;
*vpp = NULL;
kfree(ip, M_EXT2NODE);
return (error);
}
bzero((caddr_t)ip, sizeof(struct inode));
vp->v_data = ip;
ip->i_vnode = vp;
ip->i_e2fs = fs = ump->um_e2fs;
ip->i_dev = dev;
ip->i_number = ino;
#ifdef QUOTA
for (i = 0; i < MAXQUOTAS; i++)
ip->i_dquot[i] = NODQUOT;
#endif
ext2_ihashins(ip);
if (ext2fs_inode_hash_lock < 0)
wakeup(&ext2fs_inode_hash_lock);
ext2fs_inode_hash_lock = 0;
#if 0
kprintf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
#endif
error = bread(ump->um_devvp, fsbtodoff(fs, ino_to_fsba(fs, ino)),
(int)fs->s_blocksize, &bp);
if (error) {
brelse(bp);
vx_put(vp);
*vpp = NULL;
return (error);
}
ext2_ei2di((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE(fs) *
ino_to_fsbo(fs, ino)), &ip->i_din);
ip->i_block_group = ino_to_cg(fs, ino);
ip->i_next_alloc_block = 0;
ip->i_next_alloc_goal = 0;
ip->i_prealloc_count = 0;
ip->i_prealloc_block = 0;
if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) {
used_blocks = (ip->i_size+fs->s_blocksize-1) / fs->s_blocksize;
for(i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
ip->i_db[i] = 0;
}
#if 0
ext2_print_inode(ip);
#endif
bqrelse(bp);
if ((error = ext2_vinit(mp, &vp)) != 0) {
vx_put(vp);
*vpp = NULL;
return (error);
}
ip->i_devvp = ump->um_devvp;
vref(ip->i_devvp);
if (ip->i_gen == 0) {
ip->i_gen = krandom() / 2 + 1;
if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
ip->i_flag |= IN_MODIFIED;
}
vx_downgrade(vp);
*vpp = vp;
return (0);
} | [
"static",
"int",
"ext2_vget",
"(",
"struct",
"mount",
"*",
"mp",
",",
"struct",
"vnode",
"*",
"dvp",
",",
"ino_t",
"ino",
",",
"struct",
"vnode",
"*",
"*",
"vpp",
")",
"{",
"struct",
"ext2_sb_info",
"*",
"fs",
";",
"struct",
"inode",
"*",
"ip",
";",
"struct",
"ext2_mount",
"*",
"ump",
";",
"struct",
"buf",
"*",
"bp",
";",
"struct",
"vnode",
"*",
"vp",
";",
"cdev_t",
"dev",
";",
"int",
"i",
",",
"error",
";",
"int",
"used_blocks",
";",
"ump",
"=",
"VFSTOEXT2",
"(",
"mp",
")",
";",
"dev",
"=",
"ump",
"->",
"um_dev",
";",
"restart",
":",
"if",
"(",
"(",
"*",
"vpp",
"=",
"ext2_ihashget",
"(",
"dev",
",",
"ino",
")",
")",
"!=",
"NULL",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"ext2fs_inode_hash_lock",
")",
"{",
"while",
"(",
"ext2fs_inode_hash_lock",
")",
"{",
"ext2fs_inode_hash_lock",
"=",
"-1",
";",
"tsleep",
"(",
"&",
"ext2fs_inode_hash_lock",
",",
"0",
",",
"\"",
"\"",
",",
"0",
")",
";",
"}",
"goto",
"restart",
";",
"}",
"ext2fs_inode_hash_lock",
"=",
"1",
";",
"ip",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"inode",
")",
",",
"M_EXT2NODE",
",",
"M_WAITOK",
")",
";",
"if",
"(",
"(",
"error",
"=",
"getnewvnode",
"(",
"VT_EXT2FS",
",",
"mp",
",",
"&",
"vp",
",",
"0",
",",
"LK_CANRECURSE",
")",
")",
"!=",
"0",
")",
"{",
"if",
"(",
"ext2fs_inode_hash_lock",
"<",
"0",
")",
"wakeup",
"(",
"&",
"ext2fs_inode_hash_lock",
")",
";",
"ext2fs_inode_hash_lock",
"=",
"0",
";",
"*",
"vpp",
"=",
"NULL",
";",
"kfree",
"(",
"ip",
",",
"M_EXT2NODE",
")",
";",
"return",
"(",
"error",
")",
";",
"}",
"bzero",
"(",
"(",
"caddr_t",
")",
"ip",
",",
"sizeof",
"(",
"struct",
"inode",
")",
")",
";",
"vp",
"->",
"v_data",
"=",
"ip",
";",
"ip",
"->",
"i_vnode",
"=",
"vp",
";",
"ip",
"->",
"i_e2fs",
"=",
"fs",
"=",
"ump",
"->",
"um_e2fs",
";",
"ip",
"->",
"i_dev",
"=",
"dev",
";",
"ip",
"->",
"i_number",
"=",
"ino",
";",
"#ifdef",
"QUOTA",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"MAXQUOTAS",
";",
"i",
"++",
")",
"ip",
"->",
"i_dquot",
"[",
"i",
"]",
"=",
"NODQUOT",
";",
"#endif",
"ext2_ihashins",
"(",
"ip",
")",
";",
"if",
"(",
"ext2fs_inode_hash_lock",
"<",
"0",
")",
"wakeup",
"(",
"&",
"ext2fs_inode_hash_lock",
")",
";",
"ext2fs_inode_hash_lock",
"=",
"0",
";",
"#if",
"0",
"\n",
"kprintf",
"(",
"\"",
"\"",
",",
"ino",
",",
"fsbtodb",
"(",
"fs",
",",
"ino_to_fsba",
"(",
"fs",
",",
"ino",
")",
")",
")",
";",
"#endif",
"error",
"=",
"bread",
"(",
"ump",
"->",
"um_devvp",
",",
"fsbtodoff",
"(",
"fs",
",",
"ino_to_fsba",
"(",
"fs",
",",
"ino",
")",
")",
",",
"(",
"int",
")",
"fs",
"->",
"s_blocksize",
",",
"&",
"bp",
")",
";",
"if",
"(",
"error",
")",
"{",
"brelse",
"(",
"bp",
")",
";",
"vx_put",
"(",
"vp",
")",
";",
"*",
"vpp",
"=",
"NULL",
";",
"return",
"(",
"error",
")",
";",
"}",
"ext2_ei2di",
"(",
"(",
"struct",
"ext2_inode",
"*",
")",
"(",
"(",
"char",
"*",
")",
"bp",
"->",
"b_data",
"+",
"EXT2_INODE_SIZE",
"(",
"fs",
")",
"*",
"ino_to_fsbo",
"(",
"fs",
",",
"ino",
")",
")",
",",
"&",
"ip",
"->",
"i_din",
")",
";",
"ip",
"->",
"i_block_group",
"=",
"ino_to_cg",
"(",
"fs",
",",
"ino",
")",
";",
"ip",
"->",
"i_next_alloc_block",
"=",
"0",
";",
"ip",
"->",
"i_next_alloc_goal",
"=",
"0",
";",
"ip",
"->",
"i_prealloc_count",
"=",
"0",
";",
"ip",
"->",
"i_prealloc_block",
"=",
"0",
";",
"if",
"(",
"S_ISDIR",
"(",
"ip",
"->",
"i_mode",
")",
"||",
"S_ISREG",
"(",
"ip",
"->",
"i_mode",
")",
")",
"{",
"used_blocks",
"=",
"(",
"ip",
"->",
"i_size",
"+",
"fs",
"->",
"s_blocksize",
"-",
"1",
")",
"/",
"fs",
"->",
"s_blocksize",
";",
"for",
"(",
"i",
"=",
"used_blocks",
";",
"i",
"<",
"EXT2_NDIR_BLOCKS",
";",
"i",
"++",
")",
"ip",
"->",
"i_db",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"#if",
"0",
"\n",
"ext2_print_inode",
"(",
"ip",
")",
";",
"#endif",
"bqrelse",
"(",
"bp",
")",
";",
"if",
"(",
"(",
"error",
"=",
"ext2_vinit",
"(",
"mp",
",",
"&",
"vp",
")",
")",
"!=",
"0",
")",
"{",
"vx_put",
"(",
"vp",
")",
";",
"*",
"vpp",
"=",
"NULL",
";",
"return",
"(",
"error",
")",
";",
"}",
"ip",
"->",
"i_devvp",
"=",
"ump",
"->",
"um_devvp",
";",
"vref",
"(",
"ip",
"->",
"i_devvp",
")",
";",
"if",
"(",
"ip",
"->",
"i_gen",
"==",
"0",
")",
"{",
"ip",
"->",
"i_gen",
"=",
"krandom",
"(",
")",
"/",
"2",
"+",
"1",
";",
"if",
"(",
"(",
"vp",
"->",
"v_mount",
"->",
"mnt_flag",
"&",
"MNT_RDONLY",
")",
"==",
"0",
")",
"ip",
"->",
"i_flag",
"|=",
"IN_MODIFIED",
";",
"}",
"vx_downgrade",
"(",
"vp",
")",
";",
"*",
"vpp",
"=",
"vp",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Look up a EXT2FS dinode number to find its incore vnode, otherwise read it
in from disk. | [
"Look",
"up",
"a",
"EXT2FS",
"dinode",
"number",
"to",
"find",
"its",
"incore",
"vnode",
"otherwise",
"read",
"it",
"in",
"from",
"disk",
"."
] | [
"/*\n\t * Lock out the creation of new entries in the FFS hash table in\n\t * case getnewvnode() or MALLOC() blocks, otherwise a duplicate\n\t * may occur!\n\t */",
"/*\n\t * If this MALLOC() is performed after the getnewvnode()\n\t * it might block, leaving a vnode with a NULL v_data to be\n\t * found by ext2_sync() if a sync happens to fire right then,\n\t * which will cause a panic because ext2_sync() blindly\n\t * dereferences vp->v_data (as well it should).\n\t */",
"/* Allocate a new vnode/inode. */",
"/*\n\t * Put it onto its hash chain. Since our vnode is locked, other\n\t * requests for this inode will block if they arrive while we are\n\t * sleeping waiting for old data structures to be purged or for the\n\t * contents of the disk portion of this inode to be read.\n\t */",
"/* Read in the disk contents for the inode, copy into the inode. */",
"/*\n\t\t * The inode does not contain anything useful, so it would\n\t\t * be misleading to leave it on its hash chain. With mode\n\t\t * still zero, it will be unlinked and returned to the free\n\t\t * list by vput().\n\t\t */",
"/* convert ext2 inode to dinode */",
"/* now we want to make sure that block pointers for unused\n blocks are zeroed out - ext2_balloc depends on this\n\t although for regular files and directories only\n\t*/",
"/*\n\t * Initialize the vnode from the inode, check for aliases.\n\t * Note that the underlying vnode may have changed.\n\t */",
"/*\n\t * Finish inode initialization now that aliasing has been resolved.\n\t */",
"/*\n\t * Set up a generation number for this inode if it does not\n\t * already have one. This should only happen on old filesystems.\n\t */",
"/*\n\t * Return the locked and refd vnode.\n\t */",
"/* downgrade VX lock to VN lock */"
] | [
{
"param": "mp",
"type": "struct mount"
},
{
"param": "dvp",
"type": "struct vnode"
},
{
"param": "ino",
"type": "ino_t"
},
{
"param": "vpp",
"type": "struct vnode"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mp",
"type": "struct mount",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dvp",
"type": "struct vnode",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ino",
"type": "ino_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vpp",
"type": "struct vnode",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_fhtovp | int | static int
ext2_fhtovp(struct mount *mp, struct vnode *rootvp,
struct fid *fhp, struct vnode **vpp)
{
struct ufid *ufhp;
struct ext2_sb_info *fs;
struct inode *ip;
struct vnode *nvp;
int error;
ufhp = (struct ufid *)fhp;
fs = VFSTOEXT2(mp)->um_e2fs;
if (ufhp->ufid_ino < EXT2_ROOTINO ||
ufhp->ufid_ino > fs->s_groups_count * fs->s_es->s_inodes_per_group)
return (ESTALE);
error = VFS_VGET(mp, rootvp, ufhp->ufid_ino, &nvp);
if (error) {
*vpp = NULLVP;
return (error);
}
ip = VTOI(nvp);
if (ip->i_mode == 0 ||
ip->i_gen != ufhp->ufid_gen ||
(VFSTOEXT2(mp)->um_i_effnlink_valid ? ip->i_effnlink :
ip->i_nlink) <= 0) {
vput(nvp);
*vpp = NULLVP;
return (ESTALE);
}
*vpp = nvp;
return (0);
} | /*
* File handle to vnode
*
* Have to be really careful about stale file handles:
* - check that the inode number is valid
* - call ext2_vget() to get the locked inode
* - check for an unallocated inode (i_mode == 0)
* - check that the given client host has export rights and return
* those rights via. exflagsp and credanonp
*/ | File handle to vnode
Have to be really careful about stale file handles:
- check that the inode number is valid
- call ext2_vget() to get the locked inode
- check for an unallocated inode (i_mode == 0)
- check that the given client host has export rights and return
those rights via. exflagsp and credanonp | [
"File",
"handle",
"to",
"vnode",
"Have",
"to",
"be",
"really",
"careful",
"about",
"stale",
"file",
"handles",
":",
"-",
"check",
"that",
"the",
"inode",
"number",
"is",
"valid",
"-",
"call",
"ext2_vget",
"()",
"to",
"get",
"the",
"locked",
"inode",
"-",
"check",
"for",
"an",
"unallocated",
"inode",
"(",
"i_mode",
"==",
"0",
")",
"-",
"check",
"that",
"the",
"given",
"client",
"host",
"has",
"export",
"rights",
"and",
"return",
"those",
"rights",
"via",
".",
"exflagsp",
"and",
"credanonp"
] | static int
ext2_fhtovp(struct mount *mp, struct vnode *rootvp,
struct fid *fhp, struct vnode **vpp)
{
struct ufid *ufhp;
struct ext2_sb_info *fs;
struct inode *ip;
struct vnode *nvp;
int error;
ufhp = (struct ufid *)fhp;
fs = VFSTOEXT2(mp)->um_e2fs;
if (ufhp->ufid_ino < EXT2_ROOTINO ||
ufhp->ufid_ino > fs->s_groups_count * fs->s_es->s_inodes_per_group)
return (ESTALE);
error = VFS_VGET(mp, rootvp, ufhp->ufid_ino, &nvp);
if (error) {
*vpp = NULLVP;
return (error);
}
ip = VTOI(nvp);
if (ip->i_mode == 0 ||
ip->i_gen != ufhp->ufid_gen ||
(VFSTOEXT2(mp)->um_i_effnlink_valid ? ip->i_effnlink :
ip->i_nlink) <= 0) {
vput(nvp);
*vpp = NULLVP;
return (ESTALE);
}
*vpp = nvp;
return (0);
} | [
"static",
"int",
"ext2_fhtovp",
"(",
"struct",
"mount",
"*",
"mp",
",",
"struct",
"vnode",
"*",
"rootvp",
",",
"struct",
"fid",
"*",
"fhp",
",",
"struct",
"vnode",
"*",
"*",
"vpp",
")",
"{",
"struct",
"ufid",
"*",
"ufhp",
";",
"struct",
"ext2_sb_info",
"*",
"fs",
";",
"struct",
"inode",
"*",
"ip",
";",
"struct",
"vnode",
"*",
"nvp",
";",
"int",
"error",
";",
"ufhp",
"=",
"(",
"struct",
"ufid",
"*",
")",
"fhp",
";",
"fs",
"=",
"VFSTOEXT2",
"(",
"mp",
")",
"->",
"um_e2fs",
";",
"if",
"(",
"ufhp",
"->",
"ufid_ino",
"<",
"EXT2_ROOTINO",
"||",
"ufhp",
"->",
"ufid_ino",
">",
"fs",
"->",
"s_groups_count",
"*",
"fs",
"->",
"s_es",
"->",
"s_inodes_per_group",
")",
"return",
"(",
"ESTALE",
")",
";",
"error",
"=",
"VFS_VGET",
"(",
"mp",
",",
"rootvp",
",",
"ufhp",
"->",
"ufid_ino",
",",
"&",
"nvp",
")",
";",
"if",
"(",
"error",
")",
"{",
"*",
"vpp",
"=",
"NULLVP",
";",
"return",
"(",
"error",
")",
";",
"}",
"ip",
"=",
"VTOI",
"(",
"nvp",
")",
";",
"if",
"(",
"ip",
"->",
"i_mode",
"==",
"0",
"||",
"ip",
"->",
"i_gen",
"!=",
"ufhp",
"->",
"ufid_gen",
"||",
"(",
"VFSTOEXT2",
"(",
"mp",
")",
"->",
"um_i_effnlink_valid",
"?",
"ip",
"->",
"i_effnlink",
":",
"ip",
"->",
"i_nlink",
")",
"<=",
"0",
")",
"{",
"vput",
"(",
"nvp",
")",
";",
"*",
"vpp",
"=",
"NULLVP",
";",
"return",
"(",
"ESTALE",
")",
";",
"}",
"*",
"vpp",
"=",
"nvp",
";",
"return",
"(",
"0",
")",
";",
"}"
] | File handle to vnode
Have to be really careful about stale file handles:
- check that the inode number is valid
- call ext2_vget() to get the locked inode
- check for an unallocated inode (i_mode == 0)
- check that the given client host has export rights and return
those rights via. | [
"File",
"handle",
"to",
"vnode",
"Have",
"to",
"be",
"really",
"careful",
"about",
"stale",
"file",
"handles",
":",
"-",
"check",
"that",
"the",
"inode",
"number",
"is",
"valid",
"-",
"call",
"ext2_vget",
"()",
"to",
"get",
"the",
"locked",
"inode",
"-",
"check",
"for",
"an",
"unallocated",
"inode",
"(",
"i_mode",
"==",
"0",
")",
"-",
"check",
"that",
"the",
"given",
"client",
"host",
"has",
"export",
"rights",
"and",
"return",
"those",
"rights",
"via",
"."
] | [] | [
{
"param": "mp",
"type": "struct mount"
},
{
"param": "rootvp",
"type": "struct vnode"
},
{
"param": "fhp",
"type": "struct fid"
},
{
"param": "vpp",
"type": "struct vnode"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mp",
"type": "struct mount",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rootvp",
"type": "struct vnode",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fhp",
"type": "struct fid",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "vpp",
"type": "struct vnode",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb1efcc6e56bae9bcbf185ef6e5bacd33948d18a | atrens/DragonFlyBSD-src | sys/gnu/vfs/ext2fs/ext2_vfsops.c | [
"BSD-3-Clause"
] | C | ext2_sbupdate | int | static int
ext2_sbupdate(struct ext2_mount *mp, int waitfor)
{
struct ext2_sb_info *fs = mp->um_e2fs;
struct ext2_super_block *es = fs->s_es;
struct buf *bp;
int error = 0;
/*
kprintf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no");
*/
bp = getblk(mp->um_devvp, SBOFF, SBSIZE, 0, 0);
bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block));
if (waitfor == MNT_WAIT)
error = bwrite(bp);
else
bawrite(bp);
/*
* The buffers for group descriptors, inode bitmaps and block bitmaps
* are not busy at this point and are (hopefully) written by the
* usual sync mechanism. No need to write them here
*/
return (error);
} | /*
* Write a superblock and associated information back to disk.
*/ | Write a superblock and associated information back to disk. | [
"Write",
"a",
"superblock",
"and",
"associated",
"information",
"back",
"to",
"disk",
"."
] | static int
ext2_sbupdate(struct ext2_mount *mp, int waitfor)
{
struct ext2_sb_info *fs = mp->um_e2fs;
struct ext2_super_block *es = fs->s_es;
struct buf *bp;
int error = 0;
bp = getblk(mp->um_devvp, SBOFF, SBSIZE, 0, 0);
bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block));
if (waitfor == MNT_WAIT)
error = bwrite(bp);
else
bawrite(bp);
return (error);
} | [
"static",
"int",
"ext2_sbupdate",
"(",
"struct",
"ext2_mount",
"*",
"mp",
",",
"int",
"waitfor",
")",
"{",
"struct",
"ext2_sb_info",
"*",
"fs",
"=",
"mp",
"->",
"um_e2fs",
";",
"struct",
"ext2_super_block",
"*",
"es",
"=",
"fs",
"->",
"s_es",
";",
"struct",
"buf",
"*",
"bp",
";",
"int",
"error",
"=",
"0",
";",
"bp",
"=",
"getblk",
"(",
"mp",
"->",
"um_devvp",
",",
"SBOFF",
",",
"SBSIZE",
",",
"0",
",",
"0",
")",
";",
"bcopy",
"(",
"(",
"caddr_t",
")",
"es",
",",
"bp",
"->",
"b_data",
",",
"(",
"u_int",
")",
"sizeof",
"(",
"struct",
"ext2_super_block",
")",
")",
";",
"if",
"(",
"waitfor",
"==",
"MNT_WAIT",
")",
"error",
"=",
"bwrite",
"(",
"bp",
")",
";",
"else",
"bawrite",
"(",
"bp",
")",
";",
"return",
"(",
"error",
")",
";",
"}"
] | Write a superblock and associated information back to disk. | [
"Write",
"a",
"superblock",
"and",
"associated",
"information",
"back",
"to",
"disk",
"."
] | [
"/*\nkprintf(\"\\nupdating superblock, waitfor=%s\\n\", waitfor == MNT_WAIT ? \"yes\":\"no\");\n*/",
"/*\n\t * The buffers for group descriptors, inode bitmaps and block bitmaps\n\t * are not busy at this point and are (hopefully) written by the\n\t * usual sync mechanism. No need to write them here\n\t */"
] | [
{
"param": "mp",
"type": "struct ext2_mount"
},
{
"param": "waitfor",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mp",
"type": "struct ext2_mount",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "waitfor",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | rl_callback_read_char_wrapper | void | static void
rl_callback_read_char_wrapper (gdb_client_data client_data)
{
rl_callback_read_char ();
if (after_char_processing_hook)
(*after_char_processing_hook) ();
} | /* Wrapper function for calling into the readline library. The event
loop expects the callback function to have a paramter, while
readline expects none. */ | Wrapper function for calling into the readline library. The event
loop expects the callback function to have a paramter, while
readline expects none. | [
"Wrapper",
"function",
"for",
"calling",
"into",
"the",
"readline",
"library",
".",
"The",
"event",
"loop",
"expects",
"the",
"callback",
"function",
"to",
"have",
"a",
"paramter",
"while",
"readline",
"expects",
"none",
"."
] | static void
rl_callback_read_char_wrapper (gdb_client_data client_data)
{
rl_callback_read_char ();
if (after_char_processing_hook)
(*after_char_processing_hook) ();
} | [
"static",
"void",
"rl_callback_read_char_wrapper",
"(",
"gdb_client_data",
"client_data",
")",
"{",
"rl_callback_read_char",
"(",
")",
";",
"if",
"(",
"after_char_processing_hook",
")",
"(",
"*",
"after_char_processing_hook",
")",
"(",
")",
";",
"}"
] | Wrapper function for calling into the readline library. | [
"Wrapper",
"function",
"for",
"calling",
"into",
"the",
"readline",
"library",
"."
] | [] | [
{
"param": "client_data",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "client_data",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | cli_command_loop | void | void
cli_command_loop (void)
{
display_gdb_prompt (0);
/* Now it's time to start the event loop. */
start_event_loop ();
} | /* Initialize all the necessary variables, start the event loop,
register readline, and stdin, start the loop. */ | Initialize all the necessary variables, start the event loop,
register readline, and stdin, start the loop. | [
"Initialize",
"all",
"the",
"necessary",
"variables",
"start",
"the",
"event",
"loop",
"register",
"readline",
"and",
"stdin",
"start",
"the",
"loop",
"."
] | void
cli_command_loop (void)
{
display_gdb_prompt (0);
start_event_loop ();
} | [
"void",
"cli_command_loop",
"(",
"void",
")",
"{",
"display_gdb_prompt",
"(",
"0",
")",
";",
"start_event_loop",
"(",
")",
";",
"}"
] | Initialize all the necessary variables, start the event loop,
register readline, and stdin, start the loop. | [
"Initialize",
"all",
"the",
"necessary",
"variables",
"start",
"the",
"event",
"loop",
"register",
"readline",
"and",
"stdin",
"start",
"the",
"loop",
"."
] | [
"/* Now it's time to start the event loop. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | change_line_handler | void | static void
change_line_handler (void)
{
/* NOTE: this operates on input_fd, not instream. If we are reading
commands from a file, instream will point to the file. However in
async mode, we always read commands from a file with editing
off. This means that the 'set editing on/off' will have effect
only on the interactive session. */
if (async_command_editing_p)
{
/* Turn on editing by using readline. */
call_readline = rl_callback_read_char_wrapper;
input_handler = command_line_handler;
}
else
{
/* Turn off editing by using gdb_readline2. */
rl_callback_handler_remove ();
call_readline = gdb_readline2;
/* Set up the command handler as well, in case we are called as
first thing from .gdbinit. */
input_handler = command_line_handler;
}
} | /* Change the function to be invoked every time there is a character
ready on stdin. This is used when the user sets the editing off,
therefore bypassing readline, and letting gdb handle the input
itself, via gdb_readline2. Also it is used in the opposite case in
which the user sets editing on again, by restoring readline
handling of the input. */ | Change the function to be invoked every time there is a character
ready on stdin. This is used when the user sets the editing off,
therefore bypassing readline, and letting gdb handle the input
itself, via gdb_readline2. Also it is used in the opposite case in
which the user sets editing on again, by restoring readline
handling of the input. | [
"Change",
"the",
"function",
"to",
"be",
"invoked",
"every",
"time",
"there",
"is",
"a",
"character",
"ready",
"on",
"stdin",
".",
"This",
"is",
"used",
"when",
"the",
"user",
"sets",
"the",
"editing",
"off",
"therefore",
"bypassing",
"readline",
"and",
"letting",
"gdb",
"handle",
"the",
"input",
"itself",
"via",
"gdb_readline2",
".",
"Also",
"it",
"is",
"used",
"in",
"the",
"opposite",
"case",
"in",
"which",
"the",
"user",
"sets",
"editing",
"on",
"again",
"by",
"restoring",
"readline",
"handling",
"of",
"the",
"input",
"."
] | static void
change_line_handler (void)
{
if (async_command_editing_p)
{
call_readline = rl_callback_read_char_wrapper;
input_handler = command_line_handler;
}
else
{
rl_callback_handler_remove ();
call_readline = gdb_readline2;
input_handler = command_line_handler;
}
} | [
"static",
"void",
"change_line_handler",
"(",
"void",
")",
"{",
"if",
"(",
"async_command_editing_p",
")",
"{",
"call_readline",
"=",
"rl_callback_read_char_wrapper",
";",
"input_handler",
"=",
"command_line_handler",
";",
"}",
"else",
"{",
"rl_callback_handler_remove",
"(",
")",
";",
"call_readline",
"=",
"gdb_readline2",
";",
"input_handler",
"=",
"command_line_handler",
";",
"}",
"}"
] | Change the function to be invoked every time there is a character
ready on stdin. | [
"Change",
"the",
"function",
"to",
"be",
"invoked",
"every",
"time",
"there",
"is",
"a",
"character",
"ready",
"on",
"stdin",
"."
] | [
"/* NOTE: this operates on input_fd, not instream. If we are reading\n commands from a file, instream will point to the file. However in\n async mode, we always read commands from a file with editing\n off. This means that the 'set editing on/off' will have effect\n only on the interactive session. */",
"/* Turn on editing by using readline. */",
"/* Turn off editing by using gdb_readline2. */",
"/* Set up the command handler as well, in case we are called as\n first thing from .gdbinit. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | display_gdb_prompt | void | void
display_gdb_prompt (char *new_prompt)
{
char *actual_gdb_prompt = NULL;
struct cleanup *old_chain;
annotate_display_prompt ();
/* Reset the nesting depth used when trace-commands is set. */
reset_command_nest_depth ();
/* Each interpreter has its own rules on displaying the command
prompt. */
if (!current_interp_display_prompt_p ())
return;
old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
/* Do not call the python hook on an explicit prompt change as
passed to this function, as this forms a secondary/local prompt,
IE, displayed but not set. */
if (! new_prompt)
{
if (sync_execution)
{
/* This is to trick readline into not trying to display the
prompt. Even though we display the prompt using this
function, readline still tries to do its own display if
we don't call rl_callback_handler_install and
rl_callback_handler_remove (which readline detects
because a global variable is not set). If readline did
that, it could mess up gdb signal handlers for SIGINT.
Readline assumes that between calls to rl_set_signals and
rl_clear_signals gdb doesn't do anything with the signal
handlers. Well, that's not the case, because when the
target executes we change the SIGINT signal handler. If
we allowed readline to display the prompt, the signal
handler change would happen exactly between the calls to
the above two functions. Calling
rl_callback_handler_remove(), does the job. */
rl_callback_handler_remove ();
return;
}
else
{
/* Display the top level prompt. */
actual_gdb_prompt = top_level_prompt ();
}
}
else
actual_gdb_prompt = xstrdup (new_prompt);
if (async_command_editing_p)
{
rl_callback_handler_remove ();
rl_callback_handler_install (actual_gdb_prompt, input_handler);
}
/* new_prompt at this point can be the top of the stack or the one
passed in. It can't be NULL. */
else
{
/* Don't use a _filtered function here. It causes the assumed
character position to be off, since the newline we read from
the user is not accounted for. */
fputs_unfiltered (actual_gdb_prompt, gdb_stdout);
gdb_flush (gdb_stdout);
}
do_cleanups (old_chain);
} | /* Displays the prompt. If the argument NEW_PROMPT is NULL, the
prompt that is displayed is the current top level prompt.
Otherwise, it displays whatever NEW_PROMPT is as a local/secondary
prompt.
This is used after each gdb command has completed, and in the
following cases:
1. When the user enters a command line which is ended by '\'
indicating that the command will continue on the next line. In
that case the prompt that is displayed is the empty string.
2. When the user is entering 'commands' for a breakpoint, or
actions for a tracepoint. In this case the prompt will be '>'
3. On prompting for pagination. */ | Displays the prompt. If the argument NEW_PROMPT is NULL, the
prompt that is displayed is the current top level prompt.
Otherwise, it displays whatever NEW_PROMPT is as a local/secondary
prompt.
This is used after each gdb command has completed, and in the
following cases.
1. When the user enters a command line which is ended by '\'
indicating that the command will continue on the next line. In
that case the prompt that is displayed is the empty string.
2. When the user is entering 'commands' for a breakpoint, or
actions for a tracepoint. In this case the prompt will be '>'
3. On prompting for pagination. | [
"Displays",
"the",
"prompt",
".",
"If",
"the",
"argument",
"NEW_PROMPT",
"is",
"NULL",
"the",
"prompt",
"that",
"is",
"displayed",
"is",
"the",
"current",
"top",
"level",
"prompt",
".",
"Otherwise",
"it",
"displays",
"whatever",
"NEW_PROMPT",
"is",
"as",
"a",
"local",
"/",
"secondary",
"prompt",
".",
"This",
"is",
"used",
"after",
"each",
"gdb",
"command",
"has",
"completed",
"and",
"in",
"the",
"following",
"cases",
".",
"1",
".",
"When",
"the",
"user",
"enters",
"a",
"command",
"line",
"which",
"is",
"ended",
"by",
"'",
"\\",
"'",
"indicating",
"that",
"the",
"command",
"will",
"continue",
"on",
"the",
"next",
"line",
".",
"In",
"that",
"case",
"the",
"prompt",
"that",
"is",
"displayed",
"is",
"the",
"empty",
"string",
".",
"2",
".",
"When",
"the",
"user",
"is",
"entering",
"'",
"commands",
"'",
"for",
"a",
"breakpoint",
"or",
"actions",
"for",
"a",
"tracepoint",
".",
"In",
"this",
"case",
"the",
"prompt",
"will",
"be",
"'",
">",
"'",
"3",
".",
"On",
"prompting",
"for",
"pagination",
"."
] | void
display_gdb_prompt (char *new_prompt)
{
char *actual_gdb_prompt = NULL;
struct cleanup *old_chain;
annotate_display_prompt ();
reset_command_nest_depth ();
if (!current_interp_display_prompt_p ())
return;
old_chain = make_cleanup (free_current_contents, &actual_gdb_prompt);
if (! new_prompt)
{
if (sync_execution)
{
rl_callback_handler_remove ();
return;
}
else
{
actual_gdb_prompt = top_level_prompt ();
}
}
else
actual_gdb_prompt = xstrdup (new_prompt);
if (async_command_editing_p)
{
rl_callback_handler_remove ();
rl_callback_handler_install (actual_gdb_prompt, input_handler);
}
else
{
fputs_unfiltered (actual_gdb_prompt, gdb_stdout);
gdb_flush (gdb_stdout);
}
do_cleanups (old_chain);
} | [
"void",
"display_gdb_prompt",
"(",
"char",
"*",
"new_prompt",
")",
"{",
"char",
"*",
"actual_gdb_prompt",
"=",
"NULL",
";",
"struct",
"cleanup",
"*",
"old_chain",
";",
"annotate_display_prompt",
"(",
")",
";",
"reset_command_nest_depth",
"(",
")",
";",
"if",
"(",
"!",
"current_interp_display_prompt_p",
"(",
")",
")",
"return",
";",
"old_chain",
"=",
"make_cleanup",
"(",
"free_current_contents",
",",
"&",
"actual_gdb_prompt",
")",
";",
"if",
"(",
"!",
"new_prompt",
")",
"{",
"if",
"(",
"sync_execution",
")",
"{",
"rl_callback_handler_remove",
"(",
")",
";",
"return",
";",
"}",
"else",
"{",
"actual_gdb_prompt",
"=",
"top_level_prompt",
"(",
")",
";",
"}",
"}",
"else",
"actual_gdb_prompt",
"=",
"xstrdup",
"(",
"new_prompt",
")",
";",
"if",
"(",
"async_command_editing_p",
")",
"{",
"rl_callback_handler_remove",
"(",
")",
";",
"rl_callback_handler_install",
"(",
"actual_gdb_prompt",
",",
"input_handler",
")",
";",
"}",
"else",
"{",
"fputs_unfiltered",
"(",
"actual_gdb_prompt",
",",
"gdb_stdout",
")",
";",
"gdb_flush",
"(",
"gdb_stdout",
")",
";",
"}",
"do_cleanups",
"(",
"old_chain",
")",
";",
"}"
] | Displays the prompt. | [
"Displays",
"the",
"prompt",
"."
] | [
"/* Reset the nesting depth used when trace-commands is set. */",
"/* Each interpreter has its own rules on displaying the command\n prompt. */",
"/* Do not call the python hook on an explicit prompt change as\n passed to this function, as this forms a secondary/local prompt,\n IE, displayed but not set. */",
"/* This is to trick readline into not trying to display the\n\t prompt. Even though we display the prompt using this\n\t function, readline still tries to do its own display if\n\t we don't call rl_callback_handler_install and\n\t rl_callback_handler_remove (which readline detects\n\t because a global variable is not set). If readline did\n\t that, it could mess up gdb signal handlers for SIGINT.\n\t Readline assumes that between calls to rl_set_signals and\n\t rl_clear_signals gdb doesn't do anything with the signal\n\t handlers. Well, that's not the case, because when the\n\t target executes we change the SIGINT signal handler. If\n\t we allowed readline to display the prompt, the signal\n\t handler change would happen exactly between the calls to\n\t the above two functions. Calling\n\t rl_callback_handler_remove(), does the job. */",
"/* Display the top level prompt. */",
"/* new_prompt at this point can be the top of the stack or the one\n passed in. It can't be NULL. */",
"/* Don't use a _filtered function here. It causes the assumed\n character position to be off, since the newline we read from\n the user is not accounted for. */"
] | [
{
"param": "new_prompt",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_prompt",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | top_level_prompt | char | static char *
top_level_prompt (void)
{
char *prefix;
char *prompt = NULL;
char *suffix;
char *composed_prompt;
size_t prompt_length;
/* Give observers a chance of changing the prompt. E.g., the python
`gdb.prompt_hook' is installed as an observer. */
observer_notify_before_prompt (get_prompt ());
prompt = xstrdup (get_prompt ());
if (annotation_level >= 2)
{
/* Prefix needs to have new line at end. */
prefix = (char *) alloca (strlen (async_annotation_suffix) + 10);
strcpy (prefix, "\n\032\032pre-");
strcat (prefix, async_annotation_suffix);
strcat (prefix, "\n");
/* Suffix needs to have a new line at end and \032 \032 at
beginning. */
suffix = (char *) alloca (strlen (async_annotation_suffix) + 6);
strcpy (suffix, "\n\032\032");
strcat (suffix, async_annotation_suffix);
strcat (suffix, "\n");
}
else
{
prefix = "";
suffix = "";
}
prompt_length = strlen (prefix) + strlen (prompt) + strlen (suffix);
composed_prompt = xmalloc (prompt_length + 1);
strcpy (composed_prompt, prefix);
strcat (composed_prompt, prompt);
strcat (composed_prompt, suffix);
xfree (prompt);
return composed_prompt;
} | /* Return the top level prompt, as specified by "set prompt", possibly
overriden by the python gdb.prompt_hook hook, and then composed
with the prompt prefix and suffix (annotations). The caller is
responsible for freeing the returned string. */ | Return the top level prompt, as specified by "set prompt", possibly
overriden by the python gdb.prompt_hook hook, and then composed
with the prompt prefix and suffix (annotations). The caller is
responsible for freeing the returned string. | [
"Return",
"the",
"top",
"level",
"prompt",
"as",
"specified",
"by",
"\"",
"set",
"prompt",
"\"",
"possibly",
"overriden",
"by",
"the",
"python",
"gdb",
".",
"prompt_hook",
"hook",
"and",
"then",
"composed",
"with",
"the",
"prompt",
"prefix",
"and",
"suffix",
"(",
"annotations",
")",
".",
"The",
"caller",
"is",
"responsible",
"for",
"freeing",
"the",
"returned",
"string",
"."
] | static char *
top_level_prompt (void)
{
char *prefix;
char *prompt = NULL;
char *suffix;
char *composed_prompt;
size_t prompt_length;
observer_notify_before_prompt (get_prompt ());
prompt = xstrdup (get_prompt ());
if (annotation_level >= 2)
{
prefix = (char *) alloca (strlen (async_annotation_suffix) + 10);
strcpy (prefix, "\n\032\032pre-");
strcat (prefix, async_annotation_suffix);
strcat (prefix, "\n");
suffix = (char *) alloca (strlen (async_annotation_suffix) + 6);
strcpy (suffix, "\n\032\032");
strcat (suffix, async_annotation_suffix);
strcat (suffix, "\n");
}
else
{
prefix = "";
suffix = "";
}
prompt_length = strlen (prefix) + strlen (prompt) + strlen (suffix);
composed_prompt = xmalloc (prompt_length + 1);
strcpy (composed_prompt, prefix);
strcat (composed_prompt, prompt);
strcat (composed_prompt, suffix);
xfree (prompt);
return composed_prompt;
} | [
"static",
"char",
"*",
"top_level_prompt",
"(",
"void",
")",
"{",
"char",
"*",
"prefix",
";",
"char",
"*",
"prompt",
"=",
"NULL",
";",
"char",
"*",
"suffix",
";",
"char",
"*",
"composed_prompt",
";",
"size_t",
"prompt_length",
";",
"observer_notify_before_prompt",
"(",
"get_prompt",
"(",
")",
")",
";",
"prompt",
"=",
"xstrdup",
"(",
"get_prompt",
"(",
")",
")",
";",
"if",
"(",
"annotation_level",
">=",
"2",
")",
"{",
"prefix",
"=",
"(",
"char",
"*",
")",
"alloca",
"(",
"strlen",
"(",
"async_annotation_suffix",
")",
"+",
"10",
")",
";",
"strcpy",
"(",
"prefix",
",",
"\"",
"\\n",
"\\032",
"\\032",
"\"",
")",
";",
"strcat",
"(",
"prefix",
",",
"async_annotation_suffix",
")",
";",
"strcat",
"(",
"prefix",
",",
"\"",
"\\n",
"\"",
")",
";",
"suffix",
"=",
"(",
"char",
"*",
")",
"alloca",
"(",
"strlen",
"(",
"async_annotation_suffix",
")",
"+",
"6",
")",
";",
"strcpy",
"(",
"suffix",
",",
"\"",
"\\n",
"\\032",
"\\032",
"\"",
")",
";",
"strcat",
"(",
"suffix",
",",
"async_annotation_suffix",
")",
";",
"strcat",
"(",
"suffix",
",",
"\"",
"\\n",
"\"",
")",
";",
"}",
"else",
"{",
"prefix",
"=",
"\"",
"\"",
";",
"suffix",
"=",
"\"",
"\"",
";",
"}",
"prompt_length",
"=",
"strlen",
"(",
"prefix",
")",
"+",
"strlen",
"(",
"prompt",
")",
"+",
"strlen",
"(",
"suffix",
")",
";",
"composed_prompt",
"=",
"xmalloc",
"(",
"prompt_length",
"+",
"1",
")",
";",
"strcpy",
"(",
"composed_prompt",
",",
"prefix",
")",
";",
"strcat",
"(",
"composed_prompt",
",",
"prompt",
")",
";",
"strcat",
"(",
"composed_prompt",
",",
"suffix",
")",
";",
"xfree",
"(",
"prompt",
")",
";",
"return",
"composed_prompt",
";",
"}"
] | Return the top level prompt, as specified by "set prompt", possibly
overriden by the python gdb.prompt_hook hook, and then composed
with the prompt prefix and suffix (annotations). | [
"Return",
"the",
"top",
"level",
"prompt",
"as",
"specified",
"by",
"\"",
"set",
"prompt",
"\"",
"possibly",
"overriden",
"by",
"the",
"python",
"gdb",
".",
"prompt_hook",
"hook",
"and",
"then",
"composed",
"with",
"the",
"prompt",
"prefix",
"and",
"suffix",
"(",
"annotations",
")",
"."
] | [
"/* Give observers a chance of changing the prompt. E.g., the python\n `gdb.prompt_hook' is installed as an observer. */",
"/* Prefix needs to have new line at end. */",
"/* Suffix needs to have a new line at end and \\032 \\032 at\n\t beginning. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | stdin_event_handler | void | void
stdin_event_handler (int error, gdb_client_data client_data)
{
if (error)
{
printf_unfiltered (_("error detected on stdin\n"));
delete_file_handler (input_fd);
discard_all_continuations ();
discard_all_intermediate_continuations ();
/* If stdin died, we may as well kill gdb. */
quit_command ((char *) 0, stdin == instream);
}
else
(*call_readline) (client_data);
} | /* When there is an event ready on the stdin file desriptor, instead
of calling readline directly throught the callback function, or
instead of calling gdb_readline2, give gdb a chance to detect
errors and do something. */ | When there is an event ready on the stdin file desriptor, instead
of calling readline directly throught the callback function, or
instead of calling gdb_readline2, give gdb a chance to detect
errors and do something. | [
"When",
"there",
"is",
"an",
"event",
"ready",
"on",
"the",
"stdin",
"file",
"desriptor",
"instead",
"of",
"calling",
"readline",
"directly",
"throught",
"the",
"callback",
"function",
"or",
"instead",
"of",
"calling",
"gdb_readline2",
"give",
"gdb",
"a",
"chance",
"to",
"detect",
"errors",
"and",
"do",
"something",
"."
] | void
stdin_event_handler (int error, gdb_client_data client_data)
{
if (error)
{
printf_unfiltered (_("error detected on stdin\n"));
delete_file_handler (input_fd);
discard_all_continuations ();
discard_all_intermediate_continuations ();
quit_command ((char *) 0, stdin == instream);
}
else
(*call_readline) (client_data);
} | [
"void",
"stdin_event_handler",
"(",
"int",
"error",
",",
"gdb_client_data",
"client_data",
")",
"{",
"if",
"(",
"error",
")",
"{",
"printf_unfiltered",
"(",
"_",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"delete_file_handler",
"(",
"input_fd",
")",
";",
"discard_all_continuations",
"(",
")",
";",
"discard_all_intermediate_continuations",
"(",
")",
";",
"quit_command",
"(",
"(",
"char",
"*",
")",
"0",
",",
"stdin",
"==",
"instream",
")",
";",
"}",
"else",
"(",
"*",
"call_readline",
")",
"(",
"client_data",
")",
";",
"}"
] | When there is an event ready on the stdin file desriptor, instead
of calling readline directly throught the callback function, or
instead of calling gdb_readline2, give gdb a chance to detect
errors and do something. | [
"When",
"there",
"is",
"an",
"event",
"ready",
"on",
"the",
"stdin",
"file",
"desriptor",
"instead",
"of",
"calling",
"readline",
"directly",
"throught",
"the",
"callback",
"function",
"or",
"instead",
"of",
"calling",
"gdb_readline2",
"give",
"gdb",
"a",
"chance",
"to",
"detect",
"errors",
"and",
"do",
"something",
"."
] | [
"/* If stdin died, we may as well kill gdb. */"
] | [
{
"param": "error",
"type": "int"
},
{
"param": "client_data",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "error",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "client_data",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_enable_stdin | void | void
async_enable_stdin (void)
{
if (sync_execution)
{
/* See NOTE in async_disable_stdin(). */
/* FIXME: cagney/1999-09-27: Call this before clearing
sync_execution. Current target_terminal_ours() implementations
check for sync_execution before switching the terminal. */
target_terminal_ours ();
sync_execution = 0;
}
} | /* Re-enable stdin after the end of an execution command in
synchronous mode, or after an error from the target, and we aborted
the exec operation. */ | Re-enable stdin after the end of an execution command in
synchronous mode, or after an error from the target, and we aborted
the exec operation. | [
"Re",
"-",
"enable",
"stdin",
"after",
"the",
"end",
"of",
"an",
"execution",
"command",
"in",
"synchronous",
"mode",
"or",
"after",
"an",
"error",
"from",
"the",
"target",
"and",
"we",
"aborted",
"the",
"exec",
"operation",
"."
] | void
async_enable_stdin (void)
{
if (sync_execution)
{
target_terminal_ours ();
sync_execution = 0;
}
} | [
"void",
"async_enable_stdin",
"(",
"void",
")",
"{",
"if",
"(",
"sync_execution",
")",
"{",
"target_terminal_ours",
"(",
")",
";",
"sync_execution",
"=",
"0",
";",
"}",
"}"
] | Re-enable stdin after the end of an execution command in
synchronous mode, or after an error from the target, and we aborted
the exec operation. | [
"Re",
"-",
"enable",
"stdin",
"after",
"the",
"end",
"of",
"an",
"execution",
"command",
"in",
"synchronous",
"mode",
"or",
"after",
"an",
"error",
"from",
"the",
"target",
"and",
"we",
"aborted",
"the",
"exec",
"operation",
"."
] | [
"/* See NOTE in async_disable_stdin(). */",
"/* FIXME: cagney/1999-09-27: Call this before clearing\n\t sync_execution. Current target_terminal_ours() implementations\n\t check for sync_execution before switching the terminal. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_disable_stdin | void | void
async_disable_stdin (void)
{
sync_execution = 1;
} | /* Disable reads from stdin (the console) marking the command as
synchronous. */ | Disable reads from stdin (the console) marking the command as
synchronous. | [
"Disable",
"reads",
"from",
"stdin",
"(",
"the",
"console",
")",
"marking",
"the",
"command",
"as",
"synchronous",
"."
] | void
async_disable_stdin (void)
{
sync_execution = 1;
} | [
"void",
"async_disable_stdin",
"(",
"void",
")",
"{",
"sync_execution",
"=",
"1",
";",
"}"
] | Disable reads from stdin (the console) marking the command as
synchronous. | [
"Disable",
"reads",
"from",
"stdin",
"(",
"the",
"console",
")",
"marking",
"the",
"command",
"as",
"synchronous",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | command_handler | void | static void
command_handler (char *command)
{
int stdin_is_tty = ISATTY (stdin);
struct cleanup *stat_chain;
clear_quit_flag ();
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
/* If readline returned a NULL command, it means that the connection
with the terminal is gone. This happens at the end of a
testsuite run, after Expect has hung up but GDB is still alive.
In such a case, we just quit gdb killing the inferior program
too. */
if (command == 0)
{
printf_unfiltered ("quit\n");
execute_command ("quit", stdin == instream);
}
stat_chain = make_command_stats_cleanup (1);
execute_command (command, instream == stdin);
/* Do any commands attached to breakpoint we stopped at. */
bpstat_do_actions ();
do_cleanups (stat_chain);
} | /* NOTE: 1999-04-30 This is the asynchronous version of the command_loop
function. The command_loop function will be obsolete when we
switch to use the event loop at every execution of gdb. */ | 1999-04-30 This is the asynchronous version of the command_loop
function. The command_loop function will be obsolete when we
switch to use the event loop at every execution of gdb. | [
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"the",
"command_loop",
"function",
".",
"The",
"command_loop",
"function",
"will",
"be",
"obsolete",
"when",
"we",
"switch",
"to",
"use",
"the",
"event",
"loop",
"at",
"every",
"execution",
"of",
"gdb",
"."
] | static void
command_handler (char *command)
{
int stdin_is_tty = ISATTY (stdin);
struct cleanup *stat_chain;
clear_quit_flag ();
if (instream == stdin && stdin_is_tty)
reinitialize_more_filter ();
if (command == 0)
{
printf_unfiltered ("quit\n");
execute_command ("quit", stdin == instream);
}
stat_chain = make_command_stats_cleanup (1);
execute_command (command, instream == stdin);
bpstat_do_actions ();
do_cleanups (stat_chain);
} | [
"static",
"void",
"command_handler",
"(",
"char",
"*",
"command",
")",
"{",
"int",
"stdin_is_tty",
"=",
"ISATTY",
"(",
"stdin",
")",
";",
"struct",
"cleanup",
"*",
"stat_chain",
";",
"clear_quit_flag",
"(",
")",
";",
"if",
"(",
"instream",
"==",
"stdin",
"&&",
"stdin_is_tty",
")",
"reinitialize_more_filter",
"(",
")",
";",
"if",
"(",
"command",
"==",
"0",
")",
"{",
"printf_unfiltered",
"(",
"\"",
"\\n",
"\"",
")",
";",
"execute_command",
"(",
"\"",
"\"",
",",
"stdin",
"==",
"instream",
")",
";",
"}",
"stat_chain",
"=",
"make_command_stats_cleanup",
"(",
"1",
")",
";",
"execute_command",
"(",
"command",
",",
"instream",
"==",
"stdin",
")",
";",
"bpstat_do_actions",
"(",
")",
";",
"do_cleanups",
"(",
"stat_chain",
")",
";",
"}"
] | NOTE: 1999-04-30 This is the asynchronous version of the command_loop
function. | [
"NOTE",
":",
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"the",
"command_loop",
"function",
"."
] | [
"/* If readline returned a NULL command, it means that the connection\n with the terminal is gone. This happens at the end of a\n testsuite run, after Expect has hung up but GDB is still alive.\n In such a case, we just quit gdb killing the inferior program\n too. */",
"/* Do any commands attached to breakpoint we stopped at. */"
] | [
{
"param": "command",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "command",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | command_line_handler | void | static void
command_line_handler (char *rl)
{
static char *linebuffer = 0;
static unsigned linelength = 0;
char *p;
char *p1;
char *nline;
int repeat = (instream == stdin);
if (annotation_level > 1 && instream == stdin)
{
printf_unfiltered (("\n\032\032post-"));
puts_unfiltered (async_annotation_suffix);
printf_unfiltered (("\n"));
}
if (linebuffer == 0)
{
linelength = 80;
linebuffer = (char *) xmalloc (linelength);
}
p = linebuffer;
if (more_to_come)
{
strcpy (linebuffer, readline_input_state.linebuffer);
p = readline_input_state.linebuffer_ptr;
xfree (readline_input_state.linebuffer);
more_to_come = 0;
}
#ifdef STOP_SIGNAL
if (job_control)
signal (STOP_SIGNAL, handle_stop_sig);
#endif
/* Make sure that all output has been output. Some machines may let
you get away with leaving out some of the gdb_flush, but not
all. */
wrap_here ("");
gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr);
if (source_file_name != NULL)
++source_line_number;
/* If we are in this case, then command_handler will call quit
and exit from gdb. */
if (!rl || rl == (char *) EOF)
{
command_handler (0);
return; /* Lint. */
}
if (strlen (rl) + 1 + (p - linebuffer) > linelength)
{
linelength = strlen (rl) + 1 + (p - linebuffer);
nline = (char *) xrealloc (linebuffer, linelength);
p += nline - linebuffer;
linebuffer = nline;
}
p1 = rl;
/* Copy line. Don't copy null at end. (Leaves line alone
if this was just a newline). */
while (*p1)
*p++ = *p1++;
xfree (rl); /* Allocated in readline. */
if (p > linebuffer && *(p - 1) == '\\')
{
*p = '\0';
p--; /* Put on top of '\'. */
readline_input_state.linebuffer = xstrdup (linebuffer);
readline_input_state.linebuffer_ptr = p;
/* We will not invoke a execute_command if there is more
input expected to complete the command. So, we need to
print an empty prompt here. */
more_to_come = 1;
display_gdb_prompt ("");
return;
}
#ifdef STOP_SIGNAL
if (job_control)
signal (STOP_SIGNAL, SIG_DFL);
#endif
#define SERVER_COMMAND_LENGTH 7
server_command =
(p - linebuffer > SERVER_COMMAND_LENGTH)
&& strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
if (server_command)
{
/* Note that we don't set `line'. Between this and the check in
dont_repeat, this insures that repeating will still do the
right thing. */
*p = '\0';
command_handler (linebuffer + SERVER_COMMAND_LENGTH);
display_gdb_prompt (0);
return;
}
/* Do history expansion if that is wished. */
if (history_expansion_p && instream == stdin
&& ISATTY (instream))
{
char *history_value;
int expanded;
*p = '\0'; /* Insert null now. */
expanded = history_expand (linebuffer, &history_value);
if (expanded)
{
/* Print the changes. */
printf_unfiltered ("%s\n", history_value);
/* If there was an error, call this function again. */
if (expanded < 0)
{
xfree (history_value);
return;
}
if (strlen (history_value) > linelength)
{
linelength = strlen (history_value) + 1;
linebuffer = (char *) xrealloc (linebuffer, linelength);
}
strcpy (linebuffer, history_value);
p = linebuffer + strlen (linebuffer);
}
xfree (history_value);
}
/* If we just got an empty line, and that is supposed to repeat the
previous command, return the value in the global buffer. */
if (repeat && p == linebuffer && *p != '\\')
{
command_handler (saved_command_line);
display_gdb_prompt (0);
return;
}
for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++);
if (repeat && !*p1)
{
command_handler (saved_command_line);
display_gdb_prompt (0);
return;
}
*p = 0;
/* Add line to history if appropriate. */
if (instream == stdin
&& ISATTY (stdin) && *linebuffer)
add_history (linebuffer);
/* Note: lines consisting solely of comments are added to the command
history. This is useful when you type a command, and then
realize you don't want to execute it quite yet. You can comment
out the command and then later fetch it from the value history
and remove the '#'. The kill ring is probably better, but some
people are in the habit of commenting things out. */
if (*p1 == '#')
*p1 = '\0'; /* Found a comment. */
/* Save into global buffer if appropriate. */
if (repeat)
{
if (linelength > saved_command_line_size)
{
saved_command_line = xrealloc (saved_command_line, linelength);
saved_command_line_size = linelength;
}
strcpy (saved_command_line, linebuffer);
if (!more_to_come)
{
command_handler (saved_command_line);
display_gdb_prompt (0);
}
return;
}
command_handler (linebuffer);
display_gdb_prompt (0);
return;
} | /* NOTE: 1999-04-30 This is the asynchronous version of the
command_line_input function; command_line_input will become
obsolete once we use the event loop as the default mechanism in
GDB. */ | 1999-04-30 This is the asynchronous version of the
command_line_input function; command_line_input will become
obsolete once we use the event loop as the default mechanism in
GDB. | [
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"the",
"command_line_input",
"function",
";",
"command_line_input",
"will",
"become",
"obsolete",
"once",
"we",
"use",
"the",
"event",
"loop",
"as",
"the",
"default",
"mechanism",
"in",
"GDB",
"."
] | static void
command_line_handler (char *rl)
{
static char *linebuffer = 0;
static unsigned linelength = 0;
char *p;
char *p1;
char *nline;
int repeat = (instream == stdin);
if (annotation_level > 1 && instream == stdin)
{
printf_unfiltered (("\n\032\032post-"));
puts_unfiltered (async_annotation_suffix);
printf_unfiltered (("\n"));
}
if (linebuffer == 0)
{
linelength = 80;
linebuffer = (char *) xmalloc (linelength);
}
p = linebuffer;
if (more_to_come)
{
strcpy (linebuffer, readline_input_state.linebuffer);
p = readline_input_state.linebuffer_ptr;
xfree (readline_input_state.linebuffer);
more_to_come = 0;
}
#ifdef STOP_SIGNAL
if (job_control)
signal (STOP_SIGNAL, handle_stop_sig);
#endif
wrap_here ("");
gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr);
if (source_file_name != NULL)
++source_line_number;
if (!rl || rl == (char *) EOF)
{
command_handler (0);
return;
}
if (strlen (rl) + 1 + (p - linebuffer) > linelength)
{
linelength = strlen (rl) + 1 + (p - linebuffer);
nline = (char *) xrealloc (linebuffer, linelength);
p += nline - linebuffer;
linebuffer = nline;
}
p1 = rl;
while (*p1)
*p++ = *p1++;
xfree (rl);
if (p > linebuffer && *(p - 1) == '\\')
{
*p = '\0';
p--;
readline_input_state.linebuffer = xstrdup (linebuffer);
readline_input_state.linebuffer_ptr = p;
more_to_come = 1;
display_gdb_prompt ("");
return;
}
#ifdef STOP_SIGNAL
if (job_control)
signal (STOP_SIGNAL, SIG_DFL);
#endif
#define SERVER_COMMAND_LENGTH 7
server_command =
(p - linebuffer > SERVER_COMMAND_LENGTH)
&& strncmp (linebuffer, "server ", SERVER_COMMAND_LENGTH) == 0;
if (server_command)
{
*p = '\0';
command_handler (linebuffer + SERVER_COMMAND_LENGTH);
display_gdb_prompt (0);
return;
}
if (history_expansion_p && instream == stdin
&& ISATTY (instream))
{
char *history_value;
int expanded;
*p = '\0';
expanded = history_expand (linebuffer, &history_value);
if (expanded)
{
printf_unfiltered ("%s\n", history_value);
if (expanded < 0)
{
xfree (history_value);
return;
}
if (strlen (history_value) > linelength)
{
linelength = strlen (history_value) + 1;
linebuffer = (char *) xrealloc (linebuffer, linelength);
}
strcpy (linebuffer, history_value);
p = linebuffer + strlen (linebuffer);
}
xfree (history_value);
}
if (repeat && p == linebuffer && *p != '\\')
{
command_handler (saved_command_line);
display_gdb_prompt (0);
return;
}
for (p1 = linebuffer; *p1 == ' ' || *p1 == '\t'; p1++);
if (repeat && !*p1)
{
command_handler (saved_command_line);
display_gdb_prompt (0);
return;
}
*p = 0;
if (instream == stdin
&& ISATTY (stdin) && *linebuffer)
add_history (linebuffer);
if (*p1 == '#')
*p1 = '\0';
if (repeat)
{
if (linelength > saved_command_line_size)
{
saved_command_line = xrealloc (saved_command_line, linelength);
saved_command_line_size = linelength;
}
strcpy (saved_command_line, linebuffer);
if (!more_to_come)
{
command_handler (saved_command_line);
display_gdb_prompt (0);
}
return;
}
command_handler (linebuffer);
display_gdb_prompt (0);
return;
} | [
"static",
"void",
"command_line_handler",
"(",
"char",
"*",
"rl",
")",
"{",
"static",
"char",
"*",
"linebuffer",
"=",
"0",
";",
"static",
"unsigned",
"linelength",
"=",
"0",
";",
"char",
"*",
"p",
";",
"char",
"*",
"p1",
";",
"char",
"*",
"nline",
";",
"int",
"repeat",
"=",
"(",
"instream",
"==",
"stdin",
")",
";",
"if",
"(",
"annotation_level",
">",
"1",
"&&",
"instream",
"==",
"stdin",
")",
"{",
"printf_unfiltered",
"(",
"(",
"\"",
"\\n",
"\\032",
"\\032",
"\"",
")",
")",
";",
"puts_unfiltered",
"(",
"async_annotation_suffix",
")",
";",
"printf_unfiltered",
"(",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"}",
"if",
"(",
"linebuffer",
"==",
"0",
")",
"{",
"linelength",
"=",
"80",
";",
"linebuffer",
"=",
"(",
"char",
"*",
")",
"xmalloc",
"(",
"linelength",
")",
";",
"}",
"p",
"=",
"linebuffer",
";",
"if",
"(",
"more_to_come",
")",
"{",
"strcpy",
"(",
"linebuffer",
",",
"readline_input_state",
".",
"linebuffer",
")",
";",
"p",
"=",
"readline_input_state",
".",
"linebuffer_ptr",
";",
"xfree",
"(",
"readline_input_state",
".",
"linebuffer",
")",
";",
"more_to_come",
"=",
"0",
";",
"}",
"#ifdef",
"STOP_SIGNAL",
"if",
"(",
"job_control",
")",
"signal",
"(",
"STOP_SIGNAL",
",",
"handle_stop_sig",
")",
";",
"#endif",
"wrap_here",
"(",
"\"",
"\"",
")",
";",
"gdb_flush",
"(",
"gdb_stdout",
")",
";",
"gdb_flush",
"(",
"gdb_stderr",
")",
";",
"if",
"(",
"source_file_name",
"!=",
"NULL",
")",
"++",
"source_line_number",
";",
"if",
"(",
"!",
"rl",
"||",
"rl",
"==",
"(",
"char",
"*",
")",
"EOF",
")",
"{",
"command_handler",
"(",
"0",
")",
";",
"return",
";",
"}",
"if",
"(",
"strlen",
"(",
"rl",
")",
"+",
"1",
"+",
"(",
"p",
"-",
"linebuffer",
")",
">",
"linelength",
")",
"{",
"linelength",
"=",
"strlen",
"(",
"rl",
")",
"+",
"1",
"+",
"(",
"p",
"-",
"linebuffer",
")",
";",
"nline",
"=",
"(",
"char",
"*",
")",
"xrealloc",
"(",
"linebuffer",
",",
"linelength",
")",
";",
"p",
"+=",
"nline",
"-",
"linebuffer",
";",
"linebuffer",
"=",
"nline",
";",
"}",
"p1",
"=",
"rl",
";",
"while",
"(",
"*",
"p1",
")",
"*",
"p",
"++",
"=",
"*",
"p1",
"++",
";",
"xfree",
"(",
"rl",
")",
";",
"if",
"(",
"p",
">",
"linebuffer",
"&&",
"*",
"(",
"p",
"-",
"1",
")",
"==",
"'",
"\\\\",
"'",
")",
"{",
"*",
"p",
"=",
"'",
"\\0",
"'",
";",
"p",
"--",
";",
"readline_input_state",
".",
"linebuffer",
"=",
"xstrdup",
"(",
"linebuffer",
")",
";",
"readline_input_state",
".",
"linebuffer_ptr",
"=",
"p",
";",
"more_to_come",
"=",
"1",
";",
"display_gdb_prompt",
"(",
"\"",
"\"",
")",
";",
"return",
";",
"}",
"#ifdef",
"STOP_SIGNAL",
"if",
"(",
"job_control",
")",
"signal",
"(",
"STOP_SIGNAL",
",",
"SIG_DFL",
")",
";",
"#endif",
"#define",
"SERVER_COMMAND_LENGTH",
" 7",
"\n",
"server_command",
"=",
"(",
"p",
"-",
"linebuffer",
">",
"SERVER_COMMAND_LENGTH",
")",
"&&",
"strncmp",
"(",
"linebuffer",
",",
"\"",
"\"",
",",
"SERVER_COMMAND_LENGTH",
")",
"==",
"0",
";",
"if",
"(",
"server_command",
")",
"{",
"*",
"p",
"=",
"'",
"\\0",
"'",
";",
"command_handler",
"(",
"linebuffer",
"+",
"SERVER_COMMAND_LENGTH",
")",
";",
"display_gdb_prompt",
"(",
"0",
")",
";",
"return",
";",
"}",
"if",
"(",
"history_expansion_p",
"&&",
"instream",
"==",
"stdin",
"&&",
"ISATTY",
"(",
"instream",
")",
")",
"{",
"char",
"*",
"history_value",
";",
"int",
"expanded",
";",
"*",
"p",
"=",
"'",
"\\0",
"'",
";",
"expanded",
"=",
"history_expand",
"(",
"linebuffer",
",",
"&",
"history_value",
")",
";",
"if",
"(",
"expanded",
")",
"{",
"printf_unfiltered",
"(",
"\"",
"\\n",
"\"",
",",
"history_value",
")",
";",
"if",
"(",
"expanded",
"<",
"0",
")",
"{",
"xfree",
"(",
"history_value",
")",
";",
"return",
";",
"}",
"if",
"(",
"strlen",
"(",
"history_value",
")",
">",
"linelength",
")",
"{",
"linelength",
"=",
"strlen",
"(",
"history_value",
")",
"+",
"1",
";",
"linebuffer",
"=",
"(",
"char",
"*",
")",
"xrealloc",
"(",
"linebuffer",
",",
"linelength",
")",
";",
"}",
"strcpy",
"(",
"linebuffer",
",",
"history_value",
")",
";",
"p",
"=",
"linebuffer",
"+",
"strlen",
"(",
"linebuffer",
")",
";",
"}",
"xfree",
"(",
"history_value",
")",
";",
"}",
"if",
"(",
"repeat",
"&&",
"p",
"==",
"linebuffer",
"&&",
"*",
"p",
"!=",
"'",
"\\\\",
"'",
")",
"{",
"command_handler",
"(",
"saved_command_line",
")",
";",
"display_gdb_prompt",
"(",
"0",
")",
";",
"return",
";",
"}",
"for",
"(",
"p1",
"=",
"linebuffer",
";",
"*",
"p1",
"==",
"'",
"'",
"||",
"*",
"p1",
"==",
"'",
"\\t",
"'",
";",
"p1",
"++",
")",
";",
"if",
"(",
"repeat",
"&&",
"!",
"*",
"p1",
")",
"{",
"command_handler",
"(",
"saved_command_line",
")",
";",
"display_gdb_prompt",
"(",
"0",
")",
";",
"return",
";",
"}",
"*",
"p",
"=",
"0",
";",
"if",
"(",
"instream",
"==",
"stdin",
"&&",
"ISATTY",
"(",
"stdin",
")",
"&&",
"*",
"linebuffer",
")",
"add_history",
"(",
"linebuffer",
")",
";",
"if",
"(",
"*",
"p1",
"==",
"'",
"'",
")",
"*",
"p1",
"=",
"'",
"\\0",
"'",
";",
"if",
"(",
"repeat",
")",
"{",
"if",
"(",
"linelength",
">",
"saved_command_line_size",
")",
"{",
"saved_command_line",
"=",
"xrealloc",
"(",
"saved_command_line",
",",
"linelength",
")",
";",
"saved_command_line_size",
"=",
"linelength",
";",
"}",
"strcpy",
"(",
"saved_command_line",
",",
"linebuffer",
")",
";",
"if",
"(",
"!",
"more_to_come",
")",
"{",
"command_handler",
"(",
"saved_command_line",
")",
";",
"display_gdb_prompt",
"(",
"0",
")",
";",
"}",
"return",
";",
"}",
"command_handler",
"(",
"linebuffer",
")",
";",
"display_gdb_prompt",
"(",
"0",
")",
";",
"return",
";",
"}"
] | NOTE: 1999-04-30 This is the asynchronous version of the
command_line_input function; command_line_input will become
obsolete once we use the event loop as the default mechanism in
GDB. | [
"NOTE",
":",
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"the",
"command_line_input",
"function",
";",
"command_line_input",
"will",
"become",
"obsolete",
"once",
"we",
"use",
"the",
"event",
"loop",
"as",
"the",
"default",
"mechanism",
"in",
"GDB",
"."
] | [
"/* Make sure that all output has been output. Some machines may let\n you get away with leaving out some of the gdb_flush, but not\n all. */",
"/* If we are in this case, then command_handler will call quit \n and exit from gdb. */",
"/* Lint. */",
"/* Copy line. Don't copy null at end. (Leaves line alone\n if this was just a newline). */",
"/* Allocated in readline. */",
"/* Put on top of '\\'. */",
"/* We will not invoke a execute_command if there is more\n\t input expected to complete the command. So, we need to\n\t print an empty prompt here. */",
"/* Note that we don't set `line'. Between this and the check in\n dont_repeat, this insures that repeating will still do the\n right thing. */",
"/* Do history expansion if that is wished. */",
"/* Insert null now. */",
"/* Print the changes. */",
"/* If there was an error, call this function again. */",
"/* If we just got an empty line, and that is supposed to repeat the\n previous command, return the value in the global buffer. */",
"/* Add line to history if appropriate. */",
"/* Note: lines consisting solely of comments are added to the command\n history. This is useful when you type a command, and then\n realize you don't want to execute it quite yet. You can comment\n out the command and then later fetch it from the value history\n and remove the '#'. The kill ring is probably better, but some\n people are in the habit of commenting things out. */",
"/* Found a comment. */",
"/* Save into global buffer if appropriate. */"
] | [
{
"param": "rl",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rl",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | gdb_readline2 | void | void
gdb_readline2 (gdb_client_data client_data)
{
int c;
char *result;
int input_index = 0;
int result_size = 80;
static int done_once = 0;
/* Unbuffer the input stream, so that, later on, the calls to fgetc
fetch only one char at the time from the stream. The fgetc's will
get up to the first newline, but there may be more chars in the
stream after '\n'. If we buffer the input and fgetc drains the
stream, getting stuff beyond the newline as well, a select, done
afterwards will not trigger. */
if (!done_once && !ISATTY (instream))
{
setbuf (instream, NULL);
done_once = 1;
}
result = (char *) xmalloc (result_size);
/* We still need the while loop here, even though it would seem
obvious to invoke gdb_readline2 at every character entered. If
not using the readline library, the terminal is in cooked mode,
which sends the characters all at once. Poll will notice that the
input fd has changed state only after enter is pressed. At this
point we still need to fetch all the chars entered. */
while (1)
{
/* Read from stdin if we are executing a user defined command.
This is the right thing for prompt_for_continue, at least. */
c = fgetc (instream ? instream : stdin);
if (c == EOF)
{
if (input_index > 0)
/* The last line does not end with a newline. Return it,
and if we are called again fgetc will still return EOF
and we'll return NULL then. */
break;
xfree (result);
(*input_handler) (0);
return;
}
if (c == '\n')
{
if (input_index > 0 && result[input_index - 1] == '\r')
input_index--;
break;
}
result[input_index++] = c;
while (input_index >= result_size)
{
result_size *= 2;
result = (char *) xrealloc (result, result_size);
}
}
result[input_index++] = '\0';
(*input_handler) (result);
} | /* NOTE: 1999-04-30 Asynchronous version of gdb_readline; gdb_readline
will become obsolete when the event loop is made the default
execution for gdb. */ | 1999-04-30 Asynchronous version of gdb_readline; gdb_readline
will become obsolete when the event loop is made the default
execution for gdb. | [
"1999",
"-",
"04",
"-",
"30",
"Asynchronous",
"version",
"of",
"gdb_readline",
";",
"gdb_readline",
"will",
"become",
"obsolete",
"when",
"the",
"event",
"loop",
"is",
"made",
"the",
"default",
"execution",
"for",
"gdb",
"."
] | void
gdb_readline2 (gdb_client_data client_data)
{
int c;
char *result;
int input_index = 0;
int result_size = 80;
static int done_once = 0;
if (!done_once && !ISATTY (instream))
{
setbuf (instream, NULL);
done_once = 1;
}
result = (char *) xmalloc (result_size);
while (1)
{
c = fgetc (instream ? instream : stdin);
if (c == EOF)
{
if (input_index > 0)
break;
xfree (result);
(*input_handler) (0);
return;
}
if (c == '\n')
{
if (input_index > 0 && result[input_index - 1] == '\r')
input_index--;
break;
}
result[input_index++] = c;
while (input_index >= result_size)
{
result_size *= 2;
result = (char *) xrealloc (result, result_size);
}
}
result[input_index++] = '\0';
(*input_handler) (result);
} | [
"void",
"gdb_readline2",
"(",
"gdb_client_data",
"client_data",
")",
"{",
"int",
"c",
";",
"char",
"*",
"result",
";",
"int",
"input_index",
"=",
"0",
";",
"int",
"result_size",
"=",
"80",
";",
"static",
"int",
"done_once",
"=",
"0",
";",
"if",
"(",
"!",
"done_once",
"&&",
"!",
"ISATTY",
"(",
"instream",
")",
")",
"{",
"setbuf",
"(",
"instream",
",",
"NULL",
")",
";",
"done_once",
"=",
"1",
";",
"}",
"result",
"=",
"(",
"char",
"*",
")",
"xmalloc",
"(",
"result_size",
")",
";",
"while",
"(",
"1",
")",
"{",
"c",
"=",
"fgetc",
"(",
"instream",
"?",
"instream",
":",
"stdin",
")",
";",
"if",
"(",
"c",
"==",
"EOF",
")",
"{",
"if",
"(",
"input_index",
">",
"0",
")",
"break",
";",
"xfree",
"(",
"result",
")",
";",
"(",
"*",
"input_handler",
")",
"(",
"0",
")",
";",
"return",
";",
"}",
"if",
"(",
"c",
"==",
"'",
"\\n",
"'",
")",
"{",
"if",
"(",
"input_index",
">",
"0",
"&&",
"result",
"[",
"input_index",
"-",
"1",
"]",
"==",
"'",
"\\r",
"'",
")",
"input_index",
"--",
";",
"break",
";",
"}",
"result",
"[",
"input_index",
"++",
"]",
"=",
"c",
";",
"while",
"(",
"input_index",
">=",
"result_size",
")",
"{",
"result_size",
"*=",
"2",
";",
"result",
"=",
"(",
"char",
"*",
")",
"xrealloc",
"(",
"result",
",",
"result_size",
")",
";",
"}",
"}",
"result",
"[",
"input_index",
"++",
"]",
"=",
"'",
"\\0",
"'",
";",
"(",
"*",
"input_handler",
")",
"(",
"result",
")",
";",
"}"
] | NOTE: 1999-04-30 Asynchronous version of gdb_readline; gdb_readline
will become obsolete when the event loop is made the default
execution for gdb. | [
"NOTE",
":",
"1999",
"-",
"04",
"-",
"30",
"Asynchronous",
"version",
"of",
"gdb_readline",
";",
"gdb_readline",
"will",
"become",
"obsolete",
"when",
"the",
"event",
"loop",
"is",
"made",
"the",
"default",
"execution",
"for",
"gdb",
"."
] | [
"/* Unbuffer the input stream, so that, later on, the calls to fgetc\n fetch only one char at the time from the stream. The fgetc's will\n get up to the first newline, but there may be more chars in the\n stream after '\\n'. If we buffer the input and fgetc drains the\n stream, getting stuff beyond the newline as well, a select, done\n afterwards will not trigger. */",
"/* We still need the while loop here, even though it would seem\n obvious to invoke gdb_readline2 at every character entered. If\n not using the readline library, the terminal is in cooked mode,\n which sends the characters all at once. Poll will notice that the\n input fd has changed state only after enter is pressed. At this\n point we still need to fetch all the chars entered. */",
"/* Read from stdin if we are executing a user defined command.\n This is the right thing for prompt_for_continue, at least. */",
"/* The last line does not end with a newline. Return it,\n\t and if we are called again fgetc will still return EOF\n\t and we'll return NULL then. */"
] | [
{
"param": "client_data",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "client_data",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_init_signals | void | void
async_init_signals (void)
{
signal (SIGINT, handle_sigint);
sigint_token =
create_async_signal_handler (async_request_quit, NULL);
signal (SIGTERM, handle_sigterm);
/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed
to the inferior and breakpoints will be ignored. */
#ifdef SIGTRAP
signal (SIGTRAP, SIG_DFL);
#endif
#ifdef SIGQUIT
/* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get
passed to the inferior, which we don't want. It would be
possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but
on BSD4.3 systems using vfork, that can affect the
GDB process as well as the inferior (the signal handling tables
might be in memory, shared between the two). Since we establish
a handler for SIGQUIT, when we call exec it will set the signal
to SIG_DFL for us. */
signal (SIGQUIT, handle_sigquit);
sigquit_token =
create_async_signal_handler (async_do_nothing, NULL);
#endif
#ifdef SIGHUP
if (signal (SIGHUP, handle_sighup) != SIG_IGN)
sighup_token =
create_async_signal_handler (async_disconnect, NULL);
else
sighup_token =
create_async_signal_handler (async_do_nothing, NULL);
#endif
signal (SIGFPE, handle_sigfpe);
sigfpe_token =
create_async_signal_handler (async_float_handler, NULL);
#ifdef STOP_SIGNAL
sigtstp_token =
create_async_signal_handler (async_stop_sig, NULL);
#endif
} | /* NOTE: 1999-04-30 This is the asynchronous version of init_signals.
init_signals will become obsolete as we move to have to event loop
as the default for gdb. */ | 1999-04-30 This is the asynchronous version of init_signals.
init_signals will become obsolete as we move to have to event loop
as the default for gdb. | [
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"init_signals",
".",
"init_signals",
"will",
"become",
"obsolete",
"as",
"we",
"move",
"to",
"have",
"to",
"event",
"loop",
"as",
"the",
"default",
"for",
"gdb",
"."
] | void
async_init_signals (void)
{
signal (SIGINT, handle_sigint);
sigint_token =
create_async_signal_handler (async_request_quit, NULL);
signal (SIGTERM, handle_sigterm);
#ifdef SIGTRAP
signal (SIGTRAP, SIG_DFL);
#endif
#ifdef SIGQUIT
signal (SIGQUIT, handle_sigquit);
sigquit_token =
create_async_signal_handler (async_do_nothing, NULL);
#endif
#ifdef SIGHUP
if (signal (SIGHUP, handle_sighup) != SIG_IGN)
sighup_token =
create_async_signal_handler (async_disconnect, NULL);
else
sighup_token =
create_async_signal_handler (async_do_nothing, NULL);
#endif
signal (SIGFPE, handle_sigfpe);
sigfpe_token =
create_async_signal_handler (async_float_handler, NULL);
#ifdef STOP_SIGNAL
sigtstp_token =
create_async_signal_handler (async_stop_sig, NULL);
#endif
} | [
"void",
"async_init_signals",
"(",
"void",
")",
"{",
"signal",
"(",
"SIGINT",
",",
"handle_sigint",
")",
";",
"sigint_token",
"=",
"create_async_signal_handler",
"(",
"async_request_quit",
",",
"NULL",
")",
";",
"signal",
"(",
"SIGTERM",
",",
"handle_sigterm",
")",
";",
"#ifdef",
"SIGTRAP",
"signal",
"(",
"SIGTRAP",
",",
"SIG_DFL",
")",
";",
"#endif",
"#ifdef",
"SIGQUIT",
"signal",
"(",
"SIGQUIT",
",",
"handle_sigquit",
")",
";",
"sigquit_token",
"=",
"create_async_signal_handler",
"(",
"async_do_nothing",
",",
"NULL",
")",
";",
"#endif",
"#ifdef",
"SIGHUP",
"if",
"(",
"signal",
"(",
"SIGHUP",
",",
"handle_sighup",
")",
"!=",
"SIG_IGN",
")",
"sighup_token",
"=",
"create_async_signal_handler",
"(",
"async_disconnect",
",",
"NULL",
")",
";",
"else",
"sighup_token",
"=",
"create_async_signal_handler",
"(",
"async_do_nothing",
",",
"NULL",
")",
";",
"#endif",
"signal",
"(",
"SIGFPE",
",",
"handle_sigfpe",
")",
";",
"sigfpe_token",
"=",
"create_async_signal_handler",
"(",
"async_float_handler",
",",
"NULL",
")",
";",
"#ifdef",
"STOP_SIGNAL",
"sigtstp_token",
"=",
"create_async_signal_handler",
"(",
"async_stop_sig",
",",
"NULL",
")",
";",
"#endif",
"}"
] | NOTE: 1999-04-30 This is the asynchronous version of init_signals. | [
"NOTE",
":",
"1999",
"-",
"04",
"-",
"30",
"This",
"is",
"the",
"asynchronous",
"version",
"of",
"init_signals",
"."
] | [
"/* If SIGTRAP was set to SIG_IGN, then the SIG_IGN will get passed\n to the inferior and breakpoints will be ignored. */",
"/* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get\n passed to the inferior, which we don't want. It would be\n possible to do a \"signal (SIGQUIT, SIG_DFL)\" after we fork, but\n on BSD4.3 systems using vfork, that can affect the\n GDB process as well as the inferior (the signal handling tables\n might be in memory, shared between the two). Since we establish\n a handler for SIGQUIT, when we call exec it will set the signal\n to SIG_DFL for us. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | handle_sigint | void | void
handle_sigint (int sig)
{
signal (sig, handle_sigint);
/* We could be running in a loop reading in symfiles or something so
it may be quite a while before we get back to the event loop. So
set quit_flag to 1 here. Then if QUIT is called before we get to
the event loop, we will unwind as expected. */
set_quit_flag ();
/* If immediate_quit is set, we go ahead and process the SIGINT right
away, even if we usually would defer this to the event loop. The
assumption here is that it is safe to process ^C immediately if
immediate_quit is set. If we didn't, SIGINT would be really
processed only the next time through the event loop. To get to
that point, though, the command that we want to interrupt needs to
finish first, which is unacceptable. If immediate quit is not set,
we process SIGINT the next time through the loop, which is fine. */
gdb_call_async_signal_handler (sigint_token, immediate_quit);
} | /* Tell the event loop what to do if SIGINT is received.
See event-signal.c. */ | Tell the event loop what to do if SIGINT is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGINT",
"is",
"received",
"."
] | void
handle_sigint (int sig)
{
signal (sig, handle_sigint);
set_quit_flag ();
gdb_call_async_signal_handler (sigint_token, immediate_quit);
} | [
"void",
"handle_sigint",
"(",
"int",
"sig",
")",
"{",
"signal",
"(",
"sig",
",",
"handle_sigint",
")",
";",
"set_quit_flag",
"(",
")",
";",
"gdb_call_async_signal_handler",
"(",
"sigint_token",
",",
"immediate_quit",
")",
";",
"}"
] | Tell the event loop what to do if SIGINT is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGINT",
"is",
"received",
"."
] | [
"/* We could be running in a loop reading in symfiles or something so\n it may be quite a while before we get back to the event loop. So\n set quit_flag to 1 here. Then if QUIT is called before we get to\n the event loop, we will unwind as expected. */",
"/* If immediate_quit is set, we go ahead and process the SIGINT right\n away, even if we usually would defer this to the event loop. The\n assumption here is that it is safe to process ^C immediately if\n immediate_quit is set. If we didn't, SIGINT would be really\n processed only the next time through the event loop. To get to\n that point, though, the command that we want to interrupt needs to\n finish first, which is unacceptable. If immediate quit is not set,\n we process SIGINT the next time through the loop, which is fine. */"
] | [
{
"param": "sig",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sig",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | handle_sigterm | void | void
handle_sigterm (int sig)
{
signal (sig, handle_sigterm);
quit_force ((char *) 0, stdin == instream);
} | /* Quit GDB if SIGTERM is received.
GDB would quit anyway, but this way it will clean up properly. */ | Quit GDB if SIGTERM is received.
GDB would quit anyway, but this way it will clean up properly. | [
"Quit",
"GDB",
"if",
"SIGTERM",
"is",
"received",
".",
"GDB",
"would",
"quit",
"anyway",
"but",
"this",
"way",
"it",
"will",
"clean",
"up",
"properly",
"."
] | void
handle_sigterm (int sig)
{
signal (sig, handle_sigterm);
quit_force ((char *) 0, stdin == instream);
} | [
"void",
"handle_sigterm",
"(",
"int",
"sig",
")",
"{",
"signal",
"(",
"sig",
",",
"handle_sigterm",
")",
";",
"quit_force",
"(",
"(",
"char",
"*",
")",
"0",
",",
"stdin",
"==",
"instream",
")",
";",
"}"
] | Quit GDB if SIGTERM is received. | [
"Quit",
"GDB",
"if",
"SIGTERM",
"is",
"received",
"."
] | [] | [
{
"param": "sig",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sig",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_request_quit | void | void
async_request_quit (gdb_client_data arg)
{
/* If the quit_flag has gotten reset back to 0 by the time we get
back here, that means that an exception was thrown to unwind the
current command before we got back to the event loop. So there
is no reason to call quit again here. */
if (check_quit_flag ())
quit ();
} | /* Do the quit. All the checks have been done by the caller. */ | Do the quit. All the checks have been done by the caller. | [
"Do",
"the",
"quit",
".",
"All",
"the",
"checks",
"have",
"been",
"done",
"by",
"the",
"caller",
"."
] | void
async_request_quit (gdb_client_data arg)
{
if (check_quit_flag ())
quit ();
} | [
"void",
"async_request_quit",
"(",
"gdb_client_data",
"arg",
")",
"{",
"if",
"(",
"check_quit_flag",
"(",
")",
")",
"quit",
"(",
")",
";",
"}"
] | Do the quit. | [
"Do",
"the",
"quit",
"."
] | [
"/* If the quit_flag has gotten reset back to 0 by the time we get\n back here, that means that an exception was thrown to unwind the\n current command before we got back to the event loop. So there\n is no reason to call quit again here. */"
] | [
{
"param": "arg",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | handle_sigquit | void | static void
handle_sigquit (int sig)
{
mark_async_signal_handler (sigquit_token);
signal (sig, handle_sigquit);
} | /* Tell the event loop what to do if SIGQUIT is received.
See event-signal.c. */ | Tell the event loop what to do if SIGQUIT is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGQUIT",
"is",
"received",
"."
] | static void
handle_sigquit (int sig)
{
mark_async_signal_handler (sigquit_token);
signal (sig, handle_sigquit);
} | [
"static",
"void",
"handle_sigquit",
"(",
"int",
"sig",
")",
"{",
"mark_async_signal_handler",
"(",
"sigquit_token",
")",
";",
"signal",
"(",
"sig",
",",
"handle_sigquit",
")",
";",
"}"
] | Tell the event loop what to do if SIGQUIT is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGQUIT",
"is",
"received",
"."
] | [] | [
{
"param": "sig",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sig",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_do_nothing | void | static void
async_do_nothing (gdb_client_data arg)
{
/* Empty function body. */
} | /* Called by the event loop in response to a SIGQUIT or an
ignored SIGHUP. */ | Called by the event loop in response to a SIGQUIT or an
ignored SIGHUP. | [
"Called",
"by",
"the",
"event",
"loop",
"in",
"response",
"to",
"a",
"SIGQUIT",
"or",
"an",
"ignored",
"SIGHUP",
"."
] | static void
async_do_nothing (gdb_client_data arg)
{
} | [
"static",
"void",
"async_do_nothing",
"(",
"gdb_client_data",
"arg",
")",
"{",
"}"
] | Called by the event loop in response to a SIGQUIT or an
ignored SIGHUP. | [
"Called",
"by",
"the",
"event",
"loop",
"in",
"response",
"to",
"a",
"SIGQUIT",
"or",
"an",
"ignored",
"SIGHUP",
"."
] | [
"/* Empty function body. */"
] | [
{
"param": "arg",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | handle_sighup | void | static void
handle_sighup (int sig)
{
mark_async_signal_handler (sighup_token);
signal (sig, handle_sighup);
} | /* Tell the event loop what to do if SIGHUP is received.
See event-signal.c. */ | Tell the event loop what to do if SIGHUP is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGHUP",
"is",
"received",
"."
] | static void
handle_sighup (int sig)
{
mark_async_signal_handler (sighup_token);
signal (sig, handle_sighup);
} | [
"static",
"void",
"handle_sighup",
"(",
"int",
"sig",
")",
"{",
"mark_async_signal_handler",
"(",
"sighup_token",
")",
";",
"signal",
"(",
"sig",
",",
"handle_sighup",
")",
";",
"}"
] | Tell the event loop what to do if SIGHUP is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGHUP",
"is",
"received",
"."
] | [] | [
{
"param": "sig",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sig",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | async_disconnect | void | static void
async_disconnect (gdb_client_data arg)
{
volatile struct gdb_exception exception;
TRY_CATCH (exception, RETURN_MASK_ALL)
{
quit_cover ();
}
if (exception.reason < 0)
{
fputs_filtered ("Could not kill the program being debugged",
gdb_stderr);
exception_print (gdb_stderr, exception);
}
TRY_CATCH (exception, RETURN_MASK_ALL)
{
pop_all_targets (1);
}
signal (SIGHUP, SIG_DFL); /*FIXME: ??????????? */
raise (SIGHUP);
} | /* Called by the event loop to process a SIGHUP. */ | Called by the event loop to process a SIGHUP. | [
"Called",
"by",
"the",
"event",
"loop",
"to",
"process",
"a",
"SIGHUP",
"."
] | static void
async_disconnect (gdb_client_data arg)
{
volatile struct gdb_exception exception;
TRY_CATCH (exception, RETURN_MASK_ALL)
{
quit_cover ();
}
if (exception.reason < 0)
{
fputs_filtered ("Could not kill the program being debugged",
gdb_stderr);
exception_print (gdb_stderr, exception);
}
TRY_CATCH (exception, RETURN_MASK_ALL)
{
pop_all_targets (1);
}
signal (SIGHUP, SIG_DFL);
raise (SIGHUP);
} | [
"static",
"void",
"async_disconnect",
"(",
"gdb_client_data",
"arg",
")",
"{",
"volatile",
"struct",
"gdb_exception",
"exception",
";",
"TRY_CATCH",
"(",
"exception",
",",
"RETURN_MASK_ALL",
")",
"",
"{",
"quit_cover",
"(",
")",
";",
"}",
"if",
"(",
"exception",
".",
"reason",
"<",
"0",
")",
"{",
"fputs_filtered",
"(",
"\"",
"\"",
",",
"gdb_stderr",
")",
";",
"exception_print",
"(",
"gdb_stderr",
",",
"exception",
")",
";",
"}",
"TRY_CATCH",
"(",
"exception",
",",
"RETURN_MASK_ALL",
")",
"",
"{",
"pop_all_targets",
"(",
"1",
")",
";",
"}",
"signal",
"(",
"SIGHUP",
",",
"SIG_DFL",
")",
";",
"raise",
"(",
"SIGHUP",
")",
";",
"}"
] | Called by the event loop to process a SIGHUP. | [
"Called",
"by",
"the",
"event",
"loop",
"to",
"process",
"a",
"SIGHUP",
"."
] | [
"/*FIXME: ??????????? */"
] | [
{
"param": "arg",
"type": "gdb_client_data"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arg",
"type": "gdb_client_data",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | handle_sigfpe | void | static void
handle_sigfpe (int sig)
{
mark_async_signal_handler (sigfpe_token);
signal (sig, handle_sigfpe);
} | /* Tell the event loop what to do if SIGFPE is received.
See event-signal.c. */ | Tell the event loop what to do if SIGFPE is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGFPE",
"is",
"received",
"."
] | static void
handle_sigfpe (int sig)
{
mark_async_signal_handler (sigfpe_token);
signal (sig, handle_sigfpe);
} | [
"static",
"void",
"handle_sigfpe",
"(",
"int",
"sig",
")",
"{",
"mark_async_signal_handler",
"(",
"sigfpe_token",
")",
";",
"signal",
"(",
"sig",
",",
"handle_sigfpe",
")",
";",
"}"
] | Tell the event loop what to do if SIGFPE is received. | [
"Tell",
"the",
"event",
"loop",
"what",
"to",
"do",
"if",
"SIGFPE",
"is",
"received",
"."
] | [] | [
{
"param": "sig",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sig",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | gdb_setup_readline | void | void
gdb_setup_readline (void)
{
/* This function is a noop for the sync case. The assumption is
that the sync setup is ALL done in gdb_init, and we would only
mess it up here. The sync stuff should really go away over
time. */
if (!batch_silent)
gdb_stdout = stdio_fileopen (stdout);
gdb_stderr = stdio_fileopen (stderr);
gdb_stdlog = gdb_stderr; /* for moment */
gdb_stdtarg = gdb_stderr; /* for moment */
gdb_stdtargerr = gdb_stderr; /* for moment */
/* If the input stream is connected to a terminal, turn on
editing. */
if (ISATTY (instream))
{
/* Tell gdb that we will be using the readline library. This
could be overwritten by a command in .gdbinit like 'set
editing on' or 'off'. */
async_command_editing_p = 1;
/* When a character is detected on instream by select or poll,
readline will be invoked via this callback function. */
call_readline = rl_callback_read_char_wrapper;
}
else
{
async_command_editing_p = 0;
call_readline = gdb_readline2;
}
/* When readline has read an end-of-line character, it passes the
complete line to gdb for processing; command_line_handler is the
function that does this. */
input_handler = command_line_handler;
/* Tell readline to use the same input stream that gdb uses. */
rl_instream = instream;
/* Get a file descriptor for the input stream, so that we can
register it with the event loop. */
input_fd = fileno (instream);
/* Now we need to create the event sources for the input file
descriptor. */
/* At this point in time, this is the only event source that we
register with the even loop. Another source is going to be the
target program (inferior), but that must be registered only when
it actually exists (I.e. after we say 'run' or after we connect
to a remote target. */
add_file_handler (input_fd, stdin_event_handler, 0);
} | /* Set things up for readline to be invoked via the alternate
interface, i.e. via a callback function (rl_callback_read_char),
and hook up instream to the event loop. */ | Set things up for readline to be invoked via the alternate
interface, i.e. via a callback function (rl_callback_read_char),
and hook up instream to the event loop. | [
"Set",
"things",
"up",
"for",
"readline",
"to",
"be",
"invoked",
"via",
"the",
"alternate",
"interface",
"i",
".",
"e",
".",
"via",
"a",
"callback",
"function",
"(",
"rl_callback_read_char",
")",
"and",
"hook",
"up",
"instream",
"to",
"the",
"event",
"loop",
"."
] | void
gdb_setup_readline (void)
{
if (!batch_silent)
gdb_stdout = stdio_fileopen (stdout);
gdb_stderr = stdio_fileopen (stderr);
gdb_stdlog = gdb_stderr;
gdb_stdtarg = gdb_stderr;
gdb_stdtargerr = gdb_stderr;
if (ISATTY (instream))
{
async_command_editing_p = 1;
call_readline = rl_callback_read_char_wrapper;
}
else
{
async_command_editing_p = 0;
call_readline = gdb_readline2;
}
input_handler = command_line_handler;
rl_instream = instream;
input_fd = fileno (instream);
add_file_handler (input_fd, stdin_event_handler, 0);
} | [
"void",
"gdb_setup_readline",
"(",
"void",
")",
"{",
"if",
"(",
"!",
"batch_silent",
")",
"gdb_stdout",
"=",
"stdio_fileopen",
"(",
"stdout",
")",
";",
"gdb_stderr",
"=",
"stdio_fileopen",
"(",
"stderr",
")",
";",
"gdb_stdlog",
"=",
"gdb_stderr",
";",
"gdb_stdtarg",
"=",
"gdb_stderr",
";",
"gdb_stdtargerr",
"=",
"gdb_stderr",
";",
"if",
"(",
"ISATTY",
"(",
"instream",
")",
")",
"{",
"async_command_editing_p",
"=",
"1",
";",
"call_readline",
"=",
"rl_callback_read_char_wrapper",
";",
"}",
"else",
"{",
"async_command_editing_p",
"=",
"0",
";",
"call_readline",
"=",
"gdb_readline2",
";",
"}",
"input_handler",
"=",
"command_line_handler",
";",
"rl_instream",
"=",
"instream",
";",
"input_fd",
"=",
"fileno",
"(",
"instream",
")",
";",
"add_file_handler",
"(",
"input_fd",
",",
"stdin_event_handler",
",",
"0",
")",
";",
"}"
] | Set things up for readline to be invoked via the alternate
interface, i.e. | [
"Set",
"things",
"up",
"for",
"readline",
"to",
"be",
"invoked",
"via",
"the",
"alternate",
"interface",
"i",
".",
"e",
"."
] | [
"/* This function is a noop for the sync case. The assumption is\n that the sync setup is ALL done in gdb_init, and we would only\n mess it up here. The sync stuff should really go away over\n time. */",
"/* for moment */",
"/* for moment */",
"/* for moment */",
"/* If the input stream is connected to a terminal, turn on\n editing. */",
"/* Tell gdb that we will be using the readline library. This\n\t could be overwritten by a command in .gdbinit like 'set\n\t editing on' or 'off'. */",
"/* When a character is detected on instream by select or poll,\n\t readline will be invoked via this callback function. */",
"/* When readline has read an end-of-line character, it passes the\n complete line to gdb for processing; command_line_handler is the\n function that does this. */",
"/* Tell readline to use the same input stream that gdb uses. */",
"/* Get a file descriptor for the input stream, so that we can\n register it with the event loop. */",
"/* Now we need to create the event sources for the input file\n descriptor. */",
"/* At this point in time, this is the only event source that we\n register with the even loop. Another source is going to be the\n target program (inferior), but that must be registered only when\n it actually exists (I.e. after we say 'run' or after we connect\n to a remote target. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6f3dfab55e3c8889ec9043045cc237b3ab552a38 | atrens/DragonFlyBSD-src | contrib/gdb-7/gdb/event-top.c | [
"BSD-3-Clause"
] | C | gdb_disable_readline | void | void
gdb_disable_readline (void)
{
/* FIXME - It is too heavyweight to delete and remake these every
time you run an interpreter that needs readline. It is probably
better to have the interpreters cache these, which in turn means
that this needs to be moved into interpreter specific code. */
#if 0
ui_file_delete (gdb_stdout);
ui_file_delete (gdb_stderr);
gdb_stdlog = NULL;
gdb_stdtarg = NULL;
gdb_stdtargerr = NULL;
#endif
rl_callback_handler_remove ();
delete_file_handler (input_fd);
} | /* Disable command input through the standard CLI channels. Used in
the suspend proc for interpreters that use the standard gdb readline
interface, like the cli & the mi. */ | Disable command input through the standard CLI channels. Used in
the suspend proc for interpreters that use the standard gdb readline
interface, like the cli & the mi. | [
"Disable",
"command",
"input",
"through",
"the",
"standard",
"CLI",
"channels",
".",
"Used",
"in",
"the",
"suspend",
"proc",
"for",
"interpreters",
"that",
"use",
"the",
"standard",
"gdb",
"readline",
"interface",
"like",
"the",
"cli",
"&",
"the",
"mi",
"."
] | void
gdb_disable_readline (void)
{
#if 0
ui_file_delete (gdb_stdout);
ui_file_delete (gdb_stderr);
gdb_stdlog = NULL;
gdb_stdtarg = NULL;
gdb_stdtargerr = NULL;
#endif
rl_callback_handler_remove ();
delete_file_handler (input_fd);
} | [
"void",
"gdb_disable_readline",
"(",
"void",
")",
"{",
"#if",
"0",
"\n",
"ui_file_delete",
"(",
"gdb_stdout",
")",
";",
"ui_file_delete",
"(",
"gdb_stderr",
")",
";",
"gdb_stdlog",
"=",
"NULL",
";",
"gdb_stdtarg",
"=",
"NULL",
";",
"gdb_stdtargerr",
"=",
"NULL",
";",
"#endif",
"rl_callback_handler_remove",
"(",
")",
";",
"delete_file_handler",
"(",
"input_fd",
")",
";",
"}"
] | Disable command input through the standard CLI channels. | [
"Disable",
"command",
"input",
"through",
"the",
"standard",
"CLI",
"channels",
"."
] | [
"/* FIXME - It is too heavyweight to delete and remake these every\n time you run an interpreter that needs readline. It is probably\n better to have the interpreters cache these, which in turn means\n that this needs to be moved into interpreter specific code. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | newstr | char | static
char *
newstr(const char *s)
{
void *r;
if (!strtab)
strtab = symtab_new();
if ((r = symtab_find(strtab, s)))
return r;
if (!(r = strdup(s)))
return r;
symtab_insert(strtab, r, r);
return r;
} | /*
* We keep track of strings we've seen before so string comparison
* can be done w/ a simple pointer comparison
*/ | We keep track of strings we've seen before so string comparison
can be done w/ a simple pointer comparison | [
"We",
"keep",
"track",
"of",
"strings",
"we",
"'",
"ve",
"seen",
"before",
"so",
"string",
"comparison",
"can",
"be",
"done",
"w",
"/",
"a",
"simple",
"pointer",
"comparison"
] | static
char *
newstr(const char *s)
{
void *r;
if (!strtab)
strtab = symtab_new();
if ((r = symtab_find(strtab, s)))
return r;
if (!(r = strdup(s)))
return r;
symtab_insert(strtab, r, r);
return r;
} | [
"static",
"char",
"*",
"newstr",
"(",
"const",
"char",
"*",
"s",
")",
"{",
"void",
"*",
"r",
";",
"if",
"(",
"!",
"strtab",
")",
"strtab",
"=",
"symtab_new",
"(",
")",
";",
"if",
"(",
"(",
"r",
"=",
"symtab_find",
"(",
"strtab",
",",
"s",
")",
")",
")",
"return",
"r",
";",
"if",
"(",
"!",
"(",
"r",
"=",
"strdup",
"(",
"s",
")",
")",
")",
"return",
"r",
";",
"symtab_insert",
"(",
"strtab",
",",
"r",
",",
"r",
")",
";",
"return",
"r",
";",
"}"
] | We keep track of strings we've seen before so string comparison
can be done w/ a simple pointer comparison | [
"We",
"keep",
"track",
"of",
"strings",
"we",
"'",
"ve",
"seen",
"before",
"so",
"string",
"comparison",
"can",
"be",
"done",
"w",
"/",
"a",
"simple",
"pointer",
"comparison"
] | [] | [
{
"param": "s",
"type": "char"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | yy_get_previous_state | yy_state_type | static yy_state_type yy_get_previous_state (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 26 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
} | /* yy_get_previous_state - get the state just before the EOB char was reached */ | get the state just before the EOB char was reached | [
"get",
"the",
"state",
"just",
"before",
"the",
"EOB",
"char",
"was",
"reached"
] | static yy_state_type yy_get_previous_state (void)
{
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 26 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
} | [
"static",
"yy_state_type",
"yy_get_previous_state",
"(",
"void",
")",
"{",
"register",
"yy_state_type",
"yy_current_state",
";",
"register",
"char",
"*",
"yy_cp",
";",
"yy_current_state",
"=",
"(",
"yy_start",
")",
";",
"for",
"(",
"yy_cp",
"=",
"(",
"yytext_ptr",
")",
"+",
"YY_MORE_ADJ",
";",
"yy_cp",
"<",
"(",
"yy_c_buf_p",
")",
";",
"++",
"yy_cp",
")",
"{",
"register",
"YY_CHAR",
"yy_c",
"=",
"(",
"*",
"yy_cp",
"?",
"yy_ec",
"[",
"YY_SC_TO_UI",
"(",
"*",
"yy_cp",
")",
"]",
":",
"1",
")",
";",
"if",
"(",
"yy_accept",
"[",
"yy_current_state",
"]",
")",
"{",
"(",
"yy_last_accepting_state",
")",
"=",
"yy_current_state",
";",
"(",
"yy_last_accepting_cpos",
")",
"=",
"yy_cp",
";",
"}",
"while",
"(",
"yy_chk",
"[",
"yy_base",
"[",
"yy_current_state",
"]",
"+",
"yy_c",
"]",
"!=",
"yy_current_state",
")",
"{",
"yy_current_state",
"=",
"(",
"int",
")",
"yy_def",
"[",
"yy_current_state",
"]",
";",
"if",
"(",
"yy_current_state",
">=",
"26",
")",
"yy_c",
"=",
"yy_meta",
"[",
"(",
"unsigned",
"int",
")",
"yy_c",
"]",
";",
"}",
"yy_current_state",
"=",
"yy_nxt",
"[",
"yy_base",
"[",
"yy_current_state",
"]",
"+",
"(",
"unsigned",
"int",
")",
"yy_c",
"]",
";",
"}",
"return",
"yy_current_state",
";",
"}"
] | yy_get_previous_state - get the state just before the EOB char was reached | [
"yy_get_previous_state",
"-",
"get",
"the",
"state",
"just",
"before",
"the",
"EOB",
"char",
"was",
"reached"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtrestart | void | void __ktrfmtrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
__ktrfmtensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
__ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE );
}
__ktrfmt_init_buffer(YY_CURRENT_BUFFER,input_file );
__ktrfmt_load_buffer_state( );
} | /** Immediately switch to a different input stream.
* @param input_file A readable stream.
*
* @note This function does not reset the start condition to @c INITIAL .
*/ | Immediately switch to a different input stream.
@param input_file A readable stream.
@note This function does not reset the start condition to @c INITIAL . | [
"Immediately",
"switch",
"to",
"a",
"different",
"input",
"stream",
".",
"@param",
"input_file",
"A",
"readable",
"stream",
".",
"@note",
"This",
"function",
"does",
"not",
"reset",
"the",
"start",
"condition",
"to",
"@c",
"INITIAL",
"."
] | void __ktrfmtrestart (FILE * input_file )
{
if ( ! YY_CURRENT_BUFFER ){
__ktrfmtensure_buffer_stack ();
YY_CURRENT_BUFFER_LVALUE =
__ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE );
}
__ktrfmt_init_buffer(YY_CURRENT_BUFFER,input_file );
__ktrfmt_load_buffer_state( );
} | [
"void",
"__ktrfmtrestart",
"(",
"FILE",
"*",
"input_file",
")",
"{",
"if",
"(",
"!",
"YY_CURRENT_BUFFER",
")",
"{",
"__ktrfmtensure_buffer_stack",
"(",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"=",
"__ktrfmt_create_buffer",
"(",
"__ktrfmtin",
",",
"YY_BUF_SIZE",
")",
";",
"}",
"__ktrfmt_init_buffer",
"(",
"YY_CURRENT_BUFFER",
",",
"input_file",
")",
";",
"__ktrfmt_load_buffer_state",
"(",
")",
";",
"}"
] | Immediately switch to a different input stream. | [
"Immediately",
"switch",
"to",
"a",
"different",
"input",
"stream",
"."
] | [] | [
{
"param": "input_file",
"type": "FILE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmt_switch_to_buffer | void | void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
/* TODO. We should be able to replace this entire function body
* with
* __ktrfmtpop_buffer_state();
* __ktrfmtpush_buffer_state(new_buffer);
*/
__ktrfmtensure_buffer_stack ();
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
__ktrfmt_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (__ktrfmtwrap()) processing, but the only time this flag
* is looked at is after __ktrfmtwrap() is called, so it's safe
* to go ahead and always set it.
*/
(yy_did_buffer_switch_on_eof) = 1;
} | /** Switch to a different input buffer.
* @param new_buffer The new input buffer.
*
*/ | Switch to a different input buffer.
@param new_buffer The new input buffer. | [
"Switch",
"to",
"a",
"different",
"input",
"buffer",
".",
"@param",
"new_buffer",
"The",
"new",
"input",
"buffer",
"."
] | void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer )
{
__ktrfmtensure_buffer_stack ();
if ( YY_CURRENT_BUFFER == new_buffer )
return;
if ( YY_CURRENT_BUFFER )
{
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
__ktrfmt_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
} | [
"void",
"__ktrfmt_switch_to_buffer",
"(",
"YY_BUFFER_STATE",
"new_buffer",
")",
"{",
"__ktrfmtensure_buffer_stack",
"(",
")",
";",
"if",
"(",
"YY_CURRENT_BUFFER",
"==",
"new_buffer",
")",
"return",
";",
"if",
"(",
"YY_CURRENT_BUFFER",
")",
"{",
"*",
"(",
"yy_c_buf_p",
")",
"=",
"(",
"yy_hold_char",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"->",
"yy_buf_pos",
"=",
"(",
"yy_c_buf_p",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"->",
"yy_n_chars",
"=",
"(",
"yy_n_chars",
")",
";",
"}",
"YY_CURRENT_BUFFER_LVALUE",
"=",
"new_buffer",
";",
"__ktrfmt_load_buffer_state",
"(",
")",
";",
"(",
"yy_did_buffer_switch_on_eof",
")",
"=",
"1",
";",
"}"
] | Switch to a different input buffer. | [
"Switch",
"to",
"a",
"different",
"input",
"buffer",
"."
] | [
"/* TODO. We should be able to replace this entire function body\n\t * with\n\t *\t\t__ktrfmtpop_buffer_state();\n\t *\t\t__ktrfmtpush_buffer_state(new_buffer);\n */",
"/* Flush out information for old buffer. */",
"/* We don't actually know whether we did this switch during\n\t * EOF (__ktrfmtwrap()) processing, but the only time this flag\n\t * is looked at is after __ktrfmtwrap() is called, so it's safe\n\t * to go ahead and always set it.\n\t */"
] | [
{
"param": "new_buffer",
"type": "YY_BUFFER_STATE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_buffer",
"type": "YY_BUFFER_STATE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmt_create_buffer | YY_BUFFER_STATE | YY_BUFFER_STATE __ktrfmt_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) __ktrfmtalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
b->yy_is_our_buffer = 1;
__ktrfmt_init_buffer(b,file );
return b;
} | /** Allocate and initialize an input buffer state.
* @param file A readable stream.
* @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
*
* @return the allocated buffer state.
*/ | Allocate and initialize an input buffer state.
@param file A readable stream.
@param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
@return the allocated buffer state. | [
"Allocate",
"and",
"initialize",
"an",
"input",
"buffer",
"state",
".",
"@param",
"file",
"A",
"readable",
"stream",
".",
"@param",
"size",
"The",
"character",
"buffer",
"size",
"in",
"bytes",
".",
"When",
"in",
"doubt",
"use",
"@c",
"YY_BUF_SIZE",
".",
"@return",
"the",
"allocated",
"buffer",
"state",
"."
] | YY_BUFFER_STATE __ktrfmt_create_buffer (FILE * file, int size )
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
b->yy_buf_size = size;
b->yy_ch_buf = (char *) __ktrfmtalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
b->yy_is_our_buffer = 1;
__ktrfmt_init_buffer(b,file );
return b;
} | [
"YY_BUFFER_STATE",
"__ktrfmt_create_buffer",
"(",
"FILE",
"*",
"file",
",",
"int",
"size",
")",
"{",
"YY_BUFFER_STATE",
"b",
";",
"b",
"=",
"(",
"YY_BUFFER_STATE",
")",
"__ktrfmtalloc",
"(",
"sizeof",
"(",
"struct",
"yy_buffer_state",
")",
")",
";",
"if",
"(",
"!",
"b",
")",
"YY_FATAL_ERROR",
"(",
"\"",
"\"",
")",
";",
"b",
"->",
"yy_buf_size",
"=",
"size",
";",
"b",
"->",
"yy_ch_buf",
"=",
"(",
"char",
"*",
")",
"__ktrfmtalloc",
"(",
"b",
"->",
"yy_buf_size",
"+",
"2",
")",
";",
"if",
"(",
"!",
"b",
"->",
"yy_ch_buf",
")",
"YY_FATAL_ERROR",
"(",
"\"",
"\"",
")",
";",
"b",
"->",
"yy_is_our_buffer",
"=",
"1",
";",
"__ktrfmt_init_buffer",
"(",
"b",
",",
"file",
")",
";",
"return",
"b",
";",
"}"
] | Allocate and initialize an input buffer state. | [
"Allocate",
"and",
"initialize",
"an",
"input",
"buffer",
"state",
"."
] | [
"/* yy_ch_buf has to be 2 characters longer than the size given because\n\t * we need to put in 2 end-of-buffer characters.\n\t */"
] | [
{
"param": "file",
"type": "FILE"
},
{
"param": "size",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmt_init_buffer | void | static void __ktrfmt_init_buffer (YY_BUFFER_STATE b, FILE * file )
{
int oerrno = errno;
__ktrfmt_flush_buffer(b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
/* If b is the current buffer, then __ktrfmt_init_buffer was _probably_
* called from __ktrfmtrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
} | /* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a __ktrfmtrestart() or at EOF.
*/ | Initializes or reinitializes a buffer.
This function is sometimes called more than once on the same buffer,
such as during a __ktrfmtrestart() or at EOF. | [
"Initializes",
"or",
"reinitializes",
"a",
"buffer",
".",
"This",
"function",
"is",
"sometimes",
"called",
"more",
"than",
"once",
"on",
"the",
"same",
"buffer",
"such",
"as",
"during",
"a",
"__ktrfmtrestart",
"()",
"or",
"at",
"EOF",
"."
] | static void __ktrfmt_init_buffer (YY_BUFFER_STATE b, FILE * file )
{
int oerrno = errno;
__ktrfmt_flush_buffer(b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
if (b != YY_CURRENT_BUFFER){
b->yy_bs_lineno = 1;
b->yy_bs_column = 0;
}
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
errno = oerrno;
} | [
"static",
"void",
"__ktrfmt_init_buffer",
"(",
"YY_BUFFER_STATE",
"b",
",",
"FILE",
"*",
"file",
")",
"{",
"int",
"oerrno",
"=",
"errno",
";",
"__ktrfmt_flush_buffer",
"(",
"b",
")",
";",
"b",
"->",
"yy_input_file",
"=",
"file",
";",
"b",
"->",
"yy_fill_buffer",
"=",
"1",
";",
"if",
"(",
"b",
"!=",
"YY_CURRENT_BUFFER",
")",
"{",
"b",
"->",
"yy_bs_lineno",
"=",
"1",
";",
"b",
"->",
"yy_bs_column",
"=",
"0",
";",
"}",
"b",
"->",
"yy_is_interactive",
"=",
"file",
"?",
"(",
"isatty",
"(",
"fileno",
"(",
"file",
")",
")",
">",
"0",
")",
":",
"0",
";",
"errno",
"=",
"oerrno",
";",
"}"
] | Initializes or reinitializes a buffer. | [
"Initializes",
"or",
"reinitializes",
"a",
"buffer",
"."
] | [
"/* If b is the current buffer, then __ktrfmt_init_buffer was _probably_\n * called from __ktrfmtrestart() or through yy_get_next_buffer.\n * In that case, we don't want to reset the lineno or column.\n */"
] | [
{
"param": "b",
"type": "YY_BUFFER_STATE"
},
{
"param": "file",
"type": "FILE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": "YY_BUFFER_STATE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type": "FILE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmt_flush_buffer | void | void __ktrfmt_flush_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
b->yy_n_chars = 0;
/* We always need two end-of-buffer characters. The first causes
* a transition to the end-of-buffer state. The second causes
* a jam in that state.
*/
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
__ktrfmt_load_buffer_state( );
} | /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
*
*/ | Discard all buffered characters. On the next scan, YY_INPUT will be called.
@param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | [
"Discard",
"all",
"buffered",
"characters",
".",
"On",
"the",
"next",
"scan",
"YY_INPUT",
"will",
"be",
"called",
".",
"@param",
"b",
"the",
"buffer",
"state",
"to",
"be",
"flushed",
"usually",
"@c",
"YY_CURRENT_BUFFER",
"."
] | void __ktrfmt_flush_buffer (YY_BUFFER_STATE b )
{
if ( ! b )
return;
b->yy_n_chars = 0;
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
b->yy_buf_pos = &b->yy_ch_buf[0];
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
__ktrfmt_load_buffer_state( );
} | [
"void",
"__ktrfmt_flush_buffer",
"(",
"YY_BUFFER_STATE",
"b",
")",
"{",
"if",
"(",
"!",
"b",
")",
"return",
";",
"b",
"->",
"yy_n_chars",
"=",
"0",
";",
"b",
"->",
"yy_ch_buf",
"[",
"0",
"]",
"=",
"YY_END_OF_BUFFER_CHAR",
";",
"b",
"->",
"yy_ch_buf",
"[",
"1",
"]",
"=",
"YY_END_OF_BUFFER_CHAR",
";",
"b",
"->",
"yy_buf_pos",
"=",
"&",
"b",
"->",
"yy_ch_buf",
"[",
"0",
"]",
";",
"b",
"->",
"yy_at_bol",
"=",
"1",
";",
"b",
"->",
"yy_buffer_status",
"=",
"YY_BUFFER_NEW",
";",
"if",
"(",
"b",
"==",
"YY_CURRENT_BUFFER",
")",
"__ktrfmt_load_buffer_state",
"(",
")",
";",
"}"
] | Discard all buffered characters. | [
"Discard",
"all",
"buffered",
"characters",
"."
] | [
"/* We always need two end-of-buffer characters. The first causes\n\t * a transition to the end-of-buffer state. The second causes\n\t * a jam in that state.\n\t */"
] | [
{
"param": "b",
"type": "YY_BUFFER_STATE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "b",
"type": "YY_BUFFER_STATE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtpush_buffer_state | void | void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer )
{
if (new_buffer == NULL)
return;
__ktrfmtensure_buffer_stack();
/* This block is copied from __ktrfmt_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
/* Only push if top exists. Otherwise, replace top. */
if (YY_CURRENT_BUFFER)
(yy_buffer_stack_top)++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
/* copied from __ktrfmt_switch_to_buffer. */
__ktrfmt_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
} | /** Pushes the new state onto the stack. The new state becomes
* the current state. This function will allocate the stack
* if necessary.
* @param new_buffer The new state.
*
*/ | Pushes the new state onto the stack. The new state becomes
the current state. This function will allocate the stack
if necessary.
@param new_buffer The new state. | [
"Pushes",
"the",
"new",
"state",
"onto",
"the",
"stack",
".",
"The",
"new",
"state",
"becomes",
"the",
"current",
"state",
".",
"This",
"function",
"will",
"allocate",
"the",
"stack",
"if",
"necessary",
".",
"@param",
"new_buffer",
"The",
"new",
"state",
"."
] | void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer )
{
if (new_buffer == NULL)
return;
__ktrfmtensure_buffer_stack();
if ( YY_CURRENT_BUFFER )
{
*(yy_c_buf_p) = (yy_hold_char);
YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
if (YY_CURRENT_BUFFER)
(yy_buffer_stack_top)++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
__ktrfmt_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
} | [
"void",
"__ktrfmtpush_buffer_state",
"(",
"YY_BUFFER_STATE",
"new_buffer",
")",
"{",
"if",
"(",
"new_buffer",
"==",
"NULL",
")",
"return",
";",
"__ktrfmtensure_buffer_stack",
"(",
")",
";",
"if",
"(",
"YY_CURRENT_BUFFER",
")",
"{",
"*",
"(",
"yy_c_buf_p",
")",
"=",
"(",
"yy_hold_char",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"->",
"yy_buf_pos",
"=",
"(",
"yy_c_buf_p",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"->",
"yy_n_chars",
"=",
"(",
"yy_n_chars",
")",
";",
"}",
"if",
"(",
"YY_CURRENT_BUFFER",
")",
"(",
"yy_buffer_stack_top",
")",
"++",
";",
"YY_CURRENT_BUFFER_LVALUE",
"=",
"new_buffer",
";",
"__ktrfmt_load_buffer_state",
"(",
")",
";",
"(",
"yy_did_buffer_switch_on_eof",
")",
"=",
"1",
";",
"}"
] | Pushes the new state onto the stack. | [
"Pushes",
"the",
"new",
"state",
"onto",
"the",
"stack",
"."
] | [
"/* This block is copied from __ktrfmt_switch_to_buffer. */",
"/* Flush out information for old buffer. */",
"/* Only push if top exists. Otherwise, replace top. */",
"/* copied from __ktrfmt_switch_to_buffer. */"
] | [
{
"param": "new_buffer",
"type": "YY_BUFFER_STATE"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_buffer",
"type": "YY_BUFFER_STATE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtpop_buffer_state | void | void __ktrfmtpop_buffer_state (void)
{
if (!YY_CURRENT_BUFFER)
return;
__ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
__ktrfmt_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
} | /** Removes and deletes the top of the stack, if present.
* The next element becomes the new top.
*
*/ | Removes and deletes the top of the stack, if present.
The next element becomes the new top. | [
"Removes",
"and",
"deletes",
"the",
"top",
"of",
"the",
"stack",
"if",
"present",
".",
"The",
"next",
"element",
"becomes",
"the",
"new",
"top",
"."
] | void __ktrfmtpop_buffer_state (void)
{
if (!YY_CURRENT_BUFFER)
return;
__ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
if ((yy_buffer_stack_top) > 0)
--(yy_buffer_stack_top);
if (YY_CURRENT_BUFFER) {
__ktrfmt_load_buffer_state( );
(yy_did_buffer_switch_on_eof) = 1;
}
} | [
"void",
"__ktrfmtpop_buffer_state",
"(",
"void",
")",
"{",
"if",
"(",
"!",
"YY_CURRENT_BUFFER",
")",
"return",
";",
"__ktrfmt_delete_buffer",
"(",
"YY_CURRENT_BUFFER",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"=",
"NULL",
";",
"if",
"(",
"(",
"yy_buffer_stack_top",
")",
">",
"0",
")",
"--",
"(",
"yy_buffer_stack_top",
")",
";",
"if",
"(",
"YY_CURRENT_BUFFER",
")",
"{",
"__ktrfmt_load_buffer_state",
"(",
")",
";",
"(",
"yy_did_buffer_switch_on_eof",
")",
"=",
"1",
";",
"}",
"}"
] | Removes and deletes the top of the stack, if present. | [
"Removes",
"and",
"deletes",
"the",
"top",
"of",
"the",
"stack",
"if",
"present",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtensure_buffer_stack | void | static void __ktrfmtensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtrealloc
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
/* zero only the new slots.*/
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
} | /* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/ | Allocates the stack if it does not exist.
Guarantees space for at least one push. | [
"Allocates",
"the",
"stack",
"if",
"it",
"does",
"not",
"exist",
".",
"Guarantees",
"space",
"for",
"at",
"least",
"one",
"push",
"."
] | static void __ktrfmtensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
(yy_buffer_stack_top) = 0;
return;
}
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
int grow_size = 8 ;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtrealloc
((yy_buffer_stack),
num_to_alloc * sizeof(struct yy_buffer_state*)
);
if ( ! (yy_buffer_stack) )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
(yy_buffer_stack_max) = num_to_alloc;
}
} | [
"static",
"void",
"__ktrfmtensure_buffer_stack",
"(",
"void",
")",
"{",
"yy_size_t",
"num_to_alloc",
";",
"if",
"(",
"!",
"(",
"yy_buffer_stack",
")",
")",
"{",
"num_to_alloc",
"=",
"1",
";",
"(",
"yy_buffer_stack",
")",
"=",
"(",
"struct",
"yy_buffer_state",
"*",
"*",
")",
"__ktrfmtalloc",
"(",
"num_to_alloc",
"*",
"sizeof",
"(",
"struct",
"yy_buffer_state",
"*",
")",
")",
";",
"if",
"(",
"!",
"(",
"yy_buffer_stack",
")",
")",
"YY_FATAL_ERROR",
"(",
"\"",
"\"",
")",
";",
"memset",
"(",
"(",
"yy_buffer_stack",
")",
",",
"0",
",",
"num_to_alloc",
"*",
"sizeof",
"(",
"struct",
"yy_buffer_state",
"*",
")",
")",
";",
"(",
"yy_buffer_stack_max",
")",
"=",
"num_to_alloc",
";",
"(",
"yy_buffer_stack_top",
")",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"(",
"yy_buffer_stack_top",
")",
">=",
"(",
"(",
"yy_buffer_stack_max",
")",
")",
"-",
"1",
")",
"{",
"int",
"grow_size",
"=",
"8",
";",
"num_to_alloc",
"=",
"(",
"yy_buffer_stack_max",
")",
"+",
"grow_size",
";",
"(",
"yy_buffer_stack",
")",
"=",
"(",
"struct",
"yy_buffer_state",
"*",
"*",
")",
"__ktrfmtrealloc",
"(",
"(",
"yy_buffer_stack",
")",
",",
"num_to_alloc",
"*",
"sizeof",
"(",
"struct",
"yy_buffer_state",
"*",
")",
")",
";",
"if",
"(",
"!",
"(",
"yy_buffer_stack",
")",
")",
"YY_FATAL_ERROR",
"(",
"\"",
"\"",
")",
";",
"memset",
"(",
"(",
"yy_buffer_stack",
")",
"+",
"(",
"yy_buffer_stack_max",
")",
",",
"0",
",",
"grow_size",
"*",
"sizeof",
"(",
"struct",
"yy_buffer_state",
"*",
")",
")",
";",
"(",
"yy_buffer_stack_max",
")",
"=",
"num_to_alloc",
";",
"}",
"}"
] | Allocates the stack if it does not exist. | [
"Allocates",
"the",
"stack",
"if",
"it",
"does",
"not",
"exist",
"."
] | [
"/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate realloc on the next call.\n */",
"/* Increase the buffer to prepare for a possible push. */",
"/* arbitrary grow size */",
"/* zero only the new slots.*/"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmt_scan_buffer | YY_BUFFER_STATE | YY_BUFFER_STATE __ktrfmt_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_buffer()" );
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
__ktrfmt_switch_to_buffer(b );
return b;
} | /** Setup the input buffer state to scan directly from a user-specified character buffer.
* @param base the character buffer
* @param size the size in bytes of the character buffer
*
* @return the newly allocated buffer state object.
*/ | Setup the input buffer state to scan directly from a user-specified character buffer.
@param base the character buffer
@param size the size in bytes of the character buffer
@return the newly allocated buffer state object. | [
"Setup",
"the",
"input",
"buffer",
"state",
"to",
"scan",
"directly",
"from",
"a",
"user",
"-",
"specified",
"character",
"buffer",
".",
"@param",
"base",
"the",
"character",
"buffer",
"@param",
"size",
"the",
"size",
"in",
"bytes",
"of",
"the",
"character",
"buffer",
"@return",
"the",
"newly",
"allocated",
"buffer",
"state",
"object",
"."
] | YY_BUFFER_STATE __ktrfmt_scan_buffer (char * base, yy_size_t size )
{
YY_BUFFER_STATE b;
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
return 0;
b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_buffer()" );
b->yy_buf_size = size - 2;
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = 0;
b->yy_n_chars = b->yy_buf_size;
b->yy_is_interactive = 0;
b->yy_at_bol = 1;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
__ktrfmt_switch_to_buffer(b );
return b;
} | [
"YY_BUFFER_STATE",
"__ktrfmt_scan_buffer",
"(",
"char",
"*",
"base",
",",
"yy_size_t",
"size",
")",
"{",
"YY_BUFFER_STATE",
"b",
";",
"if",
"(",
"size",
"<",
"2",
"||",
"base",
"[",
"size",
"-",
"2",
"]",
"!=",
"YY_END_OF_BUFFER_CHAR",
"||",
"base",
"[",
"size",
"-",
"1",
"]",
"!=",
"YY_END_OF_BUFFER_CHAR",
")",
"return",
"0",
";",
"b",
"=",
"(",
"YY_BUFFER_STATE",
")",
"__ktrfmtalloc",
"(",
"sizeof",
"(",
"struct",
"yy_buffer_state",
")",
")",
";",
"if",
"(",
"!",
"b",
")",
"YY_FATAL_ERROR",
"(",
"\"",
"\"",
")",
";",
"b",
"->",
"yy_buf_size",
"=",
"size",
"-",
"2",
";",
"b",
"->",
"yy_buf_pos",
"=",
"b",
"->",
"yy_ch_buf",
"=",
"base",
";",
"b",
"->",
"yy_is_our_buffer",
"=",
"0",
";",
"b",
"->",
"yy_input_file",
"=",
"0",
";",
"b",
"->",
"yy_n_chars",
"=",
"b",
"->",
"yy_buf_size",
";",
"b",
"->",
"yy_is_interactive",
"=",
"0",
";",
"b",
"->",
"yy_at_bol",
"=",
"1",
";",
"b",
"->",
"yy_fill_buffer",
"=",
"0",
";",
"b",
"->",
"yy_buffer_status",
"=",
"YY_BUFFER_NEW",
";",
"__ktrfmt_switch_to_buffer",
"(",
"b",
")",
";",
"return",
"b",
";",
"}"
] | Setup the input buffer state to scan directly from a user-specified character buffer. | [
"Setup",
"the",
"input",
"buffer",
"state",
"to",
"scan",
"directly",
"from",
"a",
"user",
"-",
"specified",
"character",
"buffer",
"."
] | [
"/* They forgot to leave room for the EOB's. */",
"/* \"- 2\" to take care of EOB's */"
] | [
{
"param": "base",
"type": "char"
},
{
"param": "size",
"type": "yy_size_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base",
"type": "char",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "yy_size_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtget_lineno | int | int __ktrfmtget_lineno (void)
{
return __ktrfmtlineno;
} | /** Get the current line number.
*
*/ | Get the current line number. | [
"Get",
"the",
"current",
"line",
"number",
"."
] | int __ktrfmtget_lineno (void)
{
return __ktrfmtlineno;
} | [
"int",
"__ktrfmtget_lineno",
"(",
"void",
")",
"{",
"return",
"__ktrfmtlineno",
";",
"}"
] | Get the current line number. | [
"Get",
"the",
"current",
"line",
"number",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtset_lineno | void | void __ktrfmtset_lineno (int line_number )
{
__ktrfmtlineno = line_number;
} | /** Set the current line number.
* @param line_number
*
*/ | Set the current line number. | [
"Set",
"the",
"current",
"line",
"number",
"."
] | void __ktrfmtset_lineno (int line_number )
{
__ktrfmtlineno = line_number;
} | [
"void",
"__ktrfmtset_lineno",
"(",
"int",
"line_number",
")",
"{",
"__ktrfmtlineno",
"=",
"line_number",
";",
"}"
] | Set the current line number. | [
"Set",
"the",
"current",
"line",
"number",
"."
] | [] | [
{
"param": "line_number",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line_number",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24ac1dc0802b402a7f878791b1364cdc0da5fc64 | atrens/DragonFlyBSD-src | lib/libevtr/ktrfmt.yy.c | [
"BSD-3-Clause"
] | C | __ktrfmtlex_destroy | int | int __ktrfmtlex_destroy (void)
{
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
__ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
__ktrfmtpop_buffer_state();
}
/* Destroy the stack itself. */
__ktrfmtfree((yy_buffer_stack) );
(yy_buffer_stack) = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
* __ktrfmtlex() is called, initialization will occur. */
yy_init_globals( );
return 0;
} | /* __ktrfmtlex_destroy is for both reentrant and non-reentrant scanners. */ | ktrfmtlex_destroy is for both reentrant and non-reentrant scanners. | [
"ktrfmtlex_destroy",
"is",
"for",
"both",
"reentrant",
"and",
"non",
"-",
"reentrant",
"scanners",
"."
] | int __ktrfmtlex_destroy (void)
{
while(YY_CURRENT_BUFFER){
__ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
YY_CURRENT_BUFFER_LVALUE = NULL;
__ktrfmtpop_buffer_state();
}
__ktrfmtfree((yy_buffer_stack) );
(yy_buffer_stack) = NULL;
yy_init_globals( );
return 0;
} | [
"int",
"__ktrfmtlex_destroy",
"(",
"void",
")",
"{",
"while",
"(",
"YY_CURRENT_BUFFER",
")",
"{",
"__ktrfmt_delete_buffer",
"(",
"YY_CURRENT_BUFFER",
")",
";",
"YY_CURRENT_BUFFER_LVALUE",
"=",
"NULL",
";",
"__ktrfmtpop_buffer_state",
"(",
")",
";",
"}",
"__ktrfmtfree",
"(",
"(",
"yy_buffer_stack",
")",
")",
";",
"(",
"yy_buffer_stack",
")",
"=",
"NULL",
";",
"yy_init_globals",
"(",
")",
";",
"return",
"0",
";",
"}"
] | __ktrfmtlex_destroy is for both reentrant and non-reentrant scanners. | [
"__ktrfmtlex_destroy",
"is",
"for",
"both",
"reentrant",
"and",
"non",
"-",
"reentrant",
"scanners",
"."
] | [
"/* Pop the buffer stack, destroying each element. */",
"/* Destroy the stack itself. */",
"/* Reset the globals. This is important in a non-reentrant scanner so the next time\n * __ktrfmtlex() is called, initialization will occur. */"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
64471dd2a25389b1b516d762c2a73149d05e6c71 | atrens/DragonFlyBSD-src | sys/dev/acpica/acpi_ec.c | [
"BSD-3-Clause"
] | C | acpi_ec_ecdt_probe | void | void
acpi_ec_ecdt_probe(device_t parent)
{
ACPI_TABLE_ECDT *ecdt;
ACPI_STATUS status;
device_t child;
ACPI_HANDLE h;
struct acpi_ec_params *params;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/* Find and validate the ECDT. */
status = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt);
if (ACPI_FAILURE(status) ||
ecdt->Control.BitWidth != 8 ||
ecdt->Data.BitWidth != 8) {
return;
}
/* Create the child device with the given unit number. */
child = BUS_ADD_CHILD(parent, parent, 0, "acpi_ec", ecdt->Uid);
if (child == NULL) {
kprintf("%s: can't add child\n", __func__);
return;
}
/* Find and save the ACPI handle for this device. */
status = AcpiGetHandle(NULL, ecdt->Id, &h);
if (ACPI_FAILURE(status)) {
device_delete_child(parent, child);
kprintf("%s: can't get handle\n", __func__);
return;
}
acpi_set_handle(child, h);
/* Set the data and CSR register addresses. */
bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->Data.Address,
/*count*/1, -1);
bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->Control.Address,
/*count*/1, -1);
/*
* Store values for the probe/attach routines to use. Store the
* ECDT GPE bit and set the global lock flag according to _GLK.
* Note that it is not perfectly correct to be evaluating a method
* before initializing devices, but in practice this function
* should be safe to call at this point.
*/
params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO);
params->gpe_handle = NULL;
params->gpe_bit = ecdt->Gpe;
params->uid = ecdt->Uid;
acpi_GetInteger(h, "_GLK", ¶ms->glk);
acpi_set_private(child, params);
/* Finish the attach process. */
if (device_probe_and_attach(child) != 0)
device_delete_child(parent, child);
} | /*
* Look for an ECDT and if we find one, set up default GPE and
* space handlers to catch attempts to access EC space before
* we have a real driver instance in place.
*
* TODO: Some old Gateway laptops need us to fake up an ECDT or
* otherwise attach early so that _REG methods can run.
*/ | Look for an ECDT and if we find one, set up default GPE and
space handlers to catch attempts to access EC space before
we have a real driver instance in place.
Some old Gateway laptops need us to fake up an ECDT or
otherwise attach early so that _REG methods can run. | [
"Look",
"for",
"an",
"ECDT",
"and",
"if",
"we",
"find",
"one",
"set",
"up",
"default",
"GPE",
"and",
"space",
"handlers",
"to",
"catch",
"attempts",
"to",
"access",
"EC",
"space",
"before",
"we",
"have",
"a",
"real",
"driver",
"instance",
"in",
"place",
".",
"Some",
"old",
"Gateway",
"laptops",
"need",
"us",
"to",
"fake",
"up",
"an",
"ECDT",
"or",
"otherwise",
"attach",
"early",
"so",
"that",
"_REG",
"methods",
"can",
"run",
"."
] | void
acpi_ec_ecdt_probe(device_t parent)
{
ACPI_TABLE_ECDT *ecdt;
ACPI_STATUS status;
device_t child;
ACPI_HANDLE h;
struct acpi_ec_params *params;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
status = AcpiGetTable(ACPI_SIG_ECDT, 1, (ACPI_TABLE_HEADER **)&ecdt);
if (ACPI_FAILURE(status) ||
ecdt->Control.BitWidth != 8 ||
ecdt->Data.BitWidth != 8) {
return;
}
child = BUS_ADD_CHILD(parent, parent, 0, "acpi_ec", ecdt->Uid);
if (child == NULL) {
kprintf("%s: can't add child\n", __func__);
return;
}
status = AcpiGetHandle(NULL, ecdt->Id, &h);
if (ACPI_FAILURE(status)) {
device_delete_child(parent, child);
kprintf("%s: can't get handle\n", __func__);
return;
}
acpi_set_handle(child, h);
bus_set_resource(child, SYS_RES_IOPORT, 0, ecdt->Data.Address,
1, -1);
bus_set_resource(child, SYS_RES_IOPORT, 1, ecdt->Control.Address,
1, -1);
params = kmalloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO);
params->gpe_handle = NULL;
params->gpe_bit = ecdt->Gpe;
params->uid = ecdt->Uid;
acpi_GetInteger(h, "_GLK", ¶ms->glk);
acpi_set_private(child, params);
if (device_probe_and_attach(child) != 0)
device_delete_child(parent, child);
} | [
"void",
"acpi_ec_ecdt_probe",
"(",
"device_t",
"parent",
")",
"{",
"ACPI_TABLE_ECDT",
"*",
"ecdt",
";",
"ACPI_STATUS",
"status",
";",
"device_t",
"child",
";",
"ACPI_HANDLE",
"h",
";",
"struct",
"acpi_ec_params",
"*",
"params",
";",
"ACPI_FUNCTION_TRACE",
"(",
"(",
"char",
"*",
")",
"(",
"uintptr_t",
")",
"__func__",
")",
";",
"status",
"=",
"AcpiGetTable",
"(",
"ACPI_SIG_ECDT",
",",
"1",
",",
"(",
"ACPI_TABLE_HEADER",
"*",
"*",
")",
"&",
"ecdt",
")",
";",
"if",
"(",
"ACPI_FAILURE",
"(",
"status",
")",
"||",
"ecdt",
"->",
"Control",
".",
"BitWidth",
"!=",
"8",
"||",
"ecdt",
"->",
"Data",
".",
"BitWidth",
"!=",
"8",
")",
"{",
"return",
";",
"}",
"child",
"=",
"BUS_ADD_CHILD",
"(",
"parent",
",",
"parent",
",",
"0",
",",
"\"",
"\"",
",",
"ecdt",
"->",
"Uid",
")",
";",
"if",
"(",
"child",
"==",
"NULL",
")",
"{",
"kprintf",
"(",
"\"",
"\\n",
"\"",
",",
"__func__",
")",
";",
"return",
";",
"}",
"status",
"=",
"AcpiGetHandle",
"(",
"NULL",
",",
"ecdt",
"->",
"Id",
",",
"&",
"h",
")",
";",
"if",
"(",
"ACPI_FAILURE",
"(",
"status",
")",
")",
"{",
"device_delete_child",
"(",
"parent",
",",
"child",
")",
";",
"kprintf",
"(",
"\"",
"\\n",
"\"",
",",
"__func__",
")",
";",
"return",
";",
"}",
"acpi_set_handle",
"(",
"child",
",",
"h",
")",
";",
"bus_set_resource",
"(",
"child",
",",
"SYS_RES_IOPORT",
",",
"0",
",",
"ecdt",
"->",
"Data",
".",
"Address",
",",
"1",
",",
"-1",
")",
";",
"bus_set_resource",
"(",
"child",
",",
"SYS_RES_IOPORT",
",",
"1",
",",
"ecdt",
"->",
"Control",
".",
"Address",
",",
"1",
",",
"-1",
")",
";",
"params",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"struct",
"acpi_ec_params",
")",
",",
"M_TEMP",
",",
"M_WAITOK",
"|",
"M_ZERO",
")",
";",
"params",
"->",
"gpe_handle",
"=",
"NULL",
";",
"params",
"->",
"gpe_bit",
"=",
"ecdt",
"->",
"Gpe",
";",
"params",
"->",
"uid",
"=",
"ecdt",
"->",
"Uid",
";",
"acpi_GetInteger",
"(",
"h",
",",
"\"",
"\"",
",",
"&",
"params",
"->",
"glk",
")",
";",
"acpi_set_private",
"(",
"child",
",",
"params",
")",
";",
"if",
"(",
"device_probe_and_attach",
"(",
"child",
")",
"!=",
"0",
")",
"device_delete_child",
"(",
"parent",
",",
"child",
")",
";",
"}"
] | Look for an ECDT and if we find one, set up default GPE and
space handlers to catch attempts to access EC space before
we have a real driver instance in place. | [
"Look",
"for",
"an",
"ECDT",
"and",
"if",
"we",
"find",
"one",
"set",
"up",
"default",
"GPE",
"and",
"space",
"handlers",
"to",
"catch",
"attempts",
"to",
"access",
"EC",
"space",
"before",
"we",
"have",
"a",
"real",
"driver",
"instance",
"in",
"place",
"."
] | [
"/* Find and validate the ECDT. */",
"/* Create the child device with the given unit number. */",
"/* Find and save the ACPI handle for this device. */",
"/* Set the data and CSR register addresses. */",
"/*count*/",
"/*count*/",
"/*\n * Store values for the probe/attach routines to use. Store the\n * ECDT GPE bit and set the global lock flag according to _GLK.\n * Note that it is not perfectly correct to be evaluating a method\n * before initializing devices, but in practice this function\n * should be safe to call at this point.\n */",
"/* Finish the attach process. */"
] | [
{
"param": "parent",
"type": "device_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "parent",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
64471dd2a25389b1b516d762c2a73149d05e6c71 | atrens/DragonFlyBSD-src | sys/dev/acpica/acpi_ec.c | [
"BSD-3-Clause"
] | C | acpi_ec_read_method | int | static int
acpi_ec_read_method(device_t dev, u_int addr, UINT64 *val, int width)
{
struct acpi_ec_softc *sc;
ACPI_STATUS status;
sc = device_get_softc(dev);
status = EcSpaceHandler(ACPI_READ, addr, width * 8, val, sc, NULL);
if (ACPI_FAILURE(status))
return (ENXIO);
return (0);
} | /* Methods to allow other devices (e.g., smbat) to read/write EC space. */ | Methods to allow other devices to read/write EC space. | [
"Methods",
"to",
"allow",
"other",
"devices",
"to",
"read",
"/",
"write",
"EC",
"space",
"."
] | static int
acpi_ec_read_method(device_t dev, u_int addr, UINT64 *val, int width)
{
struct acpi_ec_softc *sc;
ACPI_STATUS status;
sc = device_get_softc(dev);
status = EcSpaceHandler(ACPI_READ, addr, width * 8, val, sc, NULL);
if (ACPI_FAILURE(status))
return (ENXIO);
return (0);
} | [
"static",
"int",
"acpi_ec_read_method",
"(",
"device_t",
"dev",
",",
"u_int",
"addr",
",",
"UINT64",
"*",
"val",
",",
"int",
"width",
")",
"{",
"struct",
"acpi_ec_softc",
"*",
"sc",
";",
"ACPI_STATUS",
"status",
";",
"sc",
"=",
"device_get_softc",
"(",
"dev",
")",
";",
"status",
"=",
"EcSpaceHandler",
"(",
"ACPI_READ",
",",
"addr",
",",
"width",
"*",
"8",
",",
"val",
",",
"sc",
",",
"NULL",
")",
";",
"if",
"(",
"ACPI_FAILURE",
"(",
"status",
")",
")",
"return",
"(",
"ENXIO",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Methods to allow other devices (e.g., smbat) to read/write EC space. | [
"Methods",
"to",
"allow",
"other",
"devices",
"(",
"e",
".",
"g",
".",
"smbat",
")",
"to",
"read",
"/",
"write",
"EC",
"space",
"."
] | [] | [
{
"param": "dev",
"type": "device_t"
},
{
"param": "addr",
"type": "u_int"
},
{
"param": "val",
"type": "UINT64"
},
{
"param": "width",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "u_int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "val",
"type": "UINT64",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "width",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
64471dd2a25389b1b516d762c2a73149d05e6c71 | atrens/DragonFlyBSD-src | sys/dev/acpica/acpi_ec.c | [
"BSD-3-Clause"
] | C | EcGpeHandler | UINT32 | static UINT32
EcGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, void *Context)
{
struct acpi_ec_softc *sc = Context;
ACPI_STATUS Status;
EC_STATUS EcStatus;
KASSERT(Context != NULL, ("EcGpeHandler called with NULL"));
KTR_LOG(acpi_ec_gpehdlstart);
/*
* Notify EcWaitEvent() that the status register is now fresh. If we
* didn't do this, it wouldn't be possible to distinguish an old IBE
* from a new one, for example when doing a write transaction (writing
* address and then data values.)
*/
atomic_add_int(&sc->ec_gencount, 1);
wakeup(sc);
/*
* If the EC_SCI bit of the status register is set, queue a query handler.
* It will run the query and _Qxx method later, under the lock.
*/
EcStatus = EC_GET_CSR(sc);
if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
KTR_LOG(acpi_ec_gpequeuehdl);
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
if (ACPI_SUCCESS(Status)) {
sc->ec_sci_pend = TRUE;
return (0);
} else {
kprintf("EcGpeHandler: queuing GPE query handler failed\n");
}
}
return (ACPI_REENABLE_GPE);
} | /*
* The GPE handler is called when IBE/OBF or SCI events occur. We are
* called from an unknown lock context.
*/ | The GPE handler is called when IBE/OBF or SCI events occur. We are
called from an unknown lock context. | [
"The",
"GPE",
"handler",
"is",
"called",
"when",
"IBE",
"/",
"OBF",
"or",
"SCI",
"events",
"occur",
".",
"We",
"are",
"called",
"from",
"an",
"unknown",
"lock",
"context",
"."
] | static UINT32
EcGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, void *Context)
{
struct acpi_ec_softc *sc = Context;
ACPI_STATUS Status;
EC_STATUS EcStatus;
KASSERT(Context != NULL, ("EcGpeHandler called with NULL"));
KTR_LOG(acpi_ec_gpehdlstart);
atomic_add_int(&sc->ec_gencount, 1);
wakeup(sc);
EcStatus = EC_GET_CSR(sc);
if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
KTR_LOG(acpi_ec_gpequeuehdl);
Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
if (ACPI_SUCCESS(Status)) {
sc->ec_sci_pend = TRUE;
return (0);
} else {
kprintf("EcGpeHandler: queuing GPE query handler failed\n");
}
}
return (ACPI_REENABLE_GPE);
} | [
"static",
"UINT32",
"EcGpeHandler",
"(",
"ACPI_HANDLE",
"GpeDevice",
",",
"UINT32",
"GpeNumber",
",",
"void",
"*",
"Context",
")",
"{",
"struct",
"acpi_ec_softc",
"*",
"sc",
"=",
"Context",
";",
"ACPI_STATUS",
"Status",
";",
"EC_STATUS",
"EcStatus",
";",
"KASSERT",
"(",
"Context",
"!=",
"NULL",
",",
"(",
"\"",
"\"",
")",
")",
";",
"KTR_LOG",
"(",
"acpi_ec_gpehdlstart",
")",
";",
"atomic_add_int",
"(",
"&",
"sc",
"->",
"ec_gencount",
",",
"1",
")",
";",
"wakeup",
"(",
"sc",
")",
";",
"EcStatus",
"=",
"EC_GET_CSR",
"(",
"sc",
")",
";",
"if",
"(",
"(",
"EcStatus",
"&",
"EC_EVENT_SCI",
")",
"&&",
"!",
"sc",
"->",
"ec_sci_pend",
")",
"{",
"KTR_LOG",
"(",
"acpi_ec_gpequeuehdl",
")",
";",
"Status",
"=",
"AcpiOsExecute",
"(",
"OSL_GPE_HANDLER",
",",
"EcGpeQueryHandler",
",",
"Context",
")",
";",
"if",
"(",
"ACPI_SUCCESS",
"(",
"Status",
")",
")",
"{",
"sc",
"->",
"ec_sci_pend",
"=",
"TRUE",
";",
"return",
"(",
"0",
")",
";",
"}",
"else",
"{",
"kprintf",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"return",
"(",
"ACPI_REENABLE_GPE",
")",
";",
"}"
] | The GPE handler is called when IBE/OBF or SCI events occur. | [
"The",
"GPE",
"handler",
"is",
"called",
"when",
"IBE",
"/",
"OBF",
"or",
"SCI",
"events",
"occur",
"."
] | [
"/*\n * Notify EcWaitEvent() that the status register is now fresh. If we\n * didn't do this, it wouldn't be possible to distinguish an old IBE\n * from a new one, for example when doing a write transaction (writing\n * address and then data values.)\n */",
"/*\n * If the EC_SCI bit of the status register is set, queue a query handler.\n * It will run the query and _Qxx method later, under the lock.\n */"
] | [
{
"param": "GpeDevice",
"type": "ACPI_HANDLE"
},
{
"param": "GpeNumber",
"type": "UINT32"
},
{
"param": "Context",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "GpeDevice",
"type": "ACPI_HANDLE",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "GpeNumber",
"type": "UINT32",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Context",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | comdat_can_be_unshared_p | bool | static bool
comdat_can_be_unshared_p (symtab_node *node)
{
if (!comdat_can_be_unshared_p_1 (node))
return false;
if (node->same_comdat_group)
{
symtab_node *next;
/* If more than one function is in the same COMDAT group, it must
be shared even if just one function in the comdat group has
address taken. */
for (next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
if (!comdat_can_be_unshared_p_1 (next))
return false;
}
return true;
} | /* COMDAT functions must be shared only if they have address taken,
otherwise we can produce our own private implementation with
-fwhole-program.
Return true when turning COMDAT function static can not lead to wrong
code when the resulting object links with a library defining same COMDAT.
Virtual functions do have their addresses taken from the vtables,
but in C++ there is no way to compare their addresses for equality. */ | COMDAT functions must be shared only if they have address taken,
otherwise we can produce our own private implementation with
fwhole-program.
Return true when turning COMDAT function static can not lead to wrong
code when the resulting object links with a library defining same COMDAT.
Virtual functions do have their addresses taken from the vtables,
but in C++ there is no way to compare their addresses for equality. | [
"COMDAT",
"functions",
"must",
"be",
"shared",
"only",
"if",
"they",
"have",
"address",
"taken",
"otherwise",
"we",
"can",
"produce",
"our",
"own",
"private",
"implementation",
"with",
"fwhole",
"-",
"program",
".",
"Return",
"true",
"when",
"turning",
"COMDAT",
"function",
"static",
"can",
"not",
"lead",
"to",
"wrong",
"code",
"when",
"the",
"resulting",
"object",
"links",
"with",
"a",
"library",
"defining",
"same",
"COMDAT",
".",
"Virtual",
"functions",
"do",
"have",
"their",
"addresses",
"taken",
"from",
"the",
"vtables",
"but",
"in",
"C",
"++",
"there",
"is",
"no",
"way",
"to",
"compare",
"their",
"addresses",
"for",
"equality",
"."
] | static bool
comdat_can_be_unshared_p (symtab_node *node)
{
if (!comdat_can_be_unshared_p_1 (node))
return false;
if (node->same_comdat_group)
{
symtab_node *next;
for (next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
if (!comdat_can_be_unshared_p_1 (next))
return false;
}
return true;
} | [
"static",
"bool",
"comdat_can_be_unshared_p",
"(",
"symtab_node",
"*",
"node",
")",
"{",
"if",
"(",
"!",
"comdat_can_be_unshared_p_1",
"(",
"node",
")",
")",
"return",
"false",
";",
"if",
"(",
"node",
"->",
"same_comdat_group",
")",
"{",
"symtab_node",
"*",
"next",
";",
"for",
"(",
"next",
"=",
"node",
"->",
"same_comdat_group",
";",
"next",
"!=",
"node",
";",
"next",
"=",
"next",
"->",
"same_comdat_group",
")",
"if",
"(",
"!",
"comdat_can_be_unshared_p_1",
"(",
"next",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | COMDAT functions must be shared only if they have address taken,
otherwise we can produce our own private implementation with
fwhole-program. | [
"COMDAT",
"functions",
"must",
"be",
"shared",
"only",
"if",
"they",
"have",
"address",
"taken",
"otherwise",
"we",
"can",
"produce",
"our",
"own",
"private",
"implementation",
"with",
"fwhole",
"-",
"program",
"."
] | [
"/* If more than one function is in the same COMDAT group, it must\n be shared even if just one function in the comdat group has\n address taken. */"
] | [
{
"param": "node",
"type": "symtab_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "symtab_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | cgraph_externally_visible_p | bool | static bool
cgraph_externally_visible_p (struct cgraph_node *node,
bool whole_program)
{
while (node->transparent_alias && node->definition)
node = node->get_alias_target ();
if (!node->definition)
return false;
if (!TREE_PUBLIC (node->decl)
|| DECL_EXTERNAL (node->decl))
return false;
/* Do not try to localize built-in functions yet. One of problems is that we
end up mangling their asm for WHOPR that makes it impossible to call them
using the implicit built-in declarations anymore. Similarly this enables
us to remove them as unreachable before actual calls may appear during
expansion or folding. */
if (DECL_BUILT_IN (node->decl))
return true;
/* If linker counts on us, we must preserve the function. */
if (node->used_from_object_file_p ())
return true;
if (DECL_PRESERVE_P (node->decl))
return true;
if (lookup_attribute ("externally_visible",
DECL_ATTRIBUTES (node->decl)))
return true;
if (lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
return true;
if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
&& lookup_attribute ("dllexport",
DECL_ATTRIBUTES (node->decl)))
return true;
if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
/* When doing LTO or whole program, we can bring COMDAT functoins static.
This improves code quality and we know we will duplicate them at most twice
(in the case that we are not using plugin and link with object file
implementing same COMDAT) */
if (((in_lto_p || whole_program) && !flag_incremental_link)
&& DECL_COMDAT (node->decl)
&& comdat_can_be_unshared_p (node))
return false;
/* When doing link time optimizations, hidden symbols become local. */
if ((in_lto_p && !flag_incremental_link)
&& (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
|| DECL_VISIBILITY (node->decl) == VISIBILITY_INTERNAL)
/* Be sure that node is defined in IR file, not in other object
file. In that case we don't set used_from_other_object_file. */
&& node->definition)
;
else if (!whole_program)
return true;
if (MAIN_NAME_P (DECL_NAME (node->decl)))
return true;
if (node->instrumentation_clone
&& MAIN_NAME_P (DECL_NAME (node->orig_decl)))
return true;
return false;
} | /* Return true when function NODE should be considered externally visible. */ | Return true when function NODE should be considered externally visible. | [
"Return",
"true",
"when",
"function",
"NODE",
"should",
"be",
"considered",
"externally",
"visible",
"."
] | static bool
cgraph_externally_visible_p (struct cgraph_node *node,
bool whole_program)
{
while (node->transparent_alias && node->definition)
node = node->get_alias_target ();
if (!node->definition)
return false;
if (!TREE_PUBLIC (node->decl)
|| DECL_EXTERNAL (node->decl))
return false;
if (DECL_BUILT_IN (node->decl))
return true;
if (node->used_from_object_file_p ())
return true;
if (DECL_PRESERVE_P (node->decl))
return true;
if (lookup_attribute ("externally_visible",
DECL_ATTRIBUTES (node->decl)))
return true;
if (lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
return true;
if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
&& lookup_attribute ("dllexport",
DECL_ATTRIBUTES (node->decl)))
return true;
if (node->resolution == LDPR_PREVAILING_DEF_IRONLY)
return false;
if (((in_lto_p || whole_program) && !flag_incremental_link)
&& DECL_COMDAT (node->decl)
&& comdat_can_be_unshared_p (node))
return false;
if ((in_lto_p && !flag_incremental_link)
&& (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
|| DECL_VISIBILITY (node->decl) == VISIBILITY_INTERNAL)
&& node->definition)
;
else if (!whole_program)
return true;
if (MAIN_NAME_P (DECL_NAME (node->decl)))
return true;
if (node->instrumentation_clone
&& MAIN_NAME_P (DECL_NAME (node->orig_decl)))
return true;
return false;
} | [
"static",
"bool",
"cgraph_externally_visible_p",
"(",
"struct",
"cgraph_node",
"*",
"node",
",",
"bool",
"whole_program",
")",
"{",
"while",
"(",
"node",
"->",
"transparent_alias",
"&&",
"node",
"->",
"definition",
")",
"node",
"=",
"node",
"->",
"get_alias_target",
"(",
")",
";",
"if",
"(",
"!",
"node",
"->",
"definition",
")",
"return",
"false",
";",
"if",
"(",
"!",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
"||",
"DECL_EXTERNAL",
"(",
"node",
"->",
"decl",
")",
")",
"return",
"false",
";",
"if",
"(",
"DECL_BUILT_IN",
"(",
"node",
"->",
"decl",
")",
")",
"return",
"true",
";",
"if",
"(",
"node",
"->",
"used_from_object_file_p",
"(",
")",
")",
"return",
"true",
";",
"if",
"(",
"DECL_PRESERVE_P",
"(",
"node",
"->",
"decl",
")",
")",
"return",
"true",
";",
"if",
"(",
"lookup_attribute",
"(",
"\"",
"\"",
",",
"DECL_ATTRIBUTES",
"(",
"node",
"->",
"decl",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"lookup_attribute",
"(",
"\"",
"\"",
",",
"DECL_ATTRIBUTES",
"(",
"node",
"->",
"decl",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"TARGET_DLLIMPORT_DECL_ATTRIBUTES",
"&&",
"lookup_attribute",
"(",
"\"",
"\"",
",",
"DECL_ATTRIBUTES",
"(",
"node",
"->",
"decl",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
")",
"return",
"false",
";",
"if",
"(",
"(",
"(",
"in_lto_p",
"||",
"whole_program",
")",
"&&",
"!",
"flag_incremental_link",
")",
"&&",
"DECL_COMDAT",
"(",
"node",
"->",
"decl",
")",
"&&",
"comdat_can_be_unshared_p",
"(",
"node",
")",
")",
"return",
"false",
";",
"if",
"(",
"(",
"in_lto_p",
"&&",
"!",
"flag_incremental_link",
")",
"&&",
"(",
"DECL_VISIBILITY",
"(",
"node",
"->",
"decl",
")",
"==",
"VISIBILITY_HIDDEN",
"||",
"DECL_VISIBILITY",
"(",
"node",
"->",
"decl",
")",
"==",
"VISIBILITY_INTERNAL",
")",
"&&",
"node",
"->",
"definition",
")",
";",
"else",
"if",
"(",
"!",
"whole_program",
")",
"return",
"true",
";",
"if",
"(",
"MAIN_NAME_P",
"(",
"DECL_NAME",
"(",
"node",
"->",
"decl",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"node",
"->",
"instrumentation_clone",
"&&",
"MAIN_NAME_P",
"(",
"DECL_NAME",
"(",
"node",
"->",
"orig_decl",
")",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Return true when function NODE should be considered externally visible. | [
"Return",
"true",
"when",
"function",
"NODE",
"should",
"be",
"considered",
"externally",
"visible",
"."
] | [
"/* Do not try to localize built-in functions yet. One of problems is that we\n end up mangling their asm for WHOPR that makes it impossible to call them\n using the implicit built-in declarations anymore. Similarly this enables\n us to remove them as unreachable before actual calls may appear during\n expansion or folding. */",
"/* If linker counts on us, we must preserve the function. */",
"/* When doing LTO or whole program, we can bring COMDAT functoins static.\n This improves code quality and we know we will duplicate them at most twice\n (in the case that we are not using plugin and link with object file\n implementing same COMDAT) */",
"/* When doing link time optimizations, hidden symbols become local. */",
"/* Be sure that node is defined in IR file, not in other object\n\t file. In that case we don't set used_from_other_object_file. */"
] | [
{
"param": "node",
"type": "struct cgraph_node"
},
{
"param": "whole_program",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "struct cgraph_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "whole_program",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | can_replace_by_local_alias | bool | static bool
can_replace_by_local_alias (symtab_node *node)
{
/* If aliases aren't supported, we can't do replacement. */
if (!TARGET_SUPPORTS_ALIASES)
return false;
/* Weakrefs have a reason to be non-local. Be sure we do not replace
them. */
while (node->transparent_alias && node->definition && !node->weakref)
node = node->get_alias_target ();
if (node->weakref)
return false;
return (node->get_availability () > AVAIL_INTERPOSABLE
&& !decl_binds_to_current_def_p (node->decl)
&& !node->can_be_discarded_p ());
} | /* Return true if reference to NODE can be replaced by a local alias.
Local aliases save dynamic linking overhead and enable more optimizations.
*/ | Return true if reference to NODE can be replaced by a local alias.
Local aliases save dynamic linking overhead and enable more optimizations. | [
"Return",
"true",
"if",
"reference",
"to",
"NODE",
"can",
"be",
"replaced",
"by",
"a",
"local",
"alias",
".",
"Local",
"aliases",
"save",
"dynamic",
"linking",
"overhead",
"and",
"enable",
"more",
"optimizations",
"."
] | static bool
can_replace_by_local_alias (symtab_node *node)
{
if (!TARGET_SUPPORTS_ALIASES)
return false;
while (node->transparent_alias && node->definition && !node->weakref)
node = node->get_alias_target ();
if (node->weakref)
return false;
return (node->get_availability () > AVAIL_INTERPOSABLE
&& !decl_binds_to_current_def_p (node->decl)
&& !node->can_be_discarded_p ());
} | [
"static",
"bool",
"can_replace_by_local_alias",
"(",
"symtab_node",
"*",
"node",
")",
"{",
"if",
"(",
"!",
"TARGET_SUPPORTS_ALIASES",
")",
"return",
"false",
";",
"while",
"(",
"node",
"->",
"transparent_alias",
"&&",
"node",
"->",
"definition",
"&&",
"!",
"node",
"->",
"weakref",
")",
"node",
"=",
"node",
"->",
"get_alias_target",
"(",
")",
";",
"if",
"(",
"node",
"->",
"weakref",
")",
"return",
"false",
";",
"return",
"(",
"node",
"->",
"get_availability",
"(",
")",
">",
"AVAIL_INTERPOSABLE",
"&&",
"!",
"decl_binds_to_current_def_p",
"(",
"node",
"->",
"decl",
")",
"&&",
"!",
"node",
"->",
"can_be_discarded_p",
"(",
")",
")",
";",
"}"
] | Return true if reference to NODE can be replaced by a local alias. | [
"Return",
"true",
"if",
"reference",
"to",
"NODE",
"can",
"be",
"replaced",
"by",
"a",
"local",
"alias",
"."
] | [
"/* If aliases aren't supported, we can't do replacement. */",
"/* Weakrefs have a reason to be non-local. Be sure we do not replace\n them. */"
] | [
{
"param": "node",
"type": "symtab_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "symtab_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | update_visibility_by_resolution_info | void | static void
update_visibility_by_resolution_info (symtab_node * node)
{
bool define;
if (!node->externally_visible
|| (!DECL_WEAK (node->decl) && !DECL_ONE_ONLY (node->decl))
|| node->resolution == LDPR_UNKNOWN)
return;
define = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF
|| node->resolution == LDPR_UNDEF
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
/* The linker decisions ought to agree in the whole group. */
if (node->same_comdat_group)
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
if (!next->externally_visible || next->transparent_alias)
continue;
bool same_def
= define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->resolution == LDPR_PREVAILING_DEF
|| next->resolution == LDPR_UNDEF
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
gcc_assert (in_lto_p || same_def);
if (!same_def)
return;
}
if (node->same_comdat_group)
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
/* During incremental linking we need to keep symbol weak for future
linking. We can still drop definition if we know non-LTO world
prevails. */
if (!flag_incremental_link)
{
DECL_WEAK (next->decl) = false;
next->set_comdat_group (NULL);
}
if (!define)
{
if (next->externally_visible)
DECL_EXTERNAL (next->decl) = true;
next->set_comdat_group (NULL);
}
}
/* During incremental linking we need to keep symbol weak for future
linking. We can still drop definition if we know non-LTO world prevails. */
if (!flag_incremental_link)
{
DECL_WEAK (node->decl) = false;
node->set_comdat_group (NULL);
node->dissolve_same_comdat_group_list ();
}
if (!define)
{
DECL_EXTERNAL (node->decl) = true;
node->set_comdat_group (NULL);
node->dissolve_same_comdat_group_list ();
}
} | /* In LTO we can remove COMDAT groups and weak symbols.
Either turn them into normal symbols or external symbol depending on
resolution info. */ | In LTO we can remove COMDAT groups and weak symbols.
Either turn them into normal symbols or external symbol depending on
resolution info. | [
"In",
"LTO",
"we",
"can",
"remove",
"COMDAT",
"groups",
"and",
"weak",
"symbols",
".",
"Either",
"turn",
"them",
"into",
"normal",
"symbols",
"or",
"external",
"symbol",
"depending",
"on",
"resolution",
"info",
"."
] | static void
update_visibility_by_resolution_info (symtab_node * node)
{
bool define;
if (!node->externally_visible
|| (!DECL_WEAK (node->decl) && !DECL_ONE_ONLY (node->decl))
|| node->resolution == LDPR_UNKNOWN)
return;
define = (node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF
|| node->resolution == LDPR_UNDEF
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
if (node->same_comdat_group)
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
if (!next->externally_visible || next->transparent_alias)
continue;
bool same_def
= define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->resolution == LDPR_PREVAILING_DEF
|| next->resolution == LDPR_UNDEF
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
gcc_assert (in_lto_p || same_def);
if (!same_def)
return;
}
if (node->same_comdat_group)
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
if (!flag_incremental_link)
{
DECL_WEAK (next->decl) = false;
next->set_comdat_group (NULL);
}
if (!define)
{
if (next->externally_visible)
DECL_EXTERNAL (next->decl) = true;
next->set_comdat_group (NULL);
}
}
if (!flag_incremental_link)
{
DECL_WEAK (node->decl) = false;
node->set_comdat_group (NULL);
node->dissolve_same_comdat_group_list ();
}
if (!define)
{
DECL_EXTERNAL (node->decl) = true;
node->set_comdat_group (NULL);
node->dissolve_same_comdat_group_list ();
}
} | [
"static",
"void",
"update_visibility_by_resolution_info",
"(",
"symtab_node",
"*",
"node",
")",
"{",
"bool",
"define",
";",
"if",
"(",
"!",
"node",
"->",
"externally_visible",
"||",
"(",
"!",
"DECL_WEAK",
"(",
"node",
"->",
"decl",
")",
"&&",
"!",
"DECL_ONE_ONLY",
"(",
"node",
"->",
"decl",
")",
")",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_UNKNOWN",
")",
"return",
";",
"define",
"=",
"(",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_UNDEF",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
")",
";",
"if",
"(",
"node",
"->",
"same_comdat_group",
")",
"for",
"(",
"symtab_node",
"*",
"next",
"=",
"node",
"->",
"same_comdat_group",
";",
"next",
"!=",
"node",
";",
"next",
"=",
"next",
"->",
"same_comdat_group",
")",
"{",
"if",
"(",
"!",
"next",
"->",
"externally_visible",
"||",
"next",
"->",
"transparent_alias",
")",
"continue",
";",
"bool",
"same_def",
"=",
"define",
"==",
"(",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
"||",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF",
"||",
"next",
"->",
"resolution",
"==",
"LDPR_UNDEF",
"||",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
")",
";",
"gcc_assert",
"(",
"in_lto_p",
"||",
"same_def",
")",
";",
"if",
"(",
"!",
"same_def",
")",
"return",
";",
"}",
"if",
"(",
"node",
"->",
"same_comdat_group",
")",
"for",
"(",
"symtab_node",
"*",
"next",
"=",
"node",
"->",
"same_comdat_group",
";",
"next",
"!=",
"node",
";",
"next",
"=",
"next",
"->",
"same_comdat_group",
")",
"{",
"if",
"(",
"!",
"flag_incremental_link",
")",
"{",
"DECL_WEAK",
"(",
"next",
"->",
"decl",
")",
"=",
"false",
";",
"next",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"}",
"if",
"(",
"!",
"define",
")",
"{",
"if",
"(",
"next",
"->",
"externally_visible",
")",
"DECL_EXTERNAL",
"(",
"next",
"->",
"decl",
")",
"=",
"true",
";",
"next",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"}",
"}",
"if",
"(",
"!",
"flag_incremental_link",
")",
"{",
"DECL_WEAK",
"(",
"node",
"->",
"decl",
")",
"=",
"false",
";",
"node",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"node",
"->",
"dissolve_same_comdat_group_list",
"(",
")",
";",
"}",
"if",
"(",
"!",
"define",
")",
"{",
"DECL_EXTERNAL",
"(",
"node",
"->",
"decl",
")",
"=",
"true",
";",
"node",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"node",
"->",
"dissolve_same_comdat_group_list",
"(",
")",
";",
"}",
"}"
] | In LTO we can remove COMDAT groups and weak symbols. | [
"In",
"LTO",
"we",
"can",
"remove",
"COMDAT",
"groups",
"and",
"weak",
"symbols",
"."
] | [
"/* The linker decisions ought to agree in the whole group. */",
"/* During incremental linking we need to keep symbol weak for future\n\t linking. We can still drop definition if we know non-LTO world\n\t prevails. */",
"/* During incremental linking we need to keep symbol weak for future\n linking. We can still drop definition if we know non-LTO world prevails. */"
] | [
{
"param": "node",
"type": "symtab_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "symtab_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | optimize_weakref | void | static void
optimize_weakref (symtab_node *node)
{
bool strip_weakref = false;
bool static_alias = false;
gcc_assert (node->weakref);
/* Weakrefs with no target defined can not be optimized. */
if (!node->analyzed)
return;
symtab_node *target = node->get_alias_target ();
/* Weakrefs to weakrefs can be optimized only if target can be. */
if (target->weakref)
optimize_weakref (target);
if (target->weakref)
return;
/* If we have definition of weakref's target and we know it binds locally,
we can turn weakref to static alias. */
if (TARGET_SUPPORTS_ALIASES
&& target->definition && decl_binds_to_current_def_p (target->decl))
strip_weakref = static_alias = true;
/* Otherwise we can turn weakref into transparent alias. This transformation
may break asm statements which directly refers to symbol name and expect
GNU as to translate it via .weakref directive. So do not optimize when
DECL_PRESERVED is set and .weakref is supported. */
else if ((!DECL_PRESERVE_P (target->decl)
|| IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)))
&& !DECL_WEAK (target->decl)
&& !DECL_EXTERNAL (target->decl)
&& ((target->definition && !target->can_be_discarded_p ())
|| target->resolution != LDPR_UNDEF))
strip_weakref = true;
if (!strip_weakref)
return;
node->weakref = false;
IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)) = 0;
TREE_CHAIN (DECL_ASSEMBLER_NAME (node->decl)) = NULL_TREE;
DECL_ATTRIBUTES (node->decl) = remove_attribute ("weakref",
DECL_ATTRIBUTES
(node->decl));
if (dump_file)
fprintf (dump_file, "Optimizing weakref %s %s\n",
node->name(),
static_alias ? "as static alias" : "as transparent alias");
if (static_alias)
{
/* make_decl_local will shortcircuit if it doesn't see TREE_PUBLIC.
be sure it really clears the WEAK flag. */
TREE_PUBLIC (node->decl) = true;
node->make_decl_local ();
node->forced_by_abi = false;
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->externally_visible = false;
gcc_assert (!DECL_WEAK (node->decl));
node->transparent_alias = false;
}
else
{
symtab->change_decl_assembler_name
(node->decl, DECL_ASSEMBLER_NAME (node->get_alias_target ()->decl));
node->transparent_alias = true;
node->copy_visibility_from (target);
}
gcc_assert (node->alias);
} | /* Try to get rid of weakref. */ | Try to get rid of weakref. | [
"Try",
"to",
"get",
"rid",
"of",
"weakref",
"."
] | static void
optimize_weakref (symtab_node *node)
{
bool strip_weakref = false;
bool static_alias = false;
gcc_assert (node->weakref);
if (!node->analyzed)
return;
symtab_node *target = node->get_alias_target ();
if (target->weakref)
optimize_weakref (target);
if (target->weakref)
return;
if (TARGET_SUPPORTS_ALIASES
&& target->definition && decl_binds_to_current_def_p (target->decl))
strip_weakref = static_alias = true;
else if ((!DECL_PRESERVE_P (target->decl)
|| IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)))
&& !DECL_WEAK (target->decl)
&& !DECL_EXTERNAL (target->decl)
&& ((target->definition && !target->can_be_discarded_p ())
|| target->resolution != LDPR_UNDEF))
strip_weakref = true;
if (!strip_weakref)
return;
node->weakref = false;
IDENTIFIER_TRANSPARENT_ALIAS (DECL_ASSEMBLER_NAME (node->decl)) = 0;
TREE_CHAIN (DECL_ASSEMBLER_NAME (node->decl)) = NULL_TREE;
DECL_ATTRIBUTES (node->decl) = remove_attribute ("weakref",
DECL_ATTRIBUTES
(node->decl));
if (dump_file)
fprintf (dump_file, "Optimizing weakref %s %s\n",
node->name(),
static_alias ? "as static alias" : "as transparent alias");
if (static_alias)
{
TREE_PUBLIC (node->decl) = true;
node->make_decl_local ();
node->forced_by_abi = false;
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->externally_visible = false;
gcc_assert (!DECL_WEAK (node->decl));
node->transparent_alias = false;
}
else
{
symtab->change_decl_assembler_name
(node->decl, DECL_ASSEMBLER_NAME (node->get_alias_target ()->decl));
node->transparent_alias = true;
node->copy_visibility_from (target);
}
gcc_assert (node->alias);
} | [
"static",
"void",
"optimize_weakref",
"(",
"symtab_node",
"*",
"node",
")",
"{",
"bool",
"strip_weakref",
"=",
"false",
";",
"bool",
"static_alias",
"=",
"false",
";",
"gcc_assert",
"(",
"node",
"->",
"weakref",
")",
";",
"if",
"(",
"!",
"node",
"->",
"analyzed",
")",
"return",
";",
"symtab_node",
"*",
"target",
"=",
"node",
"->",
"get_alias_target",
"(",
")",
";",
"if",
"(",
"target",
"->",
"weakref",
")",
"optimize_weakref",
"(",
"target",
")",
";",
"if",
"(",
"target",
"->",
"weakref",
")",
"return",
";",
"if",
"(",
"TARGET_SUPPORTS_ALIASES",
"&&",
"target",
"->",
"definition",
"&&",
"decl_binds_to_current_def_p",
"(",
"target",
"->",
"decl",
")",
")",
"strip_weakref",
"=",
"static_alias",
"=",
"true",
";",
"else",
"if",
"(",
"(",
"!",
"DECL_PRESERVE_P",
"(",
"target",
"->",
"decl",
")",
"||",
"IDENTIFIER_TRANSPARENT_ALIAS",
"(",
"DECL_ASSEMBLER_NAME",
"(",
"node",
"->",
"decl",
")",
")",
")",
"&&",
"!",
"DECL_WEAK",
"(",
"target",
"->",
"decl",
")",
"&&",
"!",
"DECL_EXTERNAL",
"(",
"target",
"->",
"decl",
")",
"&&",
"(",
"(",
"target",
"->",
"definition",
"&&",
"!",
"target",
"->",
"can_be_discarded_p",
"(",
")",
")",
"||",
"target",
"->",
"resolution",
"!=",
"LDPR_UNDEF",
")",
")",
"strip_weakref",
"=",
"true",
";",
"if",
"(",
"!",
"strip_weakref",
")",
"return",
";",
"node",
"->",
"weakref",
"=",
"false",
";",
"IDENTIFIER_TRANSPARENT_ALIAS",
"(",
"DECL_ASSEMBLER_NAME",
"(",
"node",
"->",
"decl",
")",
")",
"=",
"0",
";",
"TREE_CHAIN",
"(",
"DECL_ASSEMBLER_NAME",
"(",
"node",
"->",
"decl",
")",
")",
"=",
"NULL_TREE",
";",
"DECL_ATTRIBUTES",
"(",
"node",
"->",
"decl",
")",
"=",
"remove_attribute",
"(",
"\"",
"\"",
",",
"DECL_ATTRIBUTES",
"(",
"node",
"->",
"decl",
")",
")",
";",
"if",
"(",
"dump_file",
")",
"fprintf",
"(",
"dump_file",
",",
"\"",
"\\n",
"\"",
",",
"node",
"->",
"name",
"(",
")",
",",
"static_alias",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"if",
"(",
"static_alias",
")",
"{",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
"=",
"true",
";",
"node",
"->",
"make_decl_local",
"(",
")",
";",
"node",
"->",
"forced_by_abi",
"=",
"false",
";",
"node",
"->",
"resolution",
"=",
"LDPR_PREVAILING_DEF_IRONLY",
";",
"node",
"->",
"externally_visible",
"=",
"false",
";",
"gcc_assert",
"(",
"!",
"DECL_WEAK",
"(",
"node",
"->",
"decl",
")",
")",
";",
"node",
"->",
"transparent_alias",
"=",
"false",
";",
"}",
"else",
"{",
"symtab",
"->",
"change_decl_assembler_name",
"(",
"node",
"->",
"decl",
",",
"DECL_ASSEMBLER_NAME",
"(",
"node",
"->",
"get_alias_target",
"(",
")",
"->",
"decl",
")",
")",
";",
"node",
"->",
"transparent_alias",
"=",
"true",
";",
"node",
"->",
"copy_visibility_from",
"(",
"target",
")",
";",
"}",
"gcc_assert",
"(",
"node",
"->",
"alias",
")",
";",
"}"
] | Try to get rid of weakref. | [
"Try",
"to",
"get",
"rid",
"of",
"weakref",
"."
] | [
"/* Weakrefs with no target defined can not be optimized. */",
"/* Weakrefs to weakrefs can be optimized only if target can be. */",
"/* If we have definition of weakref's target and we know it binds locally,\n we can turn weakref to static alias. */",
"/* Otherwise we can turn weakref into transparent alias. This transformation\n may break asm statements which directly refers to symbol name and expect\n GNU as to translate it via .weakref directive. So do not optimize when\n DECL_PRESERVED is set and .weakref is supported. */",
"/* make_decl_local will shortcircuit if it doesn't see TREE_PUBLIC.\n\t be sure it really clears the WEAK flag. */"
] | [
{
"param": "node",
"type": "symtab_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "symtab_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | localize_node | void | static void
localize_node (bool whole_program, symtab_node *node)
{
gcc_assert (whole_program || in_lto_p || !TREE_PUBLIC (node->decl));
/* It is possible that one comdat group contains both hidden and non-hidden
symbols. In this case we can privatize all hidden symbol but we need
to keep non-hidden exported. */
if (node->same_comdat_group
&& (node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP))
{
symtab_node *next;
for (next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
if (next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
|| next->resolution == LDPR_PREVAILING_DEF)
break;
if (node != next)
{
if (!node->transparent_alias)
{
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->make_decl_local ();
if (!flag_incremental_link)
node->unique_name |= true;
return;
}
}
}
/* For similar reason do not privatize whole comdat when seeing comdat
local. Wait for non-comdat symbol to be privatized first. */
if (node->comdat_local_p ())
return;
if (node->same_comdat_group && TREE_PUBLIC (node->decl))
{
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
next->set_comdat_group (NULL);
if (!next->alias)
next->set_section (NULL);
if (!next->transparent_alias)
next->make_decl_local ();
next->unique_name
|= ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (next->decl)
&& !flag_incremental_link);
}
/* Now everything's localized, the grouping has no meaning, and
will cause crashes if we keep it around. */
node->dissolve_same_comdat_group_list ();
}
node->unique_name
|= ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (node->decl)
&& !flag_incremental_link);
if (TREE_PUBLIC (node->decl))
node->set_comdat_group (NULL);
if (DECL_COMDAT (node->decl) && !node->alias)
node->set_section (NULL);
if (!node->transparent_alias)
{
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->make_decl_local ();
}
} | /* NODE is an externally visible definition, which we've discovered is
not needed externally. Make it local to this compilation. */ | NODE is an externally visible definition, which we've discovered is
not needed externally. Make it local to this compilation. | [
"NODE",
"is",
"an",
"externally",
"visible",
"definition",
"which",
"we",
"'",
"ve",
"discovered",
"is",
"not",
"needed",
"externally",
".",
"Make",
"it",
"local",
"to",
"this",
"compilation",
"."
] | static void
localize_node (bool whole_program, symtab_node *node)
{
gcc_assert (whole_program || in_lto_p || !TREE_PUBLIC (node->decl));
if (node->same_comdat_group
&& (node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP))
{
symtab_node *next;
for (next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
if (next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
|| next->resolution == LDPR_PREVAILING_DEF)
break;
if (node != next)
{
if (!node->transparent_alias)
{
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->make_decl_local ();
if (!flag_incremental_link)
node->unique_name |= true;
return;
}
}
}
if (node->comdat_local_p ())
return;
if (node->same_comdat_group && TREE_PUBLIC (node->decl))
{
for (symtab_node *next = node->same_comdat_group;
next != node; next = next->same_comdat_group)
{
next->set_comdat_group (NULL);
if (!next->alias)
next->set_section (NULL);
if (!next->transparent_alias)
next->make_decl_local ();
next->unique_name
|= ((next->resolution == LDPR_PREVAILING_DEF_IRONLY
|| next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (next->decl)
&& !flag_incremental_link);
}
node->dissolve_same_comdat_group_list ();
}
node->unique_name
|= ((node->resolution == LDPR_PREVAILING_DEF_IRONLY
|| node->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP)
&& TREE_PUBLIC (node->decl)
&& !flag_incremental_link);
if (TREE_PUBLIC (node->decl))
node->set_comdat_group (NULL);
if (DECL_COMDAT (node->decl) && !node->alias)
node->set_section (NULL);
if (!node->transparent_alias)
{
node->resolution = LDPR_PREVAILING_DEF_IRONLY;
node->make_decl_local ();
}
} | [
"static",
"void",
"localize_node",
"(",
"bool",
"whole_program",
",",
"symtab_node",
"*",
"node",
")",
"{",
"gcc_assert",
"(",
"whole_program",
"||",
"in_lto_p",
"||",
"!",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
")",
";",
"if",
"(",
"node",
"->",
"same_comdat_group",
"&&",
"(",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
")",
")",
"{",
"symtab_node",
"*",
"next",
";",
"for",
"(",
"next",
"=",
"node",
"->",
"same_comdat_group",
";",
"next",
"!=",
"node",
";",
"next",
"=",
"next",
"->",
"same_comdat_group",
")",
"if",
"(",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
"||",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF",
")",
"break",
";",
"if",
"(",
"node",
"!=",
"next",
")",
"{",
"if",
"(",
"!",
"node",
"->",
"transparent_alias",
")",
"{",
"node",
"->",
"resolution",
"=",
"LDPR_PREVAILING_DEF_IRONLY",
";",
"node",
"->",
"make_decl_local",
"(",
")",
";",
"if",
"(",
"!",
"flag_incremental_link",
")",
"node",
"->",
"unique_name",
"|=",
"true",
";",
"return",
";",
"}",
"}",
"}",
"if",
"(",
"node",
"->",
"comdat_local_p",
"(",
")",
")",
"return",
";",
"if",
"(",
"node",
"->",
"same_comdat_group",
"&&",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
")",
"{",
"for",
"(",
"symtab_node",
"*",
"next",
"=",
"node",
"->",
"same_comdat_group",
";",
"next",
"!=",
"node",
";",
"next",
"=",
"next",
"->",
"same_comdat_group",
")",
"{",
"next",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"if",
"(",
"!",
"next",
"->",
"alias",
")",
"next",
"->",
"set_section",
"(",
"NULL",
")",
";",
"if",
"(",
"!",
"next",
"->",
"transparent_alias",
")",
"next",
"->",
"make_decl_local",
"(",
")",
";",
"next",
"->",
"unique_name",
"|=",
"(",
"(",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
"||",
"next",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
")",
"&&",
"TREE_PUBLIC",
"(",
"next",
"->",
"decl",
")",
"&&",
"!",
"flag_incremental_link",
")",
";",
"}",
"node",
"->",
"dissolve_same_comdat_group_list",
"(",
")",
";",
"}",
"node",
"->",
"unique_name",
"|=",
"(",
"(",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY",
"||",
"node",
"->",
"resolution",
"==",
"LDPR_PREVAILING_DEF_IRONLY_EXP",
")",
"&&",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
"&&",
"!",
"flag_incremental_link",
")",
";",
"if",
"(",
"TREE_PUBLIC",
"(",
"node",
"->",
"decl",
")",
")",
"node",
"->",
"set_comdat_group",
"(",
"NULL",
")",
";",
"if",
"(",
"DECL_COMDAT",
"(",
"node",
"->",
"decl",
")",
"&&",
"!",
"node",
"->",
"alias",
")",
"node",
"->",
"set_section",
"(",
"NULL",
")",
";",
"if",
"(",
"!",
"node",
"->",
"transparent_alias",
")",
"{",
"node",
"->",
"resolution",
"=",
"LDPR_PREVAILING_DEF_IRONLY",
";",
"node",
"->",
"make_decl_local",
"(",
")",
";",
"}",
"}"
] | NODE is an externally visible definition, which we've discovered is
not needed externally. | [
"NODE",
"is",
"an",
"externally",
"visible",
"definition",
"which",
"we",
"'",
"ve",
"discovered",
"is",
"not",
"needed",
"externally",
"."
] | [
"/* It is possible that one comdat group contains both hidden and non-hidden\n symbols. In this case we can privatize all hidden symbol but we need\n to keep non-hidden exported. */",
"/* For similar reason do not privatize whole comdat when seeing comdat\n local. Wait for non-comdat symbol to be privatized first. */",
"/* Now everything's localized, the grouping has no meaning, and\n\t will cause crashes if we keep it around. */"
] | [
{
"param": "whole_program",
"type": "bool"
},
{
"param": "node",
"type": "symtab_node"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "whole_program",
"type": "bool",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "symtab_node",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e89255e8f1dc159117518175fd4239d7da5b787 | atrens/DragonFlyBSD-src | contrib/gcc-8.0/gcc/ipa-visibility.c | [
"BSD-3-Clause"
] | C | whole_program_function_and_variable_visibility | null | static unsigned int
whole_program_function_and_variable_visibility (void)
{
function_and_variable_visibility (flag_whole_program);
if (optimize || in_lto_p)
ipa_discover_readonly_nonaddressable_vars ();
return 0;
} | /* Bring functions local at LTO time with -fwhole-program. */ | Bring functions local at LTO time with -fwhole-program. | [
"Bring",
"functions",
"local",
"at",
"LTO",
"time",
"with",
"-",
"fwhole",
"-",
"program",
"."
] | static unsigned int
whole_program_function_and_variable_visibility (void)
{
function_and_variable_visibility (flag_whole_program);
if (optimize || in_lto_p)
ipa_discover_readonly_nonaddressable_vars ();
return 0;
} | [
"static",
"unsigned",
"int",
"whole_program_function_and_variable_visibility",
"(",
"void",
")",
"{",
"function_and_variable_visibility",
"(",
"flag_whole_program",
")",
";",
"if",
"(",
"optimize",
"||",
"in_lto_p",
")",
"ipa_discover_readonly_nonaddressable_vars",
"(",
")",
";",
"return",
"0",
";",
"}"
] | Bring functions local at LTO time with -fwhole-program. | [
"Bring",
"functions",
"local",
"at",
"LTO",
"time",
"with",
"-",
"fwhole",
"-",
"program",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e0c8ba3f1ee42bfec1dfa409356a069f8fb71b79 | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldemul.c | [
"BSD-3-Clause"
] | C | ldemul_unrecognized_file | bfd_boolean | bfd_boolean
ldemul_unrecognized_file (lang_input_statement_type *entry)
{
if (ld_emulation->unrecognized_file)
return (*ld_emulation->unrecognized_file) (entry);
return FALSE;
} | /* Let the emulation code handle an unrecognized file. */ | Let the emulation code handle an unrecognized file. | [
"Let",
"the",
"emulation",
"code",
"handle",
"an",
"unrecognized",
"file",
"."
] | bfd_boolean
ldemul_unrecognized_file (lang_input_statement_type *entry)
{
if (ld_emulation->unrecognized_file)
return (*ld_emulation->unrecognized_file) (entry);
return FALSE;
} | [
"bfd_boolean",
"ldemul_unrecognized_file",
"(",
"lang_input_statement_type",
"*",
"entry",
")",
"{",
"if",
"(",
"ld_emulation",
"->",
"unrecognized_file",
")",
"return",
"(",
"*",
"ld_emulation",
"->",
"unrecognized_file",
")",
"(",
"entry",
")",
";",
"return",
"FALSE",
";",
"}"
] | Let the emulation code handle an unrecognized file. | [
"Let",
"the",
"emulation",
"code",
"handle",
"an",
"unrecognized",
"file",
"."
] | [] | [
{
"param": "entry",
"type": "lang_input_statement_type"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "lang_input_statement_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0c8ba3f1ee42bfec1dfa409356a069f8fb71b79 | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldemul.c | [
"BSD-3-Clause"
] | C | ldemul_recognized_file | bfd_boolean | bfd_boolean
ldemul_recognized_file (lang_input_statement_type *entry)
{
if (ld_emulation->recognized_file)
return (*ld_emulation->recognized_file) (entry);
return FALSE;
} | /* Let the emulation code handle a recognized file. */ | Let the emulation code handle a recognized file. | [
"Let",
"the",
"emulation",
"code",
"handle",
"a",
"recognized",
"file",
"."
] | bfd_boolean
ldemul_recognized_file (lang_input_statement_type *entry)
{
if (ld_emulation->recognized_file)
return (*ld_emulation->recognized_file) (entry);
return FALSE;
} | [
"bfd_boolean",
"ldemul_recognized_file",
"(",
"lang_input_statement_type",
"*",
"entry",
")",
"{",
"if",
"(",
"ld_emulation",
"->",
"recognized_file",
")",
"return",
"(",
"*",
"ld_emulation",
"->",
"recognized_file",
")",
"(",
"entry",
")",
";",
"return",
"FALSE",
";",
"}"
] | Let the emulation code handle a recognized file. | [
"Let",
"the",
"emulation",
"code",
"handle",
"a",
"recognized",
"file",
"."
] | [] | [
{
"param": "entry",
"type": "lang_input_statement_type"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entry",
"type": "lang_input_statement_type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0c8ba3f1ee42bfec1dfa409356a069f8fb71b79 | atrens/DragonFlyBSD-src | contrib/binutils-2.27/ld/ldemul.c | [
"BSD-3-Clause"
] | C | after_parse_default | void | void
after_parse_default (void)
{
if (entry_symbol.name != NULL
&& (bfd_link_executable (&link_info) || entry_from_cmdline))
{
bfd_boolean is_vma = FALSE;
if (entry_from_cmdline)
{
const char *send;
bfd_scan_vma (entry_symbol.name, &send, 0);
is_vma = *send == '\0';
}
if (!is_vma)
ldlang_add_undef (entry_symbol.name, entry_from_cmdline);
}
} | /* If the entry point was not specified as an address, then add the
symbol as undefined. This will cause ld to extract an archive
element defining the entry if ld is linking against such an archive.
We don't do this when generating shared libraries unless given -e
on the command line, because most shared libs are not designed to
be run as an executable. However, some are, eg. glibc ld.so and
may rely on the default linker script supplying ENTRY. So we can't
remove the ENTRY from the script, but would rather not insert
undefined _start syms. */ | If the entry point was not specified as an address, then add the
symbol as undefined. This will cause ld to extract an archive
element defining the entry if ld is linking against such an archive.
We don't do this when generating shared libraries unless given -e
on the command line, because most shared libs are not designed to
be run as an executable. However, some are, eg. glibc ld.so and
may rely on the default linker script supplying ENTRY. So we can't
remove the ENTRY from the script, but would rather not insert
undefined _start syms. | [
"If",
"the",
"entry",
"point",
"was",
"not",
"specified",
"as",
"an",
"address",
"then",
"add",
"the",
"symbol",
"as",
"undefined",
".",
"This",
"will",
"cause",
"ld",
"to",
"extract",
"an",
"archive",
"element",
"defining",
"the",
"entry",
"if",
"ld",
"is",
"linking",
"against",
"such",
"an",
"archive",
".",
"We",
"don",
"'",
"t",
"do",
"this",
"when",
"generating",
"shared",
"libraries",
"unless",
"given",
"-",
"e",
"on",
"the",
"command",
"line",
"because",
"most",
"shared",
"libs",
"are",
"not",
"designed",
"to",
"be",
"run",
"as",
"an",
"executable",
".",
"However",
"some",
"are",
"eg",
".",
"glibc",
"ld",
".",
"so",
"and",
"may",
"rely",
"on",
"the",
"default",
"linker",
"script",
"supplying",
"ENTRY",
".",
"So",
"we",
"can",
"'",
"t",
"remove",
"the",
"ENTRY",
"from",
"the",
"script",
"but",
"would",
"rather",
"not",
"insert",
"undefined",
"_start",
"syms",
"."
] | void
after_parse_default (void)
{
if (entry_symbol.name != NULL
&& (bfd_link_executable (&link_info) || entry_from_cmdline))
{
bfd_boolean is_vma = FALSE;
if (entry_from_cmdline)
{
const char *send;
bfd_scan_vma (entry_symbol.name, &send, 0);
is_vma = *send == '\0';
}
if (!is_vma)
ldlang_add_undef (entry_symbol.name, entry_from_cmdline);
}
} | [
"void",
"after_parse_default",
"(",
"void",
")",
"{",
"if",
"(",
"entry_symbol",
".",
"name",
"!=",
"NULL",
"&&",
"(",
"bfd_link_executable",
"(",
"&",
"link_info",
")",
"||",
"entry_from_cmdline",
")",
")",
"{",
"bfd_boolean",
"is_vma",
"=",
"FALSE",
";",
"if",
"(",
"entry_from_cmdline",
")",
"{",
"const",
"char",
"*",
"send",
";",
"bfd_scan_vma",
"(",
"entry_symbol",
".",
"name",
",",
"&",
"send",
",",
"0",
")",
";",
"is_vma",
"=",
"*",
"send",
"==",
"'",
"\\0",
"'",
";",
"}",
"if",
"(",
"!",
"is_vma",
")",
"ldlang_add_undef",
"(",
"entry_symbol",
".",
"name",
",",
"entry_from_cmdline",
")",
";",
"}",
"}"
] | If the entry point was not specified as an address, then add the
symbol as undefined. | [
"If",
"the",
"entry",
"point",
"was",
"not",
"specified",
"as",
"an",
"address",
"then",
"add",
"the",
"symbol",
"as",
"undefined",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a462e76a0a8e149198e9265d21bda2c51c1b5718 | atrens/DragonFlyBSD-src | usr.bin/window/wwinit.c | [
"BSD-3-Clause"
] | C | wwreset | void | void
wwreset(void)
{
int i;
xxreset();
for (i = 0; i < wwnrow; i++)
wwtouched[i] = WWU_TOUCHED;
} | /*
* Reset data structures and terminal from an unknown state.
* Restoring wwos has been taken care of elsewhere.
*/ | Reset data structures and terminal from an unknown state.
Restoring wwos has been taken care of elsewhere. | [
"Reset",
"data",
"structures",
"and",
"terminal",
"from",
"an",
"unknown",
"state",
".",
"Restoring",
"wwos",
"has",
"been",
"taken",
"care",
"of",
"elsewhere",
"."
] | void
wwreset(void)
{
int i;
xxreset();
for (i = 0; i < wwnrow; i++)
wwtouched[i] = WWU_TOUCHED;
} | [
"void",
"wwreset",
"(",
"void",
")",
"{",
"int",
"i",
";",
"xxreset",
"(",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"wwnrow",
";",
"i",
"++",
")",
"wwtouched",
"[",
"i",
"]",
"=",
"WWU_TOUCHED",
";",
"}"
] | Reset data structures and terminal from an unknown state. | [
"Reset",
"data",
"structures",
"and",
"terminal",
"from",
"an",
"unknown",
"state",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
24c9fff8e816ef59407573f6c8b75ed037142c06 | atrens/DragonFlyBSD-src | sys/dev/netif/sk/if_sk.c | [
"BSD-3-Clause"
] | C | sk_reset | void | static void
sk_reset(struct sk_softc *sc)
{
DPRINTFN(2, ("sk_reset\n"));
CSR_WRITE_2(sc, SK_CSR, SK_CSR_SW_RESET);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_MASTER_RESET);
if (SK_IS_YUKON(sc))
CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_SET);
DELAY(1000);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_SW_UNRESET);
DELAY(2);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_MASTER_UNRESET);
if (SK_IS_YUKON(sc))
CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_CLEAR);
DPRINTFN(2, ("sk_reset: sk_csr=%x\n", CSR_READ_2(sc, SK_CSR)));
DPRINTFN(2, ("sk_reset: sk_link_ctrl=%x\n",
CSR_READ_2(sc, SK_LINK_CTRL)));
if (SK_IS_GENESIS(sc)) {
/* Configure packet arbiter */
sk_win_write_2(sc, SK_PKTARB_CTL, SK_PKTARBCTL_UNRESET);
sk_win_write_2(sc, SK_RXPA1_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_TXPA1_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_RXPA2_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_TXPA2_TINIT, SK_PKTARB_TIMEOUT);
}
/* Enable RAM interface */
sk_win_write_4(sc, SK_RAMCTL, SK_RAMCTL_UNRESET);
/*
* Configure interrupt moderation. The moderation timer
* defers interrupts specified in the interrupt moderation
* timer mask based on the timeout specified in the interrupt
* moderation timer init register. Each bit in the timer
* register represents one tick, so to specify a timeout in
* microseconds, we have to multiply by the correct number of
* ticks-per-microsecond.
*/
KKASSERT(sc->sk_imtimer_ticks != 0 && sc->sk_imtime != 0);
sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc, sc->sk_imtime));
sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF|SK_ISR_TX2_S_EOF|
SK_ISR_RX1_EOF|SK_ISR_RX2_EOF);
sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START);
} | /*
* Force the GEnesis into reset, then bring it out of reset.
*/ | Force the GEnesis into reset, then bring it out of reset. | [
"Force",
"the",
"GEnesis",
"into",
"reset",
"then",
"bring",
"it",
"out",
"of",
"reset",
"."
] | static void
sk_reset(struct sk_softc *sc)
{
DPRINTFN(2, ("sk_reset\n"));
CSR_WRITE_2(sc, SK_CSR, SK_CSR_SW_RESET);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_MASTER_RESET);
if (SK_IS_YUKON(sc))
CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_SET);
DELAY(1000);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_SW_UNRESET);
DELAY(2);
CSR_WRITE_2(sc, SK_CSR, SK_CSR_MASTER_UNRESET);
if (SK_IS_YUKON(sc))
CSR_WRITE_2(sc, SK_LINK_CTRL, SK_LINK_RESET_CLEAR);
DPRINTFN(2, ("sk_reset: sk_csr=%x\n", CSR_READ_2(sc, SK_CSR)));
DPRINTFN(2, ("sk_reset: sk_link_ctrl=%x\n",
CSR_READ_2(sc, SK_LINK_CTRL)));
if (SK_IS_GENESIS(sc)) {
sk_win_write_2(sc, SK_PKTARB_CTL, SK_PKTARBCTL_UNRESET);
sk_win_write_2(sc, SK_RXPA1_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_TXPA1_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_RXPA2_TINIT, SK_PKTARB_TIMEOUT);
sk_win_write_2(sc, SK_TXPA2_TINIT, SK_PKTARB_TIMEOUT);
}
sk_win_write_4(sc, SK_RAMCTL, SK_RAMCTL_UNRESET);
KKASSERT(sc->sk_imtimer_ticks != 0 && sc->sk_imtime != 0);
sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(sc, sc->sk_imtime));
sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF|SK_ISR_TX2_S_EOF|
SK_ISR_RX1_EOF|SK_ISR_RX2_EOF);
sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START);
} | [
"static",
"void",
"sk_reset",
"(",
"struct",
"sk_softc",
"*",
"sc",
")",
"{",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_CSR",
",",
"SK_CSR_SW_RESET",
")",
";",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_CSR",
",",
"SK_CSR_MASTER_RESET",
")",
";",
"if",
"(",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_LINK_CTRL",
",",
"SK_LINK_RESET_SET",
")",
";",
"DELAY",
"(",
"1000",
")",
";",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_CSR",
",",
"SK_CSR_SW_UNRESET",
")",
";",
"DELAY",
"(",
"2",
")",
";",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_CSR",
",",
"SK_CSR_MASTER_UNRESET",
")",
";",
"if",
"(",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_LINK_CTRL",
",",
"SK_LINK_RESET_CLEAR",
")",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
",",
"CSR_READ_2",
"(",
"sc",
",",
"SK_CSR",
")",
")",
")",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
",",
"CSR_READ_2",
"(",
"sc",
",",
"SK_LINK_CTRL",
")",
")",
")",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"sk_win_write_2",
"(",
"sc",
",",
"SK_PKTARB_CTL",
",",
"SK_PKTARBCTL_UNRESET",
")",
";",
"sk_win_write_2",
"(",
"sc",
",",
"SK_RXPA1_TINIT",
",",
"SK_PKTARB_TIMEOUT",
")",
";",
"sk_win_write_2",
"(",
"sc",
",",
"SK_TXPA1_TINIT",
",",
"SK_PKTARB_TIMEOUT",
")",
";",
"sk_win_write_2",
"(",
"sc",
",",
"SK_RXPA2_TINIT",
",",
"SK_PKTARB_TIMEOUT",
")",
";",
"sk_win_write_2",
"(",
"sc",
",",
"SK_TXPA2_TINIT",
",",
"SK_PKTARB_TIMEOUT",
")",
";",
"}",
"sk_win_write_4",
"(",
"sc",
",",
"SK_RAMCTL",
",",
"SK_RAMCTL_UNRESET",
")",
";",
"KKASSERT",
"(",
"sc",
"->",
"sk_imtimer_ticks",
"!=",
"0",
"&&",
"sc",
"->",
"sk_imtime",
"!=",
"0",
")",
";",
"sk_win_write_4",
"(",
"sc",
",",
"SK_IMTIMERINIT",
",",
"SK_IM_USECS",
"(",
"sc",
",",
"sc",
"->",
"sk_imtime",
")",
")",
";",
"sk_win_write_4",
"(",
"sc",
",",
"SK_IMMR",
",",
"SK_ISR_TX1_S_EOF",
"|",
"SK_ISR_TX2_S_EOF",
"|",
"SK_ISR_RX1_EOF",
"|",
"SK_ISR_RX2_EOF",
")",
";",
"sk_win_write_1",
"(",
"sc",
",",
"SK_IMTIMERCTL",
",",
"SK_IMCTL_START",
")",
";",
"}"
] | Force the GEnesis into reset, then bring it out of reset. | [
"Force",
"the",
"GEnesis",
"into",
"reset",
"then",
"bring",
"it",
"out",
"of",
"reset",
"."
] | [
"/* Configure packet arbiter */",
"/* Enable RAM interface */",
"/*\n\t * Configure interrupt moderation. The moderation timer\n\t * defers interrupts specified in the interrupt moderation\n\t * timer mask based on the timeout specified in the interrupt\n\t * moderation timer init register. Each bit in the timer\n\t * register represents one tick, so to specify a timeout in\n\t * microseconds, we have to multiply by the correct number of\n\t * ticks-per-microsecond.\n\t */"
] | [
{
"param": "sc",
"type": "struct sk_softc"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sc",
"type": "struct sk_softc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24c9fff8e816ef59407573f6c8b75ed037142c06 | atrens/DragonFlyBSD-src | sys/dev/netif/sk/if_sk.c | [
"BSD-3-Clause"
] | C | sk_attach | int | static int
sk_attach(device_t dev)
{
struct sk_softc *sc = device_get_softc(device_get_parent(dev));
struct sk_if_softc *sc_if = device_get_softc(dev);
struct ifnet *ifp = &sc_if->arpcom.ac_if;
int i, error, if_attached = 0;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
sc_if->sk_port = *(int *)device_get_ivars(dev);
KKASSERT(sc_if->sk_port == SK_PORT_A || sc_if->sk_port == SK_PORT_B);
sc_if->sk_softc = sc;
sc->sk_if[sc_if->sk_port] = sc_if;
kfree(device_get_ivars(dev), M_DEVBUF);
device_set_ivars(dev, NULL);
if (sc_if->sk_port == SK_PORT_A)
sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0;
if (sc_if->sk_port == SK_PORT_B)
sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1;
DPRINTFN(2, ("begin sk_attach: port=%d\n", sc_if->sk_port));
/*
* Get station address for this interface. Note that
* dual port cards actually come with three station
* addresses: one for each port, plus an extra. The
* extra one is used by the SysKonnect driver software
* as a 'virtual' station address for when both ports
* are operating in failover mode. Currently we don't
* use this extra address.
*/
for (i = 0; i < ETHER_ADDR_LEN; i++) {
/* XXX */
sc_if->arpcom.ac_enaddr[i] =
sk_win_read_1(sc, SK_MAC0_0 + (sc_if->sk_port * 8) + i);
}
/*
* Set up RAM buffer addresses. The NIC will have a certain
* amount of SRAM on it, somewhere between 512K and 2MB. We
* need to divide this up a) between the transmitter and
* receiver and b) between the two XMACs, if this is a
* dual port NIC. Our algorithm is to divide up the memory
* evenly so that everyone gets a fair share.
*/
if (sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC) {
uint32_t chunk, val;
chunk = sc->sk_ramsize / 2;
val = sc->sk_rboff / sizeof(uint64_t);
sc_if->sk_rx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_rx_ramend = val - 1;
sc_if->sk_tx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_tx_ramend = val - 1;
} else {
uint32_t chunk, val;
chunk = sc->sk_ramsize / 4;
val = (sc->sk_rboff + (chunk * 2 * sc_if->sk_port)) /
sizeof(uint64_t);
sc_if->sk_rx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_rx_ramend = val - 1;
sc_if->sk_tx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_tx_ramend = val - 1;
}
DPRINTFN(2, ("sk_attach: rx_ramstart=%#x rx_ramend=%#x\n"
" tx_ramstart=%#x tx_ramend=%#x\n",
sc_if->sk_rx_ramstart, sc_if->sk_rx_ramend,
sc_if->sk_tx_ramstart, sc_if->sk_tx_ramend));
/* Read and save PHY type */
sc_if->sk_phytype = sk_win_read_1(sc, SK_EPROM1) & 0xF;
/* Set PHY address */
if (SK_IS_GENESIS(sc)) {
switch (sc_if->sk_phytype) {
case SK_PHYTYPE_XMAC:
sc_if->sk_phyaddr = SK_PHYADDR_XMAC;
break;
case SK_PHYTYPE_BCOM:
sc_if->sk_phyaddr = SK_PHYADDR_BCOM;
break;
default:
device_printf(dev, "unsupported PHY type: %d\n",
sc_if->sk_phytype);
error = ENXIO;
goto fail;
}
}
if (SK_IS_YUKON(sc)) {
if ((sc_if->sk_phytype < SK_PHYTYPE_MARV_COPPER &&
sc->sk_pmd != 'L' && sc->sk_pmd != 'S')) {
/* not initialized, punt */
sc_if->sk_phytype = SK_PHYTYPE_MARV_COPPER;
sc->sk_coppertype = 1;
}
sc_if->sk_phyaddr = SK_PHYADDR_MARV;
if (!(sc->sk_coppertype))
sc_if->sk_phytype = SK_PHYTYPE_MARV_FIBER;
}
error = sk_dma_alloc(dev);
if (error)
goto fail;
ifp->if_softc = sc_if;
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sk_ioctl;
ifp->if_start = sk_start;
ifp->if_watchdog = sk_watchdog;
ifp->if_init = sk_init;
ifp->if_baudrate = 1000000000;
ifq_set_maxlen(&ifp->if_snd, SK_TX_RING_CNT - 1);
ifq_set_ready(&ifp->if_snd);
ifp->if_capabilities = IFCAP_VLAN_MTU;
/* Don't use jumbo buffers by default */
sc_if->sk_use_jumbo = 0;
/*
* Call MI attach routines.
*
* NOTE:
* This must be done before following sk_init_xxx(), in which
* if_multiaddrs will be used.
*/
ether_ifattach(ifp, sc_if->arpcom.ac_enaddr, &sc->sk_serializer);
if_attached = 1;
/*
* Do miibus setup.
*/
switch (sc->sk_type) {
case SK_GENESIS:
sk_init_xmac(sc_if);
break;
case SK_YUKON:
case SK_YUKON_LITE:
case SK_YUKON_LP:
sk_init_yukon(sc_if);
break;
default:
device_printf(dev, "unknown device type %d\n", sc->sk_type);
error = ENXIO;
goto fail;
}
DPRINTFN(2, ("sk_attach: 1\n"));
error = mii_phy_probe(dev, &sc_if->sk_miibus,
sk_ifmedia_upd, sk_ifmedia_sts);
if (error) {
device_printf(dev, "no PHY found!\n");
goto fail;
}
callout_init(&sc_if->sk_tick_timer);
DPRINTFN(2, ("sk_attach: end\n"));
return 0;
fail:
if (if_attached)
ether_ifdetach(ifp);
sk_detach(dev);
sc->sk_if[sc_if->sk_port] = NULL;
return error;
} | /*
* Each XMAC chip is attached as a separate logical IP interface.
* Single port cards will have only one logical interface of course.
*/ | Each XMAC chip is attached as a separate logical IP interface.
Single port cards will have only one logical interface of course. | [
"Each",
"XMAC",
"chip",
"is",
"attached",
"as",
"a",
"separate",
"logical",
"IP",
"interface",
".",
"Single",
"port",
"cards",
"will",
"have",
"only",
"one",
"logical",
"interface",
"of",
"course",
"."
] | static int
sk_attach(device_t dev)
{
struct sk_softc *sc = device_get_softc(device_get_parent(dev));
struct sk_if_softc *sc_if = device_get_softc(dev);
struct ifnet *ifp = &sc_if->arpcom.ac_if;
int i, error, if_attached = 0;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
sc_if->sk_port = *(int *)device_get_ivars(dev);
KKASSERT(sc_if->sk_port == SK_PORT_A || sc_if->sk_port == SK_PORT_B);
sc_if->sk_softc = sc;
sc->sk_if[sc_if->sk_port] = sc_if;
kfree(device_get_ivars(dev), M_DEVBUF);
device_set_ivars(dev, NULL);
if (sc_if->sk_port == SK_PORT_A)
sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0;
if (sc_if->sk_port == SK_PORT_B)
sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1;
DPRINTFN(2, ("begin sk_attach: port=%d\n", sc_if->sk_port));
for (i = 0; i < ETHER_ADDR_LEN; i++) {
sc_if->arpcom.ac_enaddr[i] =
sk_win_read_1(sc, SK_MAC0_0 + (sc_if->sk_port * 8) + i);
}
if (sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC) {
uint32_t chunk, val;
chunk = sc->sk_ramsize / 2;
val = sc->sk_rboff / sizeof(uint64_t);
sc_if->sk_rx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_rx_ramend = val - 1;
sc_if->sk_tx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_tx_ramend = val - 1;
} else {
uint32_t chunk, val;
chunk = sc->sk_ramsize / 4;
val = (sc->sk_rboff + (chunk * 2 * sc_if->sk_port)) /
sizeof(uint64_t);
sc_if->sk_rx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_rx_ramend = val - 1;
sc_if->sk_tx_ramstart = val;
val += (chunk / sizeof(uint64_t));
sc_if->sk_tx_ramend = val - 1;
}
DPRINTFN(2, ("sk_attach: rx_ramstart=%#x rx_ramend=%#x\n"
" tx_ramstart=%#x tx_ramend=%#x\n",
sc_if->sk_rx_ramstart, sc_if->sk_rx_ramend,
sc_if->sk_tx_ramstart, sc_if->sk_tx_ramend));
sc_if->sk_phytype = sk_win_read_1(sc, SK_EPROM1) & 0xF;
if (SK_IS_GENESIS(sc)) {
switch (sc_if->sk_phytype) {
case SK_PHYTYPE_XMAC:
sc_if->sk_phyaddr = SK_PHYADDR_XMAC;
break;
case SK_PHYTYPE_BCOM:
sc_if->sk_phyaddr = SK_PHYADDR_BCOM;
break;
default:
device_printf(dev, "unsupported PHY type: %d\n",
sc_if->sk_phytype);
error = ENXIO;
goto fail;
}
}
if (SK_IS_YUKON(sc)) {
if ((sc_if->sk_phytype < SK_PHYTYPE_MARV_COPPER &&
sc->sk_pmd != 'L' && sc->sk_pmd != 'S')) {
sc_if->sk_phytype = SK_PHYTYPE_MARV_COPPER;
sc->sk_coppertype = 1;
}
sc_if->sk_phyaddr = SK_PHYADDR_MARV;
if (!(sc->sk_coppertype))
sc_if->sk_phytype = SK_PHYTYPE_MARV_FIBER;
}
error = sk_dma_alloc(dev);
if (error)
goto fail;
ifp->if_softc = sc_if;
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = sk_ioctl;
ifp->if_start = sk_start;
ifp->if_watchdog = sk_watchdog;
ifp->if_init = sk_init;
ifp->if_baudrate = 1000000000;
ifq_set_maxlen(&ifp->if_snd, SK_TX_RING_CNT - 1);
ifq_set_ready(&ifp->if_snd);
ifp->if_capabilities = IFCAP_VLAN_MTU;
sc_if->sk_use_jumbo = 0;
ether_ifattach(ifp, sc_if->arpcom.ac_enaddr, &sc->sk_serializer);
if_attached = 1;
switch (sc->sk_type) {
case SK_GENESIS:
sk_init_xmac(sc_if);
break;
case SK_YUKON:
case SK_YUKON_LITE:
case SK_YUKON_LP:
sk_init_yukon(sc_if);
break;
default:
device_printf(dev, "unknown device type %d\n", sc->sk_type);
error = ENXIO;
goto fail;
}
DPRINTFN(2, ("sk_attach: 1\n"));
error = mii_phy_probe(dev, &sc_if->sk_miibus,
sk_ifmedia_upd, sk_ifmedia_sts);
if (error) {
device_printf(dev, "no PHY found!\n");
goto fail;
}
callout_init(&sc_if->sk_tick_timer);
DPRINTFN(2, ("sk_attach: end\n"));
return 0;
fail:
if (if_attached)
ether_ifdetach(ifp);
sk_detach(dev);
sc->sk_if[sc_if->sk_port] = NULL;
return error;
} | [
"static",
"int",
"sk_attach",
"(",
"device_t",
"dev",
")",
"{",
"struct",
"sk_softc",
"*",
"sc",
"=",
"device_get_softc",
"(",
"device_get_parent",
"(",
"dev",
")",
")",
";",
"struct",
"sk_if_softc",
"*",
"sc_if",
"=",
"device_get_softc",
"(",
"dev",
")",
";",
"struct",
"ifnet",
"*",
"ifp",
"=",
"&",
"sc_if",
"->",
"arpcom",
".",
"ac_if",
";",
"int",
"i",
",",
"error",
",",
"if_attached",
"=",
"0",
";",
"if_initname",
"(",
"ifp",
",",
"device_get_name",
"(",
"dev",
")",
",",
"device_get_unit",
"(",
"dev",
")",
")",
";",
"sc_if",
"->",
"sk_port",
"=",
"*",
"(",
"int",
"*",
")",
"device_get_ivars",
"(",
"dev",
")",
";",
"KKASSERT",
"(",
"sc_if",
"->",
"sk_port",
"==",
"SK_PORT_A",
"||",
"sc_if",
"->",
"sk_port",
"==",
"SK_PORT_B",
")",
";",
"sc_if",
"->",
"sk_softc",
"=",
"sc",
";",
"sc",
"->",
"sk_if",
"[",
"sc_if",
"->",
"sk_port",
"]",
"=",
"sc_if",
";",
"kfree",
"(",
"device_get_ivars",
"(",
"dev",
")",
",",
"M_DEVBUF",
")",
";",
"device_set_ivars",
"(",
"dev",
",",
"NULL",
")",
";",
"if",
"(",
"sc_if",
"->",
"sk_port",
"==",
"SK_PORT_A",
")",
"sc_if",
"->",
"sk_tx_bmu",
"=",
"SK_BMU_TXS_CSR0",
";",
"if",
"(",
"sc_if",
"->",
"sk_port",
"==",
"SK_PORT_B",
")",
"sc_if",
"->",
"sk_tx_bmu",
"=",
"SK_BMU_TXS_CSR1",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
",",
"sc_if",
"->",
"sk_port",
")",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ETHER_ADDR_LEN",
";",
"i",
"++",
")",
"{",
"sc_if",
"->",
"arpcom",
".",
"ac_enaddr",
"[",
"i",
"]",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_MAC0_0",
"+",
"(",
"sc_if",
"->",
"sk_port",
"*",
"8",
")",
"+",
"i",
")",
";",
"}",
"if",
"(",
"sk_win_read_1",
"(",
"sc",
",",
"SK_CONFIG",
")",
"&",
"SK_CONFIG_SINGLEMAC",
")",
"{",
"uint32_t",
"chunk",
",",
"val",
";",
"chunk",
"=",
"sc",
"->",
"sk_ramsize",
"/",
"2",
";",
"val",
"=",
"sc",
"->",
"sk_rboff",
"/",
"sizeof",
"(",
"uint64_t",
")",
";",
"sc_if",
"->",
"sk_rx_ramstart",
"=",
"val",
";",
"val",
"+=",
"(",
"chunk",
"/",
"sizeof",
"(",
"uint64_t",
")",
")",
";",
"sc_if",
"->",
"sk_rx_ramend",
"=",
"val",
"-",
"1",
";",
"sc_if",
"->",
"sk_tx_ramstart",
"=",
"val",
";",
"val",
"+=",
"(",
"chunk",
"/",
"sizeof",
"(",
"uint64_t",
")",
")",
";",
"sc_if",
"->",
"sk_tx_ramend",
"=",
"val",
"-",
"1",
";",
"}",
"else",
"{",
"uint32_t",
"chunk",
",",
"val",
";",
"chunk",
"=",
"sc",
"->",
"sk_ramsize",
"/",
"4",
";",
"val",
"=",
"(",
"sc",
"->",
"sk_rboff",
"+",
"(",
"chunk",
"*",
"2",
"*",
"sc_if",
"->",
"sk_port",
")",
")",
"/",
"sizeof",
"(",
"uint64_t",
")",
";",
"sc_if",
"->",
"sk_rx_ramstart",
"=",
"val",
";",
"val",
"+=",
"(",
"chunk",
"/",
"sizeof",
"(",
"uint64_t",
")",
")",
";",
"sc_if",
"->",
"sk_rx_ramend",
"=",
"val",
"-",
"1",
";",
"sc_if",
"->",
"sk_tx_ramstart",
"=",
"val",
";",
"val",
"+=",
"(",
"chunk",
"/",
"sizeof",
"(",
"uint64_t",
")",
")",
";",
"sc_if",
"->",
"sk_tx_ramend",
"=",
"val",
"-",
"1",
";",
"}",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
"\"",
"\\n",
"\"",
",",
"sc_if",
"->",
"sk_rx_ramstart",
",",
"sc_if",
"->",
"sk_rx_ramend",
",",
"sc_if",
"->",
"sk_tx_ramstart",
",",
"sc_if",
"->",
"sk_tx_ramend",
")",
")",
";",
"sc_if",
"->",
"sk_phytype",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_EPROM1",
")",
"&",
"0xF",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"switch",
"(",
"sc_if",
"->",
"sk_phytype",
")",
"{",
"case",
"SK_PHYTYPE_XMAC",
":",
"sc_if",
"->",
"sk_phyaddr",
"=",
"SK_PHYADDR_XMAC",
";",
"break",
";",
"case",
"SK_PHYTYPE_BCOM",
":",
"sc_if",
"->",
"sk_phyaddr",
"=",
"SK_PHYADDR_BCOM",
";",
"break",
";",
"default",
":",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"sc_if",
"->",
"sk_phytype",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"}",
"if",
"(",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"{",
"if",
"(",
"(",
"sc_if",
"->",
"sk_phytype",
"<",
"SK_PHYTYPE_MARV_COPPER",
"&&",
"sc",
"->",
"sk_pmd",
"!=",
"'",
"'",
"&&",
"sc",
"->",
"sk_pmd",
"!=",
"'",
"'",
")",
")",
"{",
"sc_if",
"->",
"sk_phytype",
"=",
"SK_PHYTYPE_MARV_COPPER",
";",
"sc",
"->",
"sk_coppertype",
"=",
"1",
";",
"}",
"sc_if",
"->",
"sk_phyaddr",
"=",
"SK_PHYADDR_MARV",
";",
"if",
"(",
"!",
"(",
"sc",
"->",
"sk_coppertype",
")",
")",
"sc_if",
"->",
"sk_phytype",
"=",
"SK_PHYTYPE_MARV_FIBER",
";",
"}",
"error",
"=",
"sk_dma_alloc",
"(",
"dev",
")",
";",
"if",
"(",
"error",
")",
"goto",
"fail",
";",
"ifp",
"->",
"if_softc",
"=",
"sc_if",
";",
"ifp",
"->",
"if_mtu",
"=",
"ETHERMTU",
";",
"ifp",
"->",
"if_flags",
"=",
"IFF_BROADCAST",
"|",
"IFF_SIMPLEX",
"|",
"IFF_MULTICAST",
";",
"ifp",
"->",
"if_ioctl",
"=",
"sk_ioctl",
";",
"ifp",
"->",
"if_start",
"=",
"sk_start",
";",
"ifp",
"->",
"if_watchdog",
"=",
"sk_watchdog",
";",
"ifp",
"->",
"if_init",
"=",
"sk_init",
";",
"ifp",
"->",
"if_baudrate",
"=",
"1000000000",
";",
"ifq_set_maxlen",
"(",
"&",
"ifp",
"->",
"if_snd",
",",
"SK_TX_RING_CNT",
"-",
"1",
")",
";",
"ifq_set_ready",
"(",
"&",
"ifp",
"->",
"if_snd",
")",
";",
"ifp",
"->",
"if_capabilities",
"=",
"IFCAP_VLAN_MTU",
";",
"sc_if",
"->",
"sk_use_jumbo",
"=",
"0",
";",
"ether_ifattach",
"(",
"ifp",
",",
"sc_if",
"->",
"arpcom",
".",
"ac_enaddr",
",",
"&",
"sc",
"->",
"sk_serializer",
")",
";",
"if_attached",
"=",
"1",
";",
"switch",
"(",
"sc",
"->",
"sk_type",
")",
"{",
"case",
"SK_GENESIS",
":",
"sk_init_xmac",
"(",
"sc_if",
")",
";",
"break",
";",
"case",
"SK_YUKON",
":",
"case",
"SK_YUKON_LITE",
":",
"case",
"SK_YUKON_LP",
":",
"sk_init_yukon",
"(",
"sc_if",
")",
";",
"break",
";",
"default",
":",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"sc",
"->",
"sk_type",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"error",
"=",
"mii_phy_probe",
"(",
"dev",
",",
"&",
"sc_if",
"->",
"sk_miibus",
",",
"sk_ifmedia_upd",
",",
"sk_ifmedia_sts",
")",
";",
"if",
"(",
"error",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
")",
";",
"goto",
"fail",
";",
"}",
"callout_init",
"(",
"&",
"sc_if",
"->",
"sk_tick_timer",
")",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"return",
"0",
";",
"fail",
":",
"if",
"(",
"if_attached",
")",
"ether_ifdetach",
"(",
"ifp",
")",
";",
"sk_detach",
"(",
"dev",
")",
";",
"sc",
"->",
"sk_if",
"[",
"sc_if",
"->",
"sk_port",
"]",
"=",
"NULL",
";",
"return",
"error",
";",
"}"
] | Each XMAC chip is attached as a separate logical IP interface. | [
"Each",
"XMAC",
"chip",
"is",
"attached",
"as",
"a",
"separate",
"logical",
"IP",
"interface",
"."
] | [
"/*\n\t * Get station address for this interface. Note that\n\t * dual port cards actually come with three station\n\t * addresses: one for each port, plus an extra. The\n\t * extra one is used by the SysKonnect driver software\n\t * as a 'virtual' station address for when both ports\n\t * are operating in failover mode. Currently we don't\n\t * use this extra address.\n\t */",
"/* XXX */",
"/*\n\t * Set up RAM buffer addresses. The NIC will have a certain\n\t * amount of SRAM on it, somewhere between 512K and 2MB. We\n\t * need to divide this up a) between the transmitter and\n \t * receiver and b) between the two XMACs, if this is a\n\t * dual port NIC. Our algorithm is to divide up the memory\n\t * evenly so that everyone gets a fair share.\n\t */",
"/* Read and save PHY type */",
"/* Set PHY address */",
"/* not initialized, punt */",
"/* Don't use jumbo buffers by default */",
"/*\n\t * Call MI attach routines.\n\t *\n\t * NOTE:\n\t * This must be done before following sk_init_xxx(), in which\n\t * if_multiaddrs will be used.\n\t */",
"/*\n\t * Do miibus setup.\n\t */"
] | [
{
"param": "dev",
"type": "device_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24c9fff8e816ef59407573f6c8b75ed037142c06 | atrens/DragonFlyBSD-src | sys/dev/netif/sk/if_sk.c | [
"BSD-3-Clause"
] | C | skc_attach | int | static int
skc_attach(device_t dev)
{
struct sk_softc *sc = device_get_softc(dev);
uint8_t skrs;
int *port;
int error, cpuid;
DPRINTFN(2, ("begin skc_attach\n"));
sc->sk_dev = dev;
lwkt_serialize_init(&sc->sk_serializer);
#ifndef BURN_BRIDGES
/*
* Handle power management nonsense.
*/
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
uint32_t iobase, membase, irq;
/* Save important PCI config data. */
iobase = pci_read_config(dev, SK_PCI_LOIO, 4);
membase = pci_read_config(dev, SK_PCI_LOMEM, 4);
irq = pci_read_config(dev, SK_PCI_INTLINE, 4);
/* Reset the power state. */
device_printf(dev, "chip is in D%d power mode "
"-- setting to D0\n", pci_get_powerstate(dev));
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
/* Restore PCI config data. */
pci_write_config(dev, SK_PCI_LOIO, iobase, 4);
pci_write_config(dev, SK_PCI_LOMEM, membase, 4);
pci_write_config(dev, SK_PCI_INTLINE, irq, 4);
}
#endif /* BURN_BRIDGES */
/*
* Map control/status registers.
*/
pci_enable_busmaster(dev);
sc->sk_res_rid = SK_PCI_LOMEM;
sc->sk_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->sk_res_rid, RF_ACTIVE);
if (sc->sk_res == NULL) {
device_printf(dev, "couldn't map memory\n");
error = ENXIO;
goto fail;
}
sc->sk_btag = rman_get_bustag(sc->sk_res);
sc->sk_bhandle = rman_get_bushandle(sc->sk_res);
sc->sk_type = sk_win_read_1(sc, SK_CHIPVER);
sc->sk_rev = (sk_win_read_1(sc, SK_CONFIG) >> 4);
/* Bail out here if chip is not recognized */
if (!SK_IS_GENESIS(sc) && !SK_IS_YUKON(sc)) {
device_printf(dev, "unknown chip type: %d\n", sc->sk_type);
error = ENXIO;
goto fail;
}
DPRINTFN(2, ("skc_attach: allocate interrupt\n"));
/* Allocate interrupt */
sc->sk_irq_rid = 0;
sc->sk_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sk_irq_rid,
RF_SHAREABLE | RF_ACTIVE);
if (sc->sk_irq == NULL) {
device_printf(dev, "couldn't map interrupt\n");
error = ENXIO;
goto fail;
}
switch (sc->sk_type) {
case SK_GENESIS:
sc->sk_imtimer_ticks = SK_IMTIMER_TICKS_GENESIS;
break;
default:
sc->sk_imtimer_ticks = SK_IMTIMER_TICKS_YUKON;
break;
}
sc->sk_imtime = skc_imtime;
/* Reset the adapter. */
sk_reset(sc);
skrs = sk_win_read_1(sc, SK_EPROM0);
if (SK_IS_GENESIS(sc)) {
/* Read and save RAM size and RAMbuffer offset */
switch(skrs) {
case SK_RAMSIZE_512K_64:
sc->sk_ramsize = 0x80000;
sc->sk_rboff = SK_RBOFF_0;
break;
case SK_RAMSIZE_1024K_64:
sc->sk_ramsize = 0x100000;
sc->sk_rboff = SK_RBOFF_80000;
break;
case SK_RAMSIZE_1024K_128:
sc->sk_ramsize = 0x100000;
sc->sk_rboff = SK_RBOFF_0;
break;
case SK_RAMSIZE_2048K_128:
sc->sk_ramsize = 0x200000;
sc->sk_rboff = SK_RBOFF_0;
break;
default:
device_printf(dev, "unknown ram size: %d\n", skrs);
error = ENXIO;
goto fail;
}
} else {
if (skrs == 0x00)
sc->sk_ramsize = 0x20000;
else
sc->sk_ramsize = skrs * (1<<12);
sc->sk_rboff = SK_RBOFF_0;
}
DPRINTFN(2, ("skc_attach: ramsize=%d (%dk), rboff=%d\n",
sc->sk_ramsize, sc->sk_ramsize / 1024,
sc->sk_rboff));
/* Read and save physical media type */
sc->sk_pmd = sk_win_read_1(sc, SK_PMDTYPE);
if (sc->sk_pmd == 'T' || sc->sk_pmd == '1')
sc->sk_coppertype = 1;
else
sc->sk_coppertype = 0;
/* Yukon Lite Rev A0 needs special test, from sk98lin driver */
if (sc->sk_type == SK_YUKON || sc->sk_type == SK_YUKON_LP) {
uint32_t flashaddr;
uint8_t testbyte;
flashaddr = sk_win_read_4(sc, SK_EP_ADDR);
/* Test Flash-Address Register */
sk_win_write_1(sc, SK_EP_ADDR+3, 0xff);
testbyte = sk_win_read_1(sc, SK_EP_ADDR+3);
if (testbyte != 0) {
/* This is a Yukon Lite Rev A0 */
sc->sk_type = SK_YUKON_LITE;
sc->sk_rev = SK_YUKON_LITE_REV_A0;
/* Restore Flash-Address Register */
sk_win_write_4(sc, SK_EP_ADDR, flashaddr);
}
}
/*
* Create sysctl nodes.
*/
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
OID_AUTO, "imtime", CTLTYPE_INT | CTLFLAG_RW,
sc, 0, skc_sysctl_imtime, "I",
"Interrupt moderation time (usec).");
sc->sk_devs[SK_PORT_A] = device_add_child(dev, "sk", -1);
port = kmalloc(sizeof(*port), M_DEVBUF, M_WAITOK);
*port = SK_PORT_A;
device_set_ivars(sc->sk_devs[SK_PORT_A], port);
if (!(sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC)) {
sc->sk_devs[SK_PORT_B] = device_add_child(dev, "sk", -1);
port = kmalloc(sizeof(*port), M_DEVBUF, M_WAITOK);
*port = SK_PORT_B;
device_set_ivars(sc->sk_devs[SK_PORT_B], port);
}
/* Turn on the 'driver is loaded' LED. */
CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_ON);
bus_generic_attach(dev);
cpuid = rman_get_cpuid(sc->sk_irq);
if (sc->sk_if[0] != NULL)
ifq_set_cpuid(&sc->sk_if[0]->arpcom.ac_if.if_snd, cpuid);
if (sc->sk_if[1] != NULL)
ifq_set_cpuid(&sc->sk_if[1]->arpcom.ac_if.if_snd, cpuid);
error = bus_setup_intr(dev, sc->sk_irq, INTR_MPSAFE, sk_intr, sc,
&sc->sk_intrhand, &sc->sk_serializer);
if (error) {
device_printf(dev, "couldn't set up irq\n");
goto fail;
}
return 0;
fail:
skc_detach(dev);
return error;
} | /*
* Attach the interface. Allocate softc structures, do ifmedia
* setup and ethernet/BPF attach.
*/ | Attach the interface. Allocate softc structures, do ifmedia
setup and ethernet/BPF attach. | [
"Attach",
"the",
"interface",
".",
"Allocate",
"softc",
"structures",
"do",
"ifmedia",
"setup",
"and",
"ethernet",
"/",
"BPF",
"attach",
"."
] | static int
skc_attach(device_t dev)
{
struct sk_softc *sc = device_get_softc(dev);
uint8_t skrs;
int *port;
int error, cpuid;
DPRINTFN(2, ("begin skc_attach\n"));
sc->sk_dev = dev;
lwkt_serialize_init(&sc->sk_serializer);
#ifndef BURN_BRIDGES
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
uint32_t iobase, membase, irq;
iobase = pci_read_config(dev, SK_PCI_LOIO, 4);
membase = pci_read_config(dev, SK_PCI_LOMEM, 4);
irq = pci_read_config(dev, SK_PCI_INTLINE, 4);
device_printf(dev, "chip is in D%d power mode "
"-- setting to D0\n", pci_get_powerstate(dev));
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_write_config(dev, SK_PCI_LOIO, iobase, 4);
pci_write_config(dev, SK_PCI_LOMEM, membase, 4);
pci_write_config(dev, SK_PCI_INTLINE, irq, 4);
}
#endif
pci_enable_busmaster(dev);
sc->sk_res_rid = SK_PCI_LOMEM;
sc->sk_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&sc->sk_res_rid, RF_ACTIVE);
if (sc->sk_res == NULL) {
device_printf(dev, "couldn't map memory\n");
error = ENXIO;
goto fail;
}
sc->sk_btag = rman_get_bustag(sc->sk_res);
sc->sk_bhandle = rman_get_bushandle(sc->sk_res);
sc->sk_type = sk_win_read_1(sc, SK_CHIPVER);
sc->sk_rev = (sk_win_read_1(sc, SK_CONFIG) >> 4);
if (!SK_IS_GENESIS(sc) && !SK_IS_YUKON(sc)) {
device_printf(dev, "unknown chip type: %d\n", sc->sk_type);
error = ENXIO;
goto fail;
}
DPRINTFN(2, ("skc_attach: allocate interrupt\n"));
sc->sk_irq_rid = 0;
sc->sk_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sk_irq_rid,
RF_SHAREABLE | RF_ACTIVE);
if (sc->sk_irq == NULL) {
device_printf(dev, "couldn't map interrupt\n");
error = ENXIO;
goto fail;
}
switch (sc->sk_type) {
case SK_GENESIS:
sc->sk_imtimer_ticks = SK_IMTIMER_TICKS_GENESIS;
break;
default:
sc->sk_imtimer_ticks = SK_IMTIMER_TICKS_YUKON;
break;
}
sc->sk_imtime = skc_imtime;
sk_reset(sc);
skrs = sk_win_read_1(sc, SK_EPROM0);
if (SK_IS_GENESIS(sc)) {
switch(skrs) {
case SK_RAMSIZE_512K_64:
sc->sk_ramsize = 0x80000;
sc->sk_rboff = SK_RBOFF_0;
break;
case SK_RAMSIZE_1024K_64:
sc->sk_ramsize = 0x100000;
sc->sk_rboff = SK_RBOFF_80000;
break;
case SK_RAMSIZE_1024K_128:
sc->sk_ramsize = 0x100000;
sc->sk_rboff = SK_RBOFF_0;
break;
case SK_RAMSIZE_2048K_128:
sc->sk_ramsize = 0x200000;
sc->sk_rboff = SK_RBOFF_0;
break;
default:
device_printf(dev, "unknown ram size: %d\n", skrs);
error = ENXIO;
goto fail;
}
} else {
if (skrs == 0x00)
sc->sk_ramsize = 0x20000;
else
sc->sk_ramsize = skrs * (1<<12);
sc->sk_rboff = SK_RBOFF_0;
}
DPRINTFN(2, ("skc_attach: ramsize=%d (%dk), rboff=%d\n",
sc->sk_ramsize, sc->sk_ramsize / 1024,
sc->sk_rboff));
sc->sk_pmd = sk_win_read_1(sc, SK_PMDTYPE);
if (sc->sk_pmd == 'T' || sc->sk_pmd == '1')
sc->sk_coppertype = 1;
else
sc->sk_coppertype = 0;
if (sc->sk_type == SK_YUKON || sc->sk_type == SK_YUKON_LP) {
uint32_t flashaddr;
uint8_t testbyte;
flashaddr = sk_win_read_4(sc, SK_EP_ADDR);
sk_win_write_1(sc, SK_EP_ADDR+3, 0xff);
testbyte = sk_win_read_1(sc, SK_EP_ADDR+3);
if (testbyte != 0) {
sc->sk_type = SK_YUKON_LITE;
sc->sk_rev = SK_YUKON_LITE_REV_A0;
sk_win_write_4(sc, SK_EP_ADDR, flashaddr);
}
}
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
OID_AUTO, "imtime", CTLTYPE_INT | CTLFLAG_RW,
sc, 0, skc_sysctl_imtime, "I",
"Interrupt moderation time (usec).");
sc->sk_devs[SK_PORT_A] = device_add_child(dev, "sk", -1);
port = kmalloc(sizeof(*port), M_DEVBUF, M_WAITOK);
*port = SK_PORT_A;
device_set_ivars(sc->sk_devs[SK_PORT_A], port);
if (!(sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC)) {
sc->sk_devs[SK_PORT_B] = device_add_child(dev, "sk", -1);
port = kmalloc(sizeof(*port), M_DEVBUF, M_WAITOK);
*port = SK_PORT_B;
device_set_ivars(sc->sk_devs[SK_PORT_B], port);
}
CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_ON);
bus_generic_attach(dev);
cpuid = rman_get_cpuid(sc->sk_irq);
if (sc->sk_if[0] != NULL)
ifq_set_cpuid(&sc->sk_if[0]->arpcom.ac_if.if_snd, cpuid);
if (sc->sk_if[1] != NULL)
ifq_set_cpuid(&sc->sk_if[1]->arpcom.ac_if.if_snd, cpuid);
error = bus_setup_intr(dev, sc->sk_irq, INTR_MPSAFE, sk_intr, sc,
&sc->sk_intrhand, &sc->sk_serializer);
if (error) {
device_printf(dev, "couldn't set up irq\n");
goto fail;
}
return 0;
fail:
skc_detach(dev);
return error;
} | [
"static",
"int",
"skc_attach",
"(",
"device_t",
"dev",
")",
"{",
"struct",
"sk_softc",
"*",
"sc",
"=",
"device_get_softc",
"(",
"dev",
")",
";",
"uint8_t",
"skrs",
";",
"int",
"*",
"port",
";",
"int",
"error",
",",
"cpuid",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"sc",
"->",
"sk_dev",
"=",
"dev",
";",
"lwkt_serialize_init",
"(",
"&",
"sc",
"->",
"sk_serializer",
")",
";",
"#ifndef",
"BURN_BRIDGES",
"if",
"(",
"pci_get_powerstate",
"(",
"dev",
")",
"!=",
"PCI_POWERSTATE_D0",
")",
"{",
"uint32_t",
"iobase",
",",
"membase",
",",
"irq",
";",
"iobase",
"=",
"pci_read_config",
"(",
"dev",
",",
"SK_PCI_LOIO",
",",
"4",
")",
";",
"membase",
"=",
"pci_read_config",
"(",
"dev",
",",
"SK_PCI_LOMEM",
",",
"4",
")",
";",
"irq",
"=",
"pci_read_config",
"(",
"dev",
",",
"SK_PCI_INTLINE",
",",
"4",
")",
";",
"device_printf",
"(",
"dev",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"pci_get_powerstate",
"(",
"dev",
")",
")",
";",
"pci_set_powerstate",
"(",
"dev",
",",
"PCI_POWERSTATE_D0",
")",
";",
"pci_write_config",
"(",
"dev",
",",
"SK_PCI_LOIO",
",",
"iobase",
",",
"4",
")",
";",
"pci_write_config",
"(",
"dev",
",",
"SK_PCI_LOMEM",
",",
"membase",
",",
"4",
")",
";",
"pci_write_config",
"(",
"dev",
",",
"SK_PCI_INTLINE",
",",
"irq",
",",
"4",
")",
";",
"}",
"#endif",
"pci_enable_busmaster",
"(",
"dev",
")",
";",
"sc",
"->",
"sk_res_rid",
"=",
"SK_PCI_LOMEM",
";",
"sc",
"->",
"sk_res",
"=",
"bus_alloc_resource_any",
"(",
"dev",
",",
"SYS_RES_MEMORY",
",",
"&",
"sc",
"->",
"sk_res_rid",
",",
"RF_ACTIVE",
")",
";",
"if",
"(",
"sc",
"->",
"sk_res",
"==",
"NULL",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"sc",
"->",
"sk_btag",
"=",
"rman_get_bustag",
"(",
"sc",
"->",
"sk_res",
")",
";",
"sc",
"->",
"sk_bhandle",
"=",
"rman_get_bushandle",
"(",
"sc",
"->",
"sk_res",
")",
";",
"sc",
"->",
"sk_type",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_CHIPVER",
")",
";",
"sc",
"->",
"sk_rev",
"=",
"(",
"sk_win_read_1",
"(",
"sc",
",",
"SK_CONFIG",
")",
">>",
"4",
")",
";",
"if",
"(",
"!",
"SK_IS_GENESIS",
"(",
"sc",
")",
"&&",
"!",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"sc",
"->",
"sk_type",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"sc",
"->",
"sk_irq_rid",
"=",
"0",
";",
"sc",
"->",
"sk_irq",
"=",
"bus_alloc_resource_any",
"(",
"dev",
",",
"SYS_RES_IRQ",
",",
"&",
"sc",
"->",
"sk_irq_rid",
",",
"RF_SHAREABLE",
"|",
"RF_ACTIVE",
")",
";",
"if",
"(",
"sc",
"->",
"sk_irq",
"==",
"NULL",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"switch",
"(",
"sc",
"->",
"sk_type",
")",
"{",
"case",
"SK_GENESIS",
":",
"sc",
"->",
"sk_imtimer_ticks",
"=",
"SK_IMTIMER_TICKS_GENESIS",
";",
"break",
";",
"default",
":",
"sc",
"->",
"sk_imtimer_ticks",
"=",
"SK_IMTIMER_TICKS_YUKON",
";",
"break",
";",
"}",
"sc",
"->",
"sk_imtime",
"=",
"skc_imtime",
";",
"sk_reset",
"(",
"sc",
")",
";",
"skrs",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_EPROM0",
")",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"switch",
"(",
"skrs",
")",
"{",
"case",
"SK_RAMSIZE_512K_64",
":",
"sc",
"->",
"sk_ramsize",
"=",
"0x80000",
";",
"sc",
"->",
"sk_rboff",
"=",
"SK_RBOFF_0",
";",
"break",
";",
"case",
"SK_RAMSIZE_1024K_64",
":",
"sc",
"->",
"sk_ramsize",
"=",
"0x100000",
";",
"sc",
"->",
"sk_rboff",
"=",
"SK_RBOFF_80000",
";",
"break",
";",
"case",
"SK_RAMSIZE_1024K_128",
":",
"sc",
"->",
"sk_ramsize",
"=",
"0x100000",
";",
"sc",
"->",
"sk_rboff",
"=",
"SK_RBOFF_0",
";",
"break",
";",
"case",
"SK_RAMSIZE_2048K_128",
":",
"sc",
"->",
"sk_ramsize",
"=",
"0x200000",
";",
"sc",
"->",
"sk_rboff",
"=",
"SK_RBOFF_0",
";",
"break",
";",
"default",
":",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"skrs",
")",
";",
"error",
"=",
"ENXIO",
";",
"goto",
"fail",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"skrs",
"==",
"0x00",
")",
"sc",
"->",
"sk_ramsize",
"=",
"0x20000",
";",
"else",
"sc",
"->",
"sk_ramsize",
"=",
"skrs",
"*",
"(",
"1",
"<<",
"12",
")",
";",
"sc",
"->",
"sk_rboff",
"=",
"SK_RBOFF_0",
";",
"}",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
",",
"sc",
"->",
"sk_ramsize",
",",
"sc",
"->",
"sk_ramsize",
"/",
"1024",
",",
"sc",
"->",
"sk_rboff",
")",
")",
";",
"sc",
"->",
"sk_pmd",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_PMDTYPE",
")",
";",
"if",
"(",
"sc",
"->",
"sk_pmd",
"==",
"'",
"'",
"||",
"sc",
"->",
"sk_pmd",
"==",
"'",
"'",
")",
"sc",
"->",
"sk_coppertype",
"=",
"1",
";",
"else",
"sc",
"->",
"sk_coppertype",
"=",
"0",
";",
"if",
"(",
"sc",
"->",
"sk_type",
"==",
"SK_YUKON",
"||",
"sc",
"->",
"sk_type",
"==",
"SK_YUKON_LP",
")",
"{",
"uint32_t",
"flashaddr",
";",
"uint8_t",
"testbyte",
";",
"flashaddr",
"=",
"sk_win_read_4",
"(",
"sc",
",",
"SK_EP_ADDR",
")",
";",
"sk_win_write_1",
"(",
"sc",
",",
"SK_EP_ADDR",
"+",
"3",
",",
"0xff",
")",
";",
"testbyte",
"=",
"sk_win_read_1",
"(",
"sc",
",",
"SK_EP_ADDR",
"+",
"3",
")",
";",
"if",
"(",
"testbyte",
"!=",
"0",
")",
"{",
"sc",
"->",
"sk_type",
"=",
"SK_YUKON_LITE",
";",
"sc",
"->",
"sk_rev",
"=",
"SK_YUKON_LITE_REV_A0",
";",
"sk_win_write_4",
"(",
"sc",
",",
"SK_EP_ADDR",
",",
"flashaddr",
")",
";",
"}",
"}",
"SYSCTL_ADD_PROC",
"(",
"device_get_sysctl_ctx",
"(",
"dev",
")",
",",
"SYSCTL_CHILDREN",
"(",
"device_get_sysctl_tree",
"(",
"dev",
")",
")",
",",
"OID_AUTO",
",",
"\"",
"\"",
",",
"CTLTYPE_INT",
"|",
"CTLFLAG_RW",
",",
"sc",
",",
"0",
",",
"skc_sysctl_imtime",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
";",
"sc",
"->",
"sk_devs",
"[",
"SK_PORT_A",
"]",
"=",
"device_add_child",
"(",
"dev",
",",
"\"",
"\"",
",",
"-1",
")",
";",
"port",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"*",
"port",
")",
",",
"M_DEVBUF",
",",
"M_WAITOK",
")",
";",
"*",
"port",
"=",
"SK_PORT_A",
";",
"device_set_ivars",
"(",
"sc",
"->",
"sk_devs",
"[",
"SK_PORT_A",
"]",
",",
"port",
")",
";",
"if",
"(",
"!",
"(",
"sk_win_read_1",
"(",
"sc",
",",
"SK_CONFIG",
")",
"&",
"SK_CONFIG_SINGLEMAC",
")",
")",
"{",
"sc",
"->",
"sk_devs",
"[",
"SK_PORT_B",
"]",
"=",
"device_add_child",
"(",
"dev",
",",
"\"",
"\"",
",",
"-1",
")",
";",
"port",
"=",
"kmalloc",
"(",
"sizeof",
"(",
"*",
"port",
")",
",",
"M_DEVBUF",
",",
"M_WAITOK",
")",
";",
"*",
"port",
"=",
"SK_PORT_B",
";",
"device_set_ivars",
"(",
"sc",
"->",
"sk_devs",
"[",
"SK_PORT_B",
"]",
",",
"port",
")",
";",
"}",
"CSR_WRITE_2",
"(",
"sc",
",",
"SK_LED",
",",
"SK_LED_GREEN_ON",
")",
";",
"bus_generic_attach",
"(",
"dev",
")",
";",
"cpuid",
"=",
"rman_get_cpuid",
"(",
"sc",
"->",
"sk_irq",
")",
";",
"if",
"(",
"sc",
"->",
"sk_if",
"[",
"0",
"]",
"!=",
"NULL",
")",
"ifq_set_cpuid",
"(",
"&",
"sc",
"->",
"sk_if",
"[",
"0",
"]",
"->",
"arpcom",
".",
"ac_if",
".",
"if_snd",
",",
"cpuid",
")",
";",
"if",
"(",
"sc",
"->",
"sk_if",
"[",
"1",
"]",
"!=",
"NULL",
")",
"ifq_set_cpuid",
"(",
"&",
"sc",
"->",
"sk_if",
"[",
"1",
"]",
"->",
"arpcom",
".",
"ac_if",
".",
"if_snd",
",",
"cpuid",
")",
";",
"error",
"=",
"bus_setup_intr",
"(",
"dev",
",",
"sc",
"->",
"sk_irq",
",",
"INTR_MPSAFE",
",",
"sk_intr",
",",
"sc",
",",
"&",
"sc",
"->",
"sk_intrhand",
",",
"&",
"sc",
"->",
"sk_serializer",
")",
";",
"if",
"(",
"error",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
")",
";",
"goto",
"fail",
";",
"}",
"return",
"0",
";",
"fail",
":",
"skc_detach",
"(",
"dev",
")",
";",
"return",
"error",
";",
"}"
] | Attach the interface. | [
"Attach",
"the",
"interface",
"."
] | [
"/*\n\t * Handle power management nonsense.\n\t */",
"/* Save important PCI config data. */",
"/* Reset the power state. */",
"/* Restore PCI config data. */",
"/* BURN_BRIDGES */",
"/*\n\t * Map control/status registers.\n\t */",
"/* Bail out here if chip is not recognized */",
"/* Allocate interrupt */",
"/* Reset the adapter. */",
"/* Read and save RAM size and RAMbuffer offset */",
"/* Read and save physical media type */",
"/* Yukon Lite Rev A0 needs special test, from sk98lin driver */",
"/* Test Flash-Address Register */",
"/* This is a Yukon Lite Rev A0 */",
"/* Restore Flash-Address Register */",
"/*\n\t * Create sysctl nodes.\n\t */",
"/* Turn on the 'driver is loaded' LED. */"
] | [
{
"param": "dev",
"type": "device_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24c9fff8e816ef59407573f6c8b75ed037142c06 | atrens/DragonFlyBSD-src | sys/dev/netif/sk/if_sk.c | [
"BSD-3-Clause"
] | C | sk_init | void | static void
sk_init(void *xsc_if)
{
struct sk_if_softc *sc_if = xsc_if;
struct sk_softc *sc = sc_if->sk_softc;
struct ifnet *ifp = &sc_if->arpcom.ac_if;
struct mii_data *mii = device_get_softc(sc_if->sk_miibus);
DPRINTFN(2, ("sk_init\n"));
ASSERT_SERIALIZED(ifp->if_serializer);
if (ifp->if_flags & IFF_RUNNING)
return;
/* Cancel pending I/O and free all RX/TX buffers. */
sk_stop(sc_if);
/*
* NOTE: Change sk_use_jumbo after sk_stop(),
* but before real initialization.
*/
if (ifp->if_mtu > ETHER_MAX_LEN)
sc_if->sk_use_jumbo = 1;
else
sc_if->sk_use_jumbo = 0;
DPRINTF(("use jumbo buffer: %s\n", sc_if->sk_use_jumbo ? "YES" : "NO"));
if (SK_IS_GENESIS(sc)) {
/* Configure LINK_SYNC LED */
SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_ON);
SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL,
SK_LINKLED_LINKSYNC_ON);
/* Configure RX LED */
SK_IF_WRITE_1(sc_if, 0, SK_RXLED1_CTL,
SK_RXLEDCTL_COUNTER_START);
/* Configure TX LED */
SK_IF_WRITE_1(sc_if, 0, SK_TXLED1_CTL,
SK_TXLEDCTL_COUNTER_START);
}
/*
* Configure descriptor poll timer
*
* SK-NET GENESIS data sheet says that possibility of losing Start
* transmit command due to CPU/cache related interim storage problems
* under certain conditions. The document recommends a polling
* mechanism to send a Start transmit command to initiate transfer
* of ready descriptors regulary. To cope with this issue sk(4) now
* enables descriptor poll timer to initiate descriptor processing
* periodically as defined by SK_DPT_TIMER_MAX. However sk(4) still
* issue SK_TXBMU_TX_START to Tx BMU to get fast execution of Tx
* command instead of waiting for next descriptor polling time.
* The same rule may apply to Rx side too but it seems that is not
* needed at the moment.
* Since sk(4) uses descriptor polling as a last resort there is no
* need to set smaller polling time than maximum allowable one.
*/
SK_IF_WRITE_4(sc_if, 0, SK_DPT_INIT, SK_DPT_TIMER_MAX);
/* Configure I2C registers */
/* Configure XMAC(s) */
switch (sc->sk_type) {
case SK_GENESIS:
sk_init_xmac(sc_if);
break;
case SK_YUKON:
case SK_YUKON_LITE:
case SK_YUKON_LP:
sk_init_yukon(sc_if);
break;
}
mii_mediachg(mii);
if (SK_IS_GENESIS(sc)) {
/* Configure MAC FIFOs */
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_END, SK_FIFO_END);
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_ON);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_END, SK_FIFO_END);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_ON);
}
/* Configure transmit arbiter(s) */
SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL,
SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON);
/* Configure RAMbuffers */
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_START, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_WR_PTR, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_RD_PTR, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_END, sc_if->sk_rx_ramend);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_ON);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_UNRESET);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_STORENFWD_ON);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_START, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_WR_PTR, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_RD_PTR, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_END, sc_if->sk_tx_ramend);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_ON);
/* Configure BMUs */
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_ONLINE);
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_LO,
SK_ADDR_LO(sc_if->sk_rdata.sk_rx_ring_paddr));
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_HI,
SK_ADDR_HI(sc_if->sk_rdata.sk_rx_ring_paddr));
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_BMU_CSR, SK_TXBMU_ONLINE);
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_LO,
SK_ADDR_LO(sc_if->sk_rdata.sk_tx_ring_paddr));
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_HI,
SK_ADDR_HI(sc_if->sk_rdata.sk_tx_ring_paddr));
/* Init descriptors */
if (sk_init_rx_ring(sc_if) == ENOBUFS) {
if_printf(ifp, "initialization failed: "
"no memory for rx buffers\n");
sk_stop(sc_if);
return;
}
if (sk_init_tx_ring(sc_if) == ENOBUFS) {
if_printf(ifp, "initialization failed: "
"no memory for tx buffers\n");
sk_stop(sc_if);
return;
}
/* Configure interrupt handling */
CSR_READ_4(sc, SK_ISSR);
if (sc_if->sk_port == SK_PORT_A)
sc->sk_intrmask |= SK_INTRS1;
else
sc->sk_intrmask |= SK_INTRS2;
sc->sk_intrmask |= SK_ISR_EXTERNAL_REG;
CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
/* Start BMUs. */
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_RX_START);
if (SK_IS_GENESIS(sc)) {
/* Enable XMACs TX and RX state machines */
SK_XM_CLRBIT_2(sc_if, XM_MMUCMD, XM_MMUCMD_IGNPAUSE);
SK_XM_SETBIT_2(sc_if, XM_MMUCMD,
XM_MMUCMD_TX_ENB|XM_MMUCMD_RX_ENB);
}
if (SK_IS_YUKON(sc)) {
uint16_t reg = SK_YU_READ_2(sc_if, YUKON_GPCR);
reg |= YU_GPCR_TXEN | YU_GPCR_RXEN;
#if 0
/* XXX disable 100Mbps and full duplex mode? */
reg &= ~(YU_GPCR_SPEED | YU_GPCR_DPLX_DIS);
#endif
SK_YU_WRITE_2(sc_if, YUKON_GPCR, reg);
}
/* Activate descriptor polling timer */
SK_IF_WRITE_4(sc_if, 0, SK_DPT_TIMER_CTRL, SK_DPT_TCTL_START);
/* Start transfer of Tx descriptors */
CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START);
ifp->if_flags |= IFF_RUNNING;
ifq_clr_oactive(&ifp->if_snd);
if (SK_IS_YUKON(sc))
callout_reset(&sc_if->sk_tick_timer, hz, sk_yukon_tick, sc_if);
} | /*
* Note that to properly initialize any part of the GEnesis chip,
* you first have to take it out of reset mode.
*/ | Note that to properly initialize any part of the GEnesis chip,
you first have to take it out of reset mode. | [
"Note",
"that",
"to",
"properly",
"initialize",
"any",
"part",
"of",
"the",
"GEnesis",
"chip",
"you",
"first",
"have",
"to",
"take",
"it",
"out",
"of",
"reset",
"mode",
"."
] | static void
sk_init(void *xsc_if)
{
struct sk_if_softc *sc_if = xsc_if;
struct sk_softc *sc = sc_if->sk_softc;
struct ifnet *ifp = &sc_if->arpcom.ac_if;
struct mii_data *mii = device_get_softc(sc_if->sk_miibus);
DPRINTFN(2, ("sk_init\n"));
ASSERT_SERIALIZED(ifp->if_serializer);
if (ifp->if_flags & IFF_RUNNING)
return;
sk_stop(sc_if);
if (ifp->if_mtu > ETHER_MAX_LEN)
sc_if->sk_use_jumbo = 1;
else
sc_if->sk_use_jumbo = 0;
DPRINTF(("use jumbo buffer: %s\n", sc_if->sk_use_jumbo ? "YES" : "NO"));
if (SK_IS_GENESIS(sc)) {
SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_ON);
SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL,
SK_LINKLED_LINKSYNC_ON);
SK_IF_WRITE_1(sc_if, 0, SK_RXLED1_CTL,
SK_RXLEDCTL_COUNTER_START);
SK_IF_WRITE_1(sc_if, 0, SK_TXLED1_CTL,
SK_TXLEDCTL_COUNTER_START);
}
SK_IF_WRITE_4(sc_if, 0, SK_DPT_INIT, SK_DPT_TIMER_MAX);
switch (sc->sk_type) {
case SK_GENESIS:
sk_init_xmac(sc_if);
break;
case SK_YUKON:
case SK_YUKON_LITE:
case SK_YUKON_LP:
sk_init_yukon(sc_if);
break;
}
mii_mediachg(mii);
if (SK_IS_GENESIS(sc)) {
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_END, SK_FIFO_END);
SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_ON);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_END, SK_FIFO_END);
SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_ON);
}
SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL,
SK_TXARCTL_ON | SK_TXARCTL_FSYNC_ON);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_UNRESET);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_START, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_WR_PTR, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_RD_PTR, sc_if->sk_rx_ramstart);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_END, sc_if->sk_rx_ramend);
SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_ON);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_UNRESET);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_STORENFWD_ON);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_START, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_WR_PTR, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_RD_PTR, sc_if->sk_tx_ramstart);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_END, sc_if->sk_tx_ramend);
SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_ON);
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_ONLINE);
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_LO,
SK_ADDR_LO(sc_if->sk_rdata.sk_rx_ring_paddr));
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_HI,
SK_ADDR_HI(sc_if->sk_rdata.sk_rx_ring_paddr));
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_BMU_CSR, SK_TXBMU_ONLINE);
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_LO,
SK_ADDR_LO(sc_if->sk_rdata.sk_tx_ring_paddr));
SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_HI,
SK_ADDR_HI(sc_if->sk_rdata.sk_tx_ring_paddr));
if (sk_init_rx_ring(sc_if) == ENOBUFS) {
if_printf(ifp, "initialization failed: "
"no memory for rx buffers\n");
sk_stop(sc_if);
return;
}
if (sk_init_tx_ring(sc_if) == ENOBUFS) {
if_printf(ifp, "initialization failed: "
"no memory for tx buffers\n");
sk_stop(sc_if);
return;
}
CSR_READ_4(sc, SK_ISSR);
if (sc_if->sk_port == SK_PORT_A)
sc->sk_intrmask |= SK_INTRS1;
else
sc->sk_intrmask |= SK_INTRS2;
sc->sk_intrmask |= SK_ISR_EXTERNAL_REG;
CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_RX_START);
if (SK_IS_GENESIS(sc)) {
SK_XM_CLRBIT_2(sc_if, XM_MMUCMD, XM_MMUCMD_IGNPAUSE);
SK_XM_SETBIT_2(sc_if, XM_MMUCMD,
XM_MMUCMD_TX_ENB|XM_MMUCMD_RX_ENB);
}
if (SK_IS_YUKON(sc)) {
uint16_t reg = SK_YU_READ_2(sc_if, YUKON_GPCR);
reg |= YU_GPCR_TXEN | YU_GPCR_RXEN;
#if 0
reg &= ~(YU_GPCR_SPEED | YU_GPCR_DPLX_DIS);
#endif
SK_YU_WRITE_2(sc_if, YUKON_GPCR, reg);
}
SK_IF_WRITE_4(sc_if, 0, SK_DPT_TIMER_CTRL, SK_DPT_TCTL_START);
CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START);
ifp->if_flags |= IFF_RUNNING;
ifq_clr_oactive(&ifp->if_snd);
if (SK_IS_YUKON(sc))
callout_reset(&sc_if->sk_tick_timer, hz, sk_yukon_tick, sc_if);
} | [
"static",
"void",
"sk_init",
"(",
"void",
"*",
"xsc_if",
")",
"{",
"struct",
"sk_if_softc",
"*",
"sc_if",
"=",
"xsc_if",
";",
"struct",
"sk_softc",
"*",
"sc",
"=",
"sc_if",
"->",
"sk_softc",
";",
"struct",
"ifnet",
"*",
"ifp",
"=",
"&",
"sc_if",
"->",
"arpcom",
".",
"ac_if",
";",
"struct",
"mii_data",
"*",
"mii",
"=",
"device_get_softc",
"(",
"sc_if",
"->",
"sk_miibus",
")",
";",
"DPRINTFN",
"(",
"2",
",",
"(",
"\"",
"\\n",
"\"",
")",
")",
";",
"ASSERT_SERIALIZED",
"(",
"ifp",
"->",
"if_serializer",
")",
";",
"if",
"(",
"ifp",
"->",
"if_flags",
"&",
"IFF_RUNNING",
")",
"return",
";",
"sk_stop",
"(",
"sc_if",
")",
";",
"if",
"(",
"ifp",
"->",
"if_mtu",
">",
"ETHER_MAX_LEN",
")",
"sc_if",
"->",
"sk_use_jumbo",
"=",
"1",
";",
"else",
"sc_if",
"->",
"sk_use_jumbo",
"=",
"0",
";",
"DPRINTF",
"(",
"(",
"\"",
"\\n",
"\"",
",",
"sc_if",
"->",
"sk_use_jumbo",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
")",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"SK_IF_WRITE_1",
"(",
"sc_if",
",",
"0",
",",
"SK_LINKLED1_CTL",
",",
"SK_LINKLED_ON",
")",
";",
"SK_IF_WRITE_1",
"(",
"sc_if",
",",
"0",
",",
"SK_LINKLED1_CTL",
",",
"SK_LINKLED_LINKSYNC_ON",
")",
";",
"SK_IF_WRITE_1",
"(",
"sc_if",
",",
"0",
",",
"SK_RXLED1_CTL",
",",
"SK_RXLEDCTL_COUNTER_START",
")",
";",
"SK_IF_WRITE_1",
"(",
"sc_if",
",",
"0",
",",
"SK_TXLED1_CTL",
",",
"SK_TXLEDCTL_COUNTER_START",
")",
";",
"}",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_DPT_INIT",
",",
"SK_DPT_TIMER_MAX",
")",
";",
"switch",
"(",
"sc",
"->",
"sk_type",
")",
"{",
"case",
"SK_GENESIS",
":",
"sk_init_xmac",
"(",
"sc_if",
")",
";",
"break",
";",
"case",
"SK_YUKON",
":",
"case",
"SK_YUKON_LITE",
":",
"case",
"SK_YUKON_LP",
":",
"sk_init_yukon",
"(",
"sc_if",
")",
";",
"break",
";",
"}",
"mii_mediachg",
"(",
"mii",
")",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXF1_CTL",
",",
"SK_FIFO_UNRESET",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXF1_END",
",",
"SK_FIFO_END",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXF1_CTL",
",",
"SK_FIFO_ON",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_TXF1_CTL",
",",
"SK_FIFO_UNRESET",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_TXF1_END",
",",
"SK_FIFO_END",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_TXF1_CTL",
",",
"SK_FIFO_ON",
")",
";",
"}",
"SK_IF_WRITE_1",
"(",
"sc_if",
",",
"0",
",",
"SK_TXAR1_COUNTERCTL",
",",
"SK_TXARCTL_ON",
"|",
"SK_TXARCTL_FSYNC_ON",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_CTLTST",
",",
"SK_RBCTL_UNRESET",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_START",
",",
"sc_if",
"->",
"sk_rx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_WR_PTR",
",",
"sc_if",
"->",
"sk_rx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_RD_PTR",
",",
"sc_if",
"->",
"sk_rx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_END",
",",
"sc_if",
"->",
"sk_rx_ramend",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXRB1_CTLTST",
",",
"SK_RBCTL_ON",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_CTLTST",
",",
"SK_RBCTL_UNRESET",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_CTLTST",
",",
"SK_RBCTL_STORENFWD_ON",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_START",
",",
"sc_if",
"->",
"sk_tx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_WR_PTR",
",",
"sc_if",
"->",
"sk_tx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_RD_PTR",
",",
"sc_if",
"->",
"sk_tx_ramstart",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_END",
",",
"sc_if",
"->",
"sk_tx_ramend",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXRBS1_CTLTST",
",",
"SK_RBCTL_ON",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXQ1_BMU_CSR",
",",
"SK_RXBMU_ONLINE",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXQ1_CURADDR_LO",
",",
"SK_ADDR_LO",
"(",
"sc_if",
"->",
"sk_rdata",
".",
"sk_rx_ring_paddr",
")",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXQ1_CURADDR_HI",
",",
"SK_ADDR_HI",
"(",
"sc_if",
"->",
"sk_rdata",
".",
"sk_rx_ring_paddr",
")",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXQS1_BMU_CSR",
",",
"SK_TXBMU_ONLINE",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXQS1_CURADDR_LO",
",",
"SK_ADDR_LO",
"(",
"sc_if",
"->",
"sk_rdata",
".",
"sk_tx_ring_paddr",
")",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"1",
",",
"SK_TXQS1_CURADDR_HI",
",",
"SK_ADDR_HI",
"(",
"sc_if",
"->",
"sk_rdata",
".",
"sk_tx_ring_paddr",
")",
")",
";",
"if",
"(",
"sk_init_rx_ring",
"(",
"sc_if",
")",
"==",
"ENOBUFS",
")",
"{",
"if_printf",
"(",
"ifp",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
")",
";",
"sk_stop",
"(",
"sc_if",
")",
";",
"return",
";",
"}",
"if",
"(",
"sk_init_tx_ring",
"(",
"sc_if",
")",
"==",
"ENOBUFS",
")",
"{",
"if_printf",
"(",
"ifp",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
")",
";",
"sk_stop",
"(",
"sc_if",
")",
";",
"return",
";",
"}",
"CSR_READ_4",
"(",
"sc",
",",
"SK_ISSR",
")",
";",
"if",
"(",
"sc_if",
"->",
"sk_port",
"==",
"SK_PORT_A",
")",
"sc",
"->",
"sk_intrmask",
"|=",
"SK_INTRS1",
";",
"else",
"sc",
"->",
"sk_intrmask",
"|=",
"SK_INTRS2",
";",
"sc",
"->",
"sk_intrmask",
"|=",
"SK_ISR_EXTERNAL_REG",
";",
"CSR_WRITE_4",
"(",
"sc",
",",
"SK_IMR",
",",
"sc",
"->",
"sk_intrmask",
")",
";",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_RXQ1_BMU_CSR",
",",
"SK_RXBMU_RX_START",
")",
";",
"if",
"(",
"SK_IS_GENESIS",
"(",
"sc",
")",
")",
"{",
"SK_XM_CLRBIT_2",
"(",
"sc_if",
",",
"XM_MMUCMD",
",",
"XM_MMUCMD_IGNPAUSE",
")",
";",
"SK_XM_SETBIT_2",
"(",
"sc_if",
",",
"XM_MMUCMD",
",",
"XM_MMUCMD_TX_ENB",
"|",
"XM_MMUCMD_RX_ENB",
")",
";",
"}",
"if",
"(",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"{",
"uint16_t",
"reg",
"=",
"SK_YU_READ_2",
"(",
"sc_if",
",",
"YUKON_GPCR",
")",
";",
"reg",
"|=",
"YU_GPCR_TXEN",
"|",
"YU_GPCR_RXEN",
";",
"#if",
"0",
"\n",
"reg",
"&=",
"~",
"(",
"YU_GPCR_SPEED",
"|",
"YU_GPCR_DPLX_DIS",
")",
";",
"#endif",
"SK_YU_WRITE_2",
"(",
"sc_if",
",",
"YUKON_GPCR",
",",
"reg",
")",
";",
"}",
"SK_IF_WRITE_4",
"(",
"sc_if",
",",
"0",
",",
"SK_DPT_TIMER_CTRL",
",",
"SK_DPT_TCTL_START",
")",
";",
"CSR_WRITE_4",
"(",
"sc",
",",
"sc_if",
"->",
"sk_tx_bmu",
",",
"SK_TXBMU_TX_START",
")",
";",
"ifp",
"->",
"if_flags",
"|=",
"IFF_RUNNING",
";",
"ifq_clr_oactive",
"(",
"&",
"ifp",
"->",
"if_snd",
")",
";",
"if",
"(",
"SK_IS_YUKON",
"(",
"sc",
")",
")",
"callout_reset",
"(",
"&",
"sc_if",
"->",
"sk_tick_timer",
",",
"hz",
",",
"sk_yukon_tick",
",",
"sc_if",
")",
";",
"}"
] | Note that to properly initialize any part of the GEnesis chip,
you first have to take it out of reset mode. | [
"Note",
"that",
"to",
"properly",
"initialize",
"any",
"part",
"of",
"the",
"GEnesis",
"chip",
"you",
"first",
"have",
"to",
"take",
"it",
"out",
"of",
"reset",
"mode",
"."
] | [
"/* Cancel pending I/O and free all RX/TX buffers. */",
"/*\n\t * NOTE: Change sk_use_jumbo after sk_stop(),\n\t * but before real initialization.\n\t */",
"/* Configure LINK_SYNC LED */",
"/* Configure RX LED */",
"/* Configure TX LED */",
"/*\n\t * Configure descriptor poll timer\n\t *\n\t * SK-NET GENESIS data sheet says that possibility of losing Start\n\t * transmit command due to CPU/cache related interim storage problems\n\t * under certain conditions. The document recommends a polling\n\t * mechanism to send a Start transmit command to initiate transfer\n\t * of ready descriptors regulary. To cope with this issue sk(4) now\n\t * enables descriptor poll timer to initiate descriptor processing\n\t * periodically as defined by SK_DPT_TIMER_MAX. However sk(4) still\n\t * issue SK_TXBMU_TX_START to Tx BMU to get fast execution of Tx\n\t * command instead of waiting for next descriptor polling time.\n\t * The same rule may apply to Rx side too but it seems that is not\n\t * needed at the moment.\n\t * Since sk(4) uses descriptor polling as a last resort there is no\n\t * need to set smaller polling time than maximum allowable one.\n\t */",
"/* Configure I2C registers */",
"/* Configure XMAC(s) */",
"/* Configure MAC FIFOs */",
"/* Configure transmit arbiter(s) */",
"/* Configure RAMbuffers */",
"/* Configure BMUs */",
"/* Init descriptors */",
"/* Configure interrupt handling */",
"/* Start BMUs. */",
"/* Enable XMACs TX and RX state machines */",
"/* XXX disable 100Mbps and full duplex mode? */",
"/* Activate descriptor polling timer */",
"/* Start transfer of Tx descriptors */"
] | [
{
"param": "xsc_if",
"type": "void"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xsc_if",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24c9fff8e816ef59407573f6c8b75ed037142c06 | atrens/DragonFlyBSD-src | sys/dev/netif/sk/if_sk.c | [
"BSD-3-Clause"
] | C | sk_jpool_alloc | int | static int
sk_jpool_alloc(device_t dev)
{
struct sk_if_softc *sc_if = device_get_softc(dev);
struct sk_chain_data *cd = &sc_if->sk_cdata;
bus_dmamem_t dmem;
bus_addr_t paddr;
caddr_t buf;
int error, i;
lwkt_serialize_init(&cd->sk_jpool_serializer);
error = bus_dmamem_coherent(cd->sk_buf_dtag, PAGE_SIZE /* XXX */, 0,
BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
SK_JMEM, BUS_DMA_WAITOK, &dmem);
if (error) {
device_printf(dev, "can't allocate jumbo frame pool\n");
return error;
}
cd->sk_jpool_dtag = dmem.dmem_tag;
cd->sk_jpool_dmap = dmem.dmem_map;
cd->sk_jpool = dmem.dmem_addr;
paddr = dmem.dmem_busaddr;
SLIST_INIT(&cd->sk_jpool_free_ent);
buf = cd->sk_jpool;
/*
* Now divide it up into SK_JLEN pieces.
*/
for (i = 0; i < SK_JSLOTS; i++) {
struct sk_jpool_entry *entry = &cd->sk_jpool_ent[i];
entry->sc_if = sc_if;
entry->inuse = 0;
entry->slot = i;
entry->buf = buf;
entry->paddr = paddr;
SLIST_INSERT_HEAD(&cd->sk_jpool_free_ent, entry, entry_next);
buf += SK_JLEN;
paddr += SK_JLEN;
}
return 0;
} | /*
* Allocate jumbo buffer storage. The SysKonnect adapters support
* "jumbograms" (9K frames), although SysKonnect doesn't currently
* use them in their drivers. In order for us to use them, we need
* large 9K receive buffers, however standard mbuf clusters are only
* 2048 bytes in size. Consequently, we need to allocate and manage
* our own jumbo buffer pool. Fortunately, this does not require an
* excessive amount of additional code.
*/ | Allocate jumbo buffer storage. The SysKonnect adapters support
"jumbograms" (9K frames), although SysKonnect doesn't currently
use them in their drivers. In order for us to use them, we need
large 9K receive buffers, however standard mbuf clusters are only
2048 bytes in size. Consequently, we need to allocate and manage
our own jumbo buffer pool. Fortunately, this does not require an
excessive amount of additional code. | [
"Allocate",
"jumbo",
"buffer",
"storage",
".",
"The",
"SysKonnect",
"adapters",
"support",
"\"",
"jumbograms",
"\"",
"(",
"9K",
"frames",
")",
"although",
"SysKonnect",
"doesn",
"'",
"t",
"currently",
"use",
"them",
"in",
"their",
"drivers",
".",
"In",
"order",
"for",
"us",
"to",
"use",
"them",
"we",
"need",
"large",
"9K",
"receive",
"buffers",
"however",
"standard",
"mbuf",
"clusters",
"are",
"only",
"2048",
"bytes",
"in",
"size",
".",
"Consequently",
"we",
"need",
"to",
"allocate",
"and",
"manage",
"our",
"own",
"jumbo",
"buffer",
"pool",
".",
"Fortunately",
"this",
"does",
"not",
"require",
"an",
"excessive",
"amount",
"of",
"additional",
"code",
"."
] | static int
sk_jpool_alloc(device_t dev)
{
struct sk_if_softc *sc_if = device_get_softc(dev);
struct sk_chain_data *cd = &sc_if->sk_cdata;
bus_dmamem_t dmem;
bus_addr_t paddr;
caddr_t buf;
int error, i;
lwkt_serialize_init(&cd->sk_jpool_serializer);
error = bus_dmamem_coherent(cd->sk_buf_dtag, PAGE_SIZE , 0,
BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
SK_JMEM, BUS_DMA_WAITOK, &dmem);
if (error) {
device_printf(dev, "can't allocate jumbo frame pool\n");
return error;
}
cd->sk_jpool_dtag = dmem.dmem_tag;
cd->sk_jpool_dmap = dmem.dmem_map;
cd->sk_jpool = dmem.dmem_addr;
paddr = dmem.dmem_busaddr;
SLIST_INIT(&cd->sk_jpool_free_ent);
buf = cd->sk_jpool;
for (i = 0; i < SK_JSLOTS; i++) {
struct sk_jpool_entry *entry = &cd->sk_jpool_ent[i];
entry->sc_if = sc_if;
entry->inuse = 0;
entry->slot = i;
entry->buf = buf;
entry->paddr = paddr;
SLIST_INSERT_HEAD(&cd->sk_jpool_free_ent, entry, entry_next);
buf += SK_JLEN;
paddr += SK_JLEN;
}
return 0;
} | [
"static",
"int",
"sk_jpool_alloc",
"(",
"device_t",
"dev",
")",
"{",
"struct",
"sk_if_softc",
"*",
"sc_if",
"=",
"device_get_softc",
"(",
"dev",
")",
";",
"struct",
"sk_chain_data",
"*",
"cd",
"=",
"&",
"sc_if",
"->",
"sk_cdata",
";",
"bus_dmamem_t",
"dmem",
";",
"bus_addr_t",
"paddr",
";",
"caddr_t",
"buf",
";",
"int",
"error",
",",
"i",
";",
"lwkt_serialize_init",
"(",
"&",
"cd",
"->",
"sk_jpool_serializer",
")",
";",
"error",
"=",
"bus_dmamem_coherent",
"(",
"cd",
"->",
"sk_buf_dtag",
",",
"PAGE_SIZE",
",",
"0",
",",
"BUS_SPACE_MAXADDR",
",",
"BUS_SPACE_MAXADDR",
",",
"SK_JMEM",
",",
"BUS_DMA_WAITOK",
",",
"&",
"dmem",
")",
";",
"if",
"(",
"error",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
")",
";",
"return",
"error",
";",
"}",
"cd",
"->",
"sk_jpool_dtag",
"=",
"dmem",
".",
"dmem_tag",
";",
"cd",
"->",
"sk_jpool_dmap",
"=",
"dmem",
".",
"dmem_map",
";",
"cd",
"->",
"sk_jpool",
"=",
"dmem",
".",
"dmem_addr",
";",
"paddr",
"=",
"dmem",
".",
"dmem_busaddr",
";",
"SLIST_INIT",
"(",
"&",
"cd",
"->",
"sk_jpool_free_ent",
")",
";",
"buf",
"=",
"cd",
"->",
"sk_jpool",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"SK_JSLOTS",
";",
"i",
"++",
")",
"{",
"struct",
"sk_jpool_entry",
"*",
"entry",
"=",
"&",
"cd",
"->",
"sk_jpool_ent",
"[",
"i",
"]",
";",
"entry",
"->",
"sc_if",
"=",
"sc_if",
";",
"entry",
"->",
"inuse",
"=",
"0",
";",
"entry",
"->",
"slot",
"=",
"i",
";",
"entry",
"->",
"buf",
"=",
"buf",
";",
"entry",
"->",
"paddr",
"=",
"paddr",
";",
"SLIST_INSERT_HEAD",
"(",
"&",
"cd",
"->",
"sk_jpool_free_ent",
",",
"entry",
",",
"entry_next",
")",
";",
"buf",
"+=",
"SK_JLEN",
";",
"paddr",
"+=",
"SK_JLEN",
";",
"}",
"return",
"0",
";",
"}"
] | Allocate jumbo buffer storage. | [
"Allocate",
"jumbo",
"buffer",
"storage",
"."
] | [
"/* XXX */",
"/*\n\t * Now divide it up into SK_JLEN pieces.\n\t */"
] | [
{
"param": "dev",
"type": "device_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | nglmi_newhook | int | static int
nglmi_newhook(node_p node, hook_p hook, const char *name)
{
sc_p sc = NG_NODE_PRIVATE(node);
if (strcmp(name, NG_LMI_HOOK_DEBUG) == 0) {
NG_HOOK_SET_PRIVATE(hook, NULL);
return (0);
}
if (sc->flags & SCF_CONNECTED) {
/* already connected, return an error */
return (EINVAL);
}
if (strcmp(name, NG_LMI_HOOK_ANNEXA) == 0) {
sc->lmi_annexA = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 8;
SETLMITYPE(sc, SCF_ANNEX_A);
sc->protoname = NAME_ANNEXA;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_ANNEXD) == 0) {
sc->lmi_annexD = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 8;
SETLMITYPE(sc, SCF_ANNEX_D);
sc->protoname = NAME_ANNEXD;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_GROUPOF4) == 0) {
sc->lmi_group4 = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 9;
SETLMITYPE(sc, SCF_GROUP4);
sc->protoname = NAME_GROUP4;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_AUTO0) == 0) {
/* Note this, and if B is already installed, we're complete */
sc->lmi_channel0 = hook;
sc->protoname = NAME_NONE;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
if (sc->lmi_channel1023)
nglmi_startup_auto(sc);
} else if (strcmp(name, NG_LMI_HOOK_AUTO1023) == 0) {
/* Note this, and if A is already installed, we're complete */
sc->lmi_channel1023 = hook;
sc->protoname = NAME_NONE;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
if (sc->lmi_channel0)
nglmi_startup_auto(sc);
} else
return (EINVAL); /* unknown hook */
return (0);
} | /*
* The LMI channel has a private pointer which is the same as the
* node private pointer. The debug channel has a NULL private pointer.
*/ | The LMI channel has a private pointer which is the same as the
node private pointer. The debug channel has a NULL private pointer. | [
"The",
"LMI",
"channel",
"has",
"a",
"private",
"pointer",
"which",
"is",
"the",
"same",
"as",
"the",
"node",
"private",
"pointer",
".",
"The",
"debug",
"channel",
"has",
"a",
"NULL",
"private",
"pointer",
"."
] | static int
nglmi_newhook(node_p node, hook_p hook, const char *name)
{
sc_p sc = NG_NODE_PRIVATE(node);
if (strcmp(name, NG_LMI_HOOK_DEBUG) == 0) {
NG_HOOK_SET_PRIVATE(hook, NULL);
return (0);
}
if (sc->flags & SCF_CONNECTED) {
return (EINVAL);
}
if (strcmp(name, NG_LMI_HOOK_ANNEXA) == 0) {
sc->lmi_annexA = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 8;
SETLMITYPE(sc, SCF_ANNEX_A);
sc->protoname = NAME_ANNEXA;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_ANNEXD) == 0) {
sc->lmi_annexD = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 8;
SETLMITYPE(sc, SCF_ANNEX_D);
sc->protoname = NAME_ANNEXD;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_GROUPOF4) == 0) {
sc->lmi_group4 = hook;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
sc->protoID = 9;
SETLMITYPE(sc, SCF_GROUP4);
sc->protoname = NAME_GROUP4;
nglmi_startup_fixed(sc, hook);
} else if (strcmp(name, NG_LMI_HOOK_AUTO0) == 0) {
sc->lmi_channel0 = hook;
sc->protoname = NAME_NONE;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
if (sc->lmi_channel1023)
nglmi_startup_auto(sc);
} else if (strcmp(name, NG_LMI_HOOK_AUTO1023) == 0) {
sc->lmi_channel1023 = hook;
sc->protoname = NAME_NONE;
NG_HOOK_SET_PRIVATE(hook, NG_NODE_PRIVATE(node));
if (sc->lmi_channel0)
nglmi_startup_auto(sc);
} else
return (EINVAL);
return (0);
} | [
"static",
"int",
"nglmi_newhook",
"(",
"node_p",
"node",
",",
"hook_p",
"hook",
",",
"const",
"char",
"*",
"name",
")",
"{",
"sc_p",
"sc",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_DEBUG",
")",
"==",
"0",
")",
"{",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NULL",
")",
";",
"return",
"(",
"0",
")",
";",
"}",
"if",
"(",
"sc",
"->",
"flags",
"&",
"SCF_CONNECTED",
")",
"{",
"return",
"(",
"EINVAL",
")",
";",
"}",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_ANNEXA",
")",
"==",
"0",
")",
"{",
"sc",
"->",
"lmi_annexA",
"=",
"hook",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NG_NODE_PRIVATE",
"(",
"node",
")",
")",
";",
"sc",
"->",
"protoID",
"=",
"8",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_A",
")",
";",
"sc",
"->",
"protoname",
"=",
"NAME_ANNEXA",
";",
"nglmi_startup_fixed",
"(",
"sc",
",",
"hook",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_ANNEXD",
")",
"==",
"0",
")",
"{",
"sc",
"->",
"lmi_annexD",
"=",
"hook",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NG_NODE_PRIVATE",
"(",
"node",
")",
")",
";",
"sc",
"->",
"protoID",
"=",
"8",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_D",
")",
";",
"sc",
"->",
"protoname",
"=",
"NAME_ANNEXD",
";",
"nglmi_startup_fixed",
"(",
"sc",
",",
"hook",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_GROUPOF4",
")",
"==",
"0",
")",
"{",
"sc",
"->",
"lmi_group4",
"=",
"hook",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NG_NODE_PRIVATE",
"(",
"node",
")",
")",
";",
"sc",
"->",
"protoID",
"=",
"9",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_GROUP4",
")",
";",
"sc",
"->",
"protoname",
"=",
"NAME_GROUP4",
";",
"nglmi_startup_fixed",
"(",
"sc",
",",
"hook",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_AUTO0",
")",
"==",
"0",
")",
"{",
"sc",
"->",
"lmi_channel0",
"=",
"hook",
";",
"sc",
"->",
"protoname",
"=",
"NAME_NONE",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NG_NODE_PRIVATE",
"(",
"node",
")",
")",
";",
"if",
"(",
"sc",
"->",
"lmi_channel1023",
")",
"nglmi_startup_auto",
"(",
"sc",
")",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"name",
",",
"NG_LMI_HOOK_AUTO1023",
")",
"==",
"0",
")",
"{",
"sc",
"->",
"lmi_channel1023",
"=",
"hook",
";",
"sc",
"->",
"protoname",
"=",
"NAME_NONE",
";",
"NG_HOOK_SET_PRIVATE",
"(",
"hook",
",",
"NG_NODE_PRIVATE",
"(",
"node",
")",
")",
";",
"if",
"(",
"sc",
"->",
"lmi_channel0",
")",
"nglmi_startup_auto",
"(",
"sc",
")",
";",
"}",
"else",
"return",
"(",
"EINVAL",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | The LMI channel has a private pointer which is the same as the
node private pointer. | [
"The",
"LMI",
"channel",
"has",
"a",
"private",
"pointer",
"which",
"is",
"the",
"same",
"as",
"the",
"node",
"private",
"pointer",
"."
] | [
"/* already connected, return an error */",
"/* Note this, and if B is already installed, we're complete */",
"/* Note this, and if A is already installed, we're complete */",
"/* unknown hook */"
] | [
{
"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": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | LMI_ticker | void | static void
LMI_ticker(node_p node, hook_p hook, void *arg1, int arg2)
{
sc_p sc = NG_NODE_PRIVATE(node);
if (sc->flags & SCF_AUTO) {
ngauto_state_machine(sc);
ng_callout(&sc->handle, node, NULL, NG_LMI_POLL_RATE * hz,
LMI_ticker, NULL, 0);
} else {
if (sc->livs++ >= sc->liv_per_full) {
nglmi_inquire(sc, 1);
/* sc->livs = 0; *//* do this when we get the answer! */
} else {
nglmi_inquire(sc, 0);
}
ng_callout(&sc->handle, node, NULL, sc->liv_rate * hz,
LMI_ticker, NULL, 0);
}
} | /*
* We have just attached to a live (we hope) node.
* Fire out a LMI inquiry, and then start up the timers.
*/ | We have just attached to a live (we hope) node.
Fire out a LMI inquiry, and then start up the timers. | [
"We",
"have",
"just",
"attached",
"to",
"a",
"live",
"(",
"we",
"hope",
")",
"node",
".",
"Fire",
"out",
"a",
"LMI",
"inquiry",
"and",
"then",
"start",
"up",
"the",
"timers",
"."
] | static void
LMI_ticker(node_p node, hook_p hook, void *arg1, int arg2)
{
sc_p sc = NG_NODE_PRIVATE(node);
if (sc->flags & SCF_AUTO) {
ngauto_state_machine(sc);
ng_callout(&sc->handle, node, NULL, NG_LMI_POLL_RATE * hz,
LMI_ticker, NULL, 0);
} else {
if (sc->livs++ >= sc->liv_per_full) {
nglmi_inquire(sc, 1);
} else {
nglmi_inquire(sc, 0);
}
ng_callout(&sc->handle, node, NULL, sc->liv_rate * hz,
LMI_ticker, NULL, 0);
}
} | [
"static",
"void",
"LMI_ticker",
"(",
"node_p",
"node",
",",
"hook_p",
"hook",
",",
"void",
"*",
"arg1",
",",
"int",
"arg2",
")",
"{",
"sc_p",
"sc",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"if",
"(",
"sc",
"->",
"flags",
"&",
"SCF_AUTO",
")",
"{",
"ngauto_state_machine",
"(",
"sc",
")",
";",
"ng_callout",
"(",
"&",
"sc",
"->",
"handle",
",",
"node",
",",
"NULL",
",",
"NG_LMI_POLL_RATE",
"*",
"hz",
",",
"LMI_ticker",
",",
"NULL",
",",
"0",
")",
";",
"}",
"else",
"{",
"if",
"(",
"sc",
"->",
"livs",
"++",
">=",
"sc",
"->",
"liv_per_full",
")",
"{",
"nglmi_inquire",
"(",
"sc",
",",
"1",
")",
";",
"}",
"else",
"{",
"nglmi_inquire",
"(",
"sc",
",",
"0",
")",
";",
"}",
"ng_callout",
"(",
"&",
"sc",
"->",
"handle",
",",
"node",
",",
"NULL",
",",
"sc",
"->",
"liv_rate",
"*",
"hz",
",",
"LMI_ticker",
",",
"NULL",
",",
"0",
")",
";",
"}",
"}"
] | We have just attached to a live (we hope) node. | [
"We",
"have",
"just",
"attached",
"to",
"a",
"live",
"(",
"we",
"hope",
")",
"node",
"."
] | [
"/* sc->livs = 0; */",
"/* do this when we get the answer! */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "hook",
"type": "hook_p"
},
{
"param": "arg1",
"type": "void"
},
{
"param": "arg2",
"type": "int"
}
] | {
"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": "arg1",
"type": "void",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "arg2",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | ngauto_state_machine | void | static void
ngauto_state_machine(sc_p sc)
{
if ((sc->poll_count <= 0) || (sc->poll_count > LMIPOLLSIZE)) {
/* time to change states in the auto probe machine */
/* capture wild values of poll_count while we are at it */
sc->poll_count = LMIPOLLSIZE;
sc->poll_state++;
}
switch (sc->poll_state) {
case 7:
log(LOG_WARNING, "nglmi: no response from exchange\n");
default: /* capture bad states */
sc->poll_state = 1;
case 1:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_ANNEX_D);
break;
case 2:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_ANNEX_D);
break;
case 3:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_ANNEX_A);
break;
case 4:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_GROUP4);
break;
case 5:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_ANNEX_A);
break;
case 6:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_GROUP4);
break;
}
/* send an inquirey encoded appropriatly */
nglmi_inquire(sc, 0);
sc->poll_count--;
} | /*
* State machine for LMI auto-detect. The transitions are ordered
* to try the more likely possibilities first.
*/ | State machine for LMI auto-detect. The transitions are ordered
to try the more likely possibilities first. | [
"State",
"machine",
"for",
"LMI",
"auto",
"-",
"detect",
".",
"The",
"transitions",
"are",
"ordered",
"to",
"try",
"the",
"more",
"likely",
"possibilities",
"first",
"."
] | static void
ngauto_state_machine(sc_p sc)
{
if ((sc->poll_count <= 0) || (sc->poll_count > LMIPOLLSIZE)) {
sc->poll_count = LMIPOLLSIZE;
sc->poll_state++;
}
switch (sc->poll_state) {
case 7:
log(LOG_WARNING, "nglmi: no response from exchange\n");
default:
sc->poll_state = 1;
case 1:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_ANNEX_D);
break;
case 2:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_ANNEX_D);
break;
case 3:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_ANNEX_A);
break;
case 4:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_GROUP4);
break;
case 5:
sc->lmi_channel = sc->lmi_channel1023;
SETLMITYPE(sc, SCF_ANNEX_A);
break;
case 6:
sc->lmi_channel = sc->lmi_channel0;
SETLMITYPE(sc, SCF_GROUP4);
break;
}
nglmi_inquire(sc, 0);
sc->poll_count--;
} | [
"static",
"void",
"ngauto_state_machine",
"(",
"sc_p",
"sc",
")",
"{",
"if",
"(",
"(",
"sc",
"->",
"poll_count",
"<=",
"0",
")",
"||",
"(",
"sc",
"->",
"poll_count",
">",
"LMIPOLLSIZE",
")",
")",
"{",
"sc",
"->",
"poll_count",
"=",
"LMIPOLLSIZE",
";",
"sc",
"->",
"poll_state",
"++",
";",
"}",
"switch",
"(",
"sc",
"->",
"poll_state",
")",
"{",
"case",
"7",
":",
"log",
"(",
"LOG_WARNING",
",",
"\"",
"\\n",
"\"",
")",
";",
"default",
":",
"sc",
"->",
"poll_state",
"=",
"1",
";",
"case",
"1",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel0",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_D",
")",
";",
"break",
";",
"case",
"2",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel1023",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_D",
")",
";",
"break",
";",
"case",
"3",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel0",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_A",
")",
";",
"break",
";",
"case",
"4",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel1023",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_GROUP4",
")",
";",
"break",
";",
"case",
"5",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel1023",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_ANNEX_A",
")",
";",
"break",
";",
"case",
"6",
":",
"sc",
"->",
"lmi_channel",
"=",
"sc",
"->",
"lmi_channel0",
";",
"SETLMITYPE",
"(",
"sc",
",",
"SCF_GROUP4",
")",
";",
"break",
";",
"}",
"nglmi_inquire",
"(",
"sc",
",",
"0",
")",
";",
"sc",
"->",
"poll_count",
"--",
";",
"}"
] | State machine for LMI auto-detect. | [
"State",
"machine",
"for",
"LMI",
"auto",
"-",
"detect",
"."
] | [
"/* time to change states in the auto probe machine */",
"/* capture wild values of poll_count while we are at it */",
"/* capture bad states */",
"/* send an inquirey encoded appropriatly */"
] | [
{
"param": "sc",
"type": "sc_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sc",
"type": "sc_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | nglmi_rcvmsg | int | static int
nglmi_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
sc_p sc = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_GENERIC_COOKIE:
switch (msg->header.cmd) {
case NGM_TEXT_STATUS:
{
char *arg;
int pos, count;
NG_MKRESPONSE(resp, msg, NG_TEXTRESPONSE, M_WAITOK | M_NULLOK);
if (resp == NULL) {
error = ENOMEM;
break;
}
arg = resp->data;
pos = ksprintf(arg, "protocol %s ", sc->protoname);
if (sc->flags & SCF_FIXED)
pos += ksprintf(arg + pos, "fixed\n");
else if (sc->flags & SCF_AUTO)
pos += ksprintf(arg + pos, "auto-detecting\n");
else
pos += ksprintf(arg + pos, "auto on dlci %d\n",
(sc->lmi_channel == sc->lmi_channel0) ?
0 : 1023);
pos += ksprintf(arg + pos,
"keepalive period: %d seconds\n", sc->liv_rate);
pos += ksprintf(arg + pos,
"unacknowledged keepalives: %ld\n",
sc->seq_retries);
for (count = 0;
((count <= MAXDLCI)
&& (pos < (NG_TEXTRESPONSE - 20)));
count++) {
if (sc->dlci_state[count]) {
pos += ksprintf(arg + pos,
"dlci %d %s\n", count,
(sc->dlci_state[count]
== DLCI_UP) ? "up" : "down");
}
}
resp->header.arglen = pos + 1;
break;
}
default:
error = EINVAL;
break;
}
break;
case NGM_LMI_COOKIE:
switch (msg->header.cmd) {
case NGM_LMI_GET_STATUS:
{
struct nglmistat *stat;
int k;
NG_MKRESPONSE(resp, msg, sizeof(*stat), M_WAITOK | M_NULLOK);
if (!resp) {
error = ENOMEM;
break;
}
stat = (struct nglmistat *) resp->data;
strncpy(stat->proto,
sc->protoname, sizeof(stat->proto) - 1);
strncpy(stat->hook,
sc->protoname, sizeof(stat->hook) - 1);
stat->autod = !!(sc->flags & SCF_AUTO);
stat->fixed = !!(sc->flags & SCF_FIXED);
for (k = 0; k <= MAXDLCI; k++) {
switch (sc->dlci_state[k]) {
case DLCI_UP:
stat->up[k / 8] |= (1 << (k % 8));
/* fall through */
case DLCI_DOWN:
stat->seen[k / 8] |= (1 << (k % 8));
break;
}
}
break;
}
default:
error = EINVAL;
break;
}
break;
default:
error = EINVAL;
break;
}
NG_RESPOND_MSG(error, node, item, resp);
NG_FREE_MSG(msg);
return (error);
} | /*
* Receive a netgraph control message.
*/ | Receive a netgraph control message. | [
"Receive",
"a",
"netgraph",
"control",
"message",
"."
] | static int
nglmi_rcvmsg(node_p node, item_p item, hook_p lasthook)
{
sc_p sc = NG_NODE_PRIVATE(node);
struct ng_mesg *resp = NULL;
int error = 0;
struct ng_mesg *msg;
NGI_GET_MSG(item, msg);
switch (msg->header.typecookie) {
case NGM_GENERIC_COOKIE:
switch (msg->header.cmd) {
case NGM_TEXT_STATUS:
{
char *arg;
int pos, count;
NG_MKRESPONSE(resp, msg, NG_TEXTRESPONSE, M_WAITOK | M_NULLOK);
if (resp == NULL) {
error = ENOMEM;
break;
}
arg = resp->data;
pos = ksprintf(arg, "protocol %s ", sc->protoname);
if (sc->flags & SCF_FIXED)
pos += ksprintf(arg + pos, "fixed\n");
else if (sc->flags & SCF_AUTO)
pos += ksprintf(arg + pos, "auto-detecting\n");
else
pos += ksprintf(arg + pos, "auto on dlci %d\n",
(sc->lmi_channel == sc->lmi_channel0) ?
0 : 1023);
pos += ksprintf(arg + pos,
"keepalive period: %d seconds\n", sc->liv_rate);
pos += ksprintf(arg + pos,
"unacknowledged keepalives: %ld\n",
sc->seq_retries);
for (count = 0;
((count <= MAXDLCI)
&& (pos < (NG_TEXTRESPONSE - 20)));
count++) {
if (sc->dlci_state[count]) {
pos += ksprintf(arg + pos,
"dlci %d %s\n", count,
(sc->dlci_state[count]
== DLCI_UP) ? "up" : "down");
}
}
resp->header.arglen = pos + 1;
break;
}
default:
error = EINVAL;
break;
}
break;
case NGM_LMI_COOKIE:
switch (msg->header.cmd) {
case NGM_LMI_GET_STATUS:
{
struct nglmistat *stat;
int k;
NG_MKRESPONSE(resp, msg, sizeof(*stat), M_WAITOK | M_NULLOK);
if (!resp) {
error = ENOMEM;
break;
}
stat = (struct nglmistat *) resp->data;
strncpy(stat->proto,
sc->protoname, sizeof(stat->proto) - 1);
strncpy(stat->hook,
sc->protoname, sizeof(stat->hook) - 1);
stat->autod = !!(sc->flags & SCF_AUTO);
stat->fixed = !!(sc->flags & SCF_FIXED);
for (k = 0; k <= MAXDLCI; k++) {
switch (sc->dlci_state[k]) {
case DLCI_UP:
stat->up[k / 8] |= (1 << (k % 8));
case DLCI_DOWN:
stat->seen[k / 8] |= (1 << (k % 8));
break;
}
}
break;
}
default:
error = EINVAL;
break;
}
break;
default:
error = EINVAL;
break;
}
NG_RESPOND_MSG(error, node, item, resp);
NG_FREE_MSG(msg);
return (error);
} | [
"static",
"int",
"nglmi_rcvmsg",
"(",
"node_p",
"node",
",",
"item_p",
"item",
",",
"hook_p",
"lasthook",
")",
"{",
"sc_p",
"sc",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"struct",
"ng_mesg",
"*",
"resp",
"=",
"NULL",
";",
"int",
"error",
"=",
"0",
";",
"struct",
"ng_mesg",
"*",
"msg",
";",
"NGI_GET_MSG",
"(",
"item",
",",
"msg",
")",
";",
"switch",
"(",
"msg",
"->",
"header",
".",
"typecookie",
")",
"{",
"case",
"NGM_GENERIC_COOKIE",
":",
"switch",
"(",
"msg",
"->",
"header",
".",
"cmd",
")",
"{",
"case",
"NGM_TEXT_STATUS",
":",
"{",
"char",
"*",
"arg",
";",
"int",
"pos",
",",
"count",
";",
"NG_MKRESPONSE",
"(",
"resp",
",",
"msg",
",",
"NG_TEXTRESPONSE",
",",
"M_WAITOK",
"|",
"M_NULLOK",
")",
";",
"if",
"(",
"resp",
"==",
"NULL",
")",
"{",
"error",
"=",
"ENOMEM",
";",
"break",
";",
"}",
"arg",
"=",
"resp",
"->",
"data",
";",
"pos",
"=",
"ksprintf",
"(",
"arg",
",",
"\"",
"\"",
",",
"sc",
"->",
"protoname",
")",
";",
"if",
"(",
"sc",
"->",
"flags",
"&",
"SCF_FIXED",
")",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"if",
"(",
"sc",
"->",
"flags",
"&",
"SCF_AUTO",
")",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
")",
";",
"else",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
",",
"(",
"sc",
"->",
"lmi_channel",
"==",
"sc",
"->",
"lmi_channel0",
")",
"?",
"0",
":",
"1023",
")",
";",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
",",
"sc",
"->",
"liv_rate",
")",
";",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
",",
"sc",
"->",
"seq_retries",
")",
";",
"for",
"(",
"count",
"=",
"0",
";",
"(",
"(",
"count",
"<=",
"MAXDLCI",
")",
"&&",
"(",
"pos",
"<",
"(",
"NG_TEXTRESPONSE",
"-",
"20",
")",
")",
")",
";",
"count",
"++",
")",
"{",
"if",
"(",
"sc",
"->",
"dlci_state",
"[",
"count",
"]",
")",
"{",
"pos",
"+=",
"ksprintf",
"(",
"arg",
"+",
"pos",
",",
"\"",
"\\n",
"\"",
",",
"count",
",",
"(",
"sc",
"->",
"dlci_state",
"[",
"count",
"]",
"==",
"DLCI_UP",
")",
"?",
"\"",
"\"",
":",
"\"",
"\"",
")",
";",
"}",
"}",
"resp",
"->",
"header",
".",
"arglen",
"=",
"pos",
"+",
"1",
";",
"break",
";",
"}",
"default",
":",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"break",
";",
"case",
"NGM_LMI_COOKIE",
":",
"switch",
"(",
"msg",
"->",
"header",
".",
"cmd",
")",
"{",
"case",
"NGM_LMI_GET_STATUS",
":",
"{",
"struct",
"nglmistat",
"*",
"stat",
";",
"int",
"k",
";",
"NG_MKRESPONSE",
"(",
"resp",
",",
"msg",
",",
"sizeof",
"(",
"*",
"stat",
")",
",",
"M_WAITOK",
"|",
"M_NULLOK",
")",
";",
"if",
"(",
"!",
"resp",
")",
"{",
"error",
"=",
"ENOMEM",
";",
"break",
";",
"}",
"stat",
"=",
"(",
"struct",
"nglmistat",
"*",
")",
"resp",
"->",
"data",
";",
"strncpy",
"(",
"stat",
"->",
"proto",
",",
"sc",
"->",
"protoname",
",",
"sizeof",
"(",
"stat",
"->",
"proto",
")",
"-",
"1",
")",
";",
"strncpy",
"(",
"stat",
"->",
"hook",
",",
"sc",
"->",
"protoname",
",",
"sizeof",
"(",
"stat",
"->",
"hook",
")",
"-",
"1",
")",
";",
"stat",
"->",
"autod",
"=",
"!",
"!",
"(",
"sc",
"->",
"flags",
"&",
"SCF_AUTO",
")",
";",
"stat",
"->",
"fixed",
"=",
"!",
"!",
"(",
"sc",
"->",
"flags",
"&",
"SCF_FIXED",
")",
";",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<=",
"MAXDLCI",
";",
"k",
"++",
")",
"{",
"switch",
"(",
"sc",
"->",
"dlci_state",
"[",
"k",
"]",
")",
"{",
"case",
"DLCI_UP",
":",
"stat",
"->",
"up",
"[",
"k",
"/",
"8",
"]",
"|=",
"(",
"1",
"<<",
"(",
"k",
"%",
"8",
")",
")",
";",
"case",
"DLCI_DOWN",
":",
"stat",
"->",
"seen",
"[",
"k",
"/",
"8",
"]",
"|=",
"(",
"1",
"<<",
"(",
"k",
"%",
"8",
")",
")",
";",
"break",
";",
"}",
"}",
"break",
";",
"}",
"default",
":",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"break",
";",
"default",
":",
"error",
"=",
"EINVAL",
";",
"break",
";",
"}",
"NG_RESPOND_MSG",
"(",
"error",
",",
"node",
",",
"item",
",",
"resp",
")",
";",
"NG_FREE_MSG",
"(",
"msg",
")",
";",
"return",
"(",
"error",
")",
";",
"}"
] | Receive a netgraph control message. | [
"Receive",
"a",
"netgraph",
"control",
"message",
"."
] | [
"/* fall through */"
] | [
{
"param": "node",
"type": "node_p"
},
{
"param": "item",
"type": "item_p"
},
{
"param": "lasthook",
"type": "hook_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "node_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item",
"type": "item_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lasthook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | nglmi_shutdown | int | static int
nglmi_shutdown(node_p node)
{
const sc_p sc = NG_NODE_PRIVATE(node);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(sc->node);
kfree(sc, M_NETGRAPH);
return (0);
} | /*
* Do local shutdown processing..
* Cut any remaining links and free our local resources.
*/ | Do local shutdown processing
Cut any remaining links and free our local resources. | [
"Do",
"local",
"shutdown",
"processing",
"Cut",
"any",
"remaining",
"links",
"and",
"free",
"our",
"local",
"resources",
"."
] | static int
nglmi_shutdown(node_p node)
{
const sc_p sc = NG_NODE_PRIVATE(node);
NG_NODE_SET_PRIVATE(node, NULL);
NG_NODE_UNREF(sc->node);
kfree(sc, M_NETGRAPH);
return (0);
} | [
"static",
"int",
"nglmi_shutdown",
"(",
"node_p",
"node",
")",
"{",
"const",
"sc_p",
"sc",
"=",
"NG_NODE_PRIVATE",
"(",
"node",
")",
";",
"NG_NODE_SET_PRIVATE",
"(",
"node",
",",
"NULL",
")",
";",
"NG_NODE_UNREF",
"(",
"sc",
"->",
"node",
")",
";",
"kfree",
"(",
"sc",
",",
"M_NETGRAPH",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Do local shutdown processing..
Cut any remaining links and free our local resources. | [
"Do",
"local",
"shutdown",
"processing",
"..",
"Cut",
"any",
"remaining",
"links",
"and",
"free",
"our",
"local",
"resources",
"."
] | [] | [
{
"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": []
} |
e0d7af5b8d7f538cd956f401339d7834566cc087 | atrens/DragonFlyBSD-src | sys/netgraph7/lmi/ng_lmi.c | [
"BSD-3-Clause"
] | C | nglmi_disconnect | int | static int
nglmi_disconnect(hook_p hook)
{
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
/* OK to remove debug hook(s) */
if (NG_HOOK_PRIVATE(hook) == NULL)
return (0);
/* Stop timer if it's currently active */
if (sc->flags & SCF_CONNECTED)
ng_uncallout(&sc->handle, sc->node);
/* Self-destruct */
if (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))
ng_rmnode_self(NG_HOOK_NODE(hook));
return (0);
} | /*
* Hook disconnection
* For this type, removal of any link except "debug" destroys the node.
*/ | Hook disconnection
For this type, removal of any link except "debug" destroys the node. | [
"Hook",
"disconnection",
"For",
"this",
"type",
"removal",
"of",
"any",
"link",
"except",
"\"",
"debug",
"\"",
"destroys",
"the",
"node",
"."
] | static int
nglmi_disconnect(hook_p hook)
{
const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
if (NG_HOOK_PRIVATE(hook) == NULL)
return (0);
if (sc->flags & SCF_CONNECTED)
ng_uncallout(&sc->handle, sc->node);
if (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))
ng_rmnode_self(NG_HOOK_NODE(hook));
return (0);
} | [
"static",
"int",
"nglmi_disconnect",
"(",
"hook_p",
"hook",
")",
"{",
"const",
"sc_p",
"sc",
"=",
"NG_NODE_PRIVATE",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
";",
"if",
"(",
"NG_HOOK_PRIVATE",
"(",
"hook",
")",
"==",
"NULL",
")",
"return",
"(",
"0",
")",
";",
"if",
"(",
"sc",
"->",
"flags",
"&",
"SCF_CONNECTED",
")",
"ng_uncallout",
"(",
"&",
"sc",
"->",
"handle",
",",
"sc",
"->",
"node",
")",
";",
"if",
"(",
"NG_NODE_IS_VALID",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
")",
"ng_rmnode_self",
"(",
"NG_HOOK_NODE",
"(",
"hook",
")",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Hook disconnection
For this type, removal of any link except "debug" destroys the node. | [
"Hook",
"disconnection",
"For",
"this",
"type",
"removal",
"of",
"any",
"link",
"except",
"\"",
"debug",
"\"",
"destroys",
"the",
"node",
"."
] | [
"/* OK to remove debug hook(s) */",
"/* Stop timer if it's currently active */",
"/* Self-destruct */"
] | [
{
"param": "hook",
"type": "hook_p"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hook",
"type": "hook_p",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e072b96fcb29fb7fe17fbdd46360b60e37bd92ca | atrens/DragonFlyBSD-src | contrib/binutils-2.34/gold/incremental.h | [
"BSD-3-Clause"
] | C | add_object | void | void
add_object(Incremental_input_entry* obj_entry)
{
this->objects_.push_back(obj_entry);
} | // Add a member object to the archive. | Add a member object to the archive. | [
"Add",
"a",
"member",
"object",
"to",
"the",
"archive",
"."
] | void
add_object(Incremental_input_entry* obj_entry)
{
this->objects_.push_back(obj_entry);
} | [
"void",
"add_object",
"(",
"Incremental_input_entry",
"*",
"obj_entry",
")",
"{",
"this",
"->",
"objects_",
".",
"push_back",
"(",
"obj_entry",
")",
";",
"}"
] | Add a member object to the archive. | [
"Add",
"a",
"member",
"object",
"to",
"the",
"archive",
"."
] | [] | [
{
"param": "obj_entry",
"type": "Incremental_input_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj_entry",
"type": "Incremental_input_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e072b96fcb29fb7fe17fbdd46360b60e37bd92ca | atrens/DragonFlyBSD-src | contrib/binutils-2.34/gold/incremental.h | [
"BSD-3-Clause"
] | C | add_object | void | void
add_object(Incremental_object_entry* obj_entry)
{
this->members_.push_back(obj_entry);
obj_entry->set_is_member();
} | // Add a member object to the archive. | Add a member object to the archive. | [
"Add",
"a",
"member",
"object",
"to",
"the",
"archive",
"."
] | void
add_object(Incremental_object_entry* obj_entry)
{
this->members_.push_back(obj_entry);
obj_entry->set_is_member();
} | [
"void",
"add_object",
"(",
"Incremental_object_entry",
"*",
"obj_entry",
")",
"{",
"this",
"->",
"members_",
".",
"push_back",
"(",
"obj_entry",
")",
";",
"obj_entry",
"->",
"set_is_member",
"(",
")",
";",
"}"
] | Add a member object to the archive. | [
"Add",
"a",
"member",
"object",
"to",
"the",
"archive",
"."
] | [] | [
{
"param": "obj_entry",
"type": "Incremental_object_entry"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj_entry",
"type": "Incremental_object_entry",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e072b96fcb29fb7fe17fbdd46360b60e37bd92ca | atrens/DragonFlyBSD-src | contrib/binutils-2.34/gold/incremental.h | [
"BSD-3-Clause"
] | C | is_reported | bool | bool
is_reported()
{
bool was_reported = this->is_reported_;
is_reported_ = true;
return was_reported;
} | // Return FALSE on the first call to indicate that the library needs
// to be recorded; return TRUE subsequently. | Return FALSE on the first call to indicate that the library needs
to be recorded; return TRUE subsequently. | [
"Return",
"FALSE",
"on",
"the",
"first",
"call",
"to",
"indicate",
"that",
"the",
"library",
"needs",
"to",
"be",
"recorded",
";",
"return",
"TRUE",
"subsequently",
"."
] | bool
is_reported()
{
bool was_reported = this->is_reported_;
is_reported_ = true;
return was_reported;
} | [
"bool",
"is_reported",
"(",
")",
"{",
"bool",
"was_reported",
"=",
"this",
"->",
"is_reported_",
";",
"is_reported_",
"=",
"true",
";",
"return",
"was_reported",
";",
"}"
] | Return FALSE on the first call to indicate that the library needs
to be recorded; return TRUE subsequently. | [
"Return",
"FALSE",
"on",
"the",
"first",
"call",
"to",
"indicate",
"that",
"the",
"library",
"needs",
"to",
"be",
"recorded",
";",
"return",
"TRUE",
"subsequently",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f204e2a064c4a72cc858ceea5d3ff6645ab8a7b1 | atrens/DragonFlyBSD-src | contrib/gcc-4.7/gcc/tree-nomudflap.c | [
"BSD-3-Clause"
] | C | nogo | void | static void
nogo (void)
{
sorry ("mudflap: this language is not supported");
} | /* This file contains placeholder functions, to be used only for
language processors that cannot handle tree-mudflap.c directly.
(e.g. Fortran). */ | This file contains placeholder functions, to be used only for
language processors that cannot handle tree-mudflap.c directly. | [
"This",
"file",
"contains",
"placeholder",
"functions",
"to",
"be",
"used",
"only",
"for",
"language",
"processors",
"that",
"cannot",
"handle",
"tree",
"-",
"mudflap",
".",
"c",
"directly",
"."
] | static void
nogo (void)
{
sorry ("mudflap: this language is not supported");
} | [
"static",
"void",
"nogo",
"(",
"void",
")",
"{",
"sorry",
"(",
"\"",
"\"",
")",
";",
"}"
] | This file contains placeholder functions, to be used only for
language processors that cannot handle tree-mudflap.c directly. | [
"This",
"file",
"contains",
"placeholder",
"functions",
"to",
"be",
"used",
"only",
"for",
"language",
"processors",
"that",
"cannot",
"handle",
"tree",
"-",
"mudflap",
".",
"c",
"directly",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_alloc_resource | null | struct resource *
pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags, int cpuid)
{
struct pcib_softc *sc = device_get_softc(dev);
const char *name, *suffix;
int ok;
/*
* Fail the allocation for this range if it's not supported.
*/
name = device_get_nameunit(child);
if (name == NULL) {
name = "";
suffix = "";
} else
suffix = " ";
switch (type) {
case SYS_RES_IOPORT:
ok = 0;
if (!pcib_is_io_open(sc))
break;
ok = (start >= sc->iobase && end <= sc->iolimit);
/*
* Make sure we allow access to VGA I/O addresses when the
* bridge has the "VGA Enable" bit set.
*/
if (!ok && pci_is_vga_ioport_range(start, end))
ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0;
if ((sc->flags & PCIB_SUBTRACTIVE) == 0) {
if (!ok) {
if (start < sc->iobase)
start = sc->iobase;
if (end > sc->iolimit)
end = sc->iolimit;
if (start < end)
ok = 1;
}
} else {
ok = 1;
#if 1
if (start < sc->iobase && end > sc->iolimit) {
start = sc->iobase;
end = sc->iolimit;
}
#endif
}
if (end < start) {
device_printf(dev, "ioport: end (%lx) < start (%lx)\n",
end, start);
start = 0;
end = 0;
ok = 0;
}
if (!ok) {
device_printf(dev, "%s%srequested unsupported I/O "
"range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n",
name, suffix, start, end, sc->iobase, sc->iolimit);
return (NULL);
}
if (bootverbose)
device_printf(dev,
"%s%srequested I/O range 0x%lx-0x%lx: in range\n",
name, suffix, start, end);
break;
case SYS_RES_MEMORY:
ok = 0;
if (pcib_is_nonprefetch_open(sc))
ok = ok || (start >= sc->membase && end <= sc->memlimit);
if (pcib_is_prefetch_open(sc))
ok = ok || (start >= sc->pmembase && end <= sc->pmemlimit);
/*
* Make sure we allow access to VGA memory addresses when the
* bridge has the "VGA Enable" bit set.
*/
if (!ok && pci_is_vga_memory_range(start, end))
ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0;
if ((sc->flags & PCIB_SUBTRACTIVE) == 0) {
if (!ok) {
ok = 1;
if (flags & RF_PREFETCHABLE) {
if (pcib_is_prefetch_open(sc)) {
if (start < sc->pmembase)
start = sc->pmembase;
if (end > sc->pmemlimit)
end = sc->pmemlimit;
} else {
ok = 0;
}
} else { /* non-prefetchable */
if (pcib_is_nonprefetch_open(sc)) {
if (start < sc->membase)
start = sc->membase;
if (end > sc->memlimit)
end = sc->memlimit;
} else {
ok = 0;
}
}
}
} else if (!ok) {
ok = 1; /* subtractive bridge: always ok */
#if 1
if (pcib_is_nonprefetch_open(sc)) {
if (start < sc->membase && end > sc->memlimit) {
start = sc->membase;
end = sc->memlimit;
}
}
if (pcib_is_prefetch_open(sc)) {
if (start < sc->pmembase && end > sc->pmemlimit) {
start = sc->pmembase;
end = sc->pmemlimit;
}
}
#endif
}
if (end < start) {
device_printf(dev, "memory: end (%lx) < start (%lx)\n",
end, start);
start = 0;
end = 0;
ok = 0;
}
if (!ok && bootverbose)
device_printf(dev,
"%s%srequested unsupported memory range %#lx-%#lx "
"(decoding %#jx-%#jx, %#jx-%#jx)\n",
name, suffix, start, end,
(uintmax_t)sc->membase, (uintmax_t)sc->memlimit,
(uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit);
if (!ok)
return (NULL);
if (bootverbose)
device_printf(dev,"%s%srequested memory range "
"0x%lx-0x%lx: good\n",
name, suffix, start, end);
break;
default:
break;
}
/*
* Bridge is OK decoding this resource, so pass it up.
*/
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags, cpuid));
} | /*
* We have to trap resource allocation requests and ensure that the bridge
* is set up to, or capable of handling them.
*/ | We have to trap resource allocation requests and ensure that the bridge
is set up to, or capable of handling them. | [
"We",
"have",
"to",
"trap",
"resource",
"allocation",
"requests",
"and",
"ensure",
"that",
"the",
"bridge",
"is",
"set",
"up",
"to",
"or",
"capable",
"of",
"handling",
"them",
"."
] | struct resource *
pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags, int cpuid)
{
struct pcib_softc *sc = device_get_softc(dev);
const char *name, *suffix;
int ok;
name = device_get_nameunit(child);
if (name == NULL) {
name = "";
suffix = "";
} else
suffix = " ";
switch (type) {
case SYS_RES_IOPORT:
ok = 0;
if (!pcib_is_io_open(sc))
break;
ok = (start >= sc->iobase && end <= sc->iolimit);
if (!ok && pci_is_vga_ioport_range(start, end))
ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0;
if ((sc->flags & PCIB_SUBTRACTIVE) == 0) {
if (!ok) {
if (start < sc->iobase)
start = sc->iobase;
if (end > sc->iolimit)
end = sc->iolimit;
if (start < end)
ok = 1;
}
} else {
ok = 1;
#if 1
if (start < sc->iobase && end > sc->iolimit) {
start = sc->iobase;
end = sc->iolimit;
}
#endif
}
if (end < start) {
device_printf(dev, "ioport: end (%lx) < start (%lx)\n",
end, start);
start = 0;
end = 0;
ok = 0;
}
if (!ok) {
device_printf(dev, "%s%srequested unsupported I/O "
"range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n",
name, suffix, start, end, sc->iobase, sc->iolimit);
return (NULL);
}
if (bootverbose)
device_printf(dev,
"%s%srequested I/O range 0x%lx-0x%lx: in range\n",
name, suffix, start, end);
break;
case SYS_RES_MEMORY:
ok = 0;
if (pcib_is_nonprefetch_open(sc))
ok = ok || (start >= sc->membase && end <= sc->memlimit);
if (pcib_is_prefetch_open(sc))
ok = ok || (start >= sc->pmembase && end <= sc->pmemlimit);
if (!ok && pci_is_vga_memory_range(start, end))
ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0;
if ((sc->flags & PCIB_SUBTRACTIVE) == 0) {
if (!ok) {
ok = 1;
if (flags & RF_PREFETCHABLE) {
if (pcib_is_prefetch_open(sc)) {
if (start < sc->pmembase)
start = sc->pmembase;
if (end > sc->pmemlimit)
end = sc->pmemlimit;
} else {
ok = 0;
}
} else {
if (pcib_is_nonprefetch_open(sc)) {
if (start < sc->membase)
start = sc->membase;
if (end > sc->memlimit)
end = sc->memlimit;
} else {
ok = 0;
}
}
}
} else if (!ok) {
ok = 1;
#if 1
if (pcib_is_nonprefetch_open(sc)) {
if (start < sc->membase && end > sc->memlimit) {
start = sc->membase;
end = sc->memlimit;
}
}
if (pcib_is_prefetch_open(sc)) {
if (start < sc->pmembase && end > sc->pmemlimit) {
start = sc->pmembase;
end = sc->pmemlimit;
}
}
#endif
}
if (end < start) {
device_printf(dev, "memory: end (%lx) < start (%lx)\n",
end, start);
start = 0;
end = 0;
ok = 0;
}
if (!ok && bootverbose)
device_printf(dev,
"%s%srequested unsupported memory range %#lx-%#lx "
"(decoding %#jx-%#jx, %#jx-%#jx)\n",
name, suffix, start, end,
(uintmax_t)sc->membase, (uintmax_t)sc->memlimit,
(uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit);
if (!ok)
return (NULL);
if (bootverbose)
device_printf(dev,"%s%srequested memory range "
"0x%lx-0x%lx: good\n",
name, suffix, start, end);
break;
default:
break;
}
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
count, flags, cpuid));
} | [
"struct",
"resource",
"*",
"pcib_alloc_resource",
"(",
"device_t",
"dev",
",",
"device_t",
"child",
",",
"int",
"type",
",",
"int",
"*",
"rid",
",",
"u_long",
"start",
",",
"u_long",
"end",
",",
"u_long",
"count",
",",
"u_int",
"flags",
",",
"int",
"cpuid",
")",
"{",
"struct",
"pcib_softc",
"*",
"sc",
"=",
"device_get_softc",
"(",
"dev",
")",
";",
"const",
"char",
"*",
"name",
",",
"*",
"suffix",
";",
"int",
"ok",
";",
"name",
"=",
"device_get_nameunit",
"(",
"child",
")",
";",
"if",
"(",
"name",
"==",
"NULL",
")",
"{",
"name",
"=",
"\"",
"\"",
";",
"suffix",
"=",
"\"",
"\"",
";",
"}",
"else",
"suffix",
"=",
"\"",
"\"",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"SYS_RES_IOPORT",
":",
"ok",
"=",
"0",
";",
"if",
"(",
"!",
"pcib_is_io_open",
"(",
"sc",
")",
")",
"break",
";",
"ok",
"=",
"(",
"start",
">=",
"sc",
"->",
"iobase",
"&&",
"end",
"<=",
"sc",
"->",
"iolimit",
")",
";",
"if",
"(",
"!",
"ok",
"&&",
"pci_is_vga_ioport_range",
"(",
"start",
",",
"end",
")",
")",
"ok",
"=",
"(",
"sc",
"->",
"bridgectl",
"&",
"PCIB_BCR_VGA_ENABLE",
")",
"?",
"1",
":",
"0",
";",
"if",
"(",
"(",
"sc",
"->",
"flags",
"&",
"PCIB_SUBTRACTIVE",
")",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"ok",
")",
"{",
"if",
"(",
"start",
"<",
"sc",
"->",
"iobase",
")",
"start",
"=",
"sc",
"->",
"iobase",
";",
"if",
"(",
"end",
">",
"sc",
"->",
"iolimit",
")",
"end",
"=",
"sc",
"->",
"iolimit",
";",
"if",
"(",
"start",
"<",
"end",
")",
"ok",
"=",
"1",
";",
"}",
"}",
"else",
"{",
"ok",
"=",
"1",
";",
"#if",
"1",
"\n",
"if",
"(",
"start",
"<",
"sc",
"->",
"iobase",
"&&",
"end",
">",
"sc",
"->",
"iolimit",
")",
"{",
"start",
"=",
"sc",
"->",
"iobase",
";",
"end",
"=",
"sc",
"->",
"iolimit",
";",
"}",
"#endif",
"}",
"if",
"(",
"end",
"<",
"start",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"end",
",",
"start",
")",
";",
"start",
"=",
"0",
";",
"end",
"=",
"0",
";",
"ok",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"ok",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"name",
",",
"suffix",
",",
"start",
",",
"end",
",",
"sc",
"->",
"iobase",
",",
"sc",
"->",
"iolimit",
")",
";",
"return",
"(",
"NULL",
")",
";",
"}",
"if",
"(",
"bootverbose",
")",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"name",
",",
"suffix",
",",
"start",
",",
"end",
")",
";",
"break",
";",
"case",
"SYS_RES_MEMORY",
":",
"ok",
"=",
"0",
";",
"if",
"(",
"pcib_is_nonprefetch_open",
"(",
"sc",
")",
")",
"ok",
"=",
"ok",
"||",
"(",
"start",
">=",
"sc",
"->",
"membase",
"&&",
"end",
"<=",
"sc",
"->",
"memlimit",
")",
";",
"if",
"(",
"pcib_is_prefetch_open",
"(",
"sc",
")",
")",
"ok",
"=",
"ok",
"||",
"(",
"start",
">=",
"sc",
"->",
"pmembase",
"&&",
"end",
"<=",
"sc",
"->",
"pmemlimit",
")",
";",
"if",
"(",
"!",
"ok",
"&&",
"pci_is_vga_memory_range",
"(",
"start",
",",
"end",
")",
")",
"ok",
"=",
"(",
"sc",
"->",
"bridgectl",
"&",
"PCIB_BCR_VGA_ENABLE",
")",
"?",
"1",
":",
"0",
";",
"if",
"(",
"(",
"sc",
"->",
"flags",
"&",
"PCIB_SUBTRACTIVE",
")",
"==",
"0",
")",
"{",
"if",
"(",
"!",
"ok",
")",
"{",
"ok",
"=",
"1",
";",
"if",
"(",
"flags",
"&",
"RF_PREFETCHABLE",
")",
"{",
"if",
"(",
"pcib_is_prefetch_open",
"(",
"sc",
")",
")",
"{",
"if",
"(",
"start",
"<",
"sc",
"->",
"pmembase",
")",
"start",
"=",
"sc",
"->",
"pmembase",
";",
"if",
"(",
"end",
">",
"sc",
"->",
"pmemlimit",
")",
"end",
"=",
"sc",
"->",
"pmemlimit",
";",
"}",
"else",
"{",
"ok",
"=",
"0",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"pcib_is_nonprefetch_open",
"(",
"sc",
")",
")",
"{",
"if",
"(",
"start",
"<",
"sc",
"->",
"membase",
")",
"start",
"=",
"sc",
"->",
"membase",
";",
"if",
"(",
"end",
">",
"sc",
"->",
"memlimit",
")",
"end",
"=",
"sc",
"->",
"memlimit",
";",
"}",
"else",
"{",
"ok",
"=",
"0",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"!",
"ok",
")",
"{",
"ok",
"=",
"1",
";",
"#if",
"1",
"\n",
"if",
"(",
"pcib_is_nonprefetch_open",
"(",
"sc",
")",
")",
"{",
"if",
"(",
"start",
"<",
"sc",
"->",
"membase",
"&&",
"end",
">",
"sc",
"->",
"memlimit",
")",
"{",
"start",
"=",
"sc",
"->",
"membase",
";",
"end",
"=",
"sc",
"->",
"memlimit",
";",
"}",
"}",
"if",
"(",
"pcib_is_prefetch_open",
"(",
"sc",
")",
")",
"{",
"if",
"(",
"start",
"<",
"sc",
"->",
"pmembase",
"&&",
"end",
">",
"sc",
"->",
"pmemlimit",
")",
"{",
"start",
"=",
"sc",
"->",
"pmembase",
";",
"end",
"=",
"sc",
"->",
"pmemlimit",
";",
"}",
"}",
"#endif",
"}",
"if",
"(",
"end",
"<",
"start",
")",
"{",
"device_printf",
"(",
"dev",
",",
"\"",
"\\n",
"\"",
",",
"end",
",",
"start",
")",
";",
"start",
"=",
"0",
";",
"end",
"=",
"0",
";",
"ok",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"ok",
"&&",
"bootverbose",
")",
"device_printf",
"(",
"dev",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"name",
",",
"suffix",
",",
"start",
",",
"end",
",",
"(",
"uintmax_t",
")",
"sc",
"->",
"membase",
",",
"(",
"uintmax_t",
")",
"sc",
"->",
"memlimit",
",",
"(",
"uintmax_t",
")",
"sc",
"->",
"pmembase",
",",
"(",
"uintmax_t",
")",
"sc",
"->",
"pmemlimit",
")",
";",
"if",
"(",
"!",
"ok",
")",
"return",
"(",
"NULL",
")",
";",
"if",
"(",
"bootverbose",
")",
"device_printf",
"(",
"dev",
",",
"\"",
"\"",
"\"",
"\\n",
"\"",
",",
"name",
",",
"suffix",
",",
"start",
",",
"end",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"(",
"bus_generic_alloc_resource",
"(",
"dev",
",",
"child",
",",
"type",
",",
"rid",
",",
"start",
",",
"end",
",",
"count",
",",
"flags",
",",
"cpuid",
")",
")",
";",
"}"
] | We have to trap resource allocation requests and ensure that the bridge
is set up to, or capable of handling them. | [
"We",
"have",
"to",
"trap",
"resource",
"allocation",
"requests",
"and",
"ensure",
"that",
"the",
"bridge",
"is",
"set",
"up",
"to",
"or",
"capable",
"of",
"handling",
"them",
"."
] | [
"/*\n\t * Fail the allocation for this range if it's not supported.\n\t */",
"/*\n\t\t * Make sure we allow access to VGA I/O addresses when the\n\t\t * bridge has the \"VGA Enable\" bit set.\n\t\t */",
"/*\n\t\t * Make sure we allow access to VGA memory addresses when the\n\t\t * bridge has the \"VGA Enable\" bit set.\n\t\t */",
"/* non-prefetchable */",
"/* subtractive bridge: always ok */",
"/*\n\t * Bridge is OK decoding this resource, so pass it up.\n\t */"
] | [
{
"param": "dev",
"type": "device_t"
},
{
"param": "child",
"type": "device_t"
},
{
"param": "type",
"type": "int"
},
{
"param": "rid",
"type": "int"
},
{
"param": "start",
"type": "u_long"
},
{
"param": "end",
"type": "u_long"
},
{
"param": "count",
"type": "u_long"
},
{
"param": "flags",
"type": "u_int"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "child",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "type",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start",
"type": "u_long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "end",
"type": "u_long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "u_long",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "flags",
"type": "u_int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_read_config | uint32_t | uint32_t
pcib_read_config(device_t dev, int b, int s, int f, int reg, int width)
{
return(PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, width));
} | /*
* Since we are a child of a PCI bus, its parent must support the pcib interface.
*/ | Since we are a child of a PCI bus, its parent must support the pcib interface. | [
"Since",
"we",
"are",
"a",
"child",
"of",
"a",
"PCI",
"bus",
"its",
"parent",
"must",
"support",
"the",
"pcib",
"interface",
"."
] | uint32_t
pcib_read_config(device_t dev, int b, int s, int f, int reg, int width)
{
return(PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, width));
} | [
"uint32_t",
"pcib_read_config",
"(",
"device_t",
"dev",
",",
"int",
"b",
",",
"int",
"s",
",",
"int",
"f",
",",
"int",
"reg",
",",
"int",
"width",
")",
"{",
"return",
"(",
"PCIB_READ_CONFIG",
"(",
"device_get_parent",
"(",
"device_get_parent",
"(",
"dev",
")",
")",
",",
"b",
",",
"s",
",",
"f",
",",
"reg",
",",
"width",
")",
")",
";",
"}"
] | Since we are a child of a PCI bus, its parent must support the pcib interface. | [
"Since",
"we",
"are",
"a",
"child",
"of",
"a",
"PCI",
"bus",
"its",
"parent",
"must",
"support",
"the",
"pcib",
"interface",
"."
] | [] | [
{
"param": "dev",
"type": "device_t"
},
{
"param": "b",
"type": "int"
},
{
"param": "s",
"type": "int"
},
{
"param": "f",
"type": "int"
},
{
"param": "reg",
"type": "int"
},
{
"param": "width",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "s",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reg",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "width",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_route_interrupt | int | int
pcib_route_interrupt(device_t pcib, device_t dev, int pin)
{
device_t bus;
int parent_intpin;
int intnum;
/*
*
* The PCI standard defines a swizzle of the child-side device/intpin to
* the parent-side intpin as follows.
*
* device = device on child bus
* child_intpin = intpin on child bus slot (0-3)
* parent_intpin = intpin on parent bus slot (0-3)
*
* parent_intpin = (device + child_intpin) % 4
*/
parent_intpin = (pci_get_slot(dev) + (pin - 1)) % 4;
/*
* Our parent is a PCI bus. Its parent must export the pcib interface
* which includes the ability to route interrupts.
*/
bus = device_get_parent(pcib);
intnum = PCIB_ROUTE_INTERRUPT(device_get_parent(bus), pcib, parent_intpin + 1);
if (PCI_INTERRUPT_VALID(intnum) && bootverbose) {
device_printf(pcib, "slot %d INT%c is routed to irq %d\n",
pci_get_slot(dev), 'A' + pin - 1, intnum);
}
return(intnum);
} | /*
* Route an interrupt across a PCI bridge.
*/ | Route an interrupt across a PCI bridge. | [
"Route",
"an",
"interrupt",
"across",
"a",
"PCI",
"bridge",
"."
] | int
pcib_route_interrupt(device_t pcib, device_t dev, int pin)
{
device_t bus;
int parent_intpin;
int intnum;
parent_intpin = (pci_get_slot(dev) + (pin - 1)) % 4;
bus = device_get_parent(pcib);
intnum = PCIB_ROUTE_INTERRUPT(device_get_parent(bus), pcib, parent_intpin + 1);
if (PCI_INTERRUPT_VALID(intnum) && bootverbose) {
device_printf(pcib, "slot %d INT%c is routed to irq %d\n",
pci_get_slot(dev), 'A' + pin - 1, intnum);
}
return(intnum);
} | [
"int",
"pcib_route_interrupt",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"pin",
")",
"{",
"device_t",
"bus",
";",
"int",
"parent_intpin",
";",
"int",
"intnum",
";",
"parent_intpin",
"=",
"(",
"pci_get_slot",
"(",
"dev",
")",
"+",
"(",
"pin",
"-",
"1",
")",
")",
"%",
"4",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"intnum",
"=",
"PCIB_ROUTE_INTERRUPT",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"pcib",
",",
"parent_intpin",
"+",
"1",
")",
";",
"if",
"(",
"PCI_INTERRUPT_VALID",
"(",
"intnum",
")",
"&&",
"bootverbose",
")",
"{",
"device_printf",
"(",
"pcib",
",",
"\"",
"\\n",
"\"",
",",
"pci_get_slot",
"(",
"dev",
")",
",",
"'",
"'",
"+",
"pin",
"-",
"1",
",",
"intnum",
")",
";",
"}",
"return",
"(",
"intnum",
")",
";",
"}"
] | Route an interrupt across a PCI bridge. | [
"Route",
"an",
"interrupt",
"across",
"a",
"PCI",
"bridge",
"."
] | [
"/*\t\n *\n * The PCI standard defines a swizzle of the child-side device/intpin to\n * the parent-side intpin as follows.\n *\n * device = device on child bus\n * child_intpin = intpin on child bus slot (0-3)\n * parent_intpin = intpin on parent bus slot (0-3)\n *\n * parent_intpin = (device + child_intpin) % 4\n */",
"/*\n * Our parent is a PCI bus. Its parent must export the pcib interface\n * which includes the ability to route interrupts.\n */"
] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "pin",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pin",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_alloc_msi | int | int
pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
int *irqs, int cpuid)
{
struct pcib_softc *sc = device_get_softc(pcib);
device_t bus;
if (sc->flags & PCIB_DISABLE_MSI)
return (ENXIO);
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
irqs, cpuid));
} | /* Pass request to alloc MSI/MSI-X messages up to the parent bridge. */ | Pass request to alloc MSI/MSI-X messages up to the parent bridge. | [
"Pass",
"request",
"to",
"alloc",
"MSI",
"/",
"MSI",
"-",
"X",
"messages",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | int
pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
int *irqs, int cpuid)
{
struct pcib_softc *sc = device_get_softc(pcib);
device_t bus;
if (sc->flags & PCIB_DISABLE_MSI)
return (ENXIO);
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
irqs, cpuid));
} | [
"int",
"pcib_alloc_msi",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"count",
",",
"int",
"maxcount",
",",
"int",
"*",
"irqs",
",",
"int",
"cpuid",
")",
"{",
"struct",
"pcib_softc",
"*",
"sc",
"=",
"device_get_softc",
"(",
"pcib",
")",
";",
"device_t",
"bus",
";",
"if",
"(",
"sc",
"->",
"flags",
"&",
"PCIB_DISABLE_MSI",
")",
"return",
"(",
"ENXIO",
")",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"return",
"(",
"PCIB_ALLOC_MSI",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"dev",
",",
"count",
",",
"maxcount",
",",
"irqs",
",",
"cpuid",
")",
")",
";",
"}"
] | Pass request to alloc MSI/MSI-X messages up to the parent bridge. | [
"Pass",
"request",
"to",
"alloc",
"MSI",
"/",
"MSI",
"-",
"X",
"messages",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | [] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "count",
"type": "int"
},
{
"param": "maxcount",
"type": "int"
},
{
"param": "irqs",
"type": "int"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "maxcount",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irqs",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_release_msi | int | int
pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs, int cpuid)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_RELEASE_MSI(device_get_parent(bus), dev, count, irqs,
cpuid));
} | /* Pass request to release MSI/MSI-X messages up to the parent bridge. */ | Pass request to release MSI/MSI-X messages up to the parent bridge. | [
"Pass",
"request",
"to",
"release",
"MSI",
"/",
"MSI",
"-",
"X",
"messages",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | int
pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs, int cpuid)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_RELEASE_MSI(device_get_parent(bus), dev, count, irqs,
cpuid));
} | [
"int",
"pcib_release_msi",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"count",
",",
"int",
"*",
"irqs",
",",
"int",
"cpuid",
")",
"{",
"device_t",
"bus",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"return",
"(",
"PCIB_RELEASE_MSI",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"dev",
",",
"count",
",",
"irqs",
",",
"cpuid",
")",
")",
";",
"}"
] | Pass request to release MSI/MSI-X messages up to the parent bridge. | [
"Pass",
"request",
"to",
"release",
"MSI",
"/",
"MSI",
"-",
"X",
"messages",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | [] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "count",
"type": "int"
},
{
"param": "irqs",
"type": "int"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "count",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irqs",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_alloc_msix | int | int
pcib_alloc_msix(device_t pcib, device_t dev, int *irq, int cpuid)
{
struct pcib_softc *sc = device_get_softc(pcib);
device_t bus;
if (sc->flags & PCIB_DISABLE_MSI)
return (ENXIO);
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq, cpuid));
} | /* Pass request to alloc an MSI-X message up to the parent bridge. */ | Pass request to alloc an MSI-X message up to the parent bridge. | [
"Pass",
"request",
"to",
"alloc",
"an",
"MSI",
"-",
"X",
"message",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | int
pcib_alloc_msix(device_t pcib, device_t dev, int *irq, int cpuid)
{
struct pcib_softc *sc = device_get_softc(pcib);
device_t bus;
if (sc->flags & PCIB_DISABLE_MSI)
return (ENXIO);
bus = device_get_parent(pcib);
return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq, cpuid));
} | [
"int",
"pcib_alloc_msix",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"*",
"irq",
",",
"int",
"cpuid",
")",
"{",
"struct",
"pcib_softc",
"*",
"sc",
"=",
"device_get_softc",
"(",
"pcib",
")",
";",
"device_t",
"bus",
";",
"if",
"(",
"sc",
"->",
"flags",
"&",
"PCIB_DISABLE_MSI",
")",
"return",
"(",
"ENXIO",
")",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"return",
"(",
"PCIB_ALLOC_MSIX",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"dev",
",",
"irq",
",",
"cpuid",
")",
")",
";",
"}"
] | Pass request to alloc an MSI-X message up to the parent bridge. | [
"Pass",
"request",
"to",
"alloc",
"an",
"MSI",
"-",
"X",
"message",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | [] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "irq",
"type": "int"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irq",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_release_msix | int | int
pcib_release_msix(device_t pcib, device_t dev, int irq, int cpuid)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_RELEASE_MSIX(device_get_parent(bus), dev, irq, cpuid));
} | /* Pass request to release an MSI-X message up to the parent bridge. */ | Pass request to release an MSI-X message up to the parent bridge. | [
"Pass",
"request",
"to",
"release",
"an",
"MSI",
"-",
"X",
"message",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | int
pcib_release_msix(device_t pcib, device_t dev, int irq, int cpuid)
{
device_t bus;
bus = device_get_parent(pcib);
return (PCIB_RELEASE_MSIX(device_get_parent(bus), dev, irq, cpuid));
} | [
"int",
"pcib_release_msix",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"irq",
",",
"int",
"cpuid",
")",
"{",
"device_t",
"bus",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"return",
"(",
"PCIB_RELEASE_MSIX",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"dev",
",",
"irq",
",",
"cpuid",
")",
")",
";",
"}"
] | Pass request to release an MSI-X message up to the parent bridge. | [
"Pass",
"request",
"to",
"release",
"an",
"MSI",
"-",
"X",
"message",
"up",
"to",
"the",
"parent",
"bridge",
"."
] | [] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "irq",
"type": "int"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irq",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | pcib_map_msi | int | int
pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
uint32_t *data, int cpuid)
{
device_t bus;
int error;
bus = device_get_parent(pcib);
error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data,
cpuid);
if (error)
return (error);
pci_ht_map_msi(pcib, *addr);
return (0);
} | /* Pass request to map MSI/MSI-X message up to parent bridge. */ | Pass request to map MSI/MSI-X message up to parent bridge. | [
"Pass",
"request",
"to",
"map",
"MSI",
"/",
"MSI",
"-",
"X",
"message",
"up",
"to",
"parent",
"bridge",
"."
] | int
pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
uint32_t *data, int cpuid)
{
device_t bus;
int error;
bus = device_get_parent(pcib);
error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data,
cpuid);
if (error)
return (error);
pci_ht_map_msi(pcib, *addr);
return (0);
} | [
"int",
"pcib_map_msi",
"(",
"device_t",
"pcib",
",",
"device_t",
"dev",
",",
"int",
"irq",
",",
"uint64_t",
"*",
"addr",
",",
"uint32_t",
"*",
"data",
",",
"int",
"cpuid",
")",
"{",
"device_t",
"bus",
";",
"int",
"error",
";",
"bus",
"=",
"device_get_parent",
"(",
"pcib",
")",
";",
"error",
"=",
"PCIB_MAP_MSI",
"(",
"device_get_parent",
"(",
"bus",
")",
",",
"dev",
",",
"irq",
",",
"addr",
",",
"data",
",",
"cpuid",
")",
";",
"if",
"(",
"error",
")",
"return",
"(",
"error",
")",
";",
"pci_ht_map_msi",
"(",
"pcib",
",",
"*",
"addr",
")",
";",
"return",
"(",
"0",
")",
";",
"}"
] | Pass request to map MSI/MSI-X message up to parent bridge. | [
"Pass",
"request",
"to",
"map",
"MSI",
"/",
"MSI",
"-",
"X",
"message",
"up",
"to",
"parent",
"bridge",
"."
] | [] | [
{
"param": "pcib",
"type": "device_t"
},
{
"param": "dev",
"type": "device_t"
},
{
"param": "irq",
"type": "int"
},
{
"param": "addr",
"type": "uint64_t"
},
{
"param": "data",
"type": "uint32_t"
},
{
"param": "cpuid",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pcib",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dev",
"type": "device_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "irq",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "addr",
"type": "uint64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "uint32_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cpuid",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e0aad9f34903784a4bb1735165c041ea85ae767c | atrens/DragonFlyBSD-src | sys/bus/pci/pci_pci.c | [
"BSD-3-Clause"
] | C | host_pcib_get_busno | int | int
host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func,
uint8_t *busnum)
{
uint32_t id;
id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4);
if (id == 0xffffffff)
return (0);
switch (id) {
case 0x12258086:
/* Intel 824?? */
/* XXX This is a guess */
/* *busnum = read_config(bus, slot, func, 0x41, 1); */
*busnum = bus;
break;
case 0x84c48086:
/* Intel 82454KX/GX (Orion) */
*busnum = read_config(bus, slot, func, 0x4a, 1);
break;
case 0x84ca8086:
/*
* For the 450nx chipset, there is a whole bundle of
* things pretending to be host bridges. The MIOC will
* be seen first and isn't really a pci bridge (the
* actual busses are attached to the PXB's). We need to
* read the registers of the MIOC to figure out the
* bus numbers for the PXB channels.
*
* Since the MIOC doesn't have a pci bus attached, we
* pretend it wasn't there.
*/
return (0);
case 0x84cb8086:
switch (slot) {
case 0x12:
/* Intel 82454NX PXB#0, Bus#A */
*busnum = read_config(bus, 0x10, func, 0xd0, 1);
break;
case 0x13:
/* Intel 82454NX PXB#0, Bus#B */
*busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1;
break;
case 0x14:
/* Intel 82454NX PXB#1, Bus#A */
*busnum = read_config(bus, 0x10, func, 0xd3, 1);
break;
case 0x15:
/* Intel 82454NX PXB#1, Bus#B */
*busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1;
break;
}
break;
/* ServerWorks -- vendor 0x1166 */
case 0x00051166:
case 0x00061166:
case 0x00081166:
case 0x00091166:
case 0x00101166:
case 0x00111166:
case 0x00171166:
case 0x01011166:
case 0x010f1014:
case 0x02011166:
case 0x03021014:
*busnum = read_config(bus, slot, func, 0x44, 1);
break;
/* Compaq/HP -- vendor 0x0e11 */
case 0x60100e11:
*busnum = read_config(bus, slot, func, 0xc8, 1);
break;
default:
/* Don't know how to read bus number. */
return 0;
}
return 1;
} | /*
* Try to read the bus number of a host-PCI bridge using appropriate config
* registers.
*/ | Try to read the bus number of a host-PCI bridge using appropriate config
registers. | [
"Try",
"to",
"read",
"the",
"bus",
"number",
"of",
"a",
"host",
"-",
"PCI",
"bridge",
"using",
"appropriate",
"config",
"registers",
"."
] | int
host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func,
uint8_t *busnum)
{
uint32_t id;
id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4);
if (id == 0xffffffff)
return (0);
switch (id) {
case 0x12258086:
*busnum = bus;
break;
case 0x84c48086:
*busnum = read_config(bus, slot, func, 0x4a, 1);
break;
case 0x84ca8086:
return (0);
case 0x84cb8086:
switch (slot) {
case 0x12:
*busnum = read_config(bus, 0x10, func, 0xd0, 1);
break;
case 0x13:
*busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1;
break;
case 0x14:
*busnum = read_config(bus, 0x10, func, 0xd3, 1);
break;
case 0x15:
*busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1;
break;
}
break;
case 0x00051166:
case 0x00061166:
case 0x00081166:
case 0x00091166:
case 0x00101166:
case 0x00111166:
case 0x00171166:
case 0x01011166:
case 0x010f1014:
case 0x02011166:
case 0x03021014:
*busnum = read_config(bus, slot, func, 0x44, 1);
break;
case 0x60100e11:
*busnum = read_config(bus, slot, func, 0xc8, 1);
break;
default:
return 0;
}
return 1;
} | [
"int",
"host_pcib_get_busno",
"(",
"pci_read_config_fn",
"read_config",
",",
"int",
"bus",
",",
"int",
"slot",
",",
"int",
"func",
",",
"uint8_t",
"*",
"busnum",
")",
"{",
"uint32_t",
"id",
";",
"id",
"=",
"read_config",
"(",
"bus",
",",
"slot",
",",
"func",
",",
"PCIR_DEVVENDOR",
",",
"4",
")",
";",
"if",
"(",
"id",
"==",
"0xffffffff",
")",
"return",
"(",
"0",
")",
";",
"switch",
"(",
"id",
")",
"{",
"case",
"0x12258086",
":",
"*",
"busnum",
"=",
"bus",
";",
"break",
";",
"case",
"0x84c48086",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"slot",
",",
"func",
",",
"0x4a",
",",
"1",
")",
";",
"break",
";",
"case",
"0x84ca8086",
":",
"return",
"(",
"0",
")",
";",
"case",
"0x84cb8086",
":",
"switch",
"(",
"slot",
")",
"{",
"case",
"0x12",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"0x10",
",",
"func",
",",
"0xd0",
",",
"1",
")",
";",
"break",
";",
"case",
"0x13",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"0x10",
",",
"func",
",",
"0xd1",
",",
"1",
")",
"+",
"1",
";",
"break",
";",
"case",
"0x14",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"0x10",
",",
"func",
",",
"0xd3",
",",
"1",
")",
";",
"break",
";",
"case",
"0x15",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"0x10",
",",
"func",
",",
"0xd4",
",",
"1",
")",
"+",
"1",
";",
"break",
";",
"}",
"break",
";",
"case",
"0x00051166",
":",
"case",
"0x00061166",
":",
"case",
"0x00081166",
":",
"case",
"0x00091166",
":",
"case",
"0x00101166",
":",
"case",
"0x00111166",
":",
"case",
"0x00171166",
":",
"case",
"0x01011166",
":",
"case",
"0x010f1014",
":",
"case",
"0x02011166",
":",
"case",
"0x03021014",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"slot",
",",
"func",
",",
"0x44",
",",
"1",
")",
";",
"break",
";",
"case",
"0x60100e11",
":",
"*",
"busnum",
"=",
"read_config",
"(",
"bus",
",",
"slot",
",",
"func",
",",
"0xc8",
",",
"1",
")",
";",
"break",
";",
"default",
":",
"return",
"0",
";",
"}",
"return",
"1",
";",
"}"
] | Try to read the bus number of a host-PCI bridge using appropriate config
registers. | [
"Try",
"to",
"read",
"the",
"bus",
"number",
"of",
"a",
"host",
"-",
"PCI",
"bridge",
"using",
"appropriate",
"config",
"registers",
"."
] | [
"/* Intel 824?? */",
"/* XXX This is a guess */",
"/* *busnum = read_config(bus, slot, func, 0x41, 1); */",
"/* Intel 82454KX/GX (Orion) */",
"/*\n\t\t * For the 450nx chipset, there is a whole bundle of\n\t\t * things pretending to be host bridges. The MIOC will \n\t\t * be seen first and isn't really a pci bridge (the\n\t\t * actual busses are attached to the PXB's). We need to \n\t\t * read the registers of the MIOC to figure out the\n\t\t * bus numbers for the PXB channels.\n\t\t *\n\t\t * Since the MIOC doesn't have a pci bus attached, we\n\t\t * pretend it wasn't there.\n\t\t */",
"/* Intel 82454NX PXB#0, Bus#A */",
"/* Intel 82454NX PXB#0, Bus#B */",
"/* Intel 82454NX PXB#1, Bus#A */",
"/* Intel 82454NX PXB#1, Bus#B */",
"/* ServerWorks -- vendor 0x1166 */",
"/* Compaq/HP -- vendor 0x0e11 */",
"/* Don't know how to read bus number. */"
] | [
{
"param": "read_config",
"type": "pci_read_config_fn"
},
{
"param": "bus",
"type": "int"
},
{
"param": "slot",
"type": "int"
},
{
"param": "func",
"type": "int"
},
{
"param": "busnum",
"type": "uint8_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "read_config",
"type": "pci_read_config_fn",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bus",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slot",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "func",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "busnum",
"type": "uint8_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e04bc440b6497860ccd3543f459571388b10c118 | atrens/DragonFlyBSD-src | sys/dev/raid/tws/tws_hdm.c | [
"BSD-3-Clause"
] | C | tws_get_response | boolean | boolean
tws_get_response(struct tws_softc *sc, u_int16_t *req_id, u_int64_t *mfa)
{
u_int64_t out_mfa=0, val=0;
struct tws_outbound_response out_res;
*req_id = TWS_INVALID_REQID;
out_mfa = (u_int64_t)tws_read_reg(sc, TWS_I2O0_HOBQPH, 4);
if ( out_mfa == TWS_FIFO_EMPTY32 ) {
return(false);
}
out_mfa = out_mfa << 32;
val = tws_read_reg(sc, TWS_I2O0_HOBQPL, 4);
out_mfa = out_mfa | val;
out_res = *(struct tws_outbound_response *)&out_mfa;
if ( !out_res.not_mfa ) {
*mfa = out_mfa;
return(true);
} else {
*req_id = out_res.request_id;
}
return(true);
} | /*
* returns true if the respose was available othewise, false.
* In the case of error the arg mfa will contain the address and
* req_id will be TWS_INVALID_REQID
*/ | returns true if the respose was available othewise, false.
In the case of error the arg mfa will contain the address and
req_id will be TWS_INVALID_REQID | [
"returns",
"true",
"if",
"the",
"respose",
"was",
"available",
"othewise",
"false",
".",
"In",
"the",
"case",
"of",
"error",
"the",
"arg",
"mfa",
"will",
"contain",
"the",
"address",
"and",
"req_id",
"will",
"be",
"TWS_INVALID_REQID"
] | boolean
tws_get_response(struct tws_softc *sc, u_int16_t *req_id, u_int64_t *mfa)
{
u_int64_t out_mfa=0, val=0;
struct tws_outbound_response out_res;
*req_id = TWS_INVALID_REQID;
out_mfa = (u_int64_t)tws_read_reg(sc, TWS_I2O0_HOBQPH, 4);
if ( out_mfa == TWS_FIFO_EMPTY32 ) {
return(false);
}
out_mfa = out_mfa << 32;
val = tws_read_reg(sc, TWS_I2O0_HOBQPL, 4);
out_mfa = out_mfa | val;
out_res = *(struct tws_outbound_response *)&out_mfa;
if ( !out_res.not_mfa ) {
*mfa = out_mfa;
return(true);
} else {
*req_id = out_res.request_id;
}
return(true);
} | [
"boolean",
"tws_get_response",
"(",
"struct",
"tws_softc",
"*",
"sc",
",",
"u_int16_t",
"*",
"req_id",
",",
"u_int64_t",
"*",
"mfa",
")",
"{",
"u_int64_t",
"out_mfa",
"=",
"0",
",",
"val",
"=",
"0",
";",
"struct",
"tws_outbound_response",
"out_res",
";",
"*",
"req_id",
"=",
"TWS_INVALID_REQID",
";",
"out_mfa",
"=",
"(",
"u_int64_t",
")",
"tws_read_reg",
"(",
"sc",
",",
"TWS_I2O0_HOBQPH",
",",
"4",
")",
";",
"if",
"(",
"out_mfa",
"==",
"TWS_FIFO_EMPTY32",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"out_mfa",
"=",
"out_mfa",
"<<",
"32",
";",
"val",
"=",
"tws_read_reg",
"(",
"sc",
",",
"TWS_I2O0_HOBQPL",
",",
"4",
")",
";",
"out_mfa",
"=",
"out_mfa",
"|",
"val",
";",
"out_res",
"=",
"*",
"(",
"struct",
"tws_outbound_response",
"*",
")",
"&",
"out_mfa",
";",
"if",
"(",
"!",
"out_res",
".",
"not_mfa",
")",
"{",
"*",
"mfa",
"=",
"out_mfa",
";",
"return",
"(",
"true",
")",
";",
"}",
"else",
"{",
"*",
"req_id",
"=",
"out_res",
".",
"request_id",
";",
"}",
"return",
"(",
"true",
")",
";",
"}"
] | returns true if the respose was available othewise, false. | [
"returns",
"true",
"if",
"the",
"respose",
"was",
"available",
"othewise",
"false",
"."
] | [] | [
{
"param": "sc",
"type": "struct tws_softc"
},
{
"param": "req_id",
"type": "u_int16_t"
},
{
"param": "mfa",
"type": "u_int64_t"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "sc",
"type": "struct tws_softc",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req_id",
"type": "u_int16_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mfa",
"type": "u_int64_t",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
31dc47edd162d1dda799caab10741fb8029155aa | atrens/DragonFlyBSD-src | contrib/wpa_supplicant/src/ap/ieee802_11_ht.c | [
"BSD-3-Clause"
] | C | hostapd_ht_operation_update | int | int hostapd_ht_operation_update(struct hostapd_iface *iface)
{
u16 cur_op_mode, new_op_mode;
int op_mode_changes = 0;
if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed)
return 0;
wpa_printf(MSG_DEBUG, "%s current operation mode=0x%X",
__func__, iface->ht_op_mode);
if (!(iface->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)
&& iface->num_sta_ht_no_gf) {
iface->ht_op_mode |=
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
op_mode_changes++;
} else if ((iface->ht_op_mode &
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) &&
iface->num_sta_ht_no_gf == 0) {
iface->ht_op_mode &=
~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
op_mode_changes++;
}
if (!(iface->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
(iface->num_sta_no_ht || iface->olbc_ht)) {
iface->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
op_mode_changes++;
} else if ((iface->ht_op_mode &
HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
(iface->num_sta_no_ht == 0 && !iface->olbc_ht)) {
iface->ht_op_mode &=
~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
op_mode_changes++;
}
new_op_mode = 0;
if (iface->num_sta_no_ht)
new_op_mode = OP_MODE_MIXED;
else if (iface->conf->secondary_channel && iface->num_sta_ht_20mhz)
new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED;
else if (iface->olbc_ht)
new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS;
else
new_op_mode = OP_MODE_PURE;
cur_op_mode = iface->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK;
if (cur_op_mode != new_op_mode) {
iface->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK;
iface->ht_op_mode |= new_op_mode;
op_mode_changes++;
}
wpa_printf(MSG_DEBUG, "%s new operation mode=0x%X changes=%d",
__func__, iface->ht_op_mode, op_mode_changes);
return op_mode_changes;
} | /*
op_mode
Set to 0 (HT pure) under the followign conditions
- all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
- all STAs in the BSS are 20 MHz HT in 20 MHz BSS
Set to 1 (HT non-member protection) if there may be non-HT STAs
in both the primary and the secondary channel
Set to 2 if only HT STAs are associated in BSS,
however and at least one 20 MHz HT STA is associated
Set to 3 (HT mixed mode) when one or more non-HT STAs are associated
*/ | op_mode
Set to 0 (HT pure) under the followign conditions
all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
all STAs in the BSS are 20 MHz HT in 20 MHz BSS
Set to 1 (HT non-member protection) if there may be non-HT STAs
in both the primary and the secondary channel
Set to 2 if only HT STAs are associated in BSS,
however and at least one 20 MHz HT STA is associated
Set to 3 (HT mixed mode) when one or more non-HT STAs are associated | [
"op_mode",
"Set",
"to",
"0",
"(",
"HT",
"pure",
")",
"under",
"the",
"followign",
"conditions",
"all",
"STAs",
"in",
"the",
"BSS",
"are",
"20",
"/",
"40",
"MHz",
"HT",
"in",
"20",
"/",
"40",
"MHz",
"BSS",
"or",
"all",
"STAs",
"in",
"the",
"BSS",
"are",
"20",
"MHz",
"HT",
"in",
"20",
"MHz",
"BSS",
"Set",
"to",
"1",
"(",
"HT",
"non",
"-",
"member",
"protection",
")",
"if",
"there",
"may",
"be",
"non",
"-",
"HT",
"STAs",
"in",
"both",
"the",
"primary",
"and",
"the",
"secondary",
"channel",
"Set",
"to",
"2",
"if",
"only",
"HT",
"STAs",
"are",
"associated",
"in",
"BSS",
"however",
"and",
"at",
"least",
"one",
"20",
"MHz",
"HT",
"STA",
"is",
"associated",
"Set",
"to",
"3",
"(",
"HT",
"mixed",
"mode",
")",
"when",
"one",
"or",
"more",
"non",
"-",
"HT",
"STAs",
"are",
"associated"
] | int hostapd_ht_operation_update(struct hostapd_iface *iface)
{
u16 cur_op_mode, new_op_mode;
int op_mode_changes = 0;
if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed)
return 0;
wpa_printf(MSG_DEBUG, "%s current operation mode=0x%X",
__func__, iface->ht_op_mode);
if (!(iface->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)
&& iface->num_sta_ht_no_gf) {
iface->ht_op_mode |=
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
op_mode_changes++;
} else if ((iface->ht_op_mode &
HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) &&
iface->num_sta_ht_no_gf == 0) {
iface->ht_op_mode &=
~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT;
op_mode_changes++;
}
if (!(iface->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
(iface->num_sta_no_ht || iface->olbc_ht)) {
iface->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
op_mode_changes++;
} else if ((iface->ht_op_mode &
HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) &&
(iface->num_sta_no_ht == 0 && !iface->olbc_ht)) {
iface->ht_op_mode &=
~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT;
op_mode_changes++;
}
new_op_mode = 0;
if (iface->num_sta_no_ht)
new_op_mode = OP_MODE_MIXED;
else if (iface->conf->secondary_channel && iface->num_sta_ht_20mhz)
new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED;
else if (iface->olbc_ht)
new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS;
else
new_op_mode = OP_MODE_PURE;
cur_op_mode = iface->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK;
if (cur_op_mode != new_op_mode) {
iface->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK;
iface->ht_op_mode |= new_op_mode;
op_mode_changes++;
}
wpa_printf(MSG_DEBUG, "%s new operation mode=0x%X changes=%d",
__func__, iface->ht_op_mode, op_mode_changes);
return op_mode_changes;
} | [
"int",
"hostapd_ht_operation_update",
"(",
"struct",
"hostapd_iface",
"*",
"iface",
")",
"{",
"u16",
"cur_op_mode",
",",
"new_op_mode",
";",
"int",
"op_mode_changes",
"=",
"0",
";",
"if",
"(",
"!",
"iface",
"->",
"conf",
"->",
"ieee80211n",
"||",
"iface",
"->",
"conf",
"->",
"ht_op_mode_fixed",
")",
"return",
"0",
";",
"wpa_printf",
"(",
"MSG_DEBUG",
",",
"\"",
"\"",
",",
"__func__",
",",
"iface",
"->",
"ht_op_mode",
")",
";",
"if",
"(",
"!",
"(",
"iface",
"->",
"ht_op_mode",
"&",
"HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT",
")",
"&&",
"iface",
"->",
"num_sta_ht_no_gf",
")",
"{",
"iface",
"->",
"ht_op_mode",
"|=",
"HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT",
";",
"op_mode_changes",
"++",
";",
"}",
"else",
"if",
"(",
"(",
"iface",
"->",
"ht_op_mode",
"&",
"HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT",
")",
"&&",
"iface",
"->",
"num_sta_ht_no_gf",
"==",
"0",
")",
"{",
"iface",
"->",
"ht_op_mode",
"&=",
"~",
"HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT",
";",
"op_mode_changes",
"++",
";",
"}",
"if",
"(",
"!",
"(",
"iface",
"->",
"ht_op_mode",
"&",
"HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT",
")",
"&&",
"(",
"iface",
"->",
"num_sta_no_ht",
"||",
"iface",
"->",
"olbc_ht",
")",
")",
"{",
"iface",
"->",
"ht_op_mode",
"|=",
"HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT",
";",
"op_mode_changes",
"++",
";",
"}",
"else",
"if",
"(",
"(",
"iface",
"->",
"ht_op_mode",
"&",
"HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT",
")",
"&&",
"(",
"iface",
"->",
"num_sta_no_ht",
"==",
"0",
"&&",
"!",
"iface",
"->",
"olbc_ht",
")",
")",
"{",
"iface",
"->",
"ht_op_mode",
"&=",
"~",
"HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT",
";",
"op_mode_changes",
"++",
";",
"}",
"new_op_mode",
"=",
"0",
";",
"if",
"(",
"iface",
"->",
"num_sta_no_ht",
")",
"new_op_mode",
"=",
"OP_MODE_MIXED",
";",
"else",
"if",
"(",
"iface",
"->",
"conf",
"->",
"secondary_channel",
"&&",
"iface",
"->",
"num_sta_ht_20mhz",
")",
"new_op_mode",
"=",
"OP_MODE_20MHZ_HT_STA_ASSOCED",
";",
"else",
"if",
"(",
"iface",
"->",
"olbc_ht",
")",
"new_op_mode",
"=",
"OP_MODE_MAY_BE_LEGACY_STAS",
";",
"else",
"new_op_mode",
"=",
"OP_MODE_PURE",
";",
"cur_op_mode",
"=",
"iface",
"->",
"ht_op_mode",
"&",
"HT_INFO_OPERATION_MODE_OP_MODE_MASK",
";",
"if",
"(",
"cur_op_mode",
"!=",
"new_op_mode",
")",
"{",
"iface",
"->",
"ht_op_mode",
"&=",
"~",
"HT_INFO_OPERATION_MODE_OP_MODE_MASK",
";",
"iface",
"->",
"ht_op_mode",
"|=",
"new_op_mode",
";",
"op_mode_changes",
"++",
";",
"}",
"wpa_printf",
"(",
"MSG_DEBUG",
",",
"\"",
"\"",
",",
"__func__",
",",
"iface",
"->",
"ht_op_mode",
",",
"op_mode_changes",
")",
";",
"return",
"op_mode_changes",
";",
"}"
] | op_mode
Set to 0 (HT pure) under the followign conditions
all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
all STAs in the BSS are 20 MHz HT in 20 MHz BSS
Set to 1 (HT non-member protection) if there may be non-HT STAs
in both the primary and the secondary channel
Set to 2 if only HT STAs are associated in BSS,
however and at least one 20 MHz HT STA is associated
Set to 3 (HT mixed mode) when one or more non-HT STAs are associated | [
"op_mode",
"Set",
"to",
"0",
"(",
"HT",
"pure",
")",
"under",
"the",
"followign",
"conditions",
"all",
"STAs",
"in",
"the",
"BSS",
"are",
"20",
"/",
"40",
"MHz",
"HT",
"in",
"20",
"/",
"40",
"MHz",
"BSS",
"or",
"all",
"STAs",
"in",
"the",
"BSS",
"are",
"20",
"MHz",
"HT",
"in",
"20",
"MHz",
"BSS",
"Set",
"to",
"1",
"(",
"HT",
"non",
"-",
"member",
"protection",
")",
"if",
"there",
"may",
"be",
"non",
"-",
"HT",
"STAs",
"in",
"both",
"the",
"primary",
"and",
"the",
"secondary",
"channel",
"Set",
"to",
"2",
"if",
"only",
"HT",
"STAs",
"are",
"associated",
"in",
"BSS",
"however",
"and",
"at",
"least",
"one",
"20",
"MHz",
"HT",
"STA",
"is",
"associated",
"Set",
"to",
"3",
"(",
"HT",
"mixed",
"mode",
")",
"when",
"one",
"or",
"more",
"non",
"-",
"HT",
"STAs",
"are",
"associated"
] | [] | [
{
"param": "iface",
"type": "struct hostapd_iface"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iface",
"type": "struct hostapd_iface",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits