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
e041c866d9a3ba34138551a7fd22d407f90fb68f
atrens/DragonFlyBSD-src
sbin/restore/symtab.c
[ "BSD-3-Clause" ]
C
removeentry
void
static void removeentry(struct entry *ep) { struct entry *np; np = ep->e_parent; if (np->e_entries == ep) { np->e_entries = ep->e_sibling; } else { for (np = np->e_entries; np != NULL; np = np->e_sibling) { if (np->e_sibling == ep) { np->e_sibling = ep->e_sibling; break; } } if (np == NULL) badentry(ep, "cannot find entry in parent list"); } }
/* * Remove an entry in the tree structure */
Remove an entry in the tree structure
[ "Remove", "an", "entry", "in", "the", "tree", "structure" ]
static void removeentry(struct entry *ep) { struct entry *np; np = ep->e_parent; if (np->e_entries == ep) { np->e_entries = ep->e_sibling; } else { for (np = np->e_entries; np != NULL; np = np->e_sibling) { if (np->e_sibling == ep) { np->e_sibling = ep->e_sibling; break; } } if (np == NULL) badentry(ep, "cannot find entry in parent list"); } }
[ "static", "void", "removeentry", "(", "struct", "entry", "*", "ep", ")", "{", "struct", "entry", "*", "np", ";", "np", "=", "ep", "->", "e_parent", ";", "if", "(", "np", "->", "e_entries", "==", "ep", ")", "{", "np", "->", "e_entries", "=", "ep", "->", "e_sibling", ";", "}", "else", "{", "for", "(", "np", "=", "np", "->", "e_entries", ";", "np", "!=", "NULL", ";", "np", "=", "np", "->", "e_sibling", ")", "{", "if", "(", "np", "->", "e_sibling", "==", "ep", ")", "{", "np", "->", "e_sibling", "=", "ep", "->", "e_sibling", ";", "break", ";", "}", "}", "if", "(", "np", "==", "NULL", ")", "badentry", "(", "ep", ",", "\"", "\"", ")", ";", "}", "}" ]
Remove an entry in the tree structure
[ "Remove", "an", "entry", "in", "the", "tree", "structure" ]
[]
[ { "param": "ep", "type": "struct entry" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ep", "type": "struct entry", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e041c866d9a3ba34138551a7fd22d407f90fb68f
atrens/DragonFlyBSD-src
sbin/restore/symtab.c
[ "BSD-3-Clause" ]
C
savename
char
char * savename(const char *name) { struct strhdr *np; long len; char *cp; if (name == NULL) panic("bad name\n"); len = strlen(name); np = strtblhdr[len / STRTBLINCR].next; if (np != NULL) { strtblhdr[len / STRTBLINCR].next = np->next; cp = (char *)np; } else { cp = malloc((unsigned)allocsize(len)); if (cp == NULL) panic("no space for string table\n"); } strcpy(cp, name); return (cp); }
/* * Allocate space for a name. It first looks to see if it already * has an appropriate sized entry, and if not allocates a new one. */
Allocate space for a name. It first looks to see if it already has an appropriate sized entry, and if not allocates a new one.
[ "Allocate", "space", "for", "a", "name", ".", "It", "first", "looks", "to", "see", "if", "it", "already", "has", "an", "appropriate", "sized", "entry", "and", "if", "not", "allocates", "a", "new", "one", "." ]
char * savename(const char *name) { struct strhdr *np; long len; char *cp; if (name == NULL) panic("bad name\n"); len = strlen(name); np = strtblhdr[len / STRTBLINCR].next; if (np != NULL) { strtblhdr[len / STRTBLINCR].next = np->next; cp = (char *)np; } else { cp = malloc((unsigned)allocsize(len)); if (cp == NULL) panic("no space for string table\n"); } strcpy(cp, name); return (cp); }
[ "char", "*", "savename", "(", "const", "char", "*", "name", ")", "{", "struct", "strhdr", "*", "np", ";", "long", "len", ";", "char", "*", "cp", ";", "if", "(", "name", "==", "NULL", ")", "panic", "(", "\"", "\\n", "\"", ")", ";", "len", "=", "strlen", "(", "name", ")", ";", "np", "=", "strtblhdr", "[", "len", "/", "STRTBLINCR", "]", ".", "next", ";", "if", "(", "np", "!=", "NULL", ")", "{", "strtblhdr", "[", "len", "/", "STRTBLINCR", "]", ".", "next", "=", "np", "->", "next", ";", "cp", "=", "(", "char", "*", ")", "np", ";", "}", "else", "{", "cp", "=", "malloc", "(", "(", "unsigned", ")", "allocsize", "(", "len", ")", ")", ";", "if", "(", "cp", "==", "NULL", ")", "panic", "(", "\"", "\\n", "\"", ")", ";", "}", "strcpy", "(", "cp", ",", "name", ")", ";", "return", "(", "cp", ")", ";", "}" ]
Allocate space for a name.
[ "Allocate", "space", "for", "a", "name", "." ]
[]
[ { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e041c866d9a3ba34138551a7fd22d407f90fb68f
atrens/DragonFlyBSD-src
sbin/restore/symtab.c
[ "BSD-3-Clause" ]
C
freename
void
void freename(char *name) { struct strhdr *tp, *np; tp = &strtblhdr[strlen(name) / STRTBLINCR]; np = (struct strhdr *)name; np->next = tp->next; tp->next = np; }
/* * Free space for a name. The resulting entry is linked onto the * appropriate free list. */
Free space for a name. The resulting entry is linked onto the appropriate free list.
[ "Free", "space", "for", "a", "name", ".", "The", "resulting", "entry", "is", "linked", "onto", "the", "appropriate", "free", "list", "." ]
void freename(char *name) { struct strhdr *tp, *np; tp = &strtblhdr[strlen(name) / STRTBLINCR]; np = (struct strhdr *)name; np->next = tp->next; tp->next = np; }
[ "void", "freename", "(", "char", "*", "name", ")", "{", "struct", "strhdr", "*", "tp", ",", "*", "np", ";", "tp", "=", "&", "strtblhdr", "[", "strlen", "(", "name", ")", "/", "STRTBLINCR", "]", ";", "np", "=", "(", "struct", "strhdr", "*", ")", "name", ";", "np", "->", "next", "=", "tp", "->", "next", ";", "tp", "->", "next", "=", "np", ";", "}" ]
Free space for a name.
[ "Free", "space", "for", "a", "name", "." ]
[]
[ { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e041c866d9a3ba34138551a7fd22d407f90fb68f
atrens/DragonFlyBSD-src
sbin/restore/symtab.c
[ "BSD-3-Clause" ]
C
dumpsymtable
void
void dumpsymtable(const char *filename, long checkpt) { struct entry *ep, *tep; ufs1_ino_t i; struct entry temp, *tentry; long mynum = 1, stroff = 0; FILE *fd; struct symtableheader hdr; vprintf(stdout, "Check pointing the restore\n"); if (Nflag) return; if ((fd = fopen(filename, "w")) == NULL) { fprintf(stderr, "fopen: %s\n", strerror(errno)); panic("cannot create save file %s for symbol table\n", filename); done(1); } clearerr(fd); /* * Assign indices to each entry * Write out the string entries */ for (i = UFS_WINO; i <= maxino; i++) { for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { ep->e_index = mynum++; fwrite(ep->e_name, sizeof(char), (int)allocsize(ep->e_namlen), fd); } } /* * Convert pointers to indexes, and output */ tep = &temp; stroff = 0; for (i = UFS_WINO; i <= maxino; i++) { for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { memmove(tep, ep, (long)sizeof(struct entry)); tep->e_name = (char *)stroff; stroff += allocsize(ep->e_namlen); tep->e_parent = (struct entry *)ep->e_parent->e_index; if (ep->e_links != NULL) tep->e_links = (struct entry *)ep->e_links->e_index; if (ep->e_sibling != NULL) tep->e_sibling = (struct entry *)ep->e_sibling->e_index; if (ep->e_entries != NULL) tep->e_entries = (struct entry *)ep->e_entries->e_index; if (ep->e_next != NULL) tep->e_next = (struct entry *)ep->e_next->e_index; fwrite((char *)tep, sizeof(struct entry), 1, fd); } } /* * Convert entry pointers to indexes, and output */ for (i = 0; i < entrytblsize; i++) { if (entry[i] == NULL) tentry = NULL; else tentry = (struct entry *)entry[i]->e_index; fwrite((char *)&tentry, sizeof(struct entry *), 1, fd); } hdr.volno = checkpt; hdr.maxino = maxino; hdr.entrytblsize = entrytblsize; hdr.stringsize = stroff; hdr.dumptime = dumptime; hdr.dumpdate = dumpdate; hdr.ntrec = ntrec; fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd); if (ferror(fd)) { fprintf(stderr, "fwrite: %s\n", strerror(errno)); panic("output error to file %s writing symbol table\n", filename); } fclose(fd); }
/* * dump a snapshot of the symbol table */
dump a snapshot of the symbol table
[ "dump", "a", "snapshot", "of", "the", "symbol", "table" ]
void dumpsymtable(const char *filename, long checkpt) { struct entry *ep, *tep; ufs1_ino_t i; struct entry temp, *tentry; long mynum = 1, stroff = 0; FILE *fd; struct symtableheader hdr; vprintf(stdout, "Check pointing the restore\n"); if (Nflag) return; if ((fd = fopen(filename, "w")) == NULL) { fprintf(stderr, "fopen: %s\n", strerror(errno)); panic("cannot create save file %s for symbol table\n", filename); done(1); } clearerr(fd); for (i = UFS_WINO; i <= maxino; i++) { for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { ep->e_index = mynum++; fwrite(ep->e_name, sizeof(char), (int)allocsize(ep->e_namlen), fd); } } tep = &temp; stroff = 0; for (i = UFS_WINO; i <= maxino; i++) { for (ep = lookupino(i); ep != NULL; ep = ep->e_links) { memmove(tep, ep, (long)sizeof(struct entry)); tep->e_name = (char *)stroff; stroff += allocsize(ep->e_namlen); tep->e_parent = (struct entry *)ep->e_parent->e_index; if (ep->e_links != NULL) tep->e_links = (struct entry *)ep->e_links->e_index; if (ep->e_sibling != NULL) tep->e_sibling = (struct entry *)ep->e_sibling->e_index; if (ep->e_entries != NULL) tep->e_entries = (struct entry *)ep->e_entries->e_index; if (ep->e_next != NULL) tep->e_next = (struct entry *)ep->e_next->e_index; fwrite((char *)tep, sizeof(struct entry), 1, fd); } } for (i = 0; i < entrytblsize; i++) { if (entry[i] == NULL) tentry = NULL; else tentry = (struct entry *)entry[i]->e_index; fwrite((char *)&tentry, sizeof(struct entry *), 1, fd); } hdr.volno = checkpt; hdr.maxino = maxino; hdr.entrytblsize = entrytblsize; hdr.stringsize = stroff; hdr.dumptime = dumptime; hdr.dumpdate = dumpdate; hdr.ntrec = ntrec; fwrite((char *)&hdr, sizeof(struct symtableheader), 1, fd); if (ferror(fd)) { fprintf(stderr, "fwrite: %s\n", strerror(errno)); panic("output error to file %s writing symbol table\n", filename); } fclose(fd); }
[ "void", "dumpsymtable", "(", "const", "char", "*", "filename", ",", "long", "checkpt", ")", "{", "struct", "entry", "*", "ep", ",", "*", "tep", ";", "ufs1_ino_t", "i", ";", "struct", "entry", "temp", ",", "*", "tentry", ";", "long", "mynum", "=", "1", ",", "stroff", "=", "0", ";", "FILE", "*", "fd", ";", "struct", "symtableheader", "hdr", ";", "vprintf", "(", "stdout", ",", "\"", "\\n", "\"", ")", ";", "if", "(", "Nflag", ")", "return", ";", "if", "(", "(", "fd", "=", "fopen", "(", "filename", ",", "\"", "\"", ")", ")", "==", "NULL", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "panic", "(", "\"", "\\n", "\"", ",", "filename", ")", ";", "done", "(", "1", ")", ";", "}", "clearerr", "(", "fd", ")", ";", "for", "(", "i", "=", "UFS_WINO", ";", "i", "<=", "maxino", ";", "i", "++", ")", "{", "for", "(", "ep", "=", "lookupino", "(", "i", ")", ";", "ep", "!=", "NULL", ";", "ep", "=", "ep", "->", "e_links", ")", "{", "ep", "->", "e_index", "=", "mynum", "++", ";", "fwrite", "(", "ep", "->", "e_name", ",", "sizeof", "(", "char", ")", ",", "(", "int", ")", "allocsize", "(", "ep", "->", "e_namlen", ")", ",", "fd", ")", ";", "}", "}", "tep", "=", "&", "temp", ";", "stroff", "=", "0", ";", "for", "(", "i", "=", "UFS_WINO", ";", "i", "<=", "maxino", ";", "i", "++", ")", "{", "for", "(", "ep", "=", "lookupino", "(", "i", ")", ";", "ep", "!=", "NULL", ";", "ep", "=", "ep", "->", "e_links", ")", "{", "memmove", "(", "tep", ",", "ep", ",", "(", "long", ")", "sizeof", "(", "struct", "entry", ")", ")", ";", "tep", "->", "e_name", "=", "(", "char", "*", ")", "stroff", ";", "stroff", "+=", "allocsize", "(", "ep", "->", "e_namlen", ")", ";", "tep", "->", "e_parent", "=", "(", "struct", "entry", "*", ")", "ep", "->", "e_parent", "->", "e_index", ";", "if", "(", "ep", "->", "e_links", "!=", "NULL", ")", "tep", "->", "e_links", "=", "(", "struct", "entry", "*", ")", "ep", "->", "e_links", "->", "e_index", ";", "if", "(", "ep", "->", "e_sibling", "!=", "NULL", ")", "tep", "->", "e_sibling", "=", "(", "struct", "entry", "*", ")", "ep", "->", "e_sibling", "->", "e_index", ";", "if", "(", "ep", "->", "e_entries", "!=", "NULL", ")", "tep", "->", "e_entries", "=", "(", "struct", "entry", "*", ")", "ep", "->", "e_entries", "->", "e_index", ";", "if", "(", "ep", "->", "e_next", "!=", "NULL", ")", "tep", "->", "e_next", "=", "(", "struct", "entry", "*", ")", "ep", "->", "e_next", "->", "e_index", ";", "fwrite", "(", "(", "char", "*", ")", "tep", ",", "sizeof", "(", "struct", "entry", ")", ",", "1", ",", "fd", ")", ";", "}", "}", "for", "(", "i", "=", "0", ";", "i", "<", "entrytblsize", ";", "i", "++", ")", "{", "if", "(", "entry", "[", "i", "]", "==", "NULL", ")", "tentry", "=", "NULL", ";", "else", "tentry", "=", "(", "struct", "entry", "*", ")", "entry", "[", "i", "]", "->", "e_index", ";", "fwrite", "(", "(", "char", "*", ")", "&", "tentry", ",", "sizeof", "(", "struct", "entry", "*", ")", ",", "1", ",", "fd", ")", ";", "}", "hdr", ".", "volno", "=", "checkpt", ";", "hdr", ".", "maxino", "=", "maxino", ";", "hdr", ".", "entrytblsize", "=", "entrytblsize", ";", "hdr", ".", "stringsize", "=", "stroff", ";", "hdr", ".", "dumptime", "=", "dumptime", ";", "hdr", ".", "dumpdate", "=", "dumpdate", ";", "hdr", ".", "ntrec", "=", "ntrec", ";", "fwrite", "(", "(", "char", "*", ")", "&", "hdr", ",", "sizeof", "(", "struct", "symtableheader", ")", ",", "1", ",", "fd", ")", ";", "if", "(", "ferror", "(", "fd", ")", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "panic", "(", "\"", "\\n", "\"", ",", "filename", ")", ";", "}", "fclose", "(", "fd", ")", ";", "}" ]
dump a snapshot of the symbol table
[ "dump", "a", "snapshot", "of", "the", "symbol", "table" ]
[ "/*\n\t * Assign indices to each entry\n\t * Write out the string entries\n\t */", "/*\n\t * Convert pointers to indexes, and output\n\t */", "/*\n\t * Convert entry pointers to indexes, and output\n\t */" ]
[ { "param": "filename", "type": "char" }, { "param": "checkpt", "type": "long" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "checkpt", "type": "long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e041c866d9a3ba34138551a7fd22d407f90fb68f
atrens/DragonFlyBSD-src
sbin/restore/symtab.c
[ "BSD-3-Clause" ]
C
initsymtable
void
void initsymtable(const char *filename) { char *base; long tblsize; struct entry *ep; struct entry *baseep, *lep; struct symtableheader hdr; struct stat stbuf; long i; int fd; vprintf(stdout, "Initialize symbol table.\n"); if (filename == NULL) { entrytblsize = maxino / HASHFACTOR; entry = (struct entry **) calloc((unsigned)entrytblsize, sizeof(struct entry *)); if (entry == NULL) panic("no memory for entry table\n"); ep = addentry(".", UFS_ROOTINO, NODE); ep->e_flags |= NEW; return; } if ((fd = open(filename, O_RDONLY, 0)) < 0) { fprintf(stderr, "open: %s\n", strerror(errno)); panic("cannot open symbol table file %s\n", filename); } if (fstat(fd, &stbuf) < 0) { fprintf(stderr, "stat: %s\n", strerror(errno)); panic("cannot stat symbol table file %s\n", filename); } tblsize = stbuf.st_size - sizeof(struct symtableheader); base = calloc(sizeof(char), (unsigned)tblsize); if (base == NULL) panic("cannot allocate space for symbol table\n"); if (read(fd, base, (int)tblsize) < 0 || read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) { fprintf(stderr, "read: %s\n", strerror(errno)); panic("cannot read symbol table file %s\n", filename); } switch (command) { case 'r': /* * For normal continuation, insure that we are using * the next incremental tape */ if (hdr.dumpdate != dumptime) { if (hdr.dumpdate < dumptime) fprintf(stderr, "Incremental tape too low\n"); else fprintf(stderr, "Incremental tape too high\n"); done(1); } break; case 'R': /* * For restart, insure that we are using the same tape */ curfile.action = SKIP; dumptime = hdr.dumptime; dumpdate = hdr.dumpdate; if (!bflag) newtapebuf(hdr.ntrec); getvol(hdr.volno); break; default: panic("initsymtable called from command %c\n", command); break; } maxino = hdr.maxino; entrytblsize = hdr.entrytblsize; entry = (struct entry **) (base + tblsize - (entrytblsize * sizeof(struct entry *))); baseep = (struct entry *)(base + hdr.stringsize - sizeof(struct entry)); lep = (struct entry *)entry; for (i = 0; i < entrytblsize; i++) { if (entry[i] == NULL) continue; entry[i] = &baseep[(long)entry[i]]; } for (ep = &baseep[1]; ep < lep; ep++) { ep->e_name = base + (long)ep->e_name; ep->e_parent = &baseep[(long)ep->e_parent]; if (ep->e_sibling != NULL) ep->e_sibling = &baseep[(long)ep->e_sibling]; if (ep->e_links != NULL) ep->e_links = &baseep[(long)ep->e_links]; if (ep->e_entries != NULL) ep->e_entries = &baseep[(long)ep->e_entries]; if (ep->e_next != NULL) ep->e_next = &baseep[(long)ep->e_next]; } }
/* * Initialize a symbol table from a file */
Initialize a symbol table from a file
[ "Initialize", "a", "symbol", "table", "from", "a", "file" ]
void initsymtable(const char *filename) { char *base; long tblsize; struct entry *ep; struct entry *baseep, *lep; struct symtableheader hdr; struct stat stbuf; long i; int fd; vprintf(stdout, "Initialize symbol table.\n"); if (filename == NULL) { entrytblsize = maxino / HASHFACTOR; entry = (struct entry **) calloc((unsigned)entrytblsize, sizeof(struct entry *)); if (entry == NULL) panic("no memory for entry table\n"); ep = addentry(".", UFS_ROOTINO, NODE); ep->e_flags |= NEW; return; } if ((fd = open(filename, O_RDONLY, 0)) < 0) { fprintf(stderr, "open: %s\n", strerror(errno)); panic("cannot open symbol table file %s\n", filename); } if (fstat(fd, &stbuf) < 0) { fprintf(stderr, "stat: %s\n", strerror(errno)); panic("cannot stat symbol table file %s\n", filename); } tblsize = stbuf.st_size - sizeof(struct symtableheader); base = calloc(sizeof(char), (unsigned)tblsize); if (base == NULL) panic("cannot allocate space for symbol table\n"); if (read(fd, base, (int)tblsize) < 0 || read(fd, (char *)&hdr, sizeof(struct symtableheader)) < 0) { fprintf(stderr, "read: %s\n", strerror(errno)); panic("cannot read symbol table file %s\n", filename); } switch (command) { case 'r': if (hdr.dumpdate != dumptime) { if (hdr.dumpdate < dumptime) fprintf(stderr, "Incremental tape too low\n"); else fprintf(stderr, "Incremental tape too high\n"); done(1); } break; case 'R': curfile.action = SKIP; dumptime = hdr.dumptime; dumpdate = hdr.dumpdate; if (!bflag) newtapebuf(hdr.ntrec); getvol(hdr.volno); break; default: panic("initsymtable called from command %c\n", command); break; } maxino = hdr.maxino; entrytblsize = hdr.entrytblsize; entry = (struct entry **) (base + tblsize - (entrytblsize * sizeof(struct entry *))); baseep = (struct entry *)(base + hdr.stringsize - sizeof(struct entry)); lep = (struct entry *)entry; for (i = 0; i < entrytblsize; i++) { if (entry[i] == NULL) continue; entry[i] = &baseep[(long)entry[i]]; } for (ep = &baseep[1]; ep < lep; ep++) { ep->e_name = base + (long)ep->e_name; ep->e_parent = &baseep[(long)ep->e_parent]; if (ep->e_sibling != NULL) ep->e_sibling = &baseep[(long)ep->e_sibling]; if (ep->e_links != NULL) ep->e_links = &baseep[(long)ep->e_links]; if (ep->e_entries != NULL) ep->e_entries = &baseep[(long)ep->e_entries]; if (ep->e_next != NULL) ep->e_next = &baseep[(long)ep->e_next]; } }
[ "void", "initsymtable", "(", "const", "char", "*", "filename", ")", "{", "char", "*", "base", ";", "long", "tblsize", ";", "struct", "entry", "*", "ep", ";", "struct", "entry", "*", "baseep", ",", "*", "lep", ";", "struct", "symtableheader", "hdr", ";", "struct", "stat", "stbuf", ";", "long", "i", ";", "int", "fd", ";", "vprintf", "(", "stdout", ",", "\"", "\\n", "\"", ")", ";", "if", "(", "filename", "==", "NULL", ")", "{", "entrytblsize", "=", "maxino", "/", "HASHFACTOR", ";", "entry", "=", "(", "struct", "entry", "*", "*", ")", "calloc", "(", "(", "unsigned", ")", "entrytblsize", ",", "sizeof", "(", "struct", "entry", "*", ")", ")", ";", "if", "(", "entry", "==", "NULL", ")", "panic", "(", "\"", "\\n", "\"", ")", ";", "ep", "=", "addentry", "(", "\"", "\"", ",", "UFS_ROOTINO", ",", "NODE", ")", ";", "ep", "->", "e_flags", "|=", "NEW", ";", "return", ";", "}", "if", "(", "(", "fd", "=", "open", "(", "filename", ",", "O_RDONLY", ",", "0", ")", ")", "<", "0", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "panic", "(", "\"", "\\n", "\"", ",", "filename", ")", ";", "}", "if", "(", "fstat", "(", "fd", ",", "&", "stbuf", ")", "<", "0", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "panic", "(", "\"", "\\n", "\"", ",", "filename", ")", ";", "}", "tblsize", "=", "stbuf", ".", "st_size", "-", "sizeof", "(", "struct", "symtableheader", ")", ";", "base", "=", "calloc", "(", "sizeof", "(", "char", ")", ",", "(", "unsigned", ")", "tblsize", ")", ";", "if", "(", "base", "==", "NULL", ")", "panic", "(", "\"", "\\n", "\"", ")", ";", "if", "(", "read", "(", "fd", ",", "base", ",", "(", "int", ")", "tblsize", ")", "<", "0", "||", "read", "(", "fd", ",", "(", "char", "*", ")", "&", "hdr", ",", "sizeof", "(", "struct", "symtableheader", ")", ")", "<", "0", ")", "{", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "panic", "(", "\"", "\\n", "\"", ",", "filename", ")", ";", "}", "switch", "(", "command", ")", "{", "case", "'", "'", ":", "if", "(", "hdr", ".", "dumpdate", "!=", "dumptime", ")", "{", "if", "(", "hdr", ".", "dumpdate", "<", "dumptime", ")", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ";", "else", "fprintf", "(", "stderr", ",", "\"", "\\n", "\"", ")", ";", "done", "(", "1", ")", ";", "}", "break", ";", "case", "'", "'", ":", "curfile", ".", "action", "=", "SKIP", ";", "dumptime", "=", "hdr", ".", "dumptime", ";", "dumpdate", "=", "hdr", ".", "dumpdate", ";", "if", "(", "!", "bflag", ")", "newtapebuf", "(", "hdr", ".", "ntrec", ")", ";", "getvol", "(", "hdr", ".", "volno", ")", ";", "break", ";", "default", ":", "panic", "(", "\"", "\\n", "\"", ",", "command", ")", ";", "break", ";", "}", "maxino", "=", "hdr", ".", "maxino", ";", "entrytblsize", "=", "hdr", ".", "entrytblsize", ";", "entry", "=", "(", "struct", "entry", "*", "*", ")", "(", "base", "+", "tblsize", "-", "(", "entrytblsize", "*", "sizeof", "(", "struct", "entry", "*", ")", ")", ")", ";", "baseep", "=", "(", "struct", "entry", "*", ")", "(", "base", "+", "hdr", ".", "stringsize", "-", "sizeof", "(", "struct", "entry", ")", ")", ";", "lep", "=", "(", "struct", "entry", "*", ")", "entry", ";", "for", "(", "i", "=", "0", ";", "i", "<", "entrytblsize", ";", "i", "++", ")", "{", "if", "(", "entry", "[", "i", "]", "==", "NULL", ")", "continue", ";", "entry", "[", "i", "]", "=", "&", "baseep", "[", "(", "long", ")", "entry", "[", "i", "]", "]", ";", "}", "for", "(", "ep", "=", "&", "baseep", "[", "1", "]", ";", "ep", "<", "lep", ";", "ep", "++", ")", "{", "ep", "->", "e_name", "=", "base", "+", "(", "long", ")", "ep", "->", "e_name", ";", "ep", "->", "e_parent", "=", "&", "baseep", "[", "(", "long", ")", "ep", "->", "e_parent", "]", ";", "if", "(", "ep", "->", "e_sibling", "!=", "NULL", ")", "ep", "->", "e_sibling", "=", "&", "baseep", "[", "(", "long", ")", "ep", "->", "e_sibling", "]", ";", "if", "(", "ep", "->", "e_links", "!=", "NULL", ")", "ep", "->", "e_links", "=", "&", "baseep", "[", "(", "long", ")", "ep", "->", "e_links", "]", ";", "if", "(", "ep", "->", "e_entries", "!=", "NULL", ")", "ep", "->", "e_entries", "=", "&", "baseep", "[", "(", "long", ")", "ep", "->", "e_entries", "]", ";", "if", "(", "ep", "->", "e_next", "!=", "NULL", ")", "ep", "->", "e_next", "=", "&", "baseep", "[", "(", "long", ")", "ep", "->", "e_next", "]", ";", "}", "}" ]
Initialize a symbol table from a file
[ "Initialize", "a", "symbol", "table", "from", "a", "file" ]
[ "/*\n\t\t * For normal continuation, insure that we are using\n\t\t * the next incremental tape\n\t\t */", "/*\n\t\t * For restart, insure that we are using the same tape\n\t\t */" ]
[ { "param": "filename", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filename", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
054f11dc905b168201ce4d5457b6b7042e6d8a2a
atrens/DragonFlyBSD-src
lib/libc/net/gethostbynis.c
[ "BSD-3-Clause" ]
C
_gethostbynisname
nan
struct hostent * _gethostbynisname(const char *name, int af) { #ifdef YP struct hostent *he; struct hostent_data *hed; u_long oresopt; int error; res_state statp; statp = __res_state(); if ((he = __hostent_init()) == NULL || (hed = __hostent_data_init()) == NULL) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); return (NULL); } oresopt = statp->options; statp->options &= ~RES_USE_INET6; error = _gethostbynisname_r(name, af, he, hed); statp->options = oresopt; return (error == 0) ? he : NULL; #else return (NULL); #endif }
/* XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*() */
XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*()
[ "XXX", "_gethostbynisname", "/", "_gethostbynisaddr", "only", "used", "by", "getipnodeby", "*", "()" ]
struct hostent * _gethostbynisname(const char *name, int af) { #ifdef YP struct hostent *he; struct hostent_data *hed; u_long oresopt; int error; res_state statp; statp = __res_state(); if ((he = __hostent_init()) == NULL || (hed = __hostent_data_init()) == NULL) { RES_SET_H_ERRNO(statp, NETDB_INTERNAL); return (NULL); } oresopt = statp->options; statp->options &= ~RES_USE_INET6; error = _gethostbynisname_r(name, af, he, hed); statp->options = oresopt; return (error == 0) ? he : NULL; #else return (NULL); #endif }
[ "struct", "hostent", "*", "_gethostbynisname", "(", "const", "char", "*", "name", ",", "int", "af", ")", "{", "#ifdef", "YP", "struct", "hostent", "*", "he", ";", "struct", "hostent_data", "*", "hed", ";", "u_long", "oresopt", ";", "int", "error", ";", "res_state", "statp", ";", "statp", "=", "__res_state", "(", ")", ";", "if", "(", "(", "he", "=", "__hostent_init", "(", ")", ")", "==", "NULL", "||", "(", "hed", "=", "__hostent_data_init", "(", ")", ")", "==", "NULL", ")", "{", "RES_SET_H_ERRNO", "(", "statp", ",", "NETDB_INTERNAL", ")", ";", "return", "(", "NULL", ")", ";", "}", "oresopt", "=", "statp", "->", "options", ";", "statp", "->", "options", "&=", "~", "RES_USE_INET6", ";", "error", "=", "_gethostbynisname_r", "(", "name", ",", "af", ",", "he", ",", "hed", ")", ";", "statp", "->", "options", "=", "oresopt", ";", "return", "(", "error", "==", "0", ")", "?", "he", ":", "NULL", ";", "#else", "return", "(", "NULL", ")", ";", "#endif", "}" ]
XXX _gethostbynisname/_gethostbynisaddr only used by getipnodeby*()
[ "XXX", "_gethostbynisname", "/", "_gethostbynisaddr", "only", "used", "by", "getipnodeby", "*", "()" ]
[]
[ { "param": "name", "type": "char" }, { "param": "af", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "af", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_setport
int
static int ng_fec_setport(struct ifnet *ifp, u_long command, caddr_t data) { struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *oifp; struct ng_fec_portlist *p; priv = ifp->if_softc; b = &priv->fec_bundle; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { oifp = p->fec_if; if (oifp != NULL) (*oifp->if_ioctl)(oifp, command, data); } return(0); }
/* * Pass an ioctl command down to all the underyling interfaces in a * bundle. Used for setting flags. */
Pass an ioctl command down to all the underyling interfaces in a bundle. Used for setting flags.
[ "Pass", "an", "ioctl", "command", "down", "to", "all", "the", "underyling", "interfaces", "in", "a", "bundle", ".", "Used", "for", "setting", "flags", "." ]
static int ng_fec_setport(struct ifnet *ifp, u_long command, caddr_t data) { struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *oifp; struct ng_fec_portlist *p; priv = ifp->if_softc; b = &priv->fec_bundle; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { oifp = p->fec_if; if (oifp != NULL) (*oifp->if_ioctl)(oifp, command, data); } return(0); }
[ "static", "int", "ng_fec_setport", "(", "struct", "ifnet", "*", "ifp", ",", "u_long", "command", ",", "caddr_t", "data", ")", "{", "struct", "ng_fec_private", "*", "priv", ";", "struct", "ng_fec_bundle", "*", "b", ";", "struct", "ifnet", "*", "oifp", ";", "struct", "ng_fec_portlist", "*", "p", ";", "priv", "=", "ifp", "->", "if_softc", ";", "b", "=", "&", "priv", "->", "fec_bundle", ";", "TAILQ_FOREACH", "(", "p", ",", "&", "b", "->", "ng_fec_ports", ",", "fec_list", ")", "", "{", "oifp", "=", "p", "->", "fec_if", ";", "if", "(", "oifp", "!=", "NULL", ")", "(", "*", "oifp", "->", "if_ioctl", ")", "(", "oifp", ",", "command", ",", "data", ")", ";", "}", "return", "(", "0", ")", ";", "}" ]
Pass an ioctl command down to all the underyling interfaces in a bundle.
[ "Pass", "an", "ioctl", "command", "down", "to", "all", "the", "underyling", "interfaces", "in", "a", "bundle", "." ]
[]
[ { "param": "ifp", "type": "struct ifnet" }, { "param": "command", "type": "u_long" }, { "param": "data", "type": "caddr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ifp", "type": "struct ifnet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "command", "type": "u_long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "caddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_ioctl
int
static int ng_fec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct ifreq *const ifr = (struct ifreq *) data; int s, error = 0; struct ng_fec_private *priv; struct ng_fec_bundle *b; priv = ifp->if_softc; b = &priv->fec_bundle; #ifdef DEBUG ng_fec_print_ioctl(ifp, command, data); #endif s = splimp(); switch (command) { /* These two are mostly handled at a higher layer */ case SIOCSIFADDR: case SIOCGIFADDR: error = ether_ioctl(ifp, command, data); break; case SIOCSIFMTU: if (ifr->ifr_mtu >= NG_FEC_MTU_MIN && ifr->ifr_mtu <= NG_FEC_MTU_MAX) { struct ng_fec_portlist *p; struct ifnet *bifp; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { bifp = p->fec_if; error = (*bifp->if_ioctl)(bifp, SIOCSIFMTU, data); if (error != 0) break; } if (error == 0) ifp->if_mtu = ifr->ifr_mtu; } else error = EINVAL; break; /* Set flags */ case SIOCSIFFLAGS: /* * If the interface is marked up and stopped, then start it. * If it is marked down and running, then stop it. */ if (ifr->ifr_flags & IFF_UP) { if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { /* Sanity. */ if (b->fec_ifcnt != 2 && b->fec_ifcnt != FEC_BUNDLESIZ) { kprintf("fec%d: invalid bundle " "size: %d\n", priv->unit, b->fec_ifcnt); error = EINVAL; break; } ng_fec_init(priv); } /* * Bubble down changes in promisc mode to * underlying interfaces. */ if ((ifp->if_flags & IFF_PROMISC) != (priv->if_flags & IFF_PROMISC)) { ng_fec_setport(ifp, command, data); priv->if_flags = ifp->if_flags; } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) ng_fec_stop(ifp); } break; case SIOCADDMULTI: case SIOCDELMULTI: ng_fec_ether_setmulti(ifp); error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &priv->ifmedia, command); break; /* Stuff that's not supported */ case SIOCSIFPHYS: error = EOPNOTSUPP; break; default: error = EINVAL; break; } (void) splx(s); return (error); }
/* * Process an ioctl for the virtual interface */
Process an ioctl for the virtual interface
[ "Process", "an", "ioctl", "for", "the", "virtual", "interface" ]
static int ng_fec_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { struct ifreq *const ifr = (struct ifreq *) data; int s, error = 0; struct ng_fec_private *priv; struct ng_fec_bundle *b; priv = ifp->if_softc; b = &priv->fec_bundle; #ifdef DEBUG ng_fec_print_ioctl(ifp, command, data); #endif s = splimp(); switch (command) { case SIOCSIFADDR: case SIOCGIFADDR: error = ether_ioctl(ifp, command, data); break; case SIOCSIFMTU: if (ifr->ifr_mtu >= NG_FEC_MTU_MIN && ifr->ifr_mtu <= NG_FEC_MTU_MAX) { struct ng_fec_portlist *p; struct ifnet *bifp; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { bifp = p->fec_if; error = (*bifp->if_ioctl)(bifp, SIOCSIFMTU, data); if (error != 0) break; } if (error == 0) ifp->if_mtu = ifr->ifr_mtu; } else error = EINVAL; break; case SIOCSIFFLAGS: if (ifr->ifr_flags & IFF_UP) { if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { if (b->fec_ifcnt != 2 && b->fec_ifcnt != FEC_BUNDLESIZ) { kprintf("fec%d: invalid bundle " "size: %d\n", priv->unit, b->fec_ifcnt); error = EINVAL; break; } ng_fec_init(priv); } if ((ifp->if_flags & IFF_PROMISC) != (priv->if_flags & IFF_PROMISC)) { ng_fec_setport(ifp, command, data); priv->if_flags = ifp->if_flags; } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) ng_fec_stop(ifp); } break; case SIOCADDMULTI: case SIOCDELMULTI: ng_fec_ether_setmulti(ifp); error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &priv->ifmedia, command); break; case SIOCSIFPHYS: error = EOPNOTSUPP; break; default: error = EINVAL; break; } (void) splx(s); return (error); }
[ "static", "int", "ng_fec_ioctl", "(", "struct", "ifnet", "*", "ifp", ",", "u_long", "command", ",", "caddr_t", "data", ")", "{", "struct", "ifreq", "*", "const", "ifr", "=", "(", "struct", "ifreq", "*", ")", "data", ";", "int", "s", ",", "error", "=", "0", ";", "struct", "ng_fec_private", "*", "priv", ";", "struct", "ng_fec_bundle", "*", "b", ";", "priv", "=", "ifp", "->", "if_softc", ";", "b", "=", "&", "priv", "->", "fec_bundle", ";", "#ifdef", "DEBUG", "ng_fec_print_ioctl", "(", "ifp", ",", "command", ",", "data", ")", ";", "#endif", "s", "=", "splimp", "(", ")", ";", "switch", "(", "command", ")", "{", "case", "SIOCSIFADDR", ":", "case", "SIOCGIFADDR", ":", "error", "=", "ether_ioctl", "(", "ifp", ",", "command", ",", "data", ")", ";", "break", ";", "case", "SIOCSIFMTU", ":", "if", "(", "ifr", "->", "ifr_mtu", ">=", "NG_FEC_MTU_MIN", "&&", "ifr", "->", "ifr_mtu", "<=", "NG_FEC_MTU_MAX", ")", "{", "struct", "ng_fec_portlist", "*", "p", ";", "struct", "ifnet", "*", "bifp", ";", "TAILQ_FOREACH", "(", "p", ",", "&", "b", "->", "ng_fec_ports", ",", "fec_list", ")", "", "{", "bifp", "=", "p", "->", "fec_if", ";", "error", "=", "(", "*", "bifp", "->", "if_ioctl", ")", "(", "bifp", ",", "SIOCSIFMTU", ",", "data", ")", ";", "if", "(", "error", "!=", "0", ")", "break", ";", "}", "if", "(", "error", "==", "0", ")", "ifp", "->", "if_mtu", "=", "ifr", "->", "ifr_mtu", ";", "}", "else", "error", "=", "EINVAL", ";", "break", ";", "case", "SIOCSIFFLAGS", ":", "if", "(", "ifr", "->", "ifr_flags", "&", "IFF_UP", ")", "{", "if", "(", "!", "(", "ifp", "->", "if_drv_flags", "&", "IFF_DRV_RUNNING", ")", ")", "{", "if", "(", "b", "->", "fec_ifcnt", "!=", "2", "&&", "b", "->", "fec_ifcnt", "!=", "FEC_BUNDLESIZ", ")", "{", "kprintf", "(", "\"", "\"", "\"", "\\n", "\"", ",", "priv", "->", "unit", ",", "b", "->", "fec_ifcnt", ")", ";", "error", "=", "EINVAL", ";", "break", ";", "}", "ng_fec_init", "(", "priv", ")", ";", "}", "if", "(", "(", "ifp", "->", "if_flags", "&", "IFF_PROMISC", ")", "!=", "(", "priv", "->", "if_flags", "&", "IFF_PROMISC", ")", ")", "{", "ng_fec_setport", "(", "ifp", ",", "command", ",", "data", ")", ";", "priv", "->", "if_flags", "=", "ifp", "->", "if_flags", ";", "}", "}", "else", "{", "if", "(", "ifp", "->", "if_drv_flags", "&", "IFF_DRV_RUNNING", ")", "ng_fec_stop", "(", "ifp", ")", ";", "}", "break", ";", "case", "SIOCADDMULTI", ":", "case", "SIOCDELMULTI", ":", "ng_fec_ether_setmulti", "(", "ifp", ")", ";", "error", "=", "0", ";", "break", ";", "case", "SIOCGIFMEDIA", ":", "case", "SIOCSIFMEDIA", ":", "error", "=", "ifmedia_ioctl", "(", "ifp", ",", "ifr", ",", "&", "priv", "->", "ifmedia", ",", "command", ")", ";", "break", ";", "case", "SIOCSIFPHYS", ":", "error", "=", "EOPNOTSUPP", ";", "break", ";", "default", ":", "error", "=", "EINVAL", ";", "break", ";", "}", "(", "void", ")", "splx", "(", "s", ")", ";", "return", "(", "error", ")", ";", "}" ]
Process an ioctl for the virtual interface
[ "Process", "an", "ioctl", "for", "the", "virtual", "interface" ]
[ "/* These two are mostly handled at a higher layer */", "/* Set flags */", "/*\n\t\t * If the interface is marked up and stopped, then start it.\n\t\t * If it is marked down and running, then stop it.\n\t\t */", "/* Sanity. */", "/*\n\t\t\t * Bubble down changes in promisc mode to\n\t\t\t * underlying interfaces.\n\t\t\t */", "/* Stuff that's not supported */" ]
[ { "param": "ifp", "type": "struct ifnet" }, { "param": "command", "type": "u_long" }, { "param": "data", "type": "caddr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ifp", "type": "struct ifnet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "command", "type": "u_long", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "caddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_input
void
static void ng_fec_input(struct ifnet *ifp, struct mbuf *m0) { struct ng_node *node; struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *bifp; struct ng_fec_portlist *p; /* Sanity check */ if (ifp == NULL || m0 == NULL) return; node = IFP2NG(ifp); /* Sanity check part II */ if (node == NULL) return; priv = NG_NODE_PRIVATE(node); b = &priv->fec_bundle; bifp = priv->ifp; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { if (p->fec_if == m0->m_pkthdr.rcvif) break; } /* Wasn't meant for us; leave this frame alone. */ if (p == NULL) return; /* * Check for a BPF tap on the underlying interface. This * is mainly a debugging aid: it allows tcpdump-ing of an * individual interface in a bundle to work, which it * otherwise would not. BPF tapping of our own aggregate * interface will occur once we call ether_input(). */ BPF_MTAP(m0->m_pkthdr.rcvif, m0); /* Convince the system that this is our frame. */ m0->m_pkthdr.rcvif = bifp; /* * Count bytes on an individual interface in a bundle. * The bytes will also be added to the aggregate interface * once we call ether_input(). */ ifp->if_ibytes += m0->m_pkthdr.len; bifp->if_ipackets++; bifp->if_input(bifp, m0, NULL, -1); return; }
/* * This routine spies on mbufs received by underlying network device * drivers. When we add an interface to our bundle, we override its * if_input routine with a pointer to ng_fec_input(). This means we * get to look at all the device's packets before sending them to the * real ether_input() for processing by the stack. Once we verify the * packet comes from an interface that's been aggregated into * our bundle, we fix up the rcvif pointer and increment our * packet counters so that it looks like the frames are actually * coming from us. */
This routine spies on mbufs received by underlying network device drivers. When we add an interface to our bundle, we override its if_input routine with a pointer to ng_fec_input(). This means we get to look at all the device's packets before sending them to the real ether_input() for processing by the stack. Once we verify the packet comes from an interface that's been aggregated into our bundle, we fix up the rcvif pointer and increment our packet counters so that it looks like the frames are actually coming from us.
[ "This", "routine", "spies", "on", "mbufs", "received", "by", "underlying", "network", "device", "drivers", ".", "When", "we", "add", "an", "interface", "to", "our", "bundle", "we", "override", "its", "if_input", "routine", "with", "a", "pointer", "to", "ng_fec_input", "()", ".", "This", "means", "we", "get", "to", "look", "at", "all", "the", "device", "'", "s", "packets", "before", "sending", "them", "to", "the", "real", "ether_input", "()", "for", "processing", "by", "the", "stack", ".", "Once", "we", "verify", "the", "packet", "comes", "from", "an", "interface", "that", "'", "s", "been", "aggregated", "into", "our", "bundle", "we", "fix", "up", "the", "rcvif", "pointer", "and", "increment", "our", "packet", "counters", "so", "that", "it", "looks", "like", "the", "frames", "are", "actually", "coming", "from", "us", "." ]
static void ng_fec_input(struct ifnet *ifp, struct mbuf *m0) { struct ng_node *node; struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *bifp; struct ng_fec_portlist *p; if (ifp == NULL || m0 == NULL) return; node = IFP2NG(ifp); if (node == NULL) return; priv = NG_NODE_PRIVATE(node); b = &priv->fec_bundle; bifp = priv->ifp; TAILQ_FOREACH(p, &b->ng_fec_ports, fec_list) { if (p->fec_if == m0->m_pkthdr.rcvif) break; } if (p == NULL) return; BPF_MTAP(m0->m_pkthdr.rcvif, m0); m0->m_pkthdr.rcvif = bifp; ifp->if_ibytes += m0->m_pkthdr.len; bifp->if_ipackets++; bifp->if_input(bifp, m0, NULL, -1); return; }
[ "static", "void", "ng_fec_input", "(", "struct", "ifnet", "*", "ifp", ",", "struct", "mbuf", "*", "m0", ")", "{", "struct", "ng_node", "*", "node", ";", "struct", "ng_fec_private", "*", "priv", ";", "struct", "ng_fec_bundle", "*", "b", ";", "struct", "ifnet", "*", "bifp", ";", "struct", "ng_fec_portlist", "*", "p", ";", "if", "(", "ifp", "==", "NULL", "||", "m0", "==", "NULL", ")", "return", ";", "node", "=", "IFP2NG", "(", "ifp", ")", ";", "if", "(", "node", "==", "NULL", ")", "return", ";", "priv", "=", "NG_NODE_PRIVATE", "(", "node", ")", ";", "b", "=", "&", "priv", "->", "fec_bundle", ";", "bifp", "=", "priv", "->", "ifp", ";", "TAILQ_FOREACH", "(", "p", ",", "&", "b", "->", "ng_fec_ports", ",", "fec_list", ")", "", "{", "if", "(", "p", "->", "fec_if", "==", "m0", "->", "m_pkthdr", ".", "rcvif", ")", "break", ";", "}", "if", "(", "p", "==", "NULL", ")", "return", ";", "BPF_MTAP", "(", "m0", "->", "m_pkthdr", ".", "rcvif", ",", "m0", ")", ";", "m0", "->", "m_pkthdr", ".", "rcvif", "=", "bifp", ";", "ifp", "->", "if_ibytes", "+=", "m0", "->", "m_pkthdr", ".", "len", ";", "bifp", "->", "if_ipackets", "++", ";", "bifp", "->", "if_input", "(", "bifp", ",", "m0", ",", "NULL", ",", "-1", ")", ";", "return", ";", "}" ]
This routine spies on mbufs received by underlying network device drivers.
[ "This", "routine", "spies", "on", "mbufs", "received", "by", "underlying", "network", "device", "drivers", "." ]
[ "/* Sanity check */", "/* Sanity check part II */", "/* Wasn't meant for us; leave this frame alone. */", "/*\n\t * Check for a BPF tap on the underlying interface. This\n\t * is mainly a debugging aid: it allows tcpdump-ing of an\n\t * individual interface in a bundle to work, which it\n\t * otherwise would not. BPF tapping of our own aggregate\n\t * interface will occur once we call ether_input().\n\t */", "/* Convince the system that this is our frame. */", "/*\n\t * Count bytes on an individual interface in a bundle.\n\t * The bytes will also be added to the aggregate interface\n\t * once we call ether_input().\n\t */" ]
[ { "param": "ifp", "type": "struct ifnet" }, { "param": "m0", "type": "struct mbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ifp", "type": "struct ifnet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m0", "type": "struct mbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_start
void
static void ng_fec_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) { struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *oifp = NULL; struct mbuf *m0; int error; priv = ifp->if_softc; b = &priv->fec_bundle; m0 = ifq_dequeue(&ifp->if_snd); if (m0 == NULL) return; BPF_MTAP(ifp, m0); /* Queue up packet on the proper port. */ error = ng_fec_choose_port(b, m0, &oifp); if (error) { ifp->if_ierrors++; m_freem(m0); priv->if_error = ENOBUFS; return; } ifp->if_opackets++; ifnet_deserialize_tx(ifp, ifsq); error = ifq_dispatch(oifp, m0, NULL); ifnet_serialize_tx(ifp, ifsq); priv->if_error = error; }
/* * Now that the packet has been run through ether_output(), yank it * off our own send queue and stick it on the queue for the appropriate * underlying physical interface. Note that if the interface's send * queue is full, we save an error status in our private netgraph * space which will eventually be handed up to ng_fec_output(), which * will return it to the rest of the IP stack. We need to do this * in order to duplicate the effect of ether_output() returning ENOBUFS * when it detects that an interface's send queue is full. There's no * other way to signal the error status from here since the if_start() * routine is spec'ed to return void. * * Once the frame is queued, we call ether_output_frame() to initiate * transmission. */
Now that the packet has been run through ether_output(), yank it off our own send queue and stick it on the queue for the appropriate underlying physical interface. Note that if the interface's send queue is full, we save an error status in our private netgraph space which will eventually be handed up to ng_fec_output(), which will return it to the rest of the IP stack. We need to do this in order to duplicate the effect of ether_output() returning ENOBUFS when it detects that an interface's send queue is full. There's no other way to signal the error status from here since the if_start() routine is spec'ed to return void. Once the frame is queued, we call ether_output_frame() to initiate transmission.
[ "Now", "that", "the", "packet", "has", "been", "run", "through", "ether_output", "()", "yank", "it", "off", "our", "own", "send", "queue", "and", "stick", "it", "on", "the", "queue", "for", "the", "appropriate", "underlying", "physical", "interface", ".", "Note", "that", "if", "the", "interface", "'", "s", "send", "queue", "is", "full", "we", "save", "an", "error", "status", "in", "our", "private", "netgraph", "space", "which", "will", "eventually", "be", "handed", "up", "to", "ng_fec_output", "()", "which", "will", "return", "it", "to", "the", "rest", "of", "the", "IP", "stack", ".", "We", "need", "to", "do", "this", "in", "order", "to", "duplicate", "the", "effect", "of", "ether_output", "()", "returning", "ENOBUFS", "when", "it", "detects", "that", "an", "interface", "'", "s", "send", "queue", "is", "full", ".", "There", "'", "s", "no", "other", "way", "to", "signal", "the", "error", "status", "from", "here", "since", "the", "if_start", "()", "routine", "is", "spec", "'", "ed", "to", "return", "void", ".", "Once", "the", "frame", "is", "queued", "we", "call", "ether_output_frame", "()", "to", "initiate", "transmission", "." ]
static void ng_fec_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) { struct ng_fec_private *priv; struct ng_fec_bundle *b; struct ifnet *oifp = NULL; struct mbuf *m0; int error; priv = ifp->if_softc; b = &priv->fec_bundle; m0 = ifq_dequeue(&ifp->if_snd); if (m0 == NULL) return; BPF_MTAP(ifp, m0); error = ng_fec_choose_port(b, m0, &oifp); if (error) { ifp->if_ierrors++; m_freem(m0); priv->if_error = ENOBUFS; return; } ifp->if_opackets++; ifnet_deserialize_tx(ifp, ifsq); error = ifq_dispatch(oifp, m0, NULL); ifnet_serialize_tx(ifp, ifsq); priv->if_error = error; }
[ "static", "void", "ng_fec_start", "(", "struct", "ifnet", "*", "ifp", ",", "struct", "ifaltq_subque", "*", "ifsq", ")", "{", "struct", "ng_fec_private", "*", "priv", ";", "struct", "ng_fec_bundle", "*", "b", ";", "struct", "ifnet", "*", "oifp", "=", "NULL", ";", "struct", "mbuf", "*", "m0", ";", "int", "error", ";", "priv", "=", "ifp", "->", "if_softc", ";", "b", "=", "&", "priv", "->", "fec_bundle", ";", "m0", "=", "ifq_dequeue", "(", "&", "ifp", "->", "if_snd", ")", ";", "if", "(", "m0", "==", "NULL", ")", "return", ";", "BPF_MTAP", "(", "ifp", ",", "m0", ")", ";", "error", "=", "ng_fec_choose_port", "(", "b", ",", "m0", ",", "&", "oifp", ")", ";", "if", "(", "error", ")", "{", "ifp", "->", "if_ierrors", "++", ";", "m_freem", "(", "m0", ")", ";", "priv", "->", "if_error", "=", "ENOBUFS", ";", "return", ";", "}", "ifp", "->", "if_opackets", "++", ";", "ifnet_deserialize_tx", "(", "ifp", ",", "ifsq", ")", ";", "error", "=", "ifq_dispatch", "(", "oifp", ",", "m0", ",", "NULL", ")", ";", "ifnet_serialize_tx", "(", "ifp", ",", "ifsq", ")", ";", "priv", "->", "if_error", "=", "error", ";", "}" ]
Now that the packet has been run through ether_output(), yank it off our own send queue and stick it on the queue for the appropriate underlying physical interface.
[ "Now", "that", "the", "packet", "has", "been", "run", "through", "ether_output", "()", "yank", "it", "off", "our", "own", "send", "queue", "and", "stick", "it", "on", "the", "queue", "for", "the", "appropriate", "underlying", "physical", "interface", "." ]
[ "/* Queue up packet on the proper port. */" ]
[ { "param": "ifp", "type": "struct ifnet" }, { "param": "ifsq", "type": "struct ifaltq_subque" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ifp", "type": "struct ifnet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ifsq", "type": "struct ifaltq_subque", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_print_ioctl
void
static void ng_fec_print_ioctl(struct ifnet *ifp, int command, caddr_t data) { char *str; switch (command & IOC_DIRMASK) { case IOC_VOID: str = "IO"; break; case IOC_OUT: str = "IOR"; break; case IOC_IN: str = "IOW"; break; case IOC_INOUT: str = "IORW"; break; default: str = "IO??"; } log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n", ifp->if_xname, str, IOCGROUP(command), command & 0xff, IOCPARM_LEN(command)); }
/* * Display an ioctl to the virtual interface */
Display an ioctl to the virtual interface
[ "Display", "an", "ioctl", "to", "the", "virtual", "interface" ]
static void ng_fec_print_ioctl(struct ifnet *ifp, int command, caddr_t data) { char *str; switch (command & IOC_DIRMASK) { case IOC_VOID: str = "IO"; break; case IOC_OUT: str = "IOR"; break; case IOC_IN: str = "IOW"; break; case IOC_INOUT: str = "IORW"; break; default: str = "IO??"; } log(LOG_DEBUG, "%s: %s('%c', %d, char[%d])\n", ifp->if_xname, str, IOCGROUP(command), command & 0xff, IOCPARM_LEN(command)); }
[ "static", "void", "ng_fec_print_ioctl", "(", "struct", "ifnet", "*", "ifp", ",", "int", "command", ",", "caddr_t", "data", ")", "{", "char", "*", "str", ";", "switch", "(", "command", "&", "IOC_DIRMASK", ")", "{", "case", "IOC_VOID", ":", "str", "=", "\"", "\"", ";", "break", ";", "case", "IOC_OUT", ":", "str", "=", "\"", "\"", ";", "break", ";", "case", "IOC_IN", ":", "str", "=", "\"", "\"", ";", "break", ";", "case", "IOC_INOUT", ":", "str", "=", "\"", "\"", ";", "break", ";", "default", ":", "str", "=", "\"", "\"", ";", "}", "log", "(", "LOG_DEBUG", ",", "\"", "\\n", "\"", ",", "ifp", "->", "if_xname", ",", "str", ",", "IOCGROUP", "(", "command", ")", ",", "command", "&", "0xff", ",", "IOCPARM_LEN", "(", "command", ")", ")", ";", "}" ]
Display an ioctl to the virtual interface
[ "Display", "an", "ioctl", "to", "the", "virtual", "interface" ]
[]
[ { "param": "ifp", "type": "struct ifnet" }, { "param": "command", "type": "int" }, { "param": "data", "type": "caddr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ifp", "type": "struct ifnet", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "command", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "caddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_shutdown
int
static int ng_fec_shutdown(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); struct ng_fec_bundle *b; struct ng_fec_portlist *p; b = &priv->fec_bundle; ng_fec_stop(priv->ifp); while (!TAILQ_EMPTY(&b->ng_fec_ports)) { p = TAILQ_FIRST(&b->ng_fec_ports); ng_fec_ether_cmdmulti(priv->ifp, p, 0); ng_fec_delport(priv, p->fec_if->if_xname); } ether_ifdetach(priv->ifp); if_free_type(priv->ifp, IFT_ETHER); ifmedia_removeall(&priv->ifmedia); ng_fec_free_unit(priv->unit); kfree(priv, M_NETGRAPH); NG_NODE_SET_PRIVATE(node, NULL); NG_NODE_UNREF(node); return (0); }
/* * Shutdown and remove the node and its associated interface. */
Shutdown and remove the node and its associated interface.
[ "Shutdown", "and", "remove", "the", "node", "and", "its", "associated", "interface", "." ]
static int ng_fec_shutdown(node_p node) { const priv_p priv = NG_NODE_PRIVATE(node); struct ng_fec_bundle *b; struct ng_fec_portlist *p; b = &priv->fec_bundle; ng_fec_stop(priv->ifp); while (!TAILQ_EMPTY(&b->ng_fec_ports)) { p = TAILQ_FIRST(&b->ng_fec_ports); ng_fec_ether_cmdmulti(priv->ifp, p, 0); ng_fec_delport(priv, p->fec_if->if_xname); } ether_ifdetach(priv->ifp); if_free_type(priv->ifp, IFT_ETHER); ifmedia_removeall(&priv->ifmedia); ng_fec_free_unit(priv->unit); kfree(priv, M_NETGRAPH); NG_NODE_SET_PRIVATE(node, NULL); NG_NODE_UNREF(node); return (0); }
[ "static", "int", "ng_fec_shutdown", "(", "node_p", "node", ")", "{", "const", "priv_p", "priv", "=", "NG_NODE_PRIVATE", "(", "node", ")", ";", "struct", "ng_fec_bundle", "*", "b", ";", "struct", "ng_fec_portlist", "*", "p", ";", "b", "=", "&", "priv", "->", "fec_bundle", ";", "ng_fec_stop", "(", "priv", "->", "ifp", ")", ";", "while", "(", "!", "TAILQ_EMPTY", "(", "&", "b", "->", "ng_fec_ports", ")", ")", "{", "p", "=", "TAILQ_FIRST", "(", "&", "b", "->", "ng_fec_ports", ")", ";", "ng_fec_ether_cmdmulti", "(", "priv", "->", "ifp", ",", "p", ",", "0", ")", ";", "ng_fec_delport", "(", "priv", ",", "p", "->", "fec_if", "->", "if_xname", ")", ";", "}", "ether_ifdetach", "(", "priv", "->", "ifp", ")", ";", "if_free_type", "(", "priv", "->", "ifp", ",", "IFT_ETHER", ")", ";", "ifmedia_removeall", "(", "&", "priv", "->", "ifmedia", ")", ";", "ng_fec_free_unit", "(", "priv", "->", "unit", ")", ";", "kfree", "(", "priv", ",", "M_NETGRAPH", ")", ";", "NG_NODE_SET_PRIVATE", "(", "node", ",", "NULL", ")", ";", "NG_NODE_UNREF", "(", "node", ")", ";", "return", "(", "0", ")", ";", "}" ]
Shutdown and remove the node and its associated interface.
[ "Shutdown", "and", "remove", "the", "node", "and", "its", "associated", "interface", "." ]
[]
[ { "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": [] }
240efb89d5ce352eb1fc7b95d32b317ad5ed7725
atrens/DragonFlyBSD-src
sys/netgraph7/ng_fec.c
[ "BSD-3-Clause" ]
C
ng_fec_mod_event
int
static int ng_fec_mod_event(module_t mod, int event, void *data) { int error = 0; switch (event) { case MOD_LOAD: mtx_init(&ng_fec_mtx, "ng_fec", NULL, MTX_DEF); break; case MOD_UNLOAD: mtx_destroy(&ng_fec_mtx); break; default: error = EOPNOTSUPP; break; } return (error); }
/* * Handle loading and unloading for this node type. */
Handle loading and unloading for this node type.
[ "Handle", "loading", "and", "unloading", "for", "this", "node", "type", "." ]
static int ng_fec_mod_event(module_t mod, int event, void *data) { int error = 0; switch (event) { case MOD_LOAD: mtx_init(&ng_fec_mtx, "ng_fec", NULL, MTX_DEF); break; case MOD_UNLOAD: mtx_destroy(&ng_fec_mtx); break; default: error = EOPNOTSUPP; break; } return (error); }
[ "static", "int", "ng_fec_mod_event", "(", "module_t", "mod", ",", "int", "event", ",", "void", "*", "data", ")", "{", "int", "error", "=", "0", ";", "switch", "(", "event", ")", "{", "case", "MOD_LOAD", ":", "mtx_init", "(", "&", "ng_fec_mtx", ",", "\"", "\"", ",", "NULL", ",", "MTX_DEF", ")", ";", "break", ";", "case", "MOD_UNLOAD", ":", "mtx_destroy", "(", "&", "ng_fec_mtx", ")", ";", "break", ";", "default", ":", "error", "=", "EOPNOTSUPP", ";", "break", ";", "}", "return", "(", "error", ")", ";", "}" ]
Handle loading and unloading for this node type.
[ "Handle", "loading", "and", "unloading", "for", "this", "node", "type", "." ]
[]
[ { "param": "mod", "type": "module_t" }, { "param": "event", "type": "int" }, { "param": "data", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": "module_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f2231d7dcc581396832721812acb65d1f384ba0
atrens/DragonFlyBSD-src
contrib/tcpdump/print-802_11.c
[ "BSD-3-Clause" ]
C
handle_beacon
int
static int handle_beacon(const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN)) return 0; if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN) return 0; memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); offset += IEEE802_11_TSTAMP_LEN; length -= IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_BCNINT_LEN; length -= IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; ret = parse_elements(&pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); printf(" %s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"); PRINT_DS_CHANNEL(pbody); return ret; }
/********************************************************************************* * Print Handle functions for the management frame types *********************************************************************************/
Print Handle functions for the management frame types
[ "Print", "Handle", "functions", "for", "the", "management", "frame", "types" ]
static int handle_beacon(const u_char *p, u_int length) { struct mgmt_body_t pbody; int offset = 0; int ret; memset(&pbody, 0, sizeof(pbody)); if (!TTEST2(*p, IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN)) return 0; if (length < IEEE802_11_TSTAMP_LEN + IEEE802_11_BCNINT_LEN + IEEE802_11_CAPINFO_LEN) return 0; memcpy(&pbody.timestamp, p, IEEE802_11_TSTAMP_LEN); offset += IEEE802_11_TSTAMP_LEN; length -= IEEE802_11_TSTAMP_LEN; pbody.beacon_interval = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_BCNINT_LEN; length -= IEEE802_11_BCNINT_LEN; pbody.capability_info = EXTRACT_LE_16BITS(p+offset); offset += IEEE802_11_CAPINFO_LEN; length -= IEEE802_11_CAPINFO_LEN; ret = parse_elements(&pbody, p, offset, length); PRINT_SSID(pbody); PRINT_RATES(pbody); printf(" %s", CAPABILITY_ESS(pbody.capability_info) ? "ESS" : "IBSS"); PRINT_DS_CHANNEL(pbody); return ret; }
[ "static", "int", "handle_beacon", "(", "const", "u_char", "*", "p", ",", "u_int", "length", ")", "{", "struct", "mgmt_body_t", "pbody", ";", "int", "offset", "=", "0", ";", "int", "ret", ";", "memset", "(", "&", "pbody", ",", "0", ",", "sizeof", "(", "pbody", ")", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "IEEE802_11_TSTAMP_LEN", "+", "IEEE802_11_BCNINT_LEN", "+", "IEEE802_11_CAPINFO_LEN", ")", ")", "return", "0", ";", "if", "(", "length", "<", "IEEE802_11_TSTAMP_LEN", "+", "IEEE802_11_BCNINT_LEN", "+", "IEEE802_11_CAPINFO_LEN", ")", "return", "0", ";", "memcpy", "(", "&", "pbody", ".", "timestamp", ",", "p", ",", "IEEE802_11_TSTAMP_LEN", ")", ";", "offset", "+=", "IEEE802_11_TSTAMP_LEN", ";", "length", "-=", "IEEE802_11_TSTAMP_LEN", ";", "pbody", ".", "beacon_interval", "=", "EXTRACT_LE_16BITS", "(", "p", "+", "offset", ")", ";", "offset", "+=", "IEEE802_11_BCNINT_LEN", ";", "length", "-=", "IEEE802_11_BCNINT_LEN", ";", "pbody", ".", "capability_info", "=", "EXTRACT_LE_16BITS", "(", "p", "+", "offset", ")", ";", "offset", "+=", "IEEE802_11_CAPINFO_LEN", ";", "length", "-=", "IEEE802_11_CAPINFO_LEN", ";", "ret", "=", "parse_elements", "(", "&", "pbody", ",", "p", ",", "offset", ",", "length", ")", ";", "PRINT_SSID", "(", "pbody", ")", ";", "PRINT_RATES", "(", "pbody", ")", ";", "printf", "(", "\"", "\"", ",", "CAPABILITY_ESS", "(", "pbody", ".", "capability_info", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "PRINT_DS_CHANNEL", "(", "pbody", ")", ";", "return", "ret", ";", "}" ]
Print Handle functions for the management frame types
[ "Print", "Handle", "functions", "for", "the", "management", "frame", "types" ]
[]
[ { "param": "p", "type": "u_char" }, { "param": "length", "type": "u_int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "length", "type": "u_int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f2231d7dcc581396832721812acb65d1f384ba0
atrens/DragonFlyBSD-src
contrib/tcpdump/print-802_11.c
[ "BSD-3-Clause" ]
C
ctrl_body_print
int
static int ctrl_body_print(u_int16_t fc, const u_char *p) { switch (FC_SUBTYPE(fc)) { case CTRL_CONTROL_WRAPPER: printf("Control Wrapper"); /* XXX - requires special handling */ break; case CTRL_BAR: printf("BAR"); if (!TTEST2(*p, CTRL_BAR_HDRLEN)) return 0; if (!eflag) printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", etheraddr_string(((const struct ctrl_bar_t *)p)->ra), etheraddr_string(((const struct ctrl_bar_t *)p)->ta), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); break; case CTRL_BA: printf("BA"); if (!TTEST2(*p, CTRL_BA_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_ba_t *)p)->ra)); break; case CTRL_PS_POLL: printf("Power Save-Poll"); if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN)) return 0; printf(" AID(%x)", EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))); break; case CTRL_RTS: printf("Request-To-Send"); if (!TTEST2(*p, CTRL_RTS_HDRLEN)) return 0; if (!eflag) printf(" TA:%s ", etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); break; case CTRL_CTS: printf("Clear-To-Send"); if (!TTEST2(*p, CTRL_CTS_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); break; case CTRL_ACK: printf("Acknowledgment"); if (!TTEST2(*p, CTRL_ACK_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); break; case CTRL_CF_END: printf("CF-End"); if (!TTEST2(*p, CTRL_END_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_t *)p)->ra)); break; case CTRL_END_ACK: printf("CF-End+CF-Ack"); if (!TTEST2(*p, CTRL_END_ACK_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra)); break; default: printf("Unknown Ctrl Subtype"); } return 1; }
/********************************************************************************* * Handles printing all the control frame types *********************************************************************************/
Handles printing all the control frame types
[ "Handles", "printing", "all", "the", "control", "frame", "types" ]
static int ctrl_body_print(u_int16_t fc, const u_char *p) { switch (FC_SUBTYPE(fc)) { case CTRL_CONTROL_WRAPPER: printf("Control Wrapper"); break; case CTRL_BAR: printf("BAR"); if (!TTEST2(*p, CTRL_BAR_HDRLEN)) return 0; if (!eflag) printf(" RA:%s TA:%s CTL(%x) SEQ(%u) ", etheraddr_string(((const struct ctrl_bar_t *)p)->ra), etheraddr_string(((const struct ctrl_bar_t *)p)->ta), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->ctl)), EXTRACT_LE_16BITS(&(((const struct ctrl_bar_t *)p)->seq))); break; case CTRL_BA: printf("BA"); if (!TTEST2(*p, CTRL_BA_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_ba_t *)p)->ra)); break; case CTRL_PS_POLL: printf("Power Save-Poll"); if (!TTEST2(*p, CTRL_PS_POLL_HDRLEN)) return 0; printf(" AID(%x)", EXTRACT_LE_16BITS(&(((const struct ctrl_ps_poll_t *)p)->aid))); break; case CTRL_RTS: printf("Request-To-Send"); if (!TTEST2(*p, CTRL_RTS_HDRLEN)) return 0; if (!eflag) printf(" TA:%s ", etheraddr_string(((const struct ctrl_rts_t *)p)->ta)); break; case CTRL_CTS: printf("Clear-To-Send"); if (!TTEST2(*p, CTRL_CTS_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_cts_t *)p)->ra)); break; case CTRL_ACK: printf("Acknowledgment"); if (!TTEST2(*p, CTRL_ACK_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_ack_t *)p)->ra)); break; case CTRL_CF_END: printf("CF-End"); if (!TTEST2(*p, CTRL_END_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_t *)p)->ra)); break; case CTRL_END_ACK: printf("CF-End+CF-Ack"); if (!TTEST2(*p, CTRL_END_ACK_HDRLEN)) return 0; if (!eflag) printf(" RA:%s ", etheraddr_string(((const struct ctrl_end_ack_t *)p)->ra)); break; default: printf("Unknown Ctrl Subtype"); } return 1; }
[ "static", "int", "ctrl_body_print", "(", "u_int16_t", "fc", ",", "const", "u_char", "*", "p", ")", "{", "switch", "(", "FC_SUBTYPE", "(", "fc", ")", ")", "{", "case", "CTRL_CONTROL_WRAPPER", ":", "printf", "(", "\"", "\"", ")", ";", "break", ";", "case", "CTRL_BAR", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_BAR_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_bar_t", "*", ")", "p", ")", "->", "ra", ")", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_bar_t", "*", ")", "p", ")", "->", "ta", ")", ",", "EXTRACT_LE_16BITS", "(", "&", "(", "(", "(", "const", "struct", "ctrl_bar_t", "*", ")", "p", ")", "->", "ctl", ")", ")", ",", "EXTRACT_LE_16BITS", "(", "&", "(", "(", "(", "const", "struct", "ctrl_bar_t", "*", ")", "p", ")", "->", "seq", ")", ")", ")", ";", "break", ";", "case", "CTRL_BA", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_BA_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_ba_t", "*", ")", "p", ")", "->", "ra", ")", ")", ";", "break", ";", "case", "CTRL_PS_POLL", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_PS_POLL_HDRLEN", ")", ")", "return", "0", ";", "printf", "(", "\"", "\"", ",", "EXTRACT_LE_16BITS", "(", "&", "(", "(", "(", "const", "struct", "ctrl_ps_poll_t", "*", ")", "p", ")", "->", "aid", ")", ")", ")", ";", "break", ";", "case", "CTRL_RTS", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_RTS_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_rts_t", "*", ")", "p", ")", "->", "ta", ")", ")", ";", "break", ";", "case", "CTRL_CTS", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_CTS_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_cts_t", "*", ")", "p", ")", "->", "ra", ")", ")", ";", "break", ";", "case", "CTRL_ACK", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_ACK_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_ack_t", "*", ")", "p", ")", "->", "ra", ")", ")", ";", "break", ";", "case", "CTRL_CF_END", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_END_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_end_t", "*", ")", "p", ")", "->", "ra", ")", ")", ";", "break", ";", "case", "CTRL_END_ACK", ":", "printf", "(", "\"", "\"", ")", ";", "if", "(", "!", "TTEST2", "(", "*", "p", ",", "CTRL_END_ACK_HDRLEN", ")", ")", "return", "0", ";", "if", "(", "!", "eflag", ")", "printf", "(", "\"", "\"", ",", "etheraddr_string", "(", "(", "(", "const", "struct", "ctrl_end_ack_t", "*", ")", "p", ")", "->", "ra", ")", ")", ";", "break", ";", "default", ":", "printf", "(", "\"", "\"", ")", ";", "}", "return", "1", ";", "}" ]
Handles printing all the control frame types
[ "Handles", "printing", "all", "the", "control", "frame", "types" ]
[ "/* XXX - requires special handling */" ]
[ { "param": "fc", "type": "u_int16_t" }, { "param": "p", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fc", "type": "u_int16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f2231d7dcc581396832721812acb65d1f384ba0
atrens/DragonFlyBSD-src
contrib/tcpdump/print-802_11.c
[ "BSD-3-Clause" ]
C
ieee802_11_if_print
u_int
u_int ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_print(p, h->len, h->caplen, 0, 0); }
/* * This is the top level routine of the printer. 'p' points * to the 802.11 header of the packet, 'h->ts' is the timestamp, * 'h->len' is the length of the packet off the wire, and 'h->caplen' * is the number of bytes actually captured. */
This is the top level routine of the printer.
[ "This", "is", "the", "top", "level", "routine", "of", "the", "printer", "." ]
u_int ieee802_11_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_print(p, h->len, h->caplen, 0, 0); }
[ "u_int", "ieee802_11_if_print", "(", "const", "struct", "pcap_pkthdr", "*", "h", ",", "const", "u_char", "*", "p", ")", "{", "return", "ieee802_11_print", "(", "p", ",", "h", "->", "len", ",", "h", "->", "caplen", ",", "0", ",", "0", ")", ";", "}" ]
This is the top level routine of the printer.
[ "This", "is", "the", "top", "level", "routine", "of", "the", "printer", "." ]
[]
[ { "param": "h", "type": "struct pcap_pkthdr" }, { "param": "p", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "h", "type": "struct pcap_pkthdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f2231d7dcc581396832721812acb65d1f384ba0
atrens/DragonFlyBSD-src
contrib/tcpdump/print-802_11.c
[ "BSD-3-Clause" ]
C
ieee802_11_radio_if_print
u_int
u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_radio_print(p, h->len, h->caplen); }
/* * For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra * header, containing information such as radio information. */
For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra header, containing information such as radio information.
[ "For", "DLT_IEEE802_11_RADIO", ";", "like", "DLT_IEEE802_11", "but", "with", "an", "extra", "header", "containing", "information", "such", "as", "radio", "information", "." ]
u_int ieee802_11_radio_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_radio_print(p, h->len, h->caplen); }
[ "u_int", "ieee802_11_radio_if_print", "(", "const", "struct", "pcap_pkthdr", "*", "h", ",", "const", "u_char", "*", "p", ")", "{", "return", "ieee802_11_radio_print", "(", "p", ",", "h", "->", "len", ",", "h", "->", "caplen", ")", ";", "}" ]
For DLT_IEEE802_11_RADIO; like DLT_IEEE802_11, but with an extra header, containing information such as radio information.
[ "For", "DLT_IEEE802_11_RADIO", ";", "like", "DLT_IEEE802_11", "but", "with", "an", "extra", "header", "containing", "information", "such", "as", "radio", "information", "." ]
[]
[ { "param": "h", "type": "struct pcap_pkthdr" }, { "param": "p", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "h", "type": "struct pcap_pkthdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f2231d7dcc581396832721812acb65d1f384ba0
atrens/DragonFlyBSD-src
contrib/tcpdump/print-802_11.c
[ "BSD-3-Clause" ]
C
ieee802_11_radio_avs_if_print
u_int
u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_avs_radio_print(p, h->len, h->caplen); }
/* * For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an * extra header, containing information such as radio information, * which we currently ignore. */
For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an extra header, containing information such as radio information, which we currently ignore.
[ "For", "DLT_IEEE802_11_RADIO_AVS", ";", "like", "DLT_IEEE802_11", "but", "with", "an", "extra", "header", "containing", "information", "such", "as", "radio", "information", "which", "we", "currently", "ignore", "." ]
u_int ieee802_11_radio_avs_if_print(const struct pcap_pkthdr *h, const u_char *p) { return ieee802_11_avs_radio_print(p, h->len, h->caplen); }
[ "u_int", "ieee802_11_radio_avs_if_print", "(", "const", "struct", "pcap_pkthdr", "*", "h", ",", "const", "u_char", "*", "p", ")", "{", "return", "ieee802_11_avs_radio_print", "(", "p", ",", "h", "->", "len", ",", "h", "->", "caplen", ")", ";", "}" ]
For DLT_IEEE802_11_RADIO_AVS; like DLT_IEEE802_11, but with an extra header, containing information such as radio information, which we currently ignore.
[ "For", "DLT_IEEE802_11_RADIO_AVS", ";", "like", "DLT_IEEE802_11", "but", "with", "an", "extra", "header", "containing", "information", "such", "as", "radio", "information", "which", "we", "currently", "ignore", "." ]
[]
[ { "param": "h", "type": "struct pcap_pkthdr" }, { "param": "p", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "h", "type": "struct pcap_pkthdr", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcached_thread
void
static void vm_swapcached_thread(void) { enum { SWAPC_WRITING, SWAPC_CLEANING } state = SWAPC_WRITING; enum { SWAPB_BURSTING, SWAPB_RECOVERING } burst = SWAPB_BURSTING; static struct vm_page page_marker[PQ_L2_SIZE]; static swmarker_t swmarker; static struct vm_object_hash *swindex; int q; /* * Thread setup */ curthread->td_flags |= TDF_SYSTHREAD; EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_kproc, swapcached_thread, SHUTDOWN_PRI_FIRST); EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_swapcache, NULL, SHUTDOWN_PRI_SECOND); /* * Initialize our marker for the inactive scan (SWAPC_WRITING) */ bzero(&page_marker, sizeof(page_marker)); for (q = 0; q < PQ_L2_SIZE; ++q) { page_marker[q].flags = PG_FICTITIOUS | PG_MARKER; page_marker[q].busy_count = PBUSY_LOCKED; page_marker[q].queue = PQ_INACTIVE + q; page_marker[q].pc = q; page_marker[q].wire_count = 1; vm_page_queues_spin_lock(PQ_INACTIVE + q); TAILQ_INSERT_HEAD( &vm_page_queues[PQ_INACTIVE + q].pl, &page_marker[q], pageq); vm_page_queues_spin_unlock(PQ_INACTIVE + q); } vm_swapcache_min_hysteresis = 1024; vm_swapcache_hysteresis = vm_swapcache_min_hysteresis; vm_swapcache_wtrigger = -vm_swapcache_hysteresis; /* * Initialize our marker for the vm_object scan (SWAPC_CLEANING) */ bzero(&swmarker, sizeof(swmarker)); swmarker.dummy_obj.type = OBJT_MARKER; swindex = &vm_object_hash[0]; lwkt_gettoken(&swindex->token); TAILQ_INSERT_HEAD(&swindex->list, &swmarker.dummy_obj, object_entry); lwkt_reltoken(&swindex->token); for (;;) { int reached_end; int scount; int count; /* * Handle shutdown */ kproc_suspend_loop(); /* * Check every 5 seconds when not enabled or if no swap * is present. */ if ((vm_swapcache_data_enable == 0 && vm_swapcache_meta_enable == 0 && vm_swap_cache_use <= SWAPMAX(0)) || vm_swap_max == 0) { tsleep(&vm_swapcache_sleep, 0, "csleep", hz * 5); continue; } /* * Polling rate when enabled is approximately 10 hz. */ tsleep(&vm_swapcache_sleep, 0, "csleep", hz / 10); /* * State hysteresis. Generate write activity up to 75% of * swap, then clean out swap assignments down to 70%, then * repeat. */ if (state == SWAPC_WRITING) { if (vm_swap_cache_use > SWAPMAX(0)) state = SWAPC_CLEANING; } else { if (vm_swap_cache_use < SWAPMAX(-10)) state = SWAPC_WRITING; } /* * We are allowed to continue accumulating burst value * in either state. Allow the user to set curburst > maxburst * for the initial load-in. */ if (vm_swapcache_curburst < vm_swapcache_maxburst) { vm_swapcache_curburst += vm_swapcache_accrate / 10; if (vm_swapcache_curburst > vm_swapcache_maxburst) vm_swapcache_curburst = vm_swapcache_maxburst; } /* * We don't want to nickle-and-dime the scan as that will * create unnecessary fragmentation. The minimum burst * is one-seconds worth of accumulation. */ if (state != SWAPC_WRITING) { vm_swapcache_cleaning(&swmarker, &swindex); continue; } if (vm_swapcache_curburst < vm_swapcache_accrate) continue; reached_end = 0; count = vm_swapcache_maxlaunder / PQ_L2_SIZE + 2; scount = vm_swapcache_maxscan / PQ_L2_SIZE + 2; if (burst == SWAPB_BURSTING) { if (vm_swapcache_writing_heuristic()) { for (q = 0; q < PQ_L2_SIZE; ++q) { reached_end += vm_swapcache_writing( &page_marker[q], count, scount); } } if (vm_swapcache_curburst <= 0) burst = SWAPB_RECOVERING; } else if (vm_swapcache_curburst > vm_swapcache_minburst) { if (vm_swapcache_writing_heuristic()) { for (q = 0; q < PQ_L2_SIZE; ++q) { reached_end += vm_swapcache_writing( &page_marker[q], count, scount); } } burst = SWAPB_BURSTING; } if (reached_end == PQ_L2_SIZE) { vm_swapcache_wtrigger = -vm_swapcache_hysteresis; } } /* * Cleanup (NOT REACHED) */ for (q = 0; q < PQ_L2_SIZE; ++q) { vm_page_queues_spin_lock(PQ_INACTIVE + q); TAILQ_REMOVE( &vm_page_queues[PQ_INACTIVE + q].pl, &page_marker[q], pageq); vm_page_queues_spin_unlock(PQ_INACTIVE + q); } lwkt_gettoken(&swindex->token); TAILQ_REMOVE(&swindex->list, &swmarker.dummy_obj, object_entry); lwkt_reltoken(&swindex->token); }
/* * vm_swapcached is the high level pageout daemon. * * No requirements. */
vm_swapcached is the high level pageout daemon. No requirements.
[ "vm_swapcached", "is", "the", "high", "level", "pageout", "daemon", ".", "No", "requirements", "." ]
static void vm_swapcached_thread(void) { enum { SWAPC_WRITING, SWAPC_CLEANING } state = SWAPC_WRITING; enum { SWAPB_BURSTING, SWAPB_RECOVERING } burst = SWAPB_BURSTING; static struct vm_page page_marker[PQ_L2_SIZE]; static swmarker_t swmarker; static struct vm_object_hash *swindex; int q; curthread->td_flags |= TDF_SYSTHREAD; EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_kproc, swapcached_thread, SHUTDOWN_PRI_FIRST); EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_swapcache, NULL, SHUTDOWN_PRI_SECOND); bzero(&page_marker, sizeof(page_marker)); for (q = 0; q < PQ_L2_SIZE; ++q) { page_marker[q].flags = PG_FICTITIOUS | PG_MARKER; page_marker[q].busy_count = PBUSY_LOCKED; page_marker[q].queue = PQ_INACTIVE + q; page_marker[q].pc = q; page_marker[q].wire_count = 1; vm_page_queues_spin_lock(PQ_INACTIVE + q); TAILQ_INSERT_HEAD( &vm_page_queues[PQ_INACTIVE + q].pl, &page_marker[q], pageq); vm_page_queues_spin_unlock(PQ_INACTIVE + q); } vm_swapcache_min_hysteresis = 1024; vm_swapcache_hysteresis = vm_swapcache_min_hysteresis; vm_swapcache_wtrigger = -vm_swapcache_hysteresis; bzero(&swmarker, sizeof(swmarker)); swmarker.dummy_obj.type = OBJT_MARKER; swindex = &vm_object_hash[0]; lwkt_gettoken(&swindex->token); TAILQ_INSERT_HEAD(&swindex->list, &swmarker.dummy_obj, object_entry); lwkt_reltoken(&swindex->token); for (;;) { int reached_end; int scount; int count; kproc_suspend_loop(); if ((vm_swapcache_data_enable == 0 && vm_swapcache_meta_enable == 0 && vm_swap_cache_use <= SWAPMAX(0)) || vm_swap_max == 0) { tsleep(&vm_swapcache_sleep, 0, "csleep", hz * 5); continue; } tsleep(&vm_swapcache_sleep, 0, "csleep", hz / 10); if (state == SWAPC_WRITING) { if (vm_swap_cache_use > SWAPMAX(0)) state = SWAPC_CLEANING; } else { if (vm_swap_cache_use < SWAPMAX(-10)) state = SWAPC_WRITING; } if (vm_swapcache_curburst < vm_swapcache_maxburst) { vm_swapcache_curburst += vm_swapcache_accrate / 10; if (vm_swapcache_curburst > vm_swapcache_maxburst) vm_swapcache_curburst = vm_swapcache_maxburst; } if (state != SWAPC_WRITING) { vm_swapcache_cleaning(&swmarker, &swindex); continue; } if (vm_swapcache_curburst < vm_swapcache_accrate) continue; reached_end = 0; count = vm_swapcache_maxlaunder / PQ_L2_SIZE + 2; scount = vm_swapcache_maxscan / PQ_L2_SIZE + 2; if (burst == SWAPB_BURSTING) { if (vm_swapcache_writing_heuristic()) { for (q = 0; q < PQ_L2_SIZE; ++q) { reached_end += vm_swapcache_writing( &page_marker[q], count, scount); } } if (vm_swapcache_curburst <= 0) burst = SWAPB_RECOVERING; } else if (vm_swapcache_curburst > vm_swapcache_minburst) { if (vm_swapcache_writing_heuristic()) { for (q = 0; q < PQ_L2_SIZE; ++q) { reached_end += vm_swapcache_writing( &page_marker[q], count, scount); } } burst = SWAPB_BURSTING; } if (reached_end == PQ_L2_SIZE) { vm_swapcache_wtrigger = -vm_swapcache_hysteresis; } } for (q = 0; q < PQ_L2_SIZE; ++q) { vm_page_queues_spin_lock(PQ_INACTIVE + q); TAILQ_REMOVE( &vm_page_queues[PQ_INACTIVE + q].pl, &page_marker[q], pageq); vm_page_queues_spin_unlock(PQ_INACTIVE + q); } lwkt_gettoken(&swindex->token); TAILQ_REMOVE(&swindex->list, &swmarker.dummy_obj, object_entry); lwkt_reltoken(&swindex->token); }
[ "static", "void", "vm_swapcached_thread", "(", "void", ")", "{", "enum", "{", "SWAPC_WRITING", ",", "SWAPC_CLEANING", "}", "state", "=", "SWAPC_WRITING", ";", "enum", "{", "SWAPB_BURSTING", ",", "SWAPB_RECOVERING", "}", "burst", "=", "SWAPB_BURSTING", ";", "static", "struct", "vm_page", "page_marker", "[", "PQ_L2_SIZE", "]", ";", "static", "swmarker_t", "swmarker", ";", "static", "struct", "vm_object_hash", "*", "swindex", ";", "int", "q", ";", "curthread", "->", "td_flags", "|=", "TDF_SYSTHREAD", ";", "EVENTHANDLER_REGISTER", "(", "shutdown_pre_sync", ",", "shutdown_kproc", ",", "swapcached_thread", ",", "SHUTDOWN_PRI_FIRST", ")", ";", "EVENTHANDLER_REGISTER", "(", "shutdown_pre_sync", ",", "shutdown_swapcache", ",", "NULL", ",", "SHUTDOWN_PRI_SECOND", ")", ";", "bzero", "(", "&", "page_marker", ",", "sizeof", "(", "page_marker", ")", ")", ";", "for", "(", "q", "=", "0", ";", "q", "<", "PQ_L2_SIZE", ";", "++", "q", ")", "{", "page_marker", "[", "q", "]", ".", "flags", "=", "PG_FICTITIOUS", "|", "PG_MARKER", ";", "page_marker", "[", "q", "]", ".", "busy_count", "=", "PBUSY_LOCKED", ";", "page_marker", "[", "q", "]", ".", "queue", "=", "PQ_INACTIVE", "+", "q", ";", "page_marker", "[", "q", "]", ".", "pc", "=", "q", ";", "page_marker", "[", "q", "]", ".", "wire_count", "=", "1", ";", "vm_page_queues_spin_lock", "(", "PQ_INACTIVE", "+", "q", ")", ";", "TAILQ_INSERT_HEAD", "(", "&", "vm_page_queues", "[", "PQ_INACTIVE", "+", "q", "]", ".", "pl", ",", "&", "page_marker", "[", "q", "]", ",", "pageq", ")", ";", "vm_page_queues_spin_unlock", "(", "PQ_INACTIVE", "+", "q", ")", ";", "}", "vm_swapcache_min_hysteresis", "=", "1024", ";", "vm_swapcache_hysteresis", "=", "vm_swapcache_min_hysteresis", ";", "vm_swapcache_wtrigger", "=", "-", "vm_swapcache_hysteresis", ";", "bzero", "(", "&", "swmarker", ",", "sizeof", "(", "swmarker", ")", ")", ";", "swmarker", ".", "dummy_obj", ".", "type", "=", "OBJT_MARKER", ";", "swindex", "=", "&", "vm_object_hash", "[", "0", "]", ";", "lwkt_gettoken", "(", "&", "swindex", "->", "token", ")", ";", "TAILQ_INSERT_HEAD", "(", "&", "swindex", "->", "list", ",", "&", "swmarker", ".", "dummy_obj", ",", "object_entry", ")", ";", "lwkt_reltoken", "(", "&", "swindex", "->", "token", ")", ";", "for", "(", ";", ";", ")", "{", "int", "reached_end", ";", "int", "scount", ";", "int", "count", ";", "kproc_suspend_loop", "(", ")", ";", "if", "(", "(", "vm_swapcache_data_enable", "==", "0", "&&", "vm_swapcache_meta_enable", "==", "0", "&&", "vm_swap_cache_use", "<=", "SWAPMAX", "(", "0", ")", ")", "||", "vm_swap_max", "==", "0", ")", "{", "tsleep", "(", "&", "vm_swapcache_sleep", ",", "0", ",", "\"", "\"", ",", "hz", "*", "5", ")", ";", "continue", ";", "}", "tsleep", "(", "&", "vm_swapcache_sleep", ",", "0", ",", "\"", "\"", ",", "hz", "/", "10", ")", ";", "if", "(", "state", "==", "SWAPC_WRITING", ")", "{", "if", "(", "vm_swap_cache_use", ">", "SWAPMAX", "(", "0", ")", ")", "state", "=", "SWAPC_CLEANING", ";", "}", "else", "{", "if", "(", "vm_swap_cache_use", "<", "SWAPMAX", "(", "-10", ")", ")", "state", "=", "SWAPC_WRITING", ";", "}", "if", "(", "vm_swapcache_curburst", "<", "vm_swapcache_maxburst", ")", "{", "vm_swapcache_curburst", "+=", "vm_swapcache_accrate", "/", "10", ";", "if", "(", "vm_swapcache_curburst", ">", "vm_swapcache_maxburst", ")", "vm_swapcache_curburst", "=", "vm_swapcache_maxburst", ";", "}", "if", "(", "state", "!=", "SWAPC_WRITING", ")", "{", "vm_swapcache_cleaning", "(", "&", "swmarker", ",", "&", "swindex", ")", ";", "continue", ";", "}", "if", "(", "vm_swapcache_curburst", "<", "vm_swapcache_accrate", ")", "continue", ";", "reached_end", "=", "0", ";", "count", "=", "vm_swapcache_maxlaunder", "/", "PQ_L2_SIZE", "+", "2", ";", "scount", "=", "vm_swapcache_maxscan", "/", "PQ_L2_SIZE", "+", "2", ";", "if", "(", "burst", "==", "SWAPB_BURSTING", ")", "{", "if", "(", "vm_swapcache_writing_heuristic", "(", ")", ")", "{", "for", "(", "q", "=", "0", ";", "q", "<", "PQ_L2_SIZE", ";", "++", "q", ")", "{", "reached_end", "+=", "vm_swapcache_writing", "(", "&", "page_marker", "[", "q", "]", ",", "count", ",", "scount", ")", ";", "}", "}", "if", "(", "vm_swapcache_curburst", "<=", "0", ")", "burst", "=", "SWAPB_RECOVERING", ";", "}", "else", "if", "(", "vm_swapcache_curburst", ">", "vm_swapcache_minburst", ")", "{", "if", "(", "vm_swapcache_writing_heuristic", "(", ")", ")", "{", "for", "(", "q", "=", "0", ";", "q", "<", "PQ_L2_SIZE", ";", "++", "q", ")", "{", "reached_end", "+=", "vm_swapcache_writing", "(", "&", "page_marker", "[", "q", "]", ",", "count", ",", "scount", ")", ";", "}", "}", "burst", "=", "SWAPB_BURSTING", ";", "}", "if", "(", "reached_end", "==", "PQ_L2_SIZE", ")", "{", "vm_swapcache_wtrigger", "=", "-", "vm_swapcache_hysteresis", ";", "}", "}", "for", "(", "q", "=", "0", ";", "q", "<", "PQ_L2_SIZE", ";", "++", "q", ")", "{", "vm_page_queues_spin_lock", "(", "PQ_INACTIVE", "+", "q", ")", ";", "TAILQ_REMOVE", "(", "&", "vm_page_queues", "[", "PQ_INACTIVE", "+", "q", "]", ".", "pl", ",", "&", "page_marker", "[", "q", "]", ",", "pageq", ")", ";", "vm_page_queues_spin_unlock", "(", "PQ_INACTIVE", "+", "q", ")", ";", "}", "lwkt_gettoken", "(", "&", "swindex", "->", "token", ")", ";", "TAILQ_REMOVE", "(", "&", "swindex", "->", "list", ",", "&", "swmarker", ".", "dummy_obj", ",", "object_entry", ")", ";", "lwkt_reltoken", "(", "&", "swindex", "->", "token", ")", ";", "}" ]
vm_swapcached is the high level pageout daemon.
[ "vm_swapcached", "is", "the", "high", "level", "pageout", "daemon", "." ]
[ "/*\n\t * Thread setup\n\t */", "/*\n\t * Initialize our marker for the inactive scan (SWAPC_WRITING)\n\t */", "/*\n\t * Initialize our marker for the vm_object scan (SWAPC_CLEANING)\n\t */", "/*\n\t\t * Handle shutdown\n\t\t */", "/*\n\t\t * Check every 5 seconds when not enabled or if no swap\n\t\t * is present.\n\t\t */", "/*\n\t\t * Polling rate when enabled is approximately 10 hz.\n\t\t */", "/*\n\t\t * State hysteresis. Generate write activity up to 75% of\n\t\t * swap, then clean out swap assignments down to 70%, then\n\t\t * repeat.\n\t\t */", "/*\n\t\t * We are allowed to continue accumulating burst value\n\t\t * in either state. Allow the user to set curburst > maxburst\n\t\t * for the initial load-in.\n\t\t */", "/*\n\t\t * We don't want to nickle-and-dime the scan as that will\n\t\t * create unnecessary fragmentation. The minimum burst\n\t\t * is one-seconds worth of accumulation.\n\t\t */", "/*\n\t * Cleanup (NOT REACHED)\n\t */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcache_writing_heuristic
int
static int vm_swapcache_writing_heuristic(void) { int hyst; int q; long adds; hyst = vmstats.v_inactive_count / 4; if (hyst < vm_swapcache_min_hysteresis) hyst = vm_swapcache_min_hysteresis; cpu_ccfence(); vm_swapcache_hysteresis = hyst; adds = 0; for (q = PQ_INACTIVE; q < PQ_INACTIVE + PQ_L2_SIZE; ++q) { adds += atomic_swap_long(&vm_page_queues[q].adds, 0); } vm_swapcache_wtrigger += adds; if (vm_swapcache_wtrigger < -hyst) vm_swapcache_wtrigger = -hyst; return (vm_swapcache_wtrigger >= 0); }
/* * Deal with an overflow of the heuristic counter or if the user * manually changes the hysteresis. * * Try to avoid small incremental pageouts by waiting for enough * pages to buildup in the inactive queue to hopefully get a good * burst in. This heuristic is bumped by the VM system and reset * when our scan hits the end of the queue. * * Return TRUE if we need to take a writing pass. */
Deal with an overflow of the heuristic counter or if the user manually changes the hysteresis. Try to avoid small incremental pageouts by waiting for enough pages to buildup in the inactive queue to hopefully get a good burst in. This heuristic is bumped by the VM system and reset when our scan hits the end of the queue. Return TRUE if we need to take a writing pass.
[ "Deal", "with", "an", "overflow", "of", "the", "heuristic", "counter", "or", "if", "the", "user", "manually", "changes", "the", "hysteresis", ".", "Try", "to", "avoid", "small", "incremental", "pageouts", "by", "waiting", "for", "enough", "pages", "to", "buildup", "in", "the", "inactive", "queue", "to", "hopefully", "get", "a", "good", "burst", "in", ".", "This", "heuristic", "is", "bumped", "by", "the", "VM", "system", "and", "reset", "when", "our", "scan", "hits", "the", "end", "of", "the", "queue", ".", "Return", "TRUE", "if", "we", "need", "to", "take", "a", "writing", "pass", "." ]
static int vm_swapcache_writing_heuristic(void) { int hyst; int q; long adds; hyst = vmstats.v_inactive_count / 4; if (hyst < vm_swapcache_min_hysteresis) hyst = vm_swapcache_min_hysteresis; cpu_ccfence(); vm_swapcache_hysteresis = hyst; adds = 0; for (q = PQ_INACTIVE; q < PQ_INACTIVE + PQ_L2_SIZE; ++q) { adds += atomic_swap_long(&vm_page_queues[q].adds, 0); } vm_swapcache_wtrigger += adds; if (vm_swapcache_wtrigger < -hyst) vm_swapcache_wtrigger = -hyst; return (vm_swapcache_wtrigger >= 0); }
[ "static", "int", "vm_swapcache_writing_heuristic", "(", "void", ")", "{", "int", "hyst", ";", "int", "q", ";", "long", "adds", ";", "hyst", "=", "vmstats", ".", "v_inactive_count", "/", "4", ";", "if", "(", "hyst", "<", "vm_swapcache_min_hysteresis", ")", "hyst", "=", "vm_swapcache_min_hysteresis", ";", "cpu_ccfence", "(", ")", ";", "vm_swapcache_hysteresis", "=", "hyst", ";", "adds", "=", "0", ";", "for", "(", "q", "=", "PQ_INACTIVE", ";", "q", "<", "PQ_INACTIVE", "+", "PQ_L2_SIZE", ";", "++", "q", ")", "{", "adds", "+=", "atomic_swap_long", "(", "&", "vm_page_queues", "[", "q", "]", ".", "adds", ",", "0", ")", ";", "}", "vm_swapcache_wtrigger", "+=", "adds", ";", "if", "(", "vm_swapcache_wtrigger", "<", "-", "hyst", ")", "vm_swapcache_wtrigger", "=", "-", "hyst", ";", "return", "(", "vm_swapcache_wtrigger", ">=", "0", ")", ";", "}" ]
Deal with an overflow of the heuristic counter or if the user manually changes the hysteresis.
[ "Deal", "with", "an", "overflow", "of", "the", "heuristic", "counter", "or", "if", "the", "user", "manually", "changes", "the", "hysteresis", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcache_writing
int
static int vm_swapcache_writing(vm_page_t marker, int count, int scount) { vm_object_t object; struct vnode *vp; vm_page_t m; int isblkdev; /* * Scan the inactive queue from our marker to locate * suitable pages to push to the swap cache. * * We are looking for clean vnode-backed pages. */ vm_page_queues_spin_lock(marker->queue); while ((m = TAILQ_NEXT(marker, pageq)) != NULL && count > 0 && scount-- > 0) { KKASSERT(m->queue == marker->queue); /* * Stop using swap if paniced, dumping, or dumped. * Don't try to write if our curburst has been exhausted. */ if (panicstr || dumping) break; if (vm_swapcache_curburst < 0) break; /* * Move marker */ TAILQ_REMOVE( &vm_page_queues[marker->queue].pl, marker, pageq); TAILQ_INSERT_AFTER( &vm_page_queues[marker->queue].pl, m, marker, pageq); /* * Ignore markers and ignore pages that already have a swap * assignment. */ if (m->flags & (PG_MARKER | PG_SWAPPED)) continue; if (vm_page_busy_try(m, TRUE)) continue; vm_page_queues_spin_unlock(marker->queue); if ((object = m->object) == NULL) { vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } vm_object_hold(object); if (m->object != object) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_test(m)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } vp = object->handle; if (vp == NULL) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } switch(vp->v_type) { case VREG: /* * PG_NOTMETA generically means 'don't swapcache this', * and HAMMER will set this for regular data buffers * (and leave it unset for meta-data buffers) as * appropriate when double buffering is enabled. */ if (m->flags & PG_NOTMETA) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } /* * If data_enable is 0 do not try to swapcache data. * If use_chflags is set then only swapcache data for * VSWAPCACHE marked vnodes, otherwise any vnode. */ if (vm_swapcache_data_enable == 0 || ((vp->v_flag & VSWAPCACHE) == 0 && vm_swapcache_use_chflags)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_maxfilesize && object->size > (vm_swapcache_maxfilesize >> PAGE_SHIFT)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } isblkdev = 0; break; case VCHR: /* * PG_NOTMETA generically means 'don't swapcache this', * and HAMMER will set this for regular data buffers * (and leave it unset for meta-data buffers) as * appropriate when double buffering is enabled. */ if (m->flags & PG_NOTMETA) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_meta_enable == 0) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } isblkdev = 1; break; default: vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } /* * Assign swap and initiate I/O. * * (adjust for the --count which also occurs in the loop) */ count -= vm_swapcached_flush(m, isblkdev); /* * Setup for next loop using marker. */ vm_object_drop(object); vm_page_queues_spin_lock(marker->queue); } /* * The marker could wind up at the end, which is ok. If we hit the * end of the list adjust the heuristic. * * Earlier inactive pages that were dirty and become clean * are typically moved to the end of PQ_INACTIVE by virtue * of vfs_vmio_release() when they become unwired from the * buffer cache. */ vm_page_queues_spin_unlock(marker->queue); /* * m invalid but can be used to test for NULL */ return (m == NULL); }
/* * Take a writing pass on one of the inactive queues, return non-zero if * we hit the end of the queue. */
Take a writing pass on one of the inactive queues, return non-zero if we hit the end of the queue.
[ "Take", "a", "writing", "pass", "on", "one", "of", "the", "inactive", "queues", "return", "non", "-", "zero", "if", "we", "hit", "the", "end", "of", "the", "queue", "." ]
static int vm_swapcache_writing(vm_page_t marker, int count, int scount) { vm_object_t object; struct vnode *vp; vm_page_t m; int isblkdev; vm_page_queues_spin_lock(marker->queue); while ((m = TAILQ_NEXT(marker, pageq)) != NULL && count > 0 && scount-- > 0) { KKASSERT(m->queue == marker->queue); if (panicstr || dumping) break; if (vm_swapcache_curburst < 0) break; TAILQ_REMOVE( &vm_page_queues[marker->queue].pl, marker, pageq); TAILQ_INSERT_AFTER( &vm_page_queues[marker->queue].pl, m, marker, pageq); if (m->flags & (PG_MARKER | PG_SWAPPED)) continue; if (vm_page_busy_try(m, TRUE)) continue; vm_page_queues_spin_unlock(marker->queue); if ((object = m->object) == NULL) { vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } vm_object_hold(object); if (m->object != object) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_test(m)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } vp = object->handle; if (vp == NULL) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } switch(vp->v_type) { case VREG: if (m->flags & PG_NOTMETA) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_data_enable == 0 || ((vp->v_flag & VSWAPCACHE) == 0 && vm_swapcache_use_chflags)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_maxfilesize && object->size > (vm_swapcache_maxfilesize >> PAGE_SHIFT)) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } isblkdev = 0; break; case VCHR: if (m->flags & PG_NOTMETA) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } if (vm_swapcache_meta_enable == 0) { vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } isblkdev = 1; break; default: vm_object_drop(object); vm_page_wakeup(m); vm_page_queues_spin_lock(marker->queue); continue; } count -= vm_swapcached_flush(m, isblkdev); vm_object_drop(object); vm_page_queues_spin_lock(marker->queue); } vm_page_queues_spin_unlock(marker->queue); return (m == NULL); }
[ "static", "int", "vm_swapcache_writing", "(", "vm_page_t", "marker", ",", "int", "count", ",", "int", "scount", ")", "{", "vm_object_t", "object", ";", "struct", "vnode", "*", "vp", ";", "vm_page_t", "m", ";", "int", "isblkdev", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "while", "(", "(", "m", "=", "TAILQ_NEXT", "(", "marker", ",", "pageq", ")", ")", "!=", "NULL", "&&", "count", ">", "0", "&&", "scount", "--", ">", "0", ")", "{", "KKASSERT", "(", "m", "->", "queue", "==", "marker", "->", "queue", ")", ";", "if", "(", "panicstr", "||", "dumping", ")", "break", ";", "if", "(", "vm_swapcache_curburst", "<", "0", ")", "break", ";", "TAILQ_REMOVE", "(", "&", "vm_page_queues", "[", "marker", "->", "queue", "]", ".", "pl", ",", "marker", ",", "pageq", ")", ";", "TAILQ_INSERT_AFTER", "(", "&", "vm_page_queues", "[", "marker", "->", "queue", "]", ".", "pl", ",", "m", ",", "marker", ",", "pageq", ")", ";", "if", "(", "m", "->", "flags", "&", "(", "PG_MARKER", "|", "PG_SWAPPED", ")", ")", "continue", ";", "if", "(", "vm_page_busy_try", "(", "m", ",", "TRUE", ")", ")", "continue", ";", "vm_page_queues_spin_unlock", "(", "marker", "->", "queue", ")", ";", "if", "(", "(", "object", "=", "m", "->", "object", ")", "==", "NULL", ")", "{", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "vm_object_hold", "(", "object", ")", ";", "if", "(", "m", "->", "object", "!=", "object", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "if", "(", "vm_swapcache_test", "(", "m", ")", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "vp", "=", "object", "->", "handle", ";", "if", "(", "vp", "==", "NULL", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "switch", "(", "vp", "->", "v_type", ")", "{", "case", "VREG", ":", "if", "(", "m", "->", "flags", "&", "PG_NOTMETA", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "if", "(", "vm_swapcache_data_enable", "==", "0", "||", "(", "(", "vp", "->", "v_flag", "&", "VSWAPCACHE", ")", "==", "0", "&&", "vm_swapcache_use_chflags", ")", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "if", "(", "vm_swapcache_maxfilesize", "&&", "object", "->", "size", ">", "(", "vm_swapcache_maxfilesize", ">>", "PAGE_SHIFT", ")", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "isblkdev", "=", "0", ";", "break", ";", "case", "VCHR", ":", "if", "(", "m", "->", "flags", "&", "PG_NOTMETA", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "if", "(", "vm_swapcache_meta_enable", "==", "0", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "isblkdev", "=", "1", ";", "break", ";", "default", ":", "vm_object_drop", "(", "object", ")", ";", "vm_page_wakeup", "(", "m", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "continue", ";", "}", "count", "-=", "vm_swapcached_flush", "(", "m", ",", "isblkdev", ")", ";", "vm_object_drop", "(", "object", ")", ";", "vm_page_queues_spin_lock", "(", "marker", "->", "queue", ")", ";", "}", "vm_page_queues_spin_unlock", "(", "marker", "->", "queue", ")", ";", "return", "(", "m", "==", "NULL", ")", ";", "}" ]
Take a writing pass on one of the inactive queues, return non-zero if we hit the end of the queue.
[ "Take", "a", "writing", "pass", "on", "one", "of", "the", "inactive", "queues", "return", "non", "-", "zero", "if", "we", "hit", "the", "end", "of", "the", "queue", "." ]
[ "/*\n\t * Scan the inactive queue from our marker to locate\n\t * suitable pages to push to the swap cache.\n\t *\n\t * We are looking for clean vnode-backed pages.\n\t */", "/*\n\t\t * Stop using swap if paniced, dumping, or dumped.\n\t\t * Don't try to write if our curburst has been exhausted.\n\t\t */", "/*\n\t\t * Move marker\n\t\t */", "/*\n\t\t * Ignore markers and ignore pages that already have a swap\n\t\t * assignment.\n\t\t */", "/*\n\t\t\t * PG_NOTMETA generically means 'don't swapcache this',\n\t\t\t * and HAMMER will set this for regular data buffers\n\t\t\t * (and leave it unset for meta-data buffers) as\n\t\t\t * appropriate when double buffering is enabled.\n\t\t\t */", "/*\n\t\t\t * If data_enable is 0 do not try to swapcache data.\n\t\t\t * If use_chflags is set then only swapcache data for\n\t\t\t * VSWAPCACHE marked vnodes, otherwise any vnode.\n\t\t\t */", "/*\n\t\t\t * PG_NOTMETA generically means 'don't swapcache this',\n\t\t\t * and HAMMER will set this for regular data buffers\n\t\t\t * (and leave it unset for meta-data buffers) as\n\t\t\t * appropriate when double buffering is enabled.\n\t\t\t */", "/*\n\t\t * Assign swap and initiate I/O.\n\t\t *\n\t\t * (adjust for the --count which also occurs in the loop)\n\t\t */", "/*\n\t\t * Setup for next loop using marker.\n\t\t */", "/*\n\t * The marker could wind up at the end, which is ok. If we hit the\n\t * end of the list adjust the heuristic.\n\t *\n\t * Earlier inactive pages that were dirty and become clean\n\t * are typically moved to the end of PQ_INACTIVE by virtue\n\t * of vfs_vmio_release() when they become unwired from the\n\t * buffer cache.\n\t */", "/*\n\t * m invalid but can be used to test for NULL\n\t */" ]
[ { "param": "marker", "type": "vm_page_t" }, { "param": "count", "type": "int" }, { "param": "scount", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "marker", "type": "vm_page_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scount", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcached_flush
int
static int vm_swapcached_flush(vm_page_t m, int isblkdev) { vm_object_t object; vm_page_t marray[SWAP_META_PAGES]; vm_pindex_t basei; int rtvals[SWAP_META_PAGES]; int x; int i; int j; int count; int error; vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); object = m->object; vm_object_hold(object); /* * Try to cluster around (m), keeping in mind that the swap pager * can only do SMAP_META_PAGES worth of continguous write. */ x = (int)m->pindex & SWAP_META_MASK; marray[x] = m; basei = m->pindex; vm_page_wakeup(m); for (i = x - 1; i >= 0; --i) { m = vm_page_lookup_busy_try(object, basei - x + i, TRUE, &error); if (error || m == NULL) break; if (vm_swapcache_test(m)) { vm_page_wakeup(m); break; } if (isblkdev && (m->flags & PG_NOTMETA)) { vm_page_wakeup(m); break; } vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); if (m->queue - m->pc == PQ_CACHE) { vm_page_unqueue_nowakeup(m); vm_page_deactivate(m); } marray[i] = m; vm_page_wakeup(m); } ++i; for (j = x + 1; j < SWAP_META_PAGES; ++j) { m = vm_page_lookup_busy_try(object, basei - x + j, TRUE, &error); if (error || m == NULL) break; if (vm_swapcache_test(m)) { vm_page_wakeup(m); break; } if (isblkdev && (m->flags & PG_NOTMETA)) { vm_page_wakeup(m); break; } vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); if (m->queue - m->pc == PQ_CACHE) { vm_page_unqueue_nowakeup(m); vm_page_deactivate(m); } marray[j] = m; vm_page_wakeup(m); } count = j - i; vm_object_pip_add(object, count); swap_pager_putpages(object, marray + i, count, FALSE, rtvals + i); vm_swapcache_write_count += count * PAGE_SIZE; vm_swapcache_curburst -= count * PAGE_SIZE; while (i < j) { if (rtvals[i] != VM_PAGER_PEND) { vm_page_busy_wait(marray[i], FALSE, "swppgfd"); vm_page_io_finish(marray[i]); vm_page_wakeup(marray[i]); vm_object_pip_wakeup(object); } ++i; } vm_object_drop(object); return(count); }
/* * Flush the specified page using the swap_pager. The page * must be busied by the caller and its disposition will become * the responsibility of this function. * * Try to collect surrounding pages, including pages which may * have already been assigned swap. Try to cluster within a * contiguous aligned SMAP_META_PAGES (typ 16 x PAGE_SIZE) block * to match what swap_pager_putpages() can do. * * We also want to try to match against the buffer cache blocksize * but we don't really know what it is here. Since the buffer cache * wires and unwires pages in groups the fact that we skip wired pages * should be sufficient. * * Returns a count of pages we might have flushed (minimum 1) */
Flush the specified page using the swap_pager. The page must be busied by the caller and its disposition will become the responsibility of this function. Try to collect surrounding pages, including pages which may have already been assigned swap. Try to cluster within a contiguous aligned SMAP_META_PAGES (typ 16 x PAGE_SIZE) block to match what swap_pager_putpages() can do. We also want to try to match against the buffer cache blocksize but we don't really know what it is here. Since the buffer cache wires and unwires pages in groups the fact that we skip wired pages should be sufficient. Returns a count of pages we might have flushed (minimum 1)
[ "Flush", "the", "specified", "page", "using", "the", "swap_pager", ".", "The", "page", "must", "be", "busied", "by", "the", "caller", "and", "its", "disposition", "will", "become", "the", "responsibility", "of", "this", "function", ".", "Try", "to", "collect", "surrounding", "pages", "including", "pages", "which", "may", "have", "already", "been", "assigned", "swap", ".", "Try", "to", "cluster", "within", "a", "contiguous", "aligned", "SMAP_META_PAGES", "(", "typ", "16", "x", "PAGE_SIZE", ")", "block", "to", "match", "what", "swap_pager_putpages", "()", "can", "do", ".", "We", "also", "want", "to", "try", "to", "match", "against", "the", "buffer", "cache", "blocksize", "but", "we", "don", "'", "t", "really", "know", "what", "it", "is", "here", ".", "Since", "the", "buffer", "cache", "wires", "and", "unwires", "pages", "in", "groups", "the", "fact", "that", "we", "skip", "wired", "pages", "should", "be", "sufficient", ".", "Returns", "a", "count", "of", "pages", "we", "might", "have", "flushed", "(", "minimum", "1", ")" ]
static int vm_swapcached_flush(vm_page_t m, int isblkdev) { vm_object_t object; vm_page_t marray[SWAP_META_PAGES]; vm_pindex_t basei; int rtvals[SWAP_META_PAGES]; int x; int i; int j; int count; int error; vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); object = m->object; vm_object_hold(object); x = (int)m->pindex & SWAP_META_MASK; marray[x] = m; basei = m->pindex; vm_page_wakeup(m); for (i = x - 1; i >= 0; --i) { m = vm_page_lookup_busy_try(object, basei - x + i, TRUE, &error); if (error || m == NULL) break; if (vm_swapcache_test(m)) { vm_page_wakeup(m); break; } if (isblkdev && (m->flags & PG_NOTMETA)) { vm_page_wakeup(m); break; } vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); if (m->queue - m->pc == PQ_CACHE) { vm_page_unqueue_nowakeup(m); vm_page_deactivate(m); } marray[i] = m; vm_page_wakeup(m); } ++i; for (j = x + 1; j < SWAP_META_PAGES; ++j) { m = vm_page_lookup_busy_try(object, basei - x + j, TRUE, &error); if (error || m == NULL) break; if (vm_swapcache_test(m)) { vm_page_wakeup(m); break; } if (isblkdev && (m->flags & PG_NOTMETA)) { vm_page_wakeup(m); break; } vm_page_io_start(m); vm_page_protect(m, VM_PROT_READ); if (m->queue - m->pc == PQ_CACHE) { vm_page_unqueue_nowakeup(m); vm_page_deactivate(m); } marray[j] = m; vm_page_wakeup(m); } count = j - i; vm_object_pip_add(object, count); swap_pager_putpages(object, marray + i, count, FALSE, rtvals + i); vm_swapcache_write_count += count * PAGE_SIZE; vm_swapcache_curburst -= count * PAGE_SIZE; while (i < j) { if (rtvals[i] != VM_PAGER_PEND) { vm_page_busy_wait(marray[i], FALSE, "swppgfd"); vm_page_io_finish(marray[i]); vm_page_wakeup(marray[i]); vm_object_pip_wakeup(object); } ++i; } vm_object_drop(object); return(count); }
[ "static", "int", "vm_swapcached_flush", "(", "vm_page_t", "m", ",", "int", "isblkdev", ")", "{", "vm_object_t", "object", ";", "vm_page_t", "marray", "[", "SWAP_META_PAGES", "]", ";", "vm_pindex_t", "basei", ";", "int", "rtvals", "[", "SWAP_META_PAGES", "]", ";", "int", "x", ";", "int", "i", ";", "int", "j", ";", "int", "count", ";", "int", "error", ";", "vm_page_io_start", "(", "m", ")", ";", "vm_page_protect", "(", "m", ",", "VM_PROT_READ", ")", ";", "object", "=", "m", "->", "object", ";", "vm_object_hold", "(", "object", ")", ";", "x", "=", "(", "int", ")", "m", "->", "pindex", "&", "SWAP_META_MASK", ";", "marray", "[", "x", "]", "=", "m", ";", "basei", "=", "m", "->", "pindex", ";", "vm_page_wakeup", "(", "m", ")", ";", "for", "(", "i", "=", "x", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "m", "=", "vm_page_lookup_busy_try", "(", "object", ",", "basei", "-", "x", "+", "i", ",", "TRUE", ",", "&", "error", ")", ";", "if", "(", "error", "||", "m", "==", "NULL", ")", "break", ";", "if", "(", "vm_swapcache_test", "(", "m", ")", ")", "{", "vm_page_wakeup", "(", "m", ")", ";", "break", ";", "}", "if", "(", "isblkdev", "&&", "(", "m", "->", "flags", "&", "PG_NOTMETA", ")", ")", "{", "vm_page_wakeup", "(", "m", ")", ";", "break", ";", "}", "vm_page_io_start", "(", "m", ")", ";", "vm_page_protect", "(", "m", ",", "VM_PROT_READ", ")", ";", "if", "(", "m", "->", "queue", "-", "m", "->", "pc", "==", "PQ_CACHE", ")", "{", "vm_page_unqueue_nowakeup", "(", "m", ")", ";", "vm_page_deactivate", "(", "m", ")", ";", "}", "marray", "[", "i", "]", "=", "m", ";", "vm_page_wakeup", "(", "m", ")", ";", "}", "++", "i", ";", "for", "(", "j", "=", "x", "+", "1", ";", "j", "<", "SWAP_META_PAGES", ";", "++", "j", ")", "{", "m", "=", "vm_page_lookup_busy_try", "(", "object", ",", "basei", "-", "x", "+", "j", ",", "TRUE", ",", "&", "error", ")", ";", "if", "(", "error", "||", "m", "==", "NULL", ")", "break", ";", "if", "(", "vm_swapcache_test", "(", "m", ")", ")", "{", "vm_page_wakeup", "(", "m", ")", ";", "break", ";", "}", "if", "(", "isblkdev", "&&", "(", "m", "->", "flags", "&", "PG_NOTMETA", ")", ")", "{", "vm_page_wakeup", "(", "m", ")", ";", "break", ";", "}", "vm_page_io_start", "(", "m", ")", ";", "vm_page_protect", "(", "m", ",", "VM_PROT_READ", ")", ";", "if", "(", "m", "->", "queue", "-", "m", "->", "pc", "==", "PQ_CACHE", ")", "{", "vm_page_unqueue_nowakeup", "(", "m", ")", ";", "vm_page_deactivate", "(", "m", ")", ";", "}", "marray", "[", "j", "]", "=", "m", ";", "vm_page_wakeup", "(", "m", ")", ";", "}", "count", "=", "j", "-", "i", ";", "vm_object_pip_add", "(", "object", ",", "count", ")", ";", "swap_pager_putpages", "(", "object", ",", "marray", "+", "i", ",", "count", ",", "FALSE", ",", "rtvals", "+", "i", ")", ";", "vm_swapcache_write_count", "+=", "count", "*", "PAGE_SIZE", ";", "vm_swapcache_curburst", "-=", "count", "*", "PAGE_SIZE", ";", "while", "(", "i", "<", "j", ")", "{", "if", "(", "rtvals", "[", "i", "]", "!=", "VM_PAGER_PEND", ")", "{", "vm_page_busy_wait", "(", "marray", "[", "i", "]", ",", "FALSE", ",", "\"", "\"", ")", ";", "vm_page_io_finish", "(", "marray", "[", "i", "]", ")", ";", "vm_page_wakeup", "(", "marray", "[", "i", "]", ")", ";", "vm_object_pip_wakeup", "(", "object", ")", ";", "}", "++", "i", ";", "}", "vm_object_drop", "(", "object", ")", ";", "return", "(", "count", ")", ";", "}" ]
Flush the specified page using the swap_pager.
[ "Flush", "the", "specified", "page", "using", "the", "swap_pager", "." ]
[ "/*\n\t * Try to cluster around (m), keeping in mind that the swap pager\n\t * can only do SMAP_META_PAGES worth of continguous write.\n\t */" ]
[ { "param": "m", "type": "vm_page_t" }, { "param": "isblkdev", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "vm_page_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "isblkdev", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcache_cleaning
void
static void vm_swapcache_cleaning(swmarker_t *marker, struct vm_object_hash **swindexp) { vm_object_t object; struct vnode *vp; int count; int scount; int n; int didmove; count = vm_swapcache_maxlaunder; scount = vm_swapcache_maxscan; /* * Look for vnode objects */ lwkt_gettoken(&(*swindexp)->token); didmove = 0; outerloop: while ((object = TAILQ_NEXT(&marker->dummy_obj, object_entry)) != NULL) { /* * We have to skip markers. We cannot hold/drop marker * objects! */ if (object->type == OBJT_MARKER) { vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; continue; } /* * Safety, or in case there are millions of VM objects * without swapcache backing. */ if (--scount <= 0) goto breakout; /* * We must hold the object before potentially yielding. */ vm_object_hold(object); lwkt_yield(); /* * Only operate on live VNODE objects that are either * VREG or VCHR (VCHR for meta-data). */ if ((object->type != OBJT_VNODE) || ((object->flags & OBJ_DEAD) || object->swblock_count == 0) || ((vp = object->handle) == NULL) || (vp->v_type != VREG && vp->v_type != VCHR)) { vm_object_drop(object); /* object may be invalid now */ vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; continue; } /* * Reset the object pindex stored in the marker if the * working object has changed. */ if (marker->save_obj != object || didmove) { marker->dummy_obj.size = 0; marker->save_off = 0; marker->save_obj = object; didmove = 0; } /* * Look for swblocks starting at our iterator. * * The swap_pager_condfree() function attempts to free * swap space starting at the specified index. The index * will be updated on return. The function will return * a scan factor (NOT the number of blocks freed). * * If it must cut its scan of the object short due to an * excessive number of swblocks, or is able to free the * requested number of blocks, it will return n >= count * and we break and pick it back up on a future attempt. * * Scan the object linearly and try to batch large sets of * blocks that are likely to clean out entire swap radix * tree leafs. */ lwkt_token_swap(); lwkt_reltoken(&(*swindexp)->token); n = swap_pager_condfree(object, &marker->dummy_obj.size, (count + SWAP_META_MASK) & ~SWAP_META_MASK); vm_object_drop(object); /* object may be invalid now */ lwkt_gettoken(&(*swindexp)->token); /* * If we have exhausted the object or deleted our per-pass * page limit then move us to the next object. Note that * the current object may no longer be on the vm_object_entry. */ if (n <= 0 || marker->save_off > vm_swapcache_cleanperobj) { vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; } /* * If we have exhausted our max-launder stop for now. */ count -= n; marker->save_off += n * PAGE_SIZE; if (count < 0) goto breakout; } /* * Iterate vm_object_hash[] hash table */ TAILQ_REMOVE(&(*swindexp)->list, &marker->dummy_obj, object_entry); lwkt_reltoken(&(*swindexp)->token); if (++*swindexp >= &vm_object_hash[VMOBJ_HSIZE]) *swindexp = &vm_object_hash[0]; lwkt_gettoken(&(*swindexp)->token); TAILQ_INSERT_HEAD(&(*swindexp)->list, &marker->dummy_obj, object_entry); if (*swindexp != &vm_object_hash[0]) goto outerloop; breakout: lwkt_reltoken(&(*swindexp)->token); }
/* * Cleaning pass. * * We clean whole objects up to 16MB */
Cleaning pass. We clean whole objects up to 16MB
[ "Cleaning", "pass", ".", "We", "clean", "whole", "objects", "up", "to", "16MB" ]
static void vm_swapcache_cleaning(swmarker_t *marker, struct vm_object_hash **swindexp) { vm_object_t object; struct vnode *vp; int count; int scount; int n; int didmove; count = vm_swapcache_maxlaunder; scount = vm_swapcache_maxscan; lwkt_gettoken(&(*swindexp)->token); didmove = 0; outerloop: while ((object = TAILQ_NEXT(&marker->dummy_obj, object_entry)) != NULL) { if (object->type == OBJT_MARKER) { vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; continue; } if (--scount <= 0) goto breakout; vm_object_hold(object); lwkt_yield(); if ((object->type != OBJT_VNODE) || ((object->flags & OBJ_DEAD) || object->swblock_count == 0) || ((vp = object->handle) == NULL) || (vp->v_type != VREG && vp->v_type != VCHR)) { vm_object_drop(object); vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; continue; } if (marker->save_obj != object || didmove) { marker->dummy_obj.size = 0; marker->save_off = 0; marker->save_obj = object; didmove = 0; } lwkt_token_swap(); lwkt_reltoken(&(*swindexp)->token); n = swap_pager_condfree(object, &marker->dummy_obj.size, (count + SWAP_META_MASK) & ~SWAP_META_MASK); vm_object_drop(object); lwkt_gettoken(&(*swindexp)->token); if (n <= 0 || marker->save_off > vm_swapcache_cleanperobj) { vm_swapcache_movemarker(marker, *swindexp, object); didmove = 1; } count -= n; marker->save_off += n * PAGE_SIZE; if (count < 0) goto breakout; } TAILQ_REMOVE(&(*swindexp)->list, &marker->dummy_obj, object_entry); lwkt_reltoken(&(*swindexp)->token); if (++*swindexp >= &vm_object_hash[VMOBJ_HSIZE]) *swindexp = &vm_object_hash[0]; lwkt_gettoken(&(*swindexp)->token); TAILQ_INSERT_HEAD(&(*swindexp)->list, &marker->dummy_obj, object_entry); if (*swindexp != &vm_object_hash[0]) goto outerloop; breakout: lwkt_reltoken(&(*swindexp)->token); }
[ "static", "void", "vm_swapcache_cleaning", "(", "swmarker_t", "*", "marker", ",", "struct", "vm_object_hash", "*", "*", "swindexp", ")", "{", "vm_object_t", "object", ";", "struct", "vnode", "*", "vp", ";", "int", "count", ";", "int", "scount", ";", "int", "n", ";", "int", "didmove", ";", "count", "=", "vm_swapcache_maxlaunder", ";", "scount", "=", "vm_swapcache_maxscan", ";", "lwkt_gettoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "didmove", "=", "0", ";", "outerloop", ":", "while", "(", "(", "object", "=", "TAILQ_NEXT", "(", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", ")", "!=", "NULL", ")", "{", "if", "(", "object", "->", "type", "==", "OBJT_MARKER", ")", "{", "vm_swapcache_movemarker", "(", "marker", ",", "*", "swindexp", ",", "object", ")", ";", "didmove", "=", "1", ";", "continue", ";", "}", "if", "(", "--", "scount", "<=", "0", ")", "goto", "breakout", ";", "vm_object_hold", "(", "object", ")", ";", "lwkt_yield", "(", ")", ";", "if", "(", "(", "object", "->", "type", "!=", "OBJT_VNODE", ")", "||", "(", "(", "object", "->", "flags", "&", "OBJ_DEAD", ")", "||", "object", "->", "swblock_count", "==", "0", ")", "||", "(", "(", "vp", "=", "object", "->", "handle", ")", "==", "NULL", ")", "||", "(", "vp", "->", "v_type", "!=", "VREG", "&&", "vp", "->", "v_type", "!=", "VCHR", ")", ")", "{", "vm_object_drop", "(", "object", ")", ";", "vm_swapcache_movemarker", "(", "marker", ",", "*", "swindexp", ",", "object", ")", ";", "didmove", "=", "1", ";", "continue", ";", "}", "if", "(", "marker", "->", "save_obj", "!=", "object", "||", "didmove", ")", "{", "marker", "->", "dummy_obj", ".", "size", "=", "0", ";", "marker", "->", "save_off", "=", "0", ";", "marker", "->", "save_obj", "=", "object", ";", "didmove", "=", "0", ";", "}", "lwkt_token_swap", "(", ")", ";", "lwkt_reltoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "n", "=", "swap_pager_condfree", "(", "object", ",", "&", "marker", "->", "dummy_obj", ".", "size", ",", "(", "count", "+", "SWAP_META_MASK", ")", "&", "~", "SWAP_META_MASK", ")", ";", "vm_object_drop", "(", "object", ")", ";", "lwkt_gettoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "if", "(", "n", "<=", "0", "||", "marker", "->", "save_off", ">", "vm_swapcache_cleanperobj", ")", "{", "vm_swapcache_movemarker", "(", "marker", ",", "*", "swindexp", ",", "object", ")", ";", "didmove", "=", "1", ";", "}", "count", "-=", "n", ";", "marker", "->", "save_off", "+=", "n", "*", "PAGE_SIZE", ";", "if", "(", "count", "<", "0", ")", "goto", "breakout", ";", "}", "TAILQ_REMOVE", "(", "&", "(", "*", "swindexp", ")", "->", "list", ",", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", ";", "lwkt_reltoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "if", "(", "++", "*", "swindexp", ">=", "&", "vm_object_hash", "[", "VMOBJ_HSIZE", "]", ")", "*", "swindexp", "=", "&", "vm_object_hash", "[", "0", "]", ";", "lwkt_gettoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "TAILQ_INSERT_HEAD", "(", "&", "(", "*", "swindexp", ")", "->", "list", ",", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", ";", "if", "(", "*", "swindexp", "!=", "&", "vm_object_hash", "[", "0", "]", ")", "goto", "outerloop", ";", "breakout", ":", "lwkt_reltoken", "(", "&", "(", "*", "swindexp", ")", "->", "token", ")", ";", "}" ]
Cleaning pass.
[ "Cleaning", "pass", "." ]
[ "/*\n\t * Look for vnode objects\n\t */", "/*\n\t\t * We have to skip markers. We cannot hold/drop marker\n\t\t * objects!\n\t\t */", "/*\n\t\t * Safety, or in case there are millions of VM objects\n\t\t * without swapcache backing.\n\t\t */", "/*\n\t\t * We must hold the object before potentially yielding.\n\t\t */", "/* \n\t\t * Only operate on live VNODE objects that are either\n\t\t * VREG or VCHR (VCHR for meta-data).\n\t\t */", "/* object may be invalid now */", "/*\n\t\t * Reset the object pindex stored in the marker if the\n\t\t * working object has changed.\n\t\t */", "/*\n\t\t * Look for swblocks starting at our iterator.\n\t\t *\n\t\t * The swap_pager_condfree() function attempts to free\n\t\t * swap space starting at the specified index. The index\n\t\t * will be updated on return. The function will return\n\t\t * a scan factor (NOT the number of blocks freed).\n\t\t *\n\t\t * If it must cut its scan of the object short due to an\n\t\t * excessive number of swblocks, or is able to free the\n\t\t * requested number of blocks, it will return n >= count\n\t\t * and we break and pick it back up on a future attempt.\n\t\t *\n\t\t * Scan the object linearly and try to batch large sets of\n\t\t * blocks that are likely to clean out entire swap radix\n\t\t * tree leafs.\n\t\t */", "/* object may be invalid now */", "/*\n\t\t * If we have exhausted the object or deleted our per-pass\n\t\t * page limit then move us to the next object. Note that\n\t\t * the current object may no longer be on the vm_object_entry.\n\t\t */", "/*\n\t\t * If we have exhausted our max-launder stop for now.\n\t\t */", "/*\n\t * Iterate vm_object_hash[] hash table\n\t */" ]
[ { "param": "marker", "type": "swmarker_t" }, { "param": "swindexp", "type": "struct vm_object_hash" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "marker", "type": "swmarker_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "swindexp", "type": "struct vm_object_hash", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cb20a209fe6ea10bf4690d574fdd68b913ff50f0
atrens/DragonFlyBSD-src
sys/vm/vm_swapcache.c
[ "BSD-3-Clause" ]
C
vm_swapcache_movemarker
void
static void vm_swapcache_movemarker(swmarker_t *marker, struct vm_object_hash *swindex, vm_object_t object) { if (TAILQ_NEXT(&marker->dummy_obj, object_entry) == object) { TAILQ_REMOVE(&swindex->list, &marker->dummy_obj, object_entry); TAILQ_INSERT_AFTER(&swindex->list, object, &marker->dummy_obj, object_entry); } }
/* * Move the marker past the current object. Object can be stale, but we * still need it to determine if the marker has to be moved. If the object * is still the 'current object' (object after the marker), we hop-scotch * the marker past it. */
Move the marker past the current object. Object can be stale, but we still need it to determine if the marker has to be moved. If the object is still the 'current object' (object after the marker), we hop-scotch the marker past it.
[ "Move", "the", "marker", "past", "the", "current", "object", ".", "Object", "can", "be", "stale", "but", "we", "still", "need", "it", "to", "determine", "if", "the", "marker", "has", "to", "be", "moved", ".", "If", "the", "object", "is", "still", "the", "'", "current", "object", "'", "(", "object", "after", "the", "marker", ")", "we", "hop", "-", "scotch", "the", "marker", "past", "it", "." ]
static void vm_swapcache_movemarker(swmarker_t *marker, struct vm_object_hash *swindex, vm_object_t object) { if (TAILQ_NEXT(&marker->dummy_obj, object_entry) == object) { TAILQ_REMOVE(&swindex->list, &marker->dummy_obj, object_entry); TAILQ_INSERT_AFTER(&swindex->list, object, &marker->dummy_obj, object_entry); } }
[ "static", "void", "vm_swapcache_movemarker", "(", "swmarker_t", "*", "marker", ",", "struct", "vm_object_hash", "*", "swindex", ",", "vm_object_t", "object", ")", "{", "if", "(", "TAILQ_NEXT", "(", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", "==", "object", ")", "{", "TAILQ_REMOVE", "(", "&", "swindex", "->", "list", ",", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", ";", "TAILQ_INSERT_AFTER", "(", "&", "swindex", "->", "list", ",", "object", ",", "&", "marker", "->", "dummy_obj", ",", "object_entry", ")", ";", "}", "}" ]
Move the marker past the current object.
[ "Move", "the", "marker", "past", "the", "current", "object", "." ]
[]
[ { "param": "marker", "type": "swmarker_t" }, { "param": "swindex", "type": "struct vm_object_hash" }, { "param": "object", "type": "vm_object_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "marker", "type": "swmarker_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "swindex", "type": "struct vm_object_hash", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object", "type": "vm_object_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
bb_has_predicate
bool
static inline bool bb_has_predicate (basic_block bb) { return bb->aux != NULL; }
/* Returns true when the basic block BB has a predicate. */
Returns true when the basic block BB has a predicate.
[ "Returns", "true", "when", "the", "basic", "block", "BB", "has", "a", "predicate", "." ]
static inline bool bb_has_predicate (basic_block bb) { return bb->aux != NULL; }
[ "static", "inline", "bool", "bb_has_predicate", "(", "basic_block", "bb", ")", "{", "return", "bb", "->", "aux", "!=", "NULL", ";", "}" ]
Returns true when the basic block BB has a predicate.
[ "Returns", "true", "when", "the", "basic", "block", "BB", "has", "a", "predicate", "." ]
[]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
bb_predicate
tree
static inline tree bb_predicate (basic_block bb) { return ((bb_predicate_p) bb->aux)->predicate; }
/* Returns the gimplified predicate for basic block BB. */
Returns the gimplified predicate for basic block BB.
[ "Returns", "the", "gimplified", "predicate", "for", "basic", "block", "BB", "." ]
static inline tree bb_predicate (basic_block bb) { return ((bb_predicate_p) bb->aux)->predicate; }
[ "static", "inline", "tree", "bb_predicate", "(", "basic_block", "bb", ")", "{", "return", "(", "(", "bb_predicate_p", ")", "bb", "->", "aux", ")", "->", "predicate", ";", "}" ]
Returns the gimplified predicate for basic block BB.
[ "Returns", "the", "gimplified", "predicate", "for", "basic", "block", "BB", "." ]
[]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
bb_predicate_gimplified_stmts
gimple_seq
static inline gimple_seq bb_predicate_gimplified_stmts (basic_block bb) { return ((bb_predicate_p) bb->aux)->predicate_gimplified_stmts; }
/* Returns the sequence of statements of the gimplification of the predicate for basic block BB. */
Returns the sequence of statements of the gimplification of the predicate for basic block BB.
[ "Returns", "the", "sequence", "of", "statements", "of", "the", "gimplification", "of", "the", "predicate", "for", "basic", "block", "BB", "." ]
static inline gimple_seq bb_predicate_gimplified_stmts (basic_block bb) { return ((bb_predicate_p) bb->aux)->predicate_gimplified_stmts; }
[ "static", "inline", "gimple_seq", "bb_predicate_gimplified_stmts", "(", "basic_block", "bb", ")", "{", "return", "(", "(", "bb_predicate_p", ")", "bb", "->", "aux", ")", "->", "predicate_gimplified_stmts", ";", "}" ]
Returns the sequence of statements of the gimplification of the predicate for basic block BB.
[ "Returns", "the", "sequence", "of", "statements", "of", "the", "gimplification", "of", "the", "predicate", "for", "basic", "block", "BB", "." ]
[]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
add_bb_predicate_gimplified_stmts
void
static inline void add_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts) { gimple_seq_add_seq (&(((bb_predicate_p) bb->aux)->predicate_gimplified_stmts), stmts); }
/* Adds the sequence of statements STMTS to the sequence of statements of the predicate for basic block BB. */
Adds the sequence of statements STMTS to the sequence of statements of the predicate for basic block BB.
[ "Adds", "the", "sequence", "of", "statements", "STMTS", "to", "the", "sequence", "of", "statements", "of", "the", "predicate", "for", "basic", "block", "BB", "." ]
static inline void add_bb_predicate_gimplified_stmts (basic_block bb, gimple_seq stmts) { gimple_seq_add_seq (&(((bb_predicate_p) bb->aux)->predicate_gimplified_stmts), stmts); }
[ "static", "inline", "void", "add_bb_predicate_gimplified_stmts", "(", "basic_block", "bb", ",", "gimple_seq", "stmts", ")", "{", "gimple_seq_add_seq", "(", "&", "(", "(", "(", "bb_predicate_p", ")", "bb", "->", "aux", ")", "->", "predicate_gimplified_stmts", ")", ",", "stmts", ")", ";", "}" ]
Adds the sequence of statements STMTS to the sequence of statements of the predicate for basic block BB.
[ "Adds", "the", "sequence", "of", "statements", "STMTS", "to", "the", "sequence", "of", "statements", "of", "the", "predicate", "for", "basic", "block", "BB", "." ]
[]
[ { "param": "bb", "type": "basic_block" }, { "param": "stmts", "type": "gimple_seq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "stmts", "type": "gimple_seq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
free_bb_predicate
void
static inline void free_bb_predicate (basic_block bb) { gimple_seq stmts; if (!bb_has_predicate (bb)) return; /* Release the SSA_NAMEs created for the gimplification of the predicate. */ stmts = bb_predicate_gimplified_stmts (bb); if (stmts) { gimple_stmt_iterator i; for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i)) free_stmt_operands (gsi_stmt (i)); } free (bb->aux); bb->aux = NULL; }
/* Free the predicate of basic block BB. */
Free the predicate of basic block BB.
[ "Free", "the", "predicate", "of", "basic", "block", "BB", "." ]
static inline void free_bb_predicate (basic_block bb) { gimple_seq stmts; if (!bb_has_predicate (bb)) return; stmts = bb_predicate_gimplified_stmts (bb); if (stmts) { gimple_stmt_iterator i; for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i)) free_stmt_operands (gsi_stmt (i)); } free (bb->aux); bb->aux = NULL; }
[ "static", "inline", "void", "free_bb_predicate", "(", "basic_block", "bb", ")", "{", "gimple_seq", "stmts", ";", "if", "(", "!", "bb_has_predicate", "(", "bb", ")", ")", "return", ";", "stmts", "=", "bb_predicate_gimplified_stmts", "(", "bb", ")", ";", "if", "(", "stmts", ")", "{", "gimple_stmt_iterator", "i", ";", "for", "(", "i", "=", "gsi_start", "(", "stmts", ")", ";", "!", "gsi_end_p", "(", "i", ")", ";", "gsi_next", "(", "&", "i", ")", ")", "free_stmt_operands", "(", "gsi_stmt", "(", "i", ")", ")", ";", "}", "free", "(", "bb", "->", "aux", ")", ";", "bb", "->", "aux", "=", "NULL", ";", "}" ]
Free the predicate of basic block BB.
[ "Free", "the", "predicate", "of", "basic", "block", "BB", "." ]
[ "/* Release the SSA_NAMEs created for the gimplification of the\n predicate. */" ]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
reset_bb_predicate
void
static inline void reset_bb_predicate (basic_block bb) { free_bb_predicate (bb); init_bb_predicate (bb); }
/* Free the predicate of BB and reinitialize it with the true predicate. */
Free the predicate of BB and reinitialize it with the true predicate.
[ "Free", "the", "predicate", "of", "BB", "and", "reinitialize", "it", "with", "the", "true", "predicate", "." ]
static inline void reset_bb_predicate (basic_block bb) { free_bb_predicate (bb); init_bb_predicate (bb); }
[ "static", "inline", "void", "reset_bb_predicate", "(", "basic_block", "bb", ")", "{", "free_bb_predicate", "(", "bb", ")", ";", "init_bb_predicate", "(", "bb", ")", ";", "}" ]
Free the predicate of BB and reinitialize it with the true predicate.
[ "Free", "the", "predicate", "of", "BB", "and", "reinitialize", "it", "with", "the", "true", "predicate", "." ]
[]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
ifc_temp_var
tree
static tree ifc_temp_var (tree type, tree expr, gimple_stmt_iterator *gsi) { const char *name = "_ifc_"; tree var, new_name; gimple stmt; /* Create new temporary variable. */ var = create_tmp_var (type, name); add_referenced_var (var); /* Build new statement to assign EXPR to new variable. */ stmt = gimple_build_assign (var, expr); /* Get SSA name for the new variable and set make new statement its definition statement. */ new_name = make_ssa_name (var, stmt); gimple_assign_set_lhs (stmt, new_name); SSA_NAME_DEF_STMT (new_name) = stmt; update_stmt (stmt); gsi_insert_before (gsi, stmt, GSI_SAME_STMT); return gimple_assign_lhs (stmt); }
/* Returns a new SSA_NAME of type TYPE that is assigned the value of the expression EXPR. Inserts the statement created for this computation before GSI and leaves the iterator GSI at the same statement. */
Returns a new SSA_NAME of type TYPE that is assigned the value of the expression EXPR. Inserts the statement created for this computation before GSI and leaves the iterator GSI at the same statement.
[ "Returns", "a", "new", "SSA_NAME", "of", "type", "TYPE", "that", "is", "assigned", "the", "value", "of", "the", "expression", "EXPR", ".", "Inserts", "the", "statement", "created", "for", "this", "computation", "before", "GSI", "and", "leaves", "the", "iterator", "GSI", "at", "the", "same", "statement", "." ]
static tree ifc_temp_var (tree type, tree expr, gimple_stmt_iterator *gsi) { const char *name = "_ifc_"; tree var, new_name; gimple stmt; var = create_tmp_var (type, name); add_referenced_var (var); stmt = gimple_build_assign (var, expr); new_name = make_ssa_name (var, stmt); gimple_assign_set_lhs (stmt, new_name); SSA_NAME_DEF_STMT (new_name) = stmt; update_stmt (stmt); gsi_insert_before (gsi, stmt, GSI_SAME_STMT); return gimple_assign_lhs (stmt); }
[ "static", "tree", "ifc_temp_var", "(", "tree", "type", ",", "tree", "expr", ",", "gimple_stmt_iterator", "*", "gsi", ")", "{", "const", "char", "*", "name", "=", "\"", "\"", ";", "tree", "var", ",", "new_name", ";", "gimple", "stmt", ";", "var", "=", "create_tmp_var", "(", "type", ",", "name", ")", ";", "add_referenced_var", "(", "var", ")", ";", "stmt", "=", "gimple_build_assign", "(", "var", ",", "expr", ")", ";", "new_name", "=", "make_ssa_name", "(", "var", ",", "stmt", ")", ";", "gimple_assign_set_lhs", "(", "stmt", ",", "new_name", ")", ";", "SSA_NAME_DEF_STMT", "(", "new_name", ")", "=", "stmt", ";", "update_stmt", "(", "stmt", ")", ";", "gsi_insert_before", "(", "gsi", ",", "stmt", ",", "GSI_SAME_STMT", ")", ";", "return", "gimple_assign_lhs", "(", "stmt", ")", ";", "}" ]
Returns a new SSA_NAME of type TYPE that is assigned the value of the expression EXPR.
[ "Returns", "a", "new", "SSA_NAME", "of", "type", "TYPE", "that", "is", "assigned", "the", "value", "of", "the", "expression", "EXPR", "." ]
[ "/* Create new temporary variable. */", "/* Build new statement to assign EXPR to new variable. */", "/* Get SSA name for the new variable and set make new statement\n its definition statement. */" ]
[ { "param": "type", "type": "tree" }, { "param": "expr", "type": "tree" }, { "param": "gsi", "type": "gimple_stmt_iterator" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "expr", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gsi", "type": "gimple_stmt_iterator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
is_true_predicate
bool
static inline bool is_true_predicate (tree cond) { return (cond == NULL_TREE || cond == boolean_true_node || integer_onep (cond)); }
/* Return true when COND is a true predicate. */
Return true when COND is a true predicate.
[ "Return", "true", "when", "COND", "is", "a", "true", "predicate", "." ]
static inline bool is_true_predicate (tree cond) { return (cond == NULL_TREE || cond == boolean_true_node || integer_onep (cond)); }
[ "static", "inline", "bool", "is_true_predicate", "(", "tree", "cond", ")", "{", "return", "(", "cond", "==", "NULL_TREE", "||", "cond", "==", "boolean_true_node", "||", "integer_onep", "(", "cond", ")", ")", ";", "}" ]
Return true when COND is a true predicate.
[ "Return", "true", "when", "COND", "is", "a", "true", "predicate", "." ]
[]
[ { "param": "cond", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
is_predicated
bool
static inline bool is_predicated (basic_block bb) { return !is_true_predicate (bb_predicate (bb)); }
/* Returns true when BB has a predicate that is not trivial: true or NULL_TREE. */
Returns true when BB has a predicate that is not trivial: true or NULL_TREE.
[ "Returns", "true", "when", "BB", "has", "a", "predicate", "that", "is", "not", "trivial", ":", "true", "or", "NULL_TREE", "." ]
static inline bool is_predicated (basic_block bb) { return !is_true_predicate (bb_predicate (bb)); }
[ "static", "inline", "bool", "is_predicated", "(", "basic_block", "bb", ")", "{", "return", "!", "is_true_predicate", "(", "bb_predicate", "(", "bb", ")", ")", ";", "}" ]
Returns true when BB has a predicate that is not trivial: true or NULL_TREE.
[ "Returns", "true", "when", "BB", "has", "a", "predicate", "that", "is", "not", "trivial", ":", "true", "or", "NULL_TREE", "." ]
[]
[ { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
parse_predicate
null
static enum tree_code parse_predicate (tree cond, tree *op0, tree *op1) { gimple s; if (TREE_CODE (cond) == SSA_NAME && is_gimple_assign (s = SSA_NAME_DEF_STMT (cond))) { if (TREE_CODE_CLASS (gimple_assign_rhs_code (s)) == tcc_comparison) { *op0 = gimple_assign_rhs1 (s); *op1 = gimple_assign_rhs2 (s); return gimple_assign_rhs_code (s); } else if (gimple_assign_rhs_code (s) == TRUTH_NOT_EXPR) { tree op = gimple_assign_rhs1 (s); tree type = TREE_TYPE (op); enum tree_code code = parse_predicate (op, op0, op1); return code == ERROR_MARK ? ERROR_MARK : invert_tree_comparison (code, HONOR_NANS (TYPE_MODE (type))); } return ERROR_MARK; } if (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison) { *op0 = TREE_OPERAND (cond, 0); *op1 = TREE_OPERAND (cond, 1); return TREE_CODE (cond); } return ERROR_MARK; }
/* Parses the predicate COND and returns its comparison code and operands OP0 and OP1. */
Parses the predicate COND and returns its comparison code and operands OP0 and OP1.
[ "Parses", "the", "predicate", "COND", "and", "returns", "its", "comparison", "code", "and", "operands", "OP0", "and", "OP1", "." ]
static enum tree_code parse_predicate (tree cond, tree *op0, tree *op1) { gimple s; if (TREE_CODE (cond) == SSA_NAME && is_gimple_assign (s = SSA_NAME_DEF_STMT (cond))) { if (TREE_CODE_CLASS (gimple_assign_rhs_code (s)) == tcc_comparison) { *op0 = gimple_assign_rhs1 (s); *op1 = gimple_assign_rhs2 (s); return gimple_assign_rhs_code (s); } else if (gimple_assign_rhs_code (s) == TRUTH_NOT_EXPR) { tree op = gimple_assign_rhs1 (s); tree type = TREE_TYPE (op); enum tree_code code = parse_predicate (op, op0, op1); return code == ERROR_MARK ? ERROR_MARK : invert_tree_comparison (code, HONOR_NANS (TYPE_MODE (type))); } return ERROR_MARK; } if (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison) { *op0 = TREE_OPERAND (cond, 0); *op1 = TREE_OPERAND (cond, 1); return TREE_CODE (cond); } return ERROR_MARK; }
[ "static", "enum", "tree_code", "parse_predicate", "(", "tree", "cond", ",", "tree", "*", "op0", ",", "tree", "*", "op1", ")", "{", "gimple", "s", ";", "if", "(", "TREE_CODE", "(", "cond", ")", "==", "SSA_NAME", "&&", "is_gimple_assign", "(", "s", "=", "SSA_NAME_DEF_STMT", "(", "cond", ")", ")", ")", "{", "if", "(", "TREE_CODE_CLASS", "(", "gimple_assign_rhs_code", "(", "s", ")", ")", "==", "tcc_comparison", ")", "{", "*", "op0", "=", "gimple_assign_rhs1", "(", "s", ")", ";", "*", "op1", "=", "gimple_assign_rhs2", "(", "s", ")", ";", "return", "gimple_assign_rhs_code", "(", "s", ")", ";", "}", "else", "if", "(", "gimple_assign_rhs_code", "(", "s", ")", "==", "TRUTH_NOT_EXPR", ")", "{", "tree", "op", "=", "gimple_assign_rhs1", "(", "s", ")", ";", "tree", "type", "=", "TREE_TYPE", "(", "op", ")", ";", "enum", "tree_code", "code", "=", "parse_predicate", "(", "op", ",", "op0", ",", "op1", ")", ";", "return", "code", "==", "ERROR_MARK", "?", "ERROR_MARK", ":", "invert_tree_comparison", "(", "code", ",", "HONOR_NANS", "(", "TYPE_MODE", "(", "type", ")", ")", ")", ";", "}", "return", "ERROR_MARK", ";", "}", "if", "(", "TREE_CODE_CLASS", "(", "TREE_CODE", "(", "cond", ")", ")", "==", "tcc_comparison", ")", "{", "*", "op0", "=", "TREE_OPERAND", "(", "cond", ",", "0", ")", ";", "*", "op1", "=", "TREE_OPERAND", "(", "cond", ",", "1", ")", ";", "return", "TREE_CODE", "(", "cond", ")", ";", "}", "return", "ERROR_MARK", ";", "}" ]
Parses the predicate COND and returns its comparison code and operands OP0 and OP1.
[ "Parses", "the", "predicate", "COND", "and", "returns", "its", "comparison", "code", "and", "operands", "OP0", "and", "OP1", "." ]
[]
[ { "param": "cond", "type": "tree" }, { "param": "op0", "type": "tree" }, { "param": "op1", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op0", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op1", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
add_to_predicate_list
void
static inline void add_to_predicate_list (basic_block bb, tree nc) { tree bc, *tp; if (is_true_predicate (nc)) return; if (!is_predicated (bb)) bc = nc; else { bc = bb_predicate (bb); bc = fold_or_predicates (EXPR_LOCATION (bc), nc, bc); if (is_true_predicate (bc)) { reset_bb_predicate (bb); return; } } /* Allow a TRUTH_NOT_EXPR around the main predicate. */ if (TREE_CODE (bc) == TRUTH_NOT_EXPR) tp = &TREE_OPERAND (bc, 0); else tp = &bc; if (!is_gimple_condexpr (*tp)) { gimple_seq stmts; *tp = force_gimple_operand_1 (*tp, &stmts, is_gimple_condexpr, NULL_TREE); add_bb_predicate_gimplified_stmts (bb, stmts); } set_bb_predicate (bb, bc); }
/* Add condition NC to the predicate list of basic block BB. */
Add condition NC to the predicate list of basic block BB.
[ "Add", "condition", "NC", "to", "the", "predicate", "list", "of", "basic", "block", "BB", "." ]
static inline void add_to_predicate_list (basic_block bb, tree nc) { tree bc, *tp; if (is_true_predicate (nc)) return; if (!is_predicated (bb)) bc = nc; else { bc = bb_predicate (bb); bc = fold_or_predicates (EXPR_LOCATION (bc), nc, bc); if (is_true_predicate (bc)) { reset_bb_predicate (bb); return; } } if (TREE_CODE (bc) == TRUTH_NOT_EXPR) tp = &TREE_OPERAND (bc, 0); else tp = &bc; if (!is_gimple_condexpr (*tp)) { gimple_seq stmts; *tp = force_gimple_operand_1 (*tp, &stmts, is_gimple_condexpr, NULL_TREE); add_bb_predicate_gimplified_stmts (bb, stmts); } set_bb_predicate (bb, bc); }
[ "static", "inline", "void", "add_to_predicate_list", "(", "basic_block", "bb", ",", "tree", "nc", ")", "{", "tree", "bc", ",", "*", "tp", ";", "if", "(", "is_true_predicate", "(", "nc", ")", ")", "return", ";", "if", "(", "!", "is_predicated", "(", "bb", ")", ")", "bc", "=", "nc", ";", "else", "{", "bc", "=", "bb_predicate", "(", "bb", ")", ";", "bc", "=", "fold_or_predicates", "(", "EXPR_LOCATION", "(", "bc", ")", ",", "nc", ",", "bc", ")", ";", "if", "(", "is_true_predicate", "(", "bc", ")", ")", "{", "reset_bb_predicate", "(", "bb", ")", ";", "return", ";", "}", "}", "if", "(", "TREE_CODE", "(", "bc", ")", "==", "TRUTH_NOT_EXPR", ")", "tp", "=", "&", "TREE_OPERAND", "(", "bc", ",", "0", ")", ";", "else", "tp", "=", "&", "bc", ";", "if", "(", "!", "is_gimple_condexpr", "(", "*", "tp", ")", ")", "{", "gimple_seq", "stmts", ";", "*", "tp", "=", "force_gimple_operand_1", "(", "*", "tp", ",", "&", "stmts", ",", "is_gimple_condexpr", ",", "NULL_TREE", ")", ";", "add_bb_predicate_gimplified_stmts", "(", "bb", ",", "stmts", ")", ";", "}", "set_bb_predicate", "(", "bb", ",", "bc", ")", ";", "}" ]
Add condition NC to the predicate list of basic block BB.
[ "Add", "condition", "NC", "to", "the", "predicate", "list", "of", "basic", "block", "BB", "." ]
[ "/* Allow a TRUTH_NOT_EXPR around the main predicate. */" ]
[ { "param": "bb", "type": "basic_block" }, { "param": "nc", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nc", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
add_to_dst_predicate_list
void
static void add_to_dst_predicate_list (struct loop *loop, edge e, tree prev_cond, tree cond) { if (!flow_bb_inside_loop_p (loop, e->dest)) return; if (!is_true_predicate (prev_cond)) cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, prev_cond, cond); add_to_predicate_list (e->dest, cond); }
/* Add the condition COND to the previous condition PREV_COND, and add this to the predicate list of the destination of edge E. LOOP is the loop to be if-converted. */
Add the condition COND to the previous condition PREV_COND, and add this to the predicate list of the destination of edge E. LOOP is the loop to be if-converted.
[ "Add", "the", "condition", "COND", "to", "the", "previous", "condition", "PREV_COND", "and", "add", "this", "to", "the", "predicate", "list", "of", "the", "destination", "of", "edge", "E", ".", "LOOP", "is", "the", "loop", "to", "be", "if", "-", "converted", "." ]
static void add_to_dst_predicate_list (struct loop *loop, edge e, tree prev_cond, tree cond) { if (!flow_bb_inside_loop_p (loop, e->dest)) return; if (!is_true_predicate (prev_cond)) cond = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, prev_cond, cond); add_to_predicate_list (e->dest, cond); }
[ "static", "void", "add_to_dst_predicate_list", "(", "struct", "loop", "*", "loop", ",", "edge", "e", ",", "tree", "prev_cond", ",", "tree", "cond", ")", "{", "if", "(", "!", "flow_bb_inside_loop_p", "(", "loop", ",", "e", "->", "dest", ")", ")", "return", ";", "if", "(", "!", "is_true_predicate", "(", "prev_cond", ")", ")", "cond", "=", "fold_build2", "(", "TRUTH_AND_EXPR", ",", "boolean_type_node", ",", "prev_cond", ",", "cond", ")", ";", "add_to_predicate_list", "(", "e", "->", "dest", ",", "cond", ")", ";", "}" ]
Add the condition COND to the previous condition PREV_COND, and add this to the predicate list of the destination of edge E. LOOP is the loop to be if-converted.
[ "Add", "the", "condition", "COND", "to", "the", "previous", "condition", "PREV_COND", "and", "add", "this", "to", "the", "predicate", "list", "of", "the", "destination", "of", "edge", "E", ".", "LOOP", "is", "the", "loop", "to", "be", "if", "-", "converted", "." ]
[]
[ { "param": "loop", "type": "struct loop" }, { "param": "e", "type": "edge" }, { "param": "prev_cond", "type": "tree" }, { "param": "cond", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "e", "type": "edge", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prev_cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
bb_with_exit_edge_p
bool
static bool bb_with_exit_edge_p (struct loop *loop, basic_block bb) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) if (loop_exit_edge_p (loop, e)) return true; return false; }
/* Return true if one of the successor edges of BB exits LOOP. */
Return true if one of the successor edges of BB exits LOOP.
[ "Return", "true", "if", "one", "of", "the", "successor", "edges", "of", "BB", "exits", "LOOP", "." ]
static bool bb_with_exit_edge_p (struct loop *loop, basic_block bb) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) if (loop_exit_edge_p (loop, e)) return true; return false; }
[ "static", "bool", "bb_with_exit_edge_p", "(", "struct", "loop", "*", "loop", ",", "basic_block", "bb", ")", "{", "edge", "e", ";", "edge_iterator", "ei", ";", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "bb", "->", "succs", ")", "", "if", "(", "loop_exit_edge_p", "(", "loop", ",", "e", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Return true if one of the successor edges of BB exits LOOP.
[ "Return", "true", "if", "one", "of", "the", "successor", "edges", "of", "BB", "exits", "LOOP", "." ]
[]
[ { "param": "loop", "type": "struct loop" }, { "param": "bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
if_convertible_phi_p
bool
static bool if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi) { if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "-------------------------\n"); print_gimple_stmt (dump_file, phi, 0, TDF_SLIM); } if (bb != loop->header && gimple_phi_num_args (phi) != 2) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "More than two phi node args.\n"); return false; } if (flag_tree_loop_if_convert_stores) return true; /* When the flag_tree_loop_if_convert_stores is not set, check that there are no memory writes in the branches of the loop to be if-converted. */ if (!is_gimple_reg (SSA_NAME_VAR (gimple_phi_result (phi)))) { imm_use_iterator imm_iter; use_operand_p use_p; if (bb != loop->header) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Virtual phi not on loop->header.\n"); return false; } FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_phi_result (phi)) { if (gimple_code (USE_STMT (use_p)) == GIMPLE_PHI) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Difficult to handle this virtual phi.\n"); return false; } } } return true; }
/* Return true when PHI is if-convertible. PHI is part of loop LOOP and it belongs to basic block BB. PHI is not if-convertible if: - it has more than 2 arguments. When the flag_tree_loop_if_convert_stores is not set, PHI is not if-convertible if: - a virtual PHI is immediately used in another PHI node, - there is a virtual PHI in a BB other than the loop->header. */
Return true when PHI is if-convertible. PHI is part of loop LOOP and it belongs to basic block BB. PHI is not if-convertible if: it has more than 2 arguments. When the flag_tree_loop_if_convert_stores is not set, PHI is not if-convertible if: a virtual PHI is immediately used in another PHI node, there is a virtual PHI in a BB other than the loop->header.
[ "Return", "true", "when", "PHI", "is", "if", "-", "convertible", ".", "PHI", "is", "part", "of", "loop", "LOOP", "and", "it", "belongs", "to", "basic", "block", "BB", ".", "PHI", "is", "not", "if", "-", "convertible", "if", ":", "it", "has", "more", "than", "2", "arguments", ".", "When", "the", "flag_tree_loop_if_convert_stores", "is", "not", "set", "PHI", "is", "not", "if", "-", "convertible", "if", ":", "a", "virtual", "PHI", "is", "immediately", "used", "in", "another", "PHI", "node", "there", "is", "a", "virtual", "PHI", "in", "a", "BB", "other", "than", "the", "loop", "-", ">", "header", "." ]
static bool if_convertible_phi_p (struct loop *loop, basic_block bb, gimple phi) { if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "-------------------------\n"); print_gimple_stmt (dump_file, phi, 0, TDF_SLIM); } if (bb != loop->header && gimple_phi_num_args (phi) != 2) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "More than two phi node args.\n"); return false; } if (flag_tree_loop_if_convert_stores) return true; if (!is_gimple_reg (SSA_NAME_VAR (gimple_phi_result (phi)))) { imm_use_iterator imm_iter; use_operand_p use_p; if (bb != loop->header) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Virtual phi not on loop->header.\n"); return false; } FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_phi_result (phi)) { if (gimple_code (USE_STMT (use_p)) == GIMPLE_PHI) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Difficult to handle this virtual phi.\n"); return false; } } } return true; }
[ "static", "bool", "if_convertible_phi_p", "(", "struct", "loop", "*", "loop", ",", "basic_block", "bb", ",", "gimple", "phi", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "{", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "print_gimple_stmt", "(", "dump_file", ",", "phi", ",", "0", ",", "TDF_SLIM", ")", ";", "}", "if", "(", "bb", "!=", "loop", "->", "header", "&&", "gimple_phi_num_args", "(", "phi", ")", "!=", "2", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "if", "(", "flag_tree_loop_if_convert_stores", ")", "return", "true", ";", "if", "(", "!", "is_gimple_reg", "(", "SSA_NAME_VAR", "(", "gimple_phi_result", "(", "phi", ")", ")", ")", ")", "{", "imm_use_iterator", "imm_iter", ";", "use_operand_p", "use_p", ";", "if", "(", "bb", "!=", "loop", "->", "header", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "FOR_EACH_IMM_USE_FAST", "(", "use_p", ",", "imm_iter", ",", "gimple_phi_result", "(", "phi", ")", ")", "", "{", "if", "(", "gimple_code", "(", "USE_STMT", "(", "use_p", ")", ")", "==", "GIMPLE_PHI", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Return true when PHI is if-convertible.
[ "Return", "true", "when", "PHI", "is", "if", "-", "convertible", "." ]
[ "/* When the flag_tree_loop_if_convert_stores is not set, check\n that there are no memory writes in the branches of the loop to be\n if-converted. */" ]
[ { "param": "loop", "type": "struct loop" }, { "param": "bb", "type": "basic_block" }, { "param": "phi", "type": "gimple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "phi", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
if_convertible_bb_p
bool
static bool if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb) { edge e; edge_iterator ei; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "----------[%d]-------------\n", bb->index); if (EDGE_COUNT (bb->preds) > 2 || EDGE_COUNT (bb->succs) > 2) return false; if (exit_bb) { if (bb != loop->latch) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "basic block after exit bb but before latch\n"); return false; } else if (!empty_block_p (bb)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "non empty basic block after exit bb\n"); return false; } else if (bb == loop->latch && bb != exit_bb && !dominated_by_p (CDI_DOMINATORS, bb, exit_bb)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "latch is not dominated by exit_block\n"); return false; } } /* Be less adventurous and handle only normal edges. */ FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_ABNORMAL | EDGE_IRREDUCIBLE_LOOP)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Difficult to handle edges\n"); return false; } /* At least one incoming edge has to be non-critical as otherwise edge predicates are not equal to basic-block predicates of the edge source. */ if (EDGE_COUNT (bb->preds) > 1 && bb != loop->header) { bool found = false; FOR_EACH_EDGE (e, ei, bb->preds) if (EDGE_COUNT (e->src->succs) == 1) found = true; if (!found) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "only critical predecessors\n"); return false; } } return true; }
/* Return true when BB is if-convertible. This routine does not check basic block's statements and phis. A basic block is not if-convertible if: - it is non-empty and it is after the exit block (in BFS order), - it is after the exit block but before the latch, - its edges are not normal. EXIT_BB is the basic block containing the exit of the LOOP. BB is inside LOOP. */
Return true when BB is if-convertible. This routine does not check basic block's statements and phis. A basic block is not if-convertible if: it is non-empty and it is after the exit block (in BFS order), it is after the exit block but before the latch, its edges are not normal. EXIT_BB is the basic block containing the exit of the LOOP. BB is inside LOOP.
[ "Return", "true", "when", "BB", "is", "if", "-", "convertible", ".", "This", "routine", "does", "not", "check", "basic", "block", "'", "s", "statements", "and", "phis", ".", "A", "basic", "block", "is", "not", "if", "-", "convertible", "if", ":", "it", "is", "non", "-", "empty", "and", "it", "is", "after", "the", "exit", "block", "(", "in", "BFS", "order", ")", "it", "is", "after", "the", "exit", "block", "but", "before", "the", "latch", "its", "edges", "are", "not", "normal", ".", "EXIT_BB", "is", "the", "basic", "block", "containing", "the", "exit", "of", "the", "LOOP", ".", "BB", "is", "inside", "LOOP", "." ]
static bool if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb) { edge e; edge_iterator ei; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "----------[%d]-------------\n", bb->index); if (EDGE_COUNT (bb->preds) > 2 || EDGE_COUNT (bb->succs) > 2) return false; if (exit_bb) { if (bb != loop->latch) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "basic block after exit bb but before latch\n"); return false; } else if (!empty_block_p (bb)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "non empty basic block after exit bb\n"); return false; } else if (bb == loop->latch && bb != exit_bb && !dominated_by_p (CDI_DOMINATORS, bb, exit_bb)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "latch is not dominated by exit_block\n"); return false; } } FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_ABNORMAL | EDGE_IRREDUCIBLE_LOOP)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Difficult to handle edges\n"); return false; } if (EDGE_COUNT (bb->preds) > 1 && bb != loop->header) { bool found = false; FOR_EACH_EDGE (e, ei, bb->preds) if (EDGE_COUNT (e->src->succs) == 1) found = true; if (!found) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "only critical predecessors\n"); return false; } } return true; }
[ "static", "bool", "if_convertible_bb_p", "(", "struct", "loop", "*", "loop", ",", "basic_block", "bb", ",", "basic_block", "exit_bb", ")", "{", "edge", "e", ";", "edge_iterator", "ei", ";", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ",", "bb", "->", "index", ")", ";", "if", "(", "EDGE_COUNT", "(", "bb", "->", "preds", ")", ">", "2", "||", "EDGE_COUNT", "(", "bb", "->", "succs", ")", ">", "2", ")", "return", "false", ";", "if", "(", "exit_bb", ")", "{", "if", "(", "bb", "!=", "loop", "->", "latch", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "else", "if", "(", "!", "empty_block_p", "(", "bb", ")", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "else", "if", "(", "bb", "==", "loop", "->", "latch", "&&", "bb", "!=", "exit_bb", "&&", "!", "dominated_by_p", "(", "CDI_DOMINATORS", ",", "bb", ",", "exit_bb", ")", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "}", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "bb", "->", "succs", ")", "", "if", "(", "e", "->", "flags", "&", "(", "EDGE_ABNORMAL_CALL", "|", "EDGE_EH", "|", "EDGE_ABNORMAL", "|", "EDGE_IRREDUCIBLE_LOOP", ")", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "if", "(", "EDGE_COUNT", "(", "bb", "->", "preds", ")", ">", "1", "&&", "bb", "!=", "loop", "->", "header", ")", "{", "bool", "found", "=", "false", ";", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "bb", "->", "preds", ")", "", "if", "(", "EDGE_COUNT", "(", "e", "->", "src", "->", "succs", ")", "==", "1", ")", "found", "=", "true", ";", "if", "(", "!", "found", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Return true when BB is if-convertible.
[ "Return", "true", "when", "BB", "is", "if", "-", "convertible", "." ]
[ "/* Be less adventurous and handle only normal edges. */", "/* At least one incoming edge has to be non-critical as otherwise edge\n predicates are not equal to basic-block predicates of the edge\n source. */" ]
[ { "param": "loop", "type": "struct loop" }, { "param": "bb", "type": "basic_block" }, { "param": "exit_bb", "type": "basic_block" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "exit_bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
pred_blocks_visited_p
bool
static bool pred_blocks_visited_p (basic_block bb, bitmap *visited) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->preds) if (!bitmap_bit_p (*visited, e->src->index)) return false; return true; }
/* Return true when all predecessor blocks of BB are visited. The VISITED bitmap keeps track of the visited blocks. */
Return true when all predecessor blocks of BB are visited. The VISITED bitmap keeps track of the visited blocks.
[ "Return", "true", "when", "all", "predecessor", "blocks", "of", "BB", "are", "visited", ".", "The", "VISITED", "bitmap", "keeps", "track", "of", "the", "visited", "blocks", "." ]
static bool pred_blocks_visited_p (basic_block bb, bitmap *visited) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->preds) if (!bitmap_bit_p (*visited, e->src->index)) return false; return true; }
[ "static", "bool", "pred_blocks_visited_p", "(", "basic_block", "bb", ",", "bitmap", "*", "visited", ")", "{", "edge", "e", ";", "edge_iterator", "ei", ";", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "bb", "->", "preds", ")", "", "if", "(", "!", "bitmap_bit_p", "(", "*", "visited", ",", "e", "->", "src", "->", "index", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Return true when all predecessor blocks of BB are visited.
[ "Return", "true", "when", "all", "predecessor", "blocks", "of", "BB", "are", "visited", "." ]
[]
[ { "param": "bb", "type": "basic_block" }, { "param": "visited", "type": "bitmap" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "visited", "type": "bitmap", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
predicate_bbs
bool
static bool predicate_bbs (loop_p loop) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) init_bb_predicate (ifc_bbs[i]); for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; tree cond; gimple_stmt_iterator itr; /* The loop latch is always executed and has no extra conditions to be processed: skip it. */ if (bb == loop->latch) { reset_bb_predicate (loop->latch); continue; } cond = bb_predicate (bb); for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr)) { gimple stmt = gsi_stmt (itr); switch (gimple_code (stmt)) { case GIMPLE_LABEL: case GIMPLE_ASSIGN: case GIMPLE_CALL: case GIMPLE_DEBUG: break; case GIMPLE_COND: { tree c2, tem; edge true_edge, false_edge; location_t loc = gimple_location (stmt); tree c = fold_build2_loc (loc, gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); /* Add new condition into destination's predicate list. */ extract_true_false_edges_from_block (gimple_bb (stmt), &true_edge, &false_edge); /* If C is true, then TRUE_EDGE is taken. */ add_to_dst_predicate_list (loop, true_edge, unshare_expr (cond), unshare_expr (c)); /* If C is false, then FALSE_EDGE is taken. */ c2 = invert_truthvalue_loc (loc, unshare_expr (c)); tem = canonicalize_cond_expr_cond (c2); if (tem) c2 = tem; add_to_dst_predicate_list (loop, false_edge, unshare_expr (cond), c2); cond = NULL_TREE; break; } default: /* Not handled yet in if-conversion. */ return false; } } /* If current bb has only one successor, then consider it as an unconditional goto. */ if (single_succ_p (bb)) { basic_block bb_n = single_succ (bb); /* The successor bb inherits the predicate of its predecessor. If there is no predicate in the predecessor bb, then consider the successor bb as always executed. */ if (cond == NULL_TREE) cond = boolean_true_node; add_to_predicate_list (bb_n, cond); } } /* The loop header is always executed. */ reset_bb_predicate (loop->header); gcc_assert (bb_predicate_gimplified_stmts (loop->header) == NULL && bb_predicate_gimplified_stmts (loop->latch) == NULL); return true; }
/* Returns true when the analysis of the predicates for all the basic blocks in LOOP succeeded. predicate_bbs first allocates the predicates of the basic blocks. These fields are then initialized with the tree expressions representing the predicates under which a basic block is executed in the LOOP. As the loop->header is executed at each iteration, it has the "true" predicate. Other statements executed under a condition are predicated with that condition, for example | if (x) | S1; | else | S2; S1 will be predicated with "x", and S2 will be predicated with "!x". */
Returns true when the analysis of the predicates for all the basic blocks in LOOP succeeded. predicate_bbs first allocates the predicates of the basic blocks. These fields are then initialized with the tree expressions representing the predicates under which a basic block is executed in the LOOP. As the loop->header is executed at each iteration, it has the "true" predicate. Other statements executed under a condition are predicated with that condition, for example S1 will be predicated with "x", and S2 will be predicated with "!x".
[ "Returns", "true", "when", "the", "analysis", "of", "the", "predicates", "for", "all", "the", "basic", "blocks", "in", "LOOP", "succeeded", ".", "predicate_bbs", "first", "allocates", "the", "predicates", "of", "the", "basic", "blocks", ".", "These", "fields", "are", "then", "initialized", "with", "the", "tree", "expressions", "representing", "the", "predicates", "under", "which", "a", "basic", "block", "is", "executed", "in", "the", "LOOP", ".", "As", "the", "loop", "-", ">", "header", "is", "executed", "at", "each", "iteration", "it", "has", "the", "\"", "true", "\"", "predicate", ".", "Other", "statements", "executed", "under", "a", "condition", "are", "predicated", "with", "that", "condition", "for", "example", "S1", "will", "be", "predicated", "with", "\"", "x", "\"", "and", "S2", "will", "be", "predicated", "with", "\"", "!x", "\"", "." ]
static bool predicate_bbs (loop_p loop) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) init_bb_predicate (ifc_bbs[i]); for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; tree cond; gimple_stmt_iterator itr; if (bb == loop->latch) { reset_bb_predicate (loop->latch); continue; } cond = bb_predicate (bb); for (itr = gsi_start_bb (bb); !gsi_end_p (itr); gsi_next (&itr)) { gimple stmt = gsi_stmt (itr); switch (gimple_code (stmt)) { case GIMPLE_LABEL: case GIMPLE_ASSIGN: case GIMPLE_CALL: case GIMPLE_DEBUG: break; case GIMPLE_COND: { tree c2, tem; edge true_edge, false_edge; location_t loc = gimple_location (stmt); tree c = fold_build2_loc (loc, gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); extract_true_false_edges_from_block (gimple_bb (stmt), &true_edge, &false_edge); add_to_dst_predicate_list (loop, true_edge, unshare_expr (cond), unshare_expr (c)); c2 = invert_truthvalue_loc (loc, unshare_expr (c)); tem = canonicalize_cond_expr_cond (c2); if (tem) c2 = tem; add_to_dst_predicate_list (loop, false_edge, unshare_expr (cond), c2); cond = NULL_TREE; break; } default: return false; } } if (single_succ_p (bb)) { basic_block bb_n = single_succ (bb); if (cond == NULL_TREE) cond = boolean_true_node; add_to_predicate_list (bb_n, cond); } } reset_bb_predicate (loop->header); gcc_assert (bb_predicate_gimplified_stmts (loop->header) == NULL && bb_predicate_gimplified_stmts (loop->latch) == NULL); return true; }
[ "static", "bool", "predicate_bbs", "(", "loop_p", "loop", ")", "{", "unsigned", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "loop", "->", "num_nodes", ";", "i", "++", ")", "init_bb_predicate", "(", "ifc_bbs", "[", "i", "]", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "loop", "->", "num_nodes", ";", "i", "++", ")", "{", "basic_block", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "tree", "cond", ";", "gimple_stmt_iterator", "itr", ";", "if", "(", "bb", "==", "loop", "->", "latch", ")", "{", "reset_bb_predicate", "(", "loop", "->", "latch", ")", ";", "continue", ";", "}", "cond", "=", "bb_predicate", "(", "bb", ")", ";", "for", "(", "itr", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "itr", ")", ";", "gsi_next", "(", "&", "itr", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "itr", ")", ";", "switch", "(", "gimple_code", "(", "stmt", ")", ")", "{", "case", "GIMPLE_LABEL", ":", "case", "GIMPLE_ASSIGN", ":", "case", "GIMPLE_CALL", ":", "case", "GIMPLE_DEBUG", ":", "break", ";", "case", "GIMPLE_COND", ":", "{", "tree", "c2", ",", "tem", ";", "edge", "true_edge", ",", "false_edge", ";", "location_t", "loc", "=", "gimple_location", "(", "stmt", ")", ";", "tree", "c", "=", "fold_build2_loc", "(", "loc", ",", "gimple_cond_code", "(", "stmt", ")", ",", "boolean_type_node", ",", "gimple_cond_lhs", "(", "stmt", ")", ",", "gimple_cond_rhs", "(", "stmt", ")", ")", ";", "extract_true_false_edges_from_block", "(", "gimple_bb", "(", "stmt", ")", ",", "&", "true_edge", ",", "&", "false_edge", ")", ";", "add_to_dst_predicate_list", "(", "loop", ",", "true_edge", ",", "unshare_expr", "(", "cond", ")", ",", "unshare_expr", "(", "c", ")", ")", ";", "c2", "=", "invert_truthvalue_loc", "(", "loc", ",", "unshare_expr", "(", "c", ")", ")", ";", "tem", "=", "canonicalize_cond_expr_cond", "(", "c2", ")", ";", "if", "(", "tem", ")", "c2", "=", "tem", ";", "add_to_dst_predicate_list", "(", "loop", ",", "false_edge", ",", "unshare_expr", "(", "cond", ")", ",", "c2", ")", ";", "cond", "=", "NULL_TREE", ";", "break", ";", "}", "default", ":", "return", "false", ";", "}", "}", "if", "(", "single_succ_p", "(", "bb", ")", ")", "{", "basic_block", "bb_n", "=", "single_succ", "(", "bb", ")", ";", "if", "(", "cond", "==", "NULL_TREE", ")", "cond", "=", "boolean_true_node", ";", "add_to_predicate_list", "(", "bb_n", ",", "cond", ")", ";", "}", "}", "reset_bb_predicate", "(", "loop", "->", "header", ")", ";", "gcc_assert", "(", "bb_predicate_gimplified_stmts", "(", "loop", "->", "header", ")", "==", "NULL", "&&", "bb_predicate_gimplified_stmts", "(", "loop", "->", "latch", ")", "==", "NULL", ")", ";", "return", "true", ";", "}" ]
Returns true when the analysis of the predicates for all the basic blocks in LOOP succeeded.
[ "Returns", "true", "when", "the", "analysis", "of", "the", "predicates", "for", "all", "the", "basic", "blocks", "in", "LOOP", "succeeded", "." ]
[ "/* The loop latch is always executed and has no extra conditions\n\t to be processed: skip it. */", "/* Add new condition into destination's predicate list. */", "/* If C is true, then TRUE_EDGE is taken. */", "/* If C is false, then FALSE_EDGE is taken. */", "/* Not handled yet in if-conversion. */", "/* If current bb has only one successor, then consider it as an\n\t unconditional goto. */", "/* The successor bb inherits the predicate of its\n\t predecessor. If there is no predicate in the predecessor\n\t bb, then consider the successor bb as always executed. */", "/* The loop header is always executed. */" ]
[ { "param": "loop", "type": "loop_p" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "loop_p", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
if_convertible_loop_p
bool
static bool if_convertible_loop_p (struct loop *loop) { edge e; edge_iterator ei; bool res = false; VEC (data_reference_p, heap) *refs; VEC (ddr_p, heap) *ddrs; VEC (loop_p, heap) *loop_nest; /* Handle only innermost loop. */ if (!loop || loop->inner) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "not innermost loop\n"); return false; } /* If only one block, no need for if-conversion. */ if (loop->num_nodes <= 2) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "less than 2 basic blocks\n"); return false; } /* More than one loop exit is too much to handle. */ if (!single_exit (loop)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "multiple exits\n"); return false; } /* If one of the loop header's edge is an exit edge then do not apply if-conversion. */ FOR_EACH_EDGE (e, ei, loop->header->succs) if (loop_exit_edge_p (loop, e)) return false; refs = VEC_alloc (data_reference_p, heap, 5); ddrs = VEC_alloc (ddr_p, heap, 25); loop_nest = VEC_alloc (loop_p, heap, 3); res = if_convertible_loop_p_1 (loop, &loop_nest, &refs, &ddrs); if (flag_tree_loop_if_convert_stores) { data_reference_p dr; unsigned int i; for (i = 0; VEC_iterate (data_reference_p, refs, i, dr); i++) free (dr->aux); } VEC_free (loop_p, heap, loop_nest); free_data_refs (refs); free_dependence_relations (ddrs); return res; }
/* Return true when LOOP is if-convertible. LOOP is if-convertible if: - it is innermost, - it has two or more basic blocks, - it has only one exit, - loop header is not the exit edge, - if its basic blocks and phi nodes are if convertible. */
Return true when LOOP is if-convertible. LOOP is if-convertible if: it is innermost, it has two or more basic blocks, it has only one exit, loop header is not the exit edge, if its basic blocks and phi nodes are if convertible.
[ "Return", "true", "when", "LOOP", "is", "if", "-", "convertible", ".", "LOOP", "is", "if", "-", "convertible", "if", ":", "it", "is", "innermost", "it", "has", "two", "or", "more", "basic", "blocks", "it", "has", "only", "one", "exit", "loop", "header", "is", "not", "the", "exit", "edge", "if", "its", "basic", "blocks", "and", "phi", "nodes", "are", "if", "convertible", "." ]
static bool if_convertible_loop_p (struct loop *loop) { edge e; edge_iterator ei; bool res = false; VEC (data_reference_p, heap) *refs; VEC (ddr_p, heap) *ddrs; VEC (loop_p, heap) *loop_nest; if (!loop || loop->inner) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "not innermost loop\n"); return false; } if (loop->num_nodes <= 2) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "less than 2 basic blocks\n"); return false; } if (!single_exit (loop)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "multiple exits\n"); return false; } FOR_EACH_EDGE (e, ei, loop->header->succs) if (loop_exit_edge_p (loop, e)) return false; refs = VEC_alloc (data_reference_p, heap, 5); ddrs = VEC_alloc (ddr_p, heap, 25); loop_nest = VEC_alloc (loop_p, heap, 3); res = if_convertible_loop_p_1 (loop, &loop_nest, &refs, &ddrs); if (flag_tree_loop_if_convert_stores) { data_reference_p dr; unsigned int i; for (i = 0; VEC_iterate (data_reference_p, refs, i, dr); i++) free (dr->aux); } VEC_free (loop_p, heap, loop_nest); free_data_refs (refs); free_dependence_relations (ddrs); return res; }
[ "static", "bool", "if_convertible_loop_p", "(", "struct", "loop", "*", "loop", ")", "{", "edge", "e", ";", "edge_iterator", "ei", ";", "bool", "res", "=", "false", ";", "VEC", "(", "data_reference_p", ",", "heap", ")", "*", "refs", ";", "VEC", "(", "ddr_p", ",", "heap", ")", "*", "ddrs", ";", "VEC", "(", "loop_p", ",", "heap", ")", "*", "loop_nest", ";", "if", "(", "!", "loop", "||", "loop", "->", "inner", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "if", "(", "loop", "->", "num_nodes", "<=", "2", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "if", "(", "!", "single_exit", "(", "loop", ")", ")", "{", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "return", "false", ";", "}", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "loop", "->", "header", "->", "succs", ")", "", "if", "(", "loop_exit_edge_p", "(", "loop", ",", "e", ")", ")", "return", "false", ";", "refs", "=", "VEC_alloc", "(", "data_reference_p", ",", "heap", ",", "5", ")", ";", "ddrs", "=", "VEC_alloc", "(", "ddr_p", ",", "heap", ",", "25", ")", ";", "loop_nest", "=", "VEC_alloc", "(", "loop_p", ",", "heap", ",", "3", ")", ";", "res", "=", "if_convertible_loop_p_1", "(", "loop", ",", "&", "loop_nest", ",", "&", "refs", ",", "&", "ddrs", ")", ";", "if", "(", "flag_tree_loop_if_convert_stores", ")", "{", "data_reference_p", "dr", ";", "unsigned", "int", "i", ";", "for", "(", "i", "=", "0", ";", "VEC_iterate", "(", "data_reference_p", ",", "refs", ",", "i", ",", "dr", ")", ";", "i", "++", ")", "free", "(", "dr", "->", "aux", ")", ";", "}", "VEC_free", "(", "loop_p", ",", "heap", ",", "loop_nest", ")", ";", "free_data_refs", "(", "refs", ")", ";", "free_dependence_relations", "(", "ddrs", ")", ";", "return", "res", ";", "}" ]
Return true when LOOP is if-convertible.
[ "Return", "true", "when", "LOOP", "is", "if", "-", "convertible", "." ]
[ "/* Handle only innermost loop. */", "/* If only one block, no need for if-conversion. */", "/* More than one loop exit is too much to handle. */", "/* If one of the loop header's edge is an exit edge then do not\n apply if-conversion. */" ]
[ { "param": "loop", "type": "struct loop" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
find_phi_replacement_condition
basic_block
static basic_block find_phi_replacement_condition (basic_block bb, tree *cond, gimple_stmt_iterator *gsi) { edge first_edge, second_edge; tree tmp_cond; gcc_assert (EDGE_COUNT (bb->preds) == 2); first_edge = EDGE_PRED (bb, 0); second_edge = EDGE_PRED (bb, 1); /* Prefer an edge with a not negated predicate. ??? That's a very weak cost model. */ tmp_cond = bb_predicate (first_edge->src); gcc_assert (tmp_cond); if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR) { edge tmp_edge; tmp_edge = first_edge; first_edge = second_edge; second_edge = tmp_edge; } /* Check if the edge we take the condition from is not critical. We know that at least one non-critical edge exists. */ if (EDGE_COUNT (first_edge->src->succs) > 1) { *cond = bb_predicate (second_edge->src); if (TREE_CODE (*cond) == TRUTH_NOT_EXPR) *cond = TREE_OPERAND (*cond, 0); else /* Select non loop header bb. */ first_edge = second_edge; } else *cond = bb_predicate (first_edge->src); /* Gimplify the condition to a valid cond-expr conditonal operand. */ *cond = force_gimple_operand_gsi_1 (gsi, unshare_expr (*cond), is_gimple_condexpr, NULL_TREE, true, GSI_SAME_STMT); return first_edge->src; }
/* Basic block BB has two predecessors. Using predecessor's bb predicate, set an appropriate condition COND for the PHI node replacement. Return the true block whose phi arguments are selected when cond is true. LOOP is the loop containing the if-converted region, GSI is the place to insert the code for the if-conversion. */
Basic block BB has two predecessors. Using predecessor's bb predicate, set an appropriate condition COND for the PHI node replacement. Return the true block whose phi arguments are selected when cond is true. LOOP is the loop containing the if-converted region, GSI is the place to insert the code for the if-conversion.
[ "Basic", "block", "BB", "has", "two", "predecessors", ".", "Using", "predecessor", "'", "s", "bb", "predicate", "set", "an", "appropriate", "condition", "COND", "for", "the", "PHI", "node", "replacement", ".", "Return", "the", "true", "block", "whose", "phi", "arguments", "are", "selected", "when", "cond", "is", "true", ".", "LOOP", "is", "the", "loop", "containing", "the", "if", "-", "converted", "region", "GSI", "is", "the", "place", "to", "insert", "the", "code", "for", "the", "if", "-", "conversion", "." ]
static basic_block find_phi_replacement_condition (basic_block bb, tree *cond, gimple_stmt_iterator *gsi) { edge first_edge, second_edge; tree tmp_cond; gcc_assert (EDGE_COUNT (bb->preds) == 2); first_edge = EDGE_PRED (bb, 0); second_edge = EDGE_PRED (bb, 1); tmp_cond = bb_predicate (first_edge->src); gcc_assert (tmp_cond); if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR) { edge tmp_edge; tmp_edge = first_edge; first_edge = second_edge; second_edge = tmp_edge; } if (EDGE_COUNT (first_edge->src->succs) > 1) { *cond = bb_predicate (second_edge->src); if (TREE_CODE (*cond) == TRUTH_NOT_EXPR) *cond = TREE_OPERAND (*cond, 0); else first_edge = second_edge; } else *cond = bb_predicate (first_edge->src); *cond = force_gimple_operand_gsi_1 (gsi, unshare_expr (*cond), is_gimple_condexpr, NULL_TREE, true, GSI_SAME_STMT); return first_edge->src; }
[ "static", "basic_block", "find_phi_replacement_condition", "(", "basic_block", "bb", ",", "tree", "*", "cond", ",", "gimple_stmt_iterator", "*", "gsi", ")", "{", "edge", "first_edge", ",", "second_edge", ";", "tree", "tmp_cond", ";", "gcc_assert", "(", "EDGE_COUNT", "(", "bb", "->", "preds", ")", "==", "2", ")", ";", "first_edge", "=", "EDGE_PRED", "(", "bb", ",", "0", ")", ";", "second_edge", "=", "EDGE_PRED", "(", "bb", ",", "1", ")", ";", "tmp_cond", "=", "bb_predicate", "(", "first_edge", "->", "src", ")", ";", "gcc_assert", "(", "tmp_cond", ")", ";", "if", "(", "TREE_CODE", "(", "tmp_cond", ")", "==", "TRUTH_NOT_EXPR", ")", "{", "edge", "tmp_edge", ";", "tmp_edge", "=", "first_edge", ";", "first_edge", "=", "second_edge", ";", "second_edge", "=", "tmp_edge", ";", "}", "if", "(", "EDGE_COUNT", "(", "first_edge", "->", "src", "->", "succs", ")", ">", "1", ")", "{", "*", "cond", "=", "bb_predicate", "(", "second_edge", "->", "src", ")", ";", "if", "(", "TREE_CODE", "(", "*", "cond", ")", "==", "TRUTH_NOT_EXPR", ")", "*", "cond", "=", "TREE_OPERAND", "(", "*", "cond", ",", "0", ")", ";", "else", "first_edge", "=", "second_edge", ";", "}", "else", "*", "cond", "=", "bb_predicate", "(", "first_edge", "->", "src", ")", ";", "*", "cond", "=", "force_gimple_operand_gsi_1", "(", "gsi", ",", "unshare_expr", "(", "*", "cond", ")", ",", "is_gimple_condexpr", ",", "NULL_TREE", ",", "true", ",", "GSI_SAME_STMT", ")", ";", "return", "first_edge", "->", "src", ";", "}" ]
Basic block BB has two predecessors.
[ "Basic", "block", "BB", "has", "two", "predecessors", "." ]
[ "/* Prefer an edge with a not negated predicate.\n ??? That's a very weak cost model. */", "/* Check if the edge we take the condition from is not critical.\n We know that at least one non-critical edge exists. */", "/* Select non loop header bb. */", "/* Gimplify the condition to a valid cond-expr conditonal operand. */" ]
[ { "param": "bb", "type": "basic_block" }, { "param": "cond", "type": "tree" }, { "param": "gsi", "type": "gimple_stmt_iterator" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gsi", "type": "gimple_stmt_iterator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
predicate_scalar_phi
void
static void predicate_scalar_phi (gimple phi, tree cond, basic_block true_bb, gimple_stmt_iterator *gsi) { gimple new_stmt; basic_block bb; tree rhs, res, arg, scev; gcc_assert (gimple_code (phi) == GIMPLE_PHI && gimple_phi_num_args (phi) == 2); res = gimple_phi_result (phi); /* Do not handle virtual phi nodes. */ if (!is_gimple_reg (SSA_NAME_VAR (res))) return; bb = gimple_bb (phi); if ((arg = degenerate_phi_result (phi)) || ((scev = analyze_scalar_evolution (gimple_bb (phi)->loop_father, res)) && !chrec_contains_undetermined (scev) && scev != res && (arg = gimple_phi_arg_def (phi, 0)))) rhs = arg; else { tree arg_0, arg_1; /* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr. */ if (EDGE_PRED (bb, 1)->src == true_bb) { arg_0 = gimple_phi_arg_def (phi, 1); arg_1 = gimple_phi_arg_def (phi, 0); } else { arg_0 = gimple_phi_arg_def (phi, 0); arg_1 = gimple_phi_arg_def (phi, 1); } /* Build new RHS using selected condition and arguments. */ rhs = build3 (COND_EXPR, TREE_TYPE (res), unshare_expr (cond), arg_0, arg_1); } new_stmt = gimple_build_assign (res, rhs); SSA_NAME_DEF_STMT (gimple_phi_result (phi)) = new_stmt; gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); update_stmt (new_stmt); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "new phi replacement stmt\n"); print_gimple_stmt (dump_file, new_stmt, 0, TDF_SLIM); } }
/* Replace a scalar PHI node with a COND_EXPR using COND as condition. This routine does not handle PHI nodes with more than two arguments. For example, S1: A = PHI <x1(1), x2(5)> is converted into, S2: A = cond ? x1 : x2; The generated code is inserted at GSI that points to the top of basic block's statement list. When COND is true, phi arg from TRUE_BB is selected. */
Replace a scalar PHI node with a COND_EXPR using COND as condition. This routine does not handle PHI nodes with more than two arguments. For example, S1: A = PHI is converted into, S2: A = cond . The generated code is inserted at GSI that points to the top of basic block's statement list. When COND is true, phi arg from TRUE_BB is selected.
[ "Replace", "a", "scalar", "PHI", "node", "with", "a", "COND_EXPR", "using", "COND", "as", "condition", ".", "This", "routine", "does", "not", "handle", "PHI", "nodes", "with", "more", "than", "two", "arguments", ".", "For", "example", "S1", ":", "A", "=", "PHI", "is", "converted", "into", "S2", ":", "A", "=", "cond", ".", "The", "generated", "code", "is", "inserted", "at", "GSI", "that", "points", "to", "the", "top", "of", "basic", "block", "'", "s", "statement", "list", ".", "When", "COND", "is", "true", "phi", "arg", "from", "TRUE_BB", "is", "selected", "." ]
static void predicate_scalar_phi (gimple phi, tree cond, basic_block true_bb, gimple_stmt_iterator *gsi) { gimple new_stmt; basic_block bb; tree rhs, res, arg, scev; gcc_assert (gimple_code (phi) == GIMPLE_PHI && gimple_phi_num_args (phi) == 2); res = gimple_phi_result (phi); if (!is_gimple_reg (SSA_NAME_VAR (res))) return; bb = gimple_bb (phi); if ((arg = degenerate_phi_result (phi)) || ((scev = analyze_scalar_evolution (gimple_bb (phi)->loop_father, res)) && !chrec_contains_undetermined (scev) && scev != res && (arg = gimple_phi_arg_def (phi, 0)))) rhs = arg; else { tree arg_0, arg_1; if (EDGE_PRED (bb, 1)->src == true_bb) { arg_0 = gimple_phi_arg_def (phi, 1); arg_1 = gimple_phi_arg_def (phi, 0); } else { arg_0 = gimple_phi_arg_def (phi, 0); arg_1 = gimple_phi_arg_def (phi, 1); } rhs = build3 (COND_EXPR, TREE_TYPE (res), unshare_expr (cond), arg_0, arg_1); } new_stmt = gimple_build_assign (res, rhs); SSA_NAME_DEF_STMT (gimple_phi_result (phi)) = new_stmt; gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); update_stmt (new_stmt); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "new phi replacement stmt\n"); print_gimple_stmt (dump_file, new_stmt, 0, TDF_SLIM); } }
[ "static", "void", "predicate_scalar_phi", "(", "gimple", "phi", ",", "tree", "cond", ",", "basic_block", "true_bb", ",", "gimple_stmt_iterator", "*", "gsi", ")", "{", "gimple", "new_stmt", ";", "basic_block", "bb", ";", "tree", "rhs", ",", "res", ",", "arg", ",", "scev", ";", "gcc_assert", "(", "gimple_code", "(", "phi", ")", "==", "GIMPLE_PHI", "&&", "gimple_phi_num_args", "(", "phi", ")", "==", "2", ")", ";", "res", "=", "gimple_phi_result", "(", "phi", ")", ";", "if", "(", "!", "is_gimple_reg", "(", "SSA_NAME_VAR", "(", "res", ")", ")", ")", "return", ";", "bb", "=", "gimple_bb", "(", "phi", ")", ";", "if", "(", "(", "arg", "=", "degenerate_phi_result", "(", "phi", ")", ")", "||", "(", "(", "scev", "=", "analyze_scalar_evolution", "(", "gimple_bb", "(", "phi", ")", "->", "loop_father", ",", "res", ")", ")", "&&", "!", "chrec_contains_undetermined", "(", "scev", ")", "&&", "scev", "!=", "res", "&&", "(", "arg", "=", "gimple_phi_arg_def", "(", "phi", ",", "0", ")", ")", ")", ")", "rhs", "=", "arg", ";", "else", "{", "tree", "arg_0", ",", "arg_1", ";", "if", "(", "EDGE_PRED", "(", "bb", ",", "1", ")", "->", "src", "==", "true_bb", ")", "{", "arg_0", "=", "gimple_phi_arg_def", "(", "phi", ",", "1", ")", ";", "arg_1", "=", "gimple_phi_arg_def", "(", "phi", ",", "0", ")", ";", "}", "else", "{", "arg_0", "=", "gimple_phi_arg_def", "(", "phi", ",", "0", ")", ";", "arg_1", "=", "gimple_phi_arg_def", "(", "phi", ",", "1", ")", ";", "}", "rhs", "=", "build3", "(", "COND_EXPR", ",", "TREE_TYPE", "(", "res", ")", ",", "unshare_expr", "(", "cond", ")", ",", "arg_0", ",", "arg_1", ")", ";", "}", "new_stmt", "=", "gimple_build_assign", "(", "res", ",", "rhs", ")", ";", "SSA_NAME_DEF_STMT", "(", "gimple_phi_result", "(", "phi", ")", ")", "=", "new_stmt", ";", "gsi_insert_before", "(", "gsi", ",", "new_stmt", ",", "GSI_SAME_STMT", ")", ";", "update_stmt", "(", "new_stmt", ")", ";", "if", "(", "dump_file", "&&", "(", "dump_flags", "&", "TDF_DETAILS", ")", ")", "{", "fprintf", "(", "dump_file", ",", "\"", "\\n", "\"", ")", ";", "print_gimple_stmt", "(", "dump_file", ",", "new_stmt", ",", "0", ",", "TDF_SLIM", ")", ";", "}", "}" ]
Replace a scalar PHI node with a COND_EXPR using COND as condition.
[ "Replace", "a", "scalar", "PHI", "node", "with", "a", "COND_EXPR", "using", "COND", "as", "condition", "." ]
[ "/* Do not handle virtual phi nodes. */", "/* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr. */", "/* Build new RHS using selected condition and arguments. */" ]
[ { "param": "phi", "type": "gimple" }, { "param": "cond", "type": "tree" }, { "param": "true_bb", "type": "basic_block" }, { "param": "gsi", "type": "gimple_stmt_iterator" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "phi", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "true_bb", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gsi", "type": "gimple_stmt_iterator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
predicate_all_scalar_phis
void
static void predicate_all_scalar_phis (struct loop *loop) { basic_block bb; unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int i; for (i = 1; i < orig_loop_num_nodes; i++) { gimple phi; tree cond = NULL_TREE; gimple_stmt_iterator gsi, phi_gsi; basic_block true_bb = NULL; bb = ifc_bbs[i]; if (bb == loop->header) continue; phi_gsi = gsi_start_phis (bb); if (gsi_end_p (phi_gsi)) continue; /* BB has two predecessors. Using predecessor's aux field, set appropriate condition for the PHI node replacement. */ gsi = gsi_after_labels (bb); true_bb = find_phi_replacement_condition (bb, &cond, &gsi); while (!gsi_end_p (phi_gsi)) { phi = gsi_stmt (phi_gsi); predicate_scalar_phi (phi, cond, true_bb, &gsi); release_phi_node (phi); gsi_next (&phi_gsi); } set_phi_nodes (bb, NULL); } }
/* Replaces in LOOP all the scalar phi nodes other than those in the LOOP->header block with conditional modify expressions. */
Replaces in LOOP all the scalar phi nodes other than those in the LOOP->header block with conditional modify expressions.
[ "Replaces", "in", "LOOP", "all", "the", "scalar", "phi", "nodes", "other", "than", "those", "in", "the", "LOOP", "-", ">", "header", "block", "with", "conditional", "modify", "expressions", "." ]
static void predicate_all_scalar_phis (struct loop *loop) { basic_block bb; unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int i; for (i = 1; i < orig_loop_num_nodes; i++) { gimple phi; tree cond = NULL_TREE; gimple_stmt_iterator gsi, phi_gsi; basic_block true_bb = NULL; bb = ifc_bbs[i]; if (bb == loop->header) continue; phi_gsi = gsi_start_phis (bb); if (gsi_end_p (phi_gsi)) continue; gsi = gsi_after_labels (bb); true_bb = find_phi_replacement_condition (bb, &cond, &gsi); while (!gsi_end_p (phi_gsi)) { phi = gsi_stmt (phi_gsi); predicate_scalar_phi (phi, cond, true_bb, &gsi); release_phi_node (phi); gsi_next (&phi_gsi); } set_phi_nodes (bb, NULL); } }
[ "static", "void", "predicate_all_scalar_phis", "(", "struct", "loop", "*", "loop", ")", "{", "basic_block", "bb", ";", "unsigned", "int", "orig_loop_num_nodes", "=", "loop", "->", "num_nodes", ";", "unsigned", "int", "i", ";", "for", "(", "i", "=", "1", ";", "i", "<", "orig_loop_num_nodes", ";", "i", "++", ")", "{", "gimple", "phi", ";", "tree", "cond", "=", "NULL_TREE", ";", "gimple_stmt_iterator", "gsi", ",", "phi_gsi", ";", "basic_block", "true_bb", "=", "NULL", ";", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "if", "(", "bb", "==", "loop", "->", "header", ")", "continue", ";", "phi_gsi", "=", "gsi_start_phis", "(", "bb", ")", ";", "if", "(", "gsi_end_p", "(", "phi_gsi", ")", ")", "continue", ";", "gsi", "=", "gsi_after_labels", "(", "bb", ")", ";", "true_bb", "=", "find_phi_replacement_condition", "(", "bb", ",", "&", "cond", ",", "&", "gsi", ")", ";", "while", "(", "!", "gsi_end_p", "(", "phi_gsi", ")", ")", "{", "phi", "=", "gsi_stmt", "(", "phi_gsi", ")", ";", "predicate_scalar_phi", "(", "phi", ",", "cond", ",", "true_bb", ",", "&", "gsi", ")", ";", "release_phi_node", "(", "phi", ")", ";", "gsi_next", "(", "&", "phi_gsi", ")", ";", "}", "set_phi_nodes", "(", "bb", ",", "NULL", ")", ";", "}", "}" ]
Replaces in LOOP all the scalar phi nodes other than those in the LOOP->header block with conditional modify expressions.
[ "Replaces", "in", "LOOP", "all", "the", "scalar", "phi", "nodes", "other", "than", "those", "in", "the", "LOOP", "-", ">", "header", "block", "with", "conditional", "modify", "expressions", "." ]
[ "/* BB has two predecessors. Using predecessor's aux field, set\n\t appropriate condition for the PHI node replacement. */" ]
[ { "param": "loop", "type": "struct loop" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
insert_gimplified_predicates
void
static void insert_gimplified_predicates (loop_p loop) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; gimple_seq stmts; if (!is_predicated (bb)) { /* Do not insert statements for a basic block that is not predicated. Also make sure that the predicate of the basic block is set to true. */ reset_bb_predicate (bb); continue; } stmts = bb_predicate_gimplified_stmts (bb); if (stmts) { if (flag_tree_loop_if_convert_stores) { /* Insert the predicate of the BB just after the label, as the if-conversion of memory writes will use this predicate. */ gimple_stmt_iterator gsi = gsi_after_labels (bb); gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT); } else { /* Insert the predicate of the BB at the end of the BB as this would reduce the register pressure: the only use of this predicate will be in successor BBs. */ gimple_stmt_iterator gsi = gsi_last_bb (bb); if (gsi_end_p (gsi) || stmt_ends_bb_p (gsi_stmt (gsi))) gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT); else gsi_insert_seq_after (&gsi, stmts, GSI_SAME_STMT); } /* Once the sequence is code generated, set it to NULL. */ set_bb_predicate_gimplified_stmts (bb, NULL); } } }
/* Insert in each basic block of LOOP the statements produced by the gimplification of the predicates. */
Insert in each basic block of LOOP the statements produced by the gimplification of the predicates.
[ "Insert", "in", "each", "basic", "block", "of", "LOOP", "the", "statements", "produced", "by", "the", "gimplification", "of", "the", "predicates", "." ]
static void insert_gimplified_predicates (loop_p loop) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; gimple_seq stmts; if (!is_predicated (bb)) { reset_bb_predicate (bb); continue; } stmts = bb_predicate_gimplified_stmts (bb); if (stmts) { if (flag_tree_loop_if_convert_stores) { gimple_stmt_iterator gsi = gsi_after_labels (bb); gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT); } else { gimple_stmt_iterator gsi = gsi_last_bb (bb); if (gsi_end_p (gsi) || stmt_ends_bb_p (gsi_stmt (gsi))) gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT); else gsi_insert_seq_after (&gsi, stmts, GSI_SAME_STMT); } set_bb_predicate_gimplified_stmts (bb, NULL); } } }
[ "static", "void", "insert_gimplified_predicates", "(", "loop_p", "loop", ")", "{", "unsigned", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "loop", "->", "num_nodes", ";", "i", "++", ")", "{", "basic_block", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "gimple_seq", "stmts", ";", "if", "(", "!", "is_predicated", "(", "bb", ")", ")", "{", "reset_bb_predicate", "(", "bb", ")", ";", "continue", ";", "}", "stmts", "=", "bb_predicate_gimplified_stmts", "(", "bb", ")", ";", "if", "(", "stmts", ")", "{", "if", "(", "flag_tree_loop_if_convert_stores", ")", "{", "gimple_stmt_iterator", "gsi", "=", "gsi_after_labels", "(", "bb", ")", ";", "gsi_insert_seq_before", "(", "&", "gsi", ",", "stmts", ",", "GSI_SAME_STMT", ")", ";", "}", "else", "{", "gimple_stmt_iterator", "gsi", "=", "gsi_last_bb", "(", "bb", ")", ";", "if", "(", "gsi_end_p", "(", "gsi", ")", "||", "stmt_ends_bb_p", "(", "gsi_stmt", "(", "gsi", ")", ")", ")", "gsi_insert_seq_before", "(", "&", "gsi", ",", "stmts", ",", "GSI_SAME_STMT", ")", ";", "else", "gsi_insert_seq_after", "(", "&", "gsi", ",", "stmts", ",", "GSI_SAME_STMT", ")", ";", "}", "set_bb_predicate_gimplified_stmts", "(", "bb", ",", "NULL", ")", ";", "}", "}", "}" ]
Insert in each basic block of LOOP the statements produced by the gimplification of the predicates.
[ "Insert", "in", "each", "basic", "block", "of", "LOOP", "the", "statements", "produced", "by", "the", "gimplification", "of", "the", "predicates", "." ]
[ "/* Do not insert statements for a basic block that is not\n\t predicated. Also make sure that the predicate of the\n\t basic block is set to true. */", "/* Insert the predicate of the BB just after the label,\n\t\t as the if-conversion of memory writes will use this\n\t\t predicate. */", "/* Insert the predicate of the BB at the end of the BB\n\t\t as this would reduce the register pressure: the only\n\t\t use of this predicate will be in successor BBs. */", "/* Once the sequence is code generated, set it to NULL. */" ]
[ { "param": "loop", "type": "loop_p" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "loop_p", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
predicate_mem_writes
void
static void predicate_mem_writes (loop_p loop) { unsigned int i, orig_loop_num_nodes = loop->num_nodes; for (i = 1; i < orig_loop_num_nodes; i++) { gimple_stmt_iterator gsi; basic_block bb = ifc_bbs[i]; tree cond = bb_predicate (bb); bool swap; gimple stmt; if (is_true_predicate (cond)) continue; swap = false; if (TREE_CODE (cond) == TRUTH_NOT_EXPR) { swap = true; cond = TREE_OPERAND (cond, 0); } for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if ((stmt = gsi_stmt (gsi)) && gimple_assign_single_p (stmt) && gimple_vdef (stmt)) { tree lhs = gimple_assign_lhs (stmt); tree rhs = gimple_assign_rhs1 (stmt); tree type = TREE_TYPE (lhs); lhs = ifc_temp_var (type, unshare_expr (lhs), &gsi); rhs = ifc_temp_var (type, unshare_expr (rhs), &gsi); if (swap) { tree tem = lhs; lhs = rhs; rhs = tem; } cond = force_gimple_operand_gsi_1 (&gsi, unshare_expr (cond), is_gimple_condexpr, NULL_TREE, true, GSI_SAME_STMT); rhs = build3 (COND_EXPR, type, unshare_expr (cond), rhs, lhs); gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi)); update_stmt (stmt); } } }
/* Predicate each write to memory in LOOP. This function transforms control flow constructs containing memory writes of the form: | for (i = 0; i < N; i++) | if (cond) | A[i] = expr; into the following form that does not contain control flow: | for (i = 0; i < N; i++) | A[i] = cond ? expr : A[i]; The original CFG looks like this: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | cond = some_computation; | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | A[i] = expr; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 insert_gimplified_predicates inserts the computation of the COND expression at the beginning of the destination basic block: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | cond = some_computation; | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | cond = some_computation; | A[i] = expr; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 predicate_mem_writes is then predicating the memory write as follows: | bb_0 | i = 0 | end_bb_0 | | bb_1 | if (i < N) goto bb_5 else goto bb_2 | end_bb_1 | | bb_2 | if (cond) goto bb_3 else goto bb_4 | end_bb_2 | | bb_3 | cond = some_computation; | A[i] = cond ? expr : A[i]; | goto bb_4 | end_bb_3 | | bb_4 | goto bb_1 | end_bb_4 and finally combine_blocks removes the basic block boundaries making the loop vectorizable: | bb_0 | i = 0 | if (i < N) goto bb_5 else goto bb_1 | end_bb_0 | | bb_1 | cond = some_computation; | A[i] = cond ? expr : A[i]; | if (i < N) goto bb_5 else goto bb_4 | end_bb_1 | | bb_4 | goto bb_1 | end_bb_4 */
Predicate each write to memory in LOOP. This function transforms control flow constructs containing memory writes of the form. into the following form that does not contain control flow. The original CFG looks like this. insert_gimplified_predicates inserts the computation of the COND expression at the beginning of the destination basic block. predicate_mem_writes is then predicating the memory write as follows. and finally combine_blocks removes the basic block boundaries making the loop vectorizable.
[ "Predicate", "each", "write", "to", "memory", "in", "LOOP", ".", "This", "function", "transforms", "control", "flow", "constructs", "containing", "memory", "writes", "of", "the", "form", ".", "into", "the", "following", "form", "that", "does", "not", "contain", "control", "flow", ".", "The", "original", "CFG", "looks", "like", "this", ".", "insert_gimplified_predicates", "inserts", "the", "computation", "of", "the", "COND", "expression", "at", "the", "beginning", "of", "the", "destination", "basic", "block", ".", "predicate_mem_writes", "is", "then", "predicating", "the", "memory", "write", "as", "follows", ".", "and", "finally", "combine_blocks", "removes", "the", "basic", "block", "boundaries", "making", "the", "loop", "vectorizable", "." ]
static void predicate_mem_writes (loop_p loop) { unsigned int i, orig_loop_num_nodes = loop->num_nodes; for (i = 1; i < orig_loop_num_nodes; i++) { gimple_stmt_iterator gsi; basic_block bb = ifc_bbs[i]; tree cond = bb_predicate (bb); bool swap; gimple stmt; if (is_true_predicate (cond)) continue; swap = false; if (TREE_CODE (cond) == TRUTH_NOT_EXPR) { swap = true; cond = TREE_OPERAND (cond, 0); } for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if ((stmt = gsi_stmt (gsi)) && gimple_assign_single_p (stmt) && gimple_vdef (stmt)) { tree lhs = gimple_assign_lhs (stmt); tree rhs = gimple_assign_rhs1 (stmt); tree type = TREE_TYPE (lhs); lhs = ifc_temp_var (type, unshare_expr (lhs), &gsi); rhs = ifc_temp_var (type, unshare_expr (rhs), &gsi); if (swap) { tree tem = lhs; lhs = rhs; rhs = tem; } cond = force_gimple_operand_gsi_1 (&gsi, unshare_expr (cond), is_gimple_condexpr, NULL_TREE, true, GSI_SAME_STMT); rhs = build3 (COND_EXPR, type, unshare_expr (cond), rhs, lhs); gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi)); update_stmt (stmt); } } }
[ "static", "void", "predicate_mem_writes", "(", "loop_p", "loop", ")", "{", "unsigned", "int", "i", ",", "orig_loop_num_nodes", "=", "loop", "->", "num_nodes", ";", "for", "(", "i", "=", "1", ";", "i", "<", "orig_loop_num_nodes", ";", "i", "++", ")", "{", "gimple_stmt_iterator", "gsi", ";", "basic_block", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "tree", "cond", "=", "bb_predicate", "(", "bb", ")", ";", "bool", "swap", ";", "gimple", "stmt", ";", "if", "(", "is_true_predicate", "(", "cond", ")", ")", "continue", ";", "swap", "=", "false", ";", "if", "(", "TREE_CODE", "(", "cond", ")", "==", "TRUTH_NOT_EXPR", ")", "{", "swap", "=", "true", ";", "cond", "=", "TREE_OPERAND", "(", "cond", ",", "0", ")", ";", "}", "for", "(", "gsi", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "gsi", ")", ";", "gsi_next", "(", "&", "gsi", ")", ")", "if", "(", "(", "stmt", "=", "gsi_stmt", "(", "gsi", ")", ")", "&&", "gimple_assign_single_p", "(", "stmt", ")", "&&", "gimple_vdef", "(", "stmt", ")", ")", "{", "tree", "lhs", "=", "gimple_assign_lhs", "(", "stmt", ")", ";", "tree", "rhs", "=", "gimple_assign_rhs1", "(", "stmt", ")", ";", "tree", "type", "=", "TREE_TYPE", "(", "lhs", ")", ";", "lhs", "=", "ifc_temp_var", "(", "type", ",", "unshare_expr", "(", "lhs", ")", ",", "&", "gsi", ")", ";", "rhs", "=", "ifc_temp_var", "(", "type", ",", "unshare_expr", "(", "rhs", ")", ",", "&", "gsi", ")", ";", "if", "(", "swap", ")", "{", "tree", "tem", "=", "lhs", ";", "lhs", "=", "rhs", ";", "rhs", "=", "tem", ";", "}", "cond", "=", "force_gimple_operand_gsi_1", "(", "&", "gsi", ",", "unshare_expr", "(", "cond", ")", ",", "is_gimple_condexpr", ",", "NULL_TREE", ",", "true", ",", "GSI_SAME_STMT", ")", ";", "rhs", "=", "build3", "(", "COND_EXPR", ",", "type", ",", "unshare_expr", "(", "cond", ")", ",", "rhs", ",", "lhs", ")", ";", "gimple_assign_set_rhs1", "(", "stmt", ",", "ifc_temp_var", "(", "type", ",", "rhs", ",", "&", "gsi", ")", ")", ";", "update_stmt", "(", "stmt", ")", ";", "}", "}", "}" ]
Predicate each write to memory in LOOP.
[ "Predicate", "each", "write", "to", "memory", "in", "LOOP", "." ]
[]
[ { "param": "loop", "type": "loop_p" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "loop_p", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
remove_conditions_and_labels
void
static void remove_conditions_and_labels (loop_p loop) { gimple_stmt_iterator gsi; unsigned int i; for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; if (bb_with_exit_edge_p (loop, bb) || bb == loop->latch) continue; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) switch (gimple_code (gsi_stmt (gsi))) { case GIMPLE_COND: case GIMPLE_LABEL: gsi_remove (&gsi, true); break; case GIMPLE_DEBUG: /* ??? Should there be conditional GIMPLE_DEBUG_BINDs? */ if (gimple_debug_bind_p (gsi_stmt (gsi))) { gimple_debug_bind_reset_value (gsi_stmt (gsi)); update_stmt (gsi_stmt (gsi)); } gsi_next (&gsi); break; default: gsi_next (&gsi); } } }
/* Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks other than the exit and latch of the LOOP. Also resets the GIMPLE_DEBUG information. */
Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks other than the exit and latch of the LOOP. Also resets the GIMPLE_DEBUG information.
[ "Remove", "all", "GIMPLE_CONDs", "and", "GIMPLE_LABELs", "of", "all", "the", "basic", "blocks", "other", "than", "the", "exit", "and", "latch", "of", "the", "LOOP", ".", "Also", "resets", "the", "GIMPLE_DEBUG", "information", "." ]
static void remove_conditions_and_labels (loop_p loop) { gimple_stmt_iterator gsi; unsigned int i; for (i = 0; i < loop->num_nodes; i++) { basic_block bb = ifc_bbs[i]; if (bb_with_exit_edge_p (loop, bb) || bb == loop->latch) continue; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); ) switch (gimple_code (gsi_stmt (gsi))) { case GIMPLE_COND: case GIMPLE_LABEL: gsi_remove (&gsi, true); break; case GIMPLE_DEBUG: if (gimple_debug_bind_p (gsi_stmt (gsi))) { gimple_debug_bind_reset_value (gsi_stmt (gsi)); update_stmt (gsi_stmt (gsi)); } gsi_next (&gsi); break; default: gsi_next (&gsi); } } }
[ "static", "void", "remove_conditions_and_labels", "(", "loop_p", "loop", ")", "{", "gimple_stmt_iterator", "gsi", ";", "unsigned", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "loop", "->", "num_nodes", ";", "i", "++", ")", "{", "basic_block", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "if", "(", "bb_with_exit_edge_p", "(", "loop", ",", "bb", ")", "||", "bb", "==", "loop", "->", "latch", ")", "continue", ";", "for", "(", "gsi", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "gsi", ")", ";", ")", "switch", "(", "gimple_code", "(", "gsi_stmt", "(", "gsi", ")", ")", ")", "{", "case", "GIMPLE_COND", ":", "case", "GIMPLE_LABEL", ":", "gsi_remove", "(", "&", "gsi", ",", "true", ")", ";", "break", ";", "case", "GIMPLE_DEBUG", ":", "if", "(", "gimple_debug_bind_p", "(", "gsi_stmt", "(", "gsi", ")", ")", ")", "{", "gimple_debug_bind_reset_value", "(", "gsi_stmt", "(", "gsi", ")", ")", ";", "update_stmt", "(", "gsi_stmt", "(", "gsi", ")", ")", ";", "}", "gsi_next", "(", "&", "gsi", ")", ";", "break", ";", "default", ":", "gsi_next", "(", "&", "gsi", ")", ";", "}", "}", "}" ]
Remove all GIMPLE_CONDs and GIMPLE_LABELs of all the basic blocks other than the exit and latch of the LOOP.
[ "Remove", "all", "GIMPLE_CONDs", "and", "GIMPLE_LABELs", "of", "all", "the", "basic", "blocks", "other", "than", "the", "exit", "and", "latch", "of", "the", "LOOP", "." ]
[ "/* ??? Should there be conditional GIMPLE_DEBUG_BINDs? */" ]
[ { "param": "loop", "type": "loop_p" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "loop_p", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
combine_blocks
void
static void combine_blocks (struct loop *loop) { basic_block bb, exit_bb, merge_target_bb; unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int i; edge e; edge_iterator ei; remove_conditions_and_labels (loop); insert_gimplified_predicates (loop); predicate_all_scalar_phis (loop); if (flag_tree_loop_if_convert_stores) predicate_mem_writes (loop); /* Merge basic blocks: first remove all the edges in the loop, except for those from the exit block. */ exit_bb = NULL; for (i = 0; i < orig_loop_num_nodes; i++) { bb = ifc_bbs[i]; free_bb_predicate (bb); if (bb_with_exit_edge_p (loop, bb)) { exit_bb = bb; break; } } gcc_assert (exit_bb != loop->latch); for (i = 1; i < orig_loop_num_nodes; i++) { bb = ifc_bbs[i]; for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei));) { if (e->src == exit_bb) ei_next (&ei); else remove_edge (e); } } if (exit_bb != NULL) { if (exit_bb != loop->header) { /* Connect this node to loop header. */ make_edge (loop->header, exit_bb, EDGE_FALLTHRU); set_immediate_dominator (CDI_DOMINATORS, exit_bb, loop->header); } /* Redirect non-exit edges to loop->latch. */ FOR_EACH_EDGE (e, ei, exit_bb->succs) { if (!loop_exit_edge_p (loop, e)) redirect_edge_and_branch (e, loop->latch); } set_immediate_dominator (CDI_DOMINATORS, loop->latch, exit_bb); } else { /* If the loop does not have an exit, reconnect header and latch. */ make_edge (loop->header, loop->latch, EDGE_FALLTHRU); set_immediate_dominator (CDI_DOMINATORS, loop->latch, loop->header); } merge_target_bb = loop->header; for (i = 1; i < orig_loop_num_nodes; i++) { gimple_stmt_iterator gsi; gimple_stmt_iterator last; bb = ifc_bbs[i]; if (bb == exit_bb || bb == loop->latch) continue; /* Make stmts member of loop->header. */ for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) gimple_set_bb (gsi_stmt (gsi), merge_target_bb); /* Update stmt list. */ last = gsi_last_bb (merge_target_bb); gsi_insert_seq_after (&last, bb_seq (bb), GSI_NEW_STMT); set_bb_seq (bb, NULL); delete_basic_block (bb); } /* If possible, merge loop header to the block with the exit edge. This reduces the number of basic blocks to two, to please the vectorizer that handles only loops with two nodes. */ if (exit_bb && exit_bb != loop->header && can_merge_blocks_p (loop->header, exit_bb)) merge_blocks (loop->header, exit_bb); free (ifc_bbs); ifc_bbs = NULL; }
/* Combine all the basic blocks from LOOP into one or two super basic blocks. Replace PHI nodes with conditional modify expressions. */
Combine all the basic blocks from LOOP into one or two super basic blocks. Replace PHI nodes with conditional modify expressions.
[ "Combine", "all", "the", "basic", "blocks", "from", "LOOP", "into", "one", "or", "two", "super", "basic", "blocks", ".", "Replace", "PHI", "nodes", "with", "conditional", "modify", "expressions", "." ]
static void combine_blocks (struct loop *loop) { basic_block bb, exit_bb, merge_target_bb; unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int i; edge e; edge_iterator ei; remove_conditions_and_labels (loop); insert_gimplified_predicates (loop); predicate_all_scalar_phis (loop); if (flag_tree_loop_if_convert_stores) predicate_mem_writes (loop); exit_bb = NULL; for (i = 0; i < orig_loop_num_nodes; i++) { bb = ifc_bbs[i]; free_bb_predicate (bb); if (bb_with_exit_edge_p (loop, bb)) { exit_bb = bb; break; } } gcc_assert (exit_bb != loop->latch); for (i = 1; i < orig_loop_num_nodes; i++) { bb = ifc_bbs[i]; for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei));) { if (e->src == exit_bb) ei_next (&ei); else remove_edge (e); } } if (exit_bb != NULL) { if (exit_bb != loop->header) { make_edge (loop->header, exit_bb, EDGE_FALLTHRU); set_immediate_dominator (CDI_DOMINATORS, exit_bb, loop->header); } FOR_EACH_EDGE (e, ei, exit_bb->succs) { if (!loop_exit_edge_p (loop, e)) redirect_edge_and_branch (e, loop->latch); } set_immediate_dominator (CDI_DOMINATORS, loop->latch, exit_bb); } else { make_edge (loop->header, loop->latch, EDGE_FALLTHRU); set_immediate_dominator (CDI_DOMINATORS, loop->latch, loop->header); } merge_target_bb = loop->header; for (i = 1; i < orig_loop_num_nodes; i++) { gimple_stmt_iterator gsi; gimple_stmt_iterator last; bb = ifc_bbs[i]; if (bb == exit_bb || bb == loop->latch) continue; for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) gimple_set_bb (gsi_stmt (gsi), merge_target_bb); last = gsi_last_bb (merge_target_bb); gsi_insert_seq_after (&last, bb_seq (bb), GSI_NEW_STMT); set_bb_seq (bb, NULL); delete_basic_block (bb); } if (exit_bb && exit_bb != loop->header && can_merge_blocks_p (loop->header, exit_bb)) merge_blocks (loop->header, exit_bb); free (ifc_bbs); ifc_bbs = NULL; }
[ "static", "void", "combine_blocks", "(", "struct", "loop", "*", "loop", ")", "{", "basic_block", "bb", ",", "exit_bb", ",", "merge_target_bb", ";", "unsigned", "int", "orig_loop_num_nodes", "=", "loop", "->", "num_nodes", ";", "unsigned", "int", "i", ";", "edge", "e", ";", "edge_iterator", "ei", ";", "remove_conditions_and_labels", "(", "loop", ")", ";", "insert_gimplified_predicates", "(", "loop", ")", ";", "predicate_all_scalar_phis", "(", "loop", ")", ";", "if", "(", "flag_tree_loop_if_convert_stores", ")", "predicate_mem_writes", "(", "loop", ")", ";", "exit_bb", "=", "NULL", ";", "for", "(", "i", "=", "0", ";", "i", "<", "orig_loop_num_nodes", ";", "i", "++", ")", "{", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "free_bb_predicate", "(", "bb", ")", ";", "if", "(", "bb_with_exit_edge_p", "(", "loop", ",", "bb", ")", ")", "{", "exit_bb", "=", "bb", ";", "break", ";", "}", "}", "gcc_assert", "(", "exit_bb", "!=", "loop", "->", "latch", ")", ";", "for", "(", "i", "=", "1", ";", "i", "<", "orig_loop_num_nodes", ";", "i", "++", ")", "{", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "for", "(", "ei", "=", "ei_start", "(", "bb", "->", "preds", ")", ";", "(", "e", "=", "ei_safe_edge", "(", "ei", ")", ")", ";", ")", "{", "if", "(", "e", "->", "src", "==", "exit_bb", ")", "ei_next", "(", "&", "ei", ")", ";", "else", "remove_edge", "(", "e", ")", ";", "}", "}", "if", "(", "exit_bb", "!=", "NULL", ")", "{", "if", "(", "exit_bb", "!=", "loop", "->", "header", ")", "{", "make_edge", "(", "loop", "->", "header", ",", "exit_bb", ",", "EDGE_FALLTHRU", ")", ";", "set_immediate_dominator", "(", "CDI_DOMINATORS", ",", "exit_bb", ",", "loop", "->", "header", ")", ";", "}", "FOR_EACH_EDGE", "(", "e", ",", "ei", ",", "exit_bb", "->", "succs", ")", "", "{", "if", "(", "!", "loop_exit_edge_p", "(", "loop", ",", "e", ")", ")", "redirect_edge_and_branch", "(", "e", ",", "loop", "->", "latch", ")", ";", "}", "set_immediate_dominator", "(", "CDI_DOMINATORS", ",", "loop", "->", "latch", ",", "exit_bb", ")", ";", "}", "else", "{", "make_edge", "(", "loop", "->", "header", ",", "loop", "->", "latch", ",", "EDGE_FALLTHRU", ")", ";", "set_immediate_dominator", "(", "CDI_DOMINATORS", ",", "loop", "->", "latch", ",", "loop", "->", "header", ")", ";", "}", "merge_target_bb", "=", "loop", "->", "header", ";", "for", "(", "i", "=", "1", ";", "i", "<", "orig_loop_num_nodes", ";", "i", "++", ")", "{", "gimple_stmt_iterator", "gsi", ";", "gimple_stmt_iterator", "last", ";", "bb", "=", "ifc_bbs", "[", "i", "]", ";", "if", "(", "bb", "==", "exit_bb", "||", "bb", "==", "loop", "->", "latch", ")", "continue", ";", "for", "(", "gsi", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "gsi", ")", ";", "gsi_next", "(", "&", "gsi", ")", ")", "gimple_set_bb", "(", "gsi_stmt", "(", "gsi", ")", ",", "merge_target_bb", ")", ";", "last", "=", "gsi_last_bb", "(", "merge_target_bb", ")", ";", "gsi_insert_seq_after", "(", "&", "last", ",", "bb_seq", "(", "bb", ")", ",", "GSI_NEW_STMT", ")", ";", "set_bb_seq", "(", "bb", ",", "NULL", ")", ";", "delete_basic_block", "(", "bb", ")", ";", "}", "if", "(", "exit_bb", "&&", "exit_bb", "!=", "loop", "->", "header", "&&", "can_merge_blocks_p", "(", "loop", "->", "header", ",", "exit_bb", ")", ")", "merge_blocks", "(", "loop", "->", "header", ",", "exit_bb", ")", ";", "free", "(", "ifc_bbs", ")", ";", "ifc_bbs", "=", "NULL", ";", "}" ]
Combine all the basic blocks from LOOP into one or two super basic blocks.
[ "Combine", "all", "the", "basic", "blocks", "from", "LOOP", "into", "one", "or", "two", "super", "basic", "blocks", "." ]
[ "/* Merge basic blocks: first remove all the edges in the loop,\n except for those from the exit block. */", "/* Connect this node to loop header. */", "/* Redirect non-exit edges to loop->latch. */", "/* If the loop does not have an exit, reconnect header and latch. */", "/* Make stmts member of loop->header. */", "/* Update stmt list. */", "/* If possible, merge loop header to the block with the exit edge.\n This reduces the number of basic blocks to two, to please the\n vectorizer that handles only loops with two nodes. */" ]
[ { "param": "loop", "type": "struct loop" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
tree_if_conversion
bool
static bool tree_if_conversion (struct loop *loop) { bool changed = false; ifc_bbs = NULL; if (!if_convertible_loop_p (loop) || !dbg_cnt (if_conversion_tree)) goto cleanup; /* Now all statements are if-convertible. Combine all the basic blocks into one huge basic block doing the if-conversion on-the-fly. */ combine_blocks (loop); if (flag_tree_loop_if_convert_stores) mark_sym_for_renaming (gimple_vop (cfun)); changed = true; cleanup: if (ifc_bbs) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) free_bb_predicate (ifc_bbs[i]); free (ifc_bbs); ifc_bbs = NULL; } return changed; }
/* If-convert LOOP when it is legal. For the moment this pass has no profitability analysis. Returns true when something changed. */
If-convert LOOP when it is legal. For the moment this pass has no profitability analysis. Returns true when something changed.
[ "If", "-", "convert", "LOOP", "when", "it", "is", "legal", ".", "For", "the", "moment", "this", "pass", "has", "no", "profitability", "analysis", ".", "Returns", "true", "when", "something", "changed", "." ]
static bool tree_if_conversion (struct loop *loop) { bool changed = false; ifc_bbs = NULL; if (!if_convertible_loop_p (loop) || !dbg_cnt (if_conversion_tree)) goto cleanup; combine_blocks (loop); if (flag_tree_loop_if_convert_stores) mark_sym_for_renaming (gimple_vop (cfun)); changed = true; cleanup: if (ifc_bbs) { unsigned int i; for (i = 0; i < loop->num_nodes; i++) free_bb_predicate (ifc_bbs[i]); free (ifc_bbs); ifc_bbs = NULL; } return changed; }
[ "static", "bool", "tree_if_conversion", "(", "struct", "loop", "*", "loop", ")", "{", "bool", "changed", "=", "false", ";", "ifc_bbs", "=", "NULL", ";", "if", "(", "!", "if_convertible_loop_p", "(", "loop", ")", "||", "!", "dbg_cnt", "(", "if_conversion_tree", ")", ")", "goto", "cleanup", ";", "combine_blocks", "(", "loop", ")", ";", "if", "(", "flag_tree_loop_if_convert_stores", ")", "mark_sym_for_renaming", "(", "gimple_vop", "(", "cfun", ")", ")", ";", "changed", "=", "true", ";", "cleanup", ":", "if", "(", "ifc_bbs", ")", "{", "unsigned", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "loop", "->", "num_nodes", ";", "i", "++", ")", "free_bb_predicate", "(", "ifc_bbs", "[", "i", "]", ")", ";", "free", "(", "ifc_bbs", ")", ";", "ifc_bbs", "=", "NULL", ";", "}", "return", "changed", ";", "}" ]
If-convert LOOP when it is legal.
[ "If", "-", "convert", "LOOP", "when", "it", "is", "legal", "." ]
[ "/* Now all statements are if-convertible. Combine all the basic\n blocks into one huge basic block doing the if-conversion\n on-the-fly. */" ]
[ { "param": "loop", "type": "struct loop" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loop", "type": "struct loop", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
316b4e2d57dcea7b811461bb50418728afd202f5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-if-conv.c
[ "BSD-3-Clause" ]
C
gate_tree_if_conversion
bool
static bool gate_tree_if_conversion (void) { return ((flag_tree_vectorize && flag_tree_loop_if_convert != 0) || flag_tree_loop_if_convert == 1 || flag_tree_loop_if_convert_stores == 1); }
/* Returns true when the if-conversion pass is enabled. */
Returns true when the if-conversion pass is enabled.
[ "Returns", "true", "when", "the", "if", "-", "conversion", "pass", "is", "enabled", "." ]
static bool gate_tree_if_conversion (void) { return ((flag_tree_vectorize && flag_tree_loop_if_convert != 0) || flag_tree_loop_if_convert == 1 || flag_tree_loop_if_convert_stores == 1); }
[ "static", "bool", "gate_tree_if_conversion", "(", "void", ")", "{", "return", "(", "(", "flag_tree_vectorize", "&&", "flag_tree_loop_if_convert", "!=", "0", ")", "||", "flag_tree_loop_if_convert", "==", "1", "||", "flag_tree_loop_if_convert_stores", "==", "1", ")", ";", "}" ]
Returns true when the if-conversion pass is enabled.
[ "Returns", "true", "when", "the", "if", "-", "conversion", "pass", "is", "enabled", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
1e432e7d0664d13169028cf047e211660a4d6554
atrens/DragonFlyBSD-src
bin/rm/rm.c
[ "BSD-3-Clause" ]
C
rm_overwrite
int
static int rm_overwrite(const char *file, struct stat *sbp) { struct stat sb; struct statfs fsb; off_t len; int bsize, fd, wlen; char *buf = NULL; fd = -1; if (sbp == NULL) { if (lstat(file, &sb)) goto err; sbp = &sb; } if (!S_ISREG(sbp->st_mode)) { warnx("%s: cannot overwrite a non-regular file", file); return (1); } if (sbp->st_nlink > 1) { warnx("%s (inode %ju): not overwritten due to multiple links", file, (uintmax_t)sbp->st_ino); return (0); } if ((fd = open(file, O_WRONLY, 0)) == -1) goto err; if (fstatfs(fd, &fsb) == -1) goto err; bsize = MAX(fsb.f_iosize, 1024); if ((buf = malloc(bsize)) == NULL) err(1, "%s malloc failed", file); #define PASS(byte) { \ memset(buf, byte, bsize); \ for (len = sbp->st_size; len > 0; len -= wlen) { \ wlen = len < bsize ? len : bsize; \ if (write(fd, buf, wlen) != wlen) \ goto err; \ } \ } PASS(0xff); if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0x00); if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0xff); if (!fsync(fd) && !close(fd)) { free(buf); return (1); } err: eval = 1; if (buf) free(buf); if (fd != -1) close(fd); warn("%s", file); return (0); }
/* * rm_overwrite -- * Overwrite the file 3 times with varying bit patterns. * * XXX * This is a cheap way to *really* delete files. Note that only regular * files are deleted, directories (and therefore names) will remain. * Also, this assumes a fixed-block filesystem (like FFS, or a V7 or a * System V filesystem). In a logging filesystem, you'll have to have * kernel support. */
rm_overwrite Overwrite the file 3 times with varying bit patterns. XXX This is a cheap way to *really* delete files. Note that only regular files are deleted, directories (and therefore names) will remain. Also, this assumes a fixed-block filesystem (like FFS, or a V7 or a System V filesystem). In a logging filesystem, you'll have to have kernel support.
[ "rm_overwrite", "Overwrite", "the", "file", "3", "times", "with", "varying", "bit", "patterns", ".", "XXX", "This", "is", "a", "cheap", "way", "to", "*", "really", "*", "delete", "files", ".", "Note", "that", "only", "regular", "files", "are", "deleted", "directories", "(", "and", "therefore", "names", ")", "will", "remain", ".", "Also", "this", "assumes", "a", "fixed", "-", "block", "filesystem", "(", "like", "FFS", "or", "a", "V7", "or", "a", "System", "V", "filesystem", ")", ".", "In", "a", "logging", "filesystem", "you", "'", "ll", "have", "to", "have", "kernel", "support", "." ]
static int rm_overwrite(const char *file, struct stat *sbp) { struct stat sb; struct statfs fsb; off_t len; int bsize, fd, wlen; char *buf = NULL; fd = -1; if (sbp == NULL) { if (lstat(file, &sb)) goto err; sbp = &sb; } if (!S_ISREG(sbp->st_mode)) { warnx("%s: cannot overwrite a non-regular file", file); return (1); } if (sbp->st_nlink > 1) { warnx("%s (inode %ju): not overwritten due to multiple links", file, (uintmax_t)sbp->st_ino); return (0); } if ((fd = open(file, O_WRONLY, 0)) == -1) goto err; if (fstatfs(fd, &fsb) == -1) goto err; bsize = MAX(fsb.f_iosize, 1024); if ((buf = malloc(bsize)) == NULL) err(1, "%s malloc failed", file); #define PASS(byte) { \ memset(buf, byte, bsize); \ for (len = sbp->st_size; len > 0; len -= wlen) { \ wlen = len < bsize ? len : bsize; \ if (write(fd, buf, wlen) != wlen) \ goto err; \ } \ } PASS(0xff); if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0x00); if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) goto err; PASS(0xff); if (!fsync(fd) && !close(fd)) { free(buf); return (1); } err: eval = 1; if (buf) free(buf); if (fd != -1) close(fd); warn("%s", file); return (0); }
[ "static", "int", "rm_overwrite", "(", "const", "char", "*", "file", ",", "struct", "stat", "*", "sbp", ")", "{", "struct", "stat", "sb", ";", "struct", "statfs", "fsb", ";", "off_t", "len", ";", "int", "bsize", ",", "fd", ",", "wlen", ";", "char", "*", "buf", "=", "NULL", ";", "fd", "=", "-1", ";", "if", "(", "sbp", "==", "NULL", ")", "{", "if", "(", "lstat", "(", "file", ",", "&", "sb", ")", ")", "goto", "err", ";", "sbp", "=", "&", "sb", ";", "}", "if", "(", "!", "S_ISREG", "(", "sbp", "->", "st_mode", ")", ")", "{", "warnx", "(", "\"", "\"", ",", "file", ")", ";", "return", "(", "1", ")", ";", "}", "if", "(", "sbp", "->", "st_nlink", ">", "1", ")", "{", "warnx", "(", "\"", "\"", ",", "file", ",", "(", "uintmax_t", ")", "sbp", "->", "st_ino", ")", ";", "return", "(", "0", ")", ";", "}", "if", "(", "(", "fd", "=", "open", "(", "file", ",", "O_WRONLY", ",", "0", ")", ")", "==", "-1", ")", "goto", "err", ";", "if", "(", "fstatfs", "(", "fd", ",", "&", "fsb", ")", "==", "-1", ")", "goto", "err", ";", "bsize", "=", "MAX", "(", "fsb", ".", "f_iosize", ",", "1024", ")", ";", "if", "(", "(", "buf", "=", "malloc", "(", "bsize", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "\"", "\"", ",", "file", ")", ";", "#define", "PASS", "(", "byte", ")", " {\t\t\t\t\t\t\t\\\n\tmemset(buf, byte, bsize);\t\t\t\t\t\\\n\tfor (len = sbp->st_size; len > 0; len -= wlen) {\t\t\\\n\t\twlen = len < bsize ? len : bsize;\t\t\t\\\n\t\tif (write(fd, buf, wlen) != wlen)\t\t\t\\\n\t\t\tgoto err;\t\t\t\t\t\\\n\t}\t\t\t\t\t\t\t\t\\\n}", "\n", "PASS", "(", "0xff", ")", ";", "if", "(", "fsync", "(", "fd", ")", "||", "lseek", "(", "fd", ",", "(", "off_t", ")", "0", ",", "SEEK_SET", ")", ")", "goto", "err", ";", "PASS", "(", "0x00", ")", ";", "if", "(", "fsync", "(", "fd", ")", "||", "lseek", "(", "fd", ",", "(", "off_t", ")", "0", ",", "SEEK_SET", ")", ")", "goto", "err", ";", "PASS", "(", "0xff", ")", ";", "if", "(", "!", "fsync", "(", "fd", ")", "&&", "!", "close", "(", "fd", ")", ")", "{", "free", "(", "buf", ")", ";", "return", "(", "1", ")", ";", "}", "err", ":", "eval", "=", "1", ";", "if", "(", "buf", ")", "free", "(", "buf", ")", ";", "if", "(", "fd", "!=", "-1", ")", "close", "(", "fd", ")", ";", "warn", "(", "\"", "\"", ",", "file", ")", ";", "return", "(", "0", ")", ";", "}" ]
rm_overwrite Overwrite the file 3 times with varying bit patterns.
[ "rm_overwrite", "Overwrite", "the", "file", "3", "times", "with", "varying", "bit", "patterns", "." ]
[]
[ { "param": "file", "type": "char" }, { "param": "sbp", "type": "struct stat" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sbp", "type": "struct stat", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
assign_mem_slot
void
static void assign_mem_slot (int i) { rtx x = NULL_RTX; machine_mode mode = GET_MODE (regno_reg_rtx[i]); poly_int64 inherent_size = PSEUDO_REGNO_BYTES (i); machine_mode wider_mode = wider_subreg_mode (mode, lra_reg_info[i].biggest_mode); poly_int64 total_size = GET_MODE_SIZE (wider_mode); poly_int64 adjust = 0; lra_assert (regno_reg_rtx[i] != NULL_RTX && REG_P (regno_reg_rtx[i]) && lra_reg_info[i].nrefs != 0 && reg_renumber[i] < 0); unsigned int slot_num = pseudo_slots[i].slot_num; x = slots[slot_num].mem; if (!x) { x = assign_stack_local (BLKmode, slots[slot_num].size, slots[slot_num].align); slots[slot_num].mem = x; } /* On a big endian machine, the "address" of the slot is the address of the low part that fits its inherent mode. */ adjust += subreg_size_lowpart_offset (inherent_size, total_size); x = adjust_address_nv (x, GET_MODE (regno_reg_rtx[i]), adjust); /* Set all of the memory attributes as appropriate for a spill. */ set_mem_attrs_for_spill (x); pseudo_slots[i].mem = x; }
/* Set up memory of the spilled pseudo I. The function can allocate the corresponding stack slot if it is not done yet. */
Set up memory of the spilled pseudo I. The function can allocate the corresponding stack slot if it is not done yet.
[ "Set", "up", "memory", "of", "the", "spilled", "pseudo", "I", ".", "The", "function", "can", "allocate", "the", "corresponding", "stack", "slot", "if", "it", "is", "not", "done", "yet", "." ]
static void assign_mem_slot (int i) { rtx x = NULL_RTX; machine_mode mode = GET_MODE (regno_reg_rtx[i]); poly_int64 inherent_size = PSEUDO_REGNO_BYTES (i); machine_mode wider_mode = wider_subreg_mode (mode, lra_reg_info[i].biggest_mode); poly_int64 total_size = GET_MODE_SIZE (wider_mode); poly_int64 adjust = 0; lra_assert (regno_reg_rtx[i] != NULL_RTX && REG_P (regno_reg_rtx[i]) && lra_reg_info[i].nrefs != 0 && reg_renumber[i] < 0); unsigned int slot_num = pseudo_slots[i].slot_num; x = slots[slot_num].mem; if (!x) { x = assign_stack_local (BLKmode, slots[slot_num].size, slots[slot_num].align); slots[slot_num].mem = x; } adjust += subreg_size_lowpart_offset (inherent_size, total_size); x = adjust_address_nv (x, GET_MODE (regno_reg_rtx[i]), adjust); set_mem_attrs_for_spill (x); pseudo_slots[i].mem = x; }
[ "static", "void", "assign_mem_slot", "(", "int", "i", ")", "{", "rtx", "x", "=", "NULL_RTX", ";", "machine_mode", "mode", "=", "GET_MODE", "(", "regno_reg_rtx", "[", "i", "]", ")", ";", "poly_int64", "inherent_size", "=", "PSEUDO_REGNO_BYTES", "(", "i", ")", ";", "machine_mode", "wider_mode", "=", "wider_subreg_mode", "(", "mode", ",", "lra_reg_info", "[", "i", "]", ".", "biggest_mode", ")", ";", "poly_int64", "total_size", "=", "GET_MODE_SIZE", "(", "wider_mode", ")", ";", "poly_int64", "adjust", "=", "0", ";", "lra_assert", "(", "regno_reg_rtx", "[", "i", "]", "!=", "NULL_RTX", "&&", "REG_P", "(", "regno_reg_rtx", "[", "i", "]", ")", "&&", "lra_reg_info", "[", "i", "]", ".", "nrefs", "!=", "0", "&&", "reg_renumber", "[", "i", "]", "<", "0", ")", ";", "unsigned", "int", "slot_num", "=", "pseudo_slots", "[", "i", "]", ".", "slot_num", ";", "x", "=", "slots", "[", "slot_num", "]", ".", "mem", ";", "if", "(", "!", "x", ")", "{", "x", "=", "assign_stack_local", "(", "BLKmode", ",", "slots", "[", "slot_num", "]", ".", "size", ",", "slots", "[", "slot_num", "]", ".", "align", ")", ";", "slots", "[", "slot_num", "]", ".", "mem", "=", "x", ";", "}", "adjust", "+=", "subreg_size_lowpart_offset", "(", "inherent_size", ",", "total_size", ")", ";", "x", "=", "adjust_address_nv", "(", "x", ",", "GET_MODE", "(", "regno_reg_rtx", "[", "i", "]", ")", ",", "adjust", ")", ";", "set_mem_attrs_for_spill", "(", "x", ")", ";", "pseudo_slots", "[", "i", "]", ".", "mem", "=", "x", ";", "}" ]
Set up memory of the spilled pseudo I.
[ "Set", "up", "memory", "of", "the", "spilled", "pseudo", "I", "." ]
[ "/* On a big endian machine, the \"address\" of the slot is the address\n of the low part that fits its inherent mode. */", "/* Set all of the memory attributes as appropriate for a spill. */" ]
[ { "param": "i", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "i", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
regno_freq_compare
int
static int regno_freq_compare (const void *v1p, const void *v2p) { const int regno1 = *(const int *) v1p; const int regno2 = *(const int *) v2p; int diff; if ((diff = lra_reg_info[regno2].freq - lra_reg_info[regno1].freq) != 0) return diff; return regno1 - regno2; }
/* Sort pseudos according their usage frequencies. */
Sort pseudos according their usage frequencies.
[ "Sort", "pseudos", "according", "their", "usage", "frequencies", "." ]
static int regno_freq_compare (const void *v1p, const void *v2p) { const int regno1 = *(const int *) v1p; const int regno2 = *(const int *) v2p; int diff; if ((diff = lra_reg_info[regno2].freq - lra_reg_info[regno1].freq) != 0) return diff; return regno1 - regno2; }
[ "static", "int", "regno_freq_compare", "(", "const", "void", "*", "v1p", ",", "const", "void", "*", "v2p", ")", "{", "const", "int", "regno1", "=", "*", "(", "const", "int", "*", ")", "v1p", ";", "const", "int", "regno2", "=", "*", "(", "const", "int", "*", ")", "v2p", ";", "int", "diff", ";", "if", "(", "(", "diff", "=", "lra_reg_info", "[", "regno2", "]", ".", "freq", "-", "lra_reg_info", "[", "regno1", "]", ".", "freq", ")", "!=", "0", ")", "return", "diff", ";", "return", "regno1", "-", "regno2", ";", "}" ]
Sort pseudos according their usage frequencies.
[ "Sort", "pseudos", "according", "their", "usage", "frequencies", "." ]
[]
[ { "param": "v1p", "type": "void" }, { "param": "v2p", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1p", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2p", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
add_pseudo_to_slot
void
static void add_pseudo_to_slot (int regno, int slot_num) { struct pseudo_slot *first; /* Each pseudo has an inherent size which comes from its own mode, and a total size which provides room for paradoxical subregs. We need to make sure the size and alignment of the slot are sufficient for both. */ machine_mode mode = wider_subreg_mode (PSEUDO_REGNO_MODE (regno), lra_reg_info[regno].biggest_mode); unsigned int align = spill_slot_alignment (mode); slots[slot_num].align = MAX (slots[slot_num].align, align); slots[slot_num].size = upper_bound (slots[slot_num].size, GET_MODE_SIZE (mode)); if (slots[slot_num].regno < 0) { /* It is the first pseudo in the slot. */ slots[slot_num].regno = regno; pseudo_slots[regno].first = &pseudo_slots[regno]; pseudo_slots[regno].next = NULL; } else { first = pseudo_slots[regno].first = &pseudo_slots[slots[slot_num].regno]; pseudo_slots[regno].next = first->next; first->next = &pseudo_slots[regno]; } pseudo_slots[regno].mem = NULL_RTX; pseudo_slots[regno].slot_num = slot_num; slots[slot_num].live_ranges = lra_merge_live_ranges (slots[slot_num].live_ranges, lra_copy_live_range_list (lra_reg_info[regno].live_ranges)); }
/* Add pseudo REGNO to slot SLOT_NUM. */
Add pseudo REGNO to slot SLOT_NUM.
[ "Add", "pseudo", "REGNO", "to", "slot", "SLOT_NUM", "." ]
static void add_pseudo_to_slot (int regno, int slot_num) { struct pseudo_slot *first; machine_mode mode = wider_subreg_mode (PSEUDO_REGNO_MODE (regno), lra_reg_info[regno].biggest_mode); unsigned int align = spill_slot_alignment (mode); slots[slot_num].align = MAX (slots[slot_num].align, align); slots[slot_num].size = upper_bound (slots[slot_num].size, GET_MODE_SIZE (mode)); if (slots[slot_num].regno < 0) { slots[slot_num].regno = regno; pseudo_slots[regno].first = &pseudo_slots[regno]; pseudo_slots[regno].next = NULL; } else { first = pseudo_slots[regno].first = &pseudo_slots[slots[slot_num].regno]; pseudo_slots[regno].next = first->next; first->next = &pseudo_slots[regno]; } pseudo_slots[regno].mem = NULL_RTX; pseudo_slots[regno].slot_num = slot_num; slots[slot_num].live_ranges = lra_merge_live_ranges (slots[slot_num].live_ranges, lra_copy_live_range_list (lra_reg_info[regno].live_ranges)); }
[ "static", "void", "add_pseudo_to_slot", "(", "int", "regno", ",", "int", "slot_num", ")", "{", "struct", "pseudo_slot", "*", "first", ";", "machine_mode", "mode", "=", "wider_subreg_mode", "(", "PSEUDO_REGNO_MODE", "(", "regno", ")", ",", "lra_reg_info", "[", "regno", "]", ".", "biggest_mode", ")", ";", "unsigned", "int", "align", "=", "spill_slot_alignment", "(", "mode", ")", ";", "slots", "[", "slot_num", "]", ".", "align", "=", "MAX", "(", "slots", "[", "slot_num", "]", ".", "align", ",", "align", ")", ";", "slots", "[", "slot_num", "]", ".", "size", "=", "upper_bound", "(", "slots", "[", "slot_num", "]", ".", "size", ",", "GET_MODE_SIZE", "(", "mode", ")", ")", ";", "if", "(", "slots", "[", "slot_num", "]", ".", "regno", "<", "0", ")", "{", "slots", "[", "slot_num", "]", ".", "regno", "=", "regno", ";", "pseudo_slots", "[", "regno", "]", ".", "first", "=", "&", "pseudo_slots", "[", "regno", "]", ";", "pseudo_slots", "[", "regno", "]", ".", "next", "=", "NULL", ";", "}", "else", "{", "first", "=", "pseudo_slots", "[", "regno", "]", ".", "first", "=", "&", "pseudo_slots", "[", "slots", "[", "slot_num", "]", ".", "regno", "]", ";", "pseudo_slots", "[", "regno", "]", ".", "next", "=", "first", "->", "next", ";", "first", "->", "next", "=", "&", "pseudo_slots", "[", "regno", "]", ";", "}", "pseudo_slots", "[", "regno", "]", ".", "mem", "=", "NULL_RTX", ";", "pseudo_slots", "[", "regno", "]", ".", "slot_num", "=", "slot_num", ";", "slots", "[", "slot_num", "]", ".", "live_ranges", "=", "lra_merge_live_ranges", "(", "slots", "[", "slot_num", "]", ".", "live_ranges", ",", "lra_copy_live_range_list", "(", "lra_reg_info", "[", "regno", "]", ".", "live_ranges", ")", ")", ";", "}" ]
Add pseudo REGNO to slot SLOT_NUM.
[ "Add", "pseudo", "REGNO", "to", "slot", "SLOT_NUM", "." ]
[ "/* Each pseudo has an inherent size which comes from its own mode,\n and a total size which provides room for paradoxical subregs.\n We need to make sure the size and alignment of the slot are\n sufficient for both. */", "/* It is the first pseudo in the slot. */" ]
[ { "param": "regno", "type": "int" }, { "param": "slot_num", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "regno", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "slot_num", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
assign_stack_slot_num_and_sort_pseudos
void
static void assign_stack_slot_num_and_sort_pseudos (int *pseudo_regnos, int n) { int i, j, regno; slots_num = 0; /* Assign stack slot numbers to spilled pseudos, use smaller numbers for most frequently used pseudos. */ for (i = 0; i < n; i++) { regno = pseudo_regnos[i]; if (! flag_ira_share_spill_slots) j = slots_num; else { machine_mode mode = wider_subreg_mode (PSEUDO_REGNO_MODE (regno), lra_reg_info[regno].biggest_mode); for (j = 0; j < slots_num; j++) if (slots[j].hard_regno < 0 /* Although it's possible to share slots between modes with constant and non-constant widths, we usually get better spill code by keeping the constant and non-constant areas separate. */ && (GET_MODE_SIZE (mode).is_constant () == slots[j].size.is_constant ()) && ! (lra_intersected_live_ranges_p (slots[j].live_ranges, lra_reg_info[regno].live_ranges))) break; } if (j >= slots_num) { /* New slot. */ slots[j].live_ranges = NULL; slots[j].size = 0; slots[j].align = BITS_PER_UNIT; slots[j].regno = slots[j].hard_regno = -1; slots[j].mem = NULL_RTX; slots_num++; } add_pseudo_to_slot (regno, j); } /* Sort regnos according to their slot numbers. */ qsort (pseudo_regnos, n, sizeof (int), pseudo_reg_slot_compare); }
/* Assign stack slot numbers to pseudos in array PSEUDO_REGNOS of length N. Sort pseudos in PSEUDO_REGNOS for subsequent assigning memory stack slots. */
Assign stack slot numbers to pseudos in array PSEUDO_REGNOS of length N. Sort pseudos in PSEUDO_REGNOS for subsequent assigning memory stack slots.
[ "Assign", "stack", "slot", "numbers", "to", "pseudos", "in", "array", "PSEUDO_REGNOS", "of", "length", "N", ".", "Sort", "pseudos", "in", "PSEUDO_REGNOS", "for", "subsequent", "assigning", "memory", "stack", "slots", "." ]
static void assign_stack_slot_num_and_sort_pseudos (int *pseudo_regnos, int n) { int i, j, regno; slots_num = 0; for (i = 0; i < n; i++) { regno = pseudo_regnos[i]; if (! flag_ira_share_spill_slots) j = slots_num; else { machine_mode mode = wider_subreg_mode (PSEUDO_REGNO_MODE (regno), lra_reg_info[regno].biggest_mode); for (j = 0; j < slots_num; j++) if (slots[j].hard_regno < 0 && (GET_MODE_SIZE (mode).is_constant () == slots[j].size.is_constant ()) && ! (lra_intersected_live_ranges_p (slots[j].live_ranges, lra_reg_info[regno].live_ranges))) break; } if (j >= slots_num) { slots[j].live_ranges = NULL; slots[j].size = 0; slots[j].align = BITS_PER_UNIT; slots[j].regno = slots[j].hard_regno = -1; slots[j].mem = NULL_RTX; slots_num++; } add_pseudo_to_slot (regno, j); } qsort (pseudo_regnos, n, sizeof (int), pseudo_reg_slot_compare); }
[ "static", "void", "assign_stack_slot_num_and_sort_pseudos", "(", "int", "*", "pseudo_regnos", ",", "int", "n", ")", "{", "int", "i", ",", "j", ",", "regno", ";", "slots_num", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n", ";", "i", "++", ")", "{", "regno", "=", "pseudo_regnos", "[", "i", "]", ";", "if", "(", "!", "flag_ira_share_spill_slots", ")", "j", "=", "slots_num", ";", "else", "{", "machine_mode", "mode", "=", "wider_subreg_mode", "(", "PSEUDO_REGNO_MODE", "(", "regno", ")", ",", "lra_reg_info", "[", "regno", "]", ".", "biggest_mode", ")", ";", "for", "(", "j", "=", "0", ";", "j", "<", "slots_num", ";", "j", "++", ")", "if", "(", "slots", "[", "j", "]", ".", "hard_regno", "<", "0", "&&", "(", "GET_MODE_SIZE", "(", "mode", ")", ".", "is_constant", "(", ")", "==", "slots", "[", "j", "]", ".", "size", ".", "is_constant", "(", ")", ")", "&&", "!", "(", "lra_intersected_live_ranges_p", "(", "slots", "[", "j", "]", ".", "live_ranges", ",", "lra_reg_info", "[", "regno", "]", ".", "live_ranges", ")", ")", ")", "break", ";", "}", "if", "(", "j", ">=", "slots_num", ")", "{", "slots", "[", "j", "]", ".", "live_ranges", "=", "NULL", ";", "slots", "[", "j", "]", ".", "size", "=", "0", ";", "slots", "[", "j", "]", ".", "align", "=", "BITS_PER_UNIT", ";", "slots", "[", "j", "]", ".", "regno", "=", "slots", "[", "j", "]", ".", "hard_regno", "=", "-1", ";", "slots", "[", "j", "]", ".", "mem", "=", "NULL_RTX", ";", "slots_num", "++", ";", "}", "add_pseudo_to_slot", "(", "regno", ",", "j", ")", ";", "}", "qsort", "(", "pseudo_regnos", ",", "n", ",", "sizeof", "(", "int", ")", ",", "pseudo_reg_slot_compare", ")", ";", "}" ]
Assign stack slot numbers to pseudos in array PSEUDO_REGNOS of length N. Sort pseudos in PSEUDO_REGNOS for subsequent assigning memory stack slots.
[ "Assign", "stack", "slot", "numbers", "to", "pseudos", "in", "array", "PSEUDO_REGNOS", "of", "length", "N", ".", "Sort", "pseudos", "in", "PSEUDO_REGNOS", "for", "subsequent", "assigning", "memory", "stack", "slots", "." ]
[ "/* Assign stack slot numbers to spilled pseudos, use smaller numbers\n for most frequently used pseudos.\t*/", "/* Although it's possible to share slots between modes\n\t\t with constant and non-constant widths, we usually\n\t\t get better spill code by keeping the constant and\n\t\t non-constant areas separate. */", "/* New slot.\t*/", "/* Sort regnos according to their slot numbers. */" ]
[ { "param": "pseudo_regnos", "type": "int" }, { "param": "n", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pseudo_regnos", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
remove_pseudos
bool
static bool remove_pseudos (rtx *loc, rtx_insn *insn) { int i; rtx hard_reg; const char *fmt; enum rtx_code code; bool res = false; if (*loc == NULL_RTX) return res; code = GET_CODE (*loc); if (code == REG && (i = REGNO (*loc)) >= FIRST_PSEUDO_REGISTER && lra_get_regno_hard_regno (i) < 0 /* We do not want to assign memory for former scratches because it might result in an address reload for some targets. In any case we transform such pseudos not getting hard registers into scratches back. */ && ! lra_former_scratch_p (i)) { if (lra_reg_info[i].nrefs == 0 && pseudo_slots[i].mem == NULL && spill_hard_reg[i] == NULL) return true; if ((hard_reg = spill_hard_reg[i]) != NULL_RTX) *loc = copy_rtx (hard_reg); else { rtx x = lra_eliminate_regs_1 (insn, pseudo_slots[i].mem, GET_MODE (pseudo_slots[i].mem), false, false, 0, true); *loc = x != pseudo_slots[i].mem ? x : copy_rtx (x); } return res; } fmt = GET_RTX_FORMAT (code); for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') res = remove_pseudos (&XEXP (*loc, i), insn) || res; else if (fmt[i] == 'E') { int j; for (j = XVECLEN (*loc, i) - 1; j >= 0; j--) res = remove_pseudos (&XVECEXP (*loc, i, j), insn) || res; } } return res; }
/* Recursively process LOC in INSN and change spilled pseudos to the corresponding memory or spilled hard reg. Ignore spilled pseudos created from the scratches. Return true if the pseudo nrefs equal to 0 (don't change the pseudo in this case). Otherwise return false. */
Recursively process LOC in INSN and change spilled pseudos to the corresponding memory or spilled hard reg. Ignore spilled pseudos created from the scratches. Return true if the pseudo nrefs equal to 0 (don't change the pseudo in this case). Otherwise return false.
[ "Recursively", "process", "LOC", "in", "INSN", "and", "change", "spilled", "pseudos", "to", "the", "corresponding", "memory", "or", "spilled", "hard", "reg", ".", "Ignore", "spilled", "pseudos", "created", "from", "the", "scratches", ".", "Return", "true", "if", "the", "pseudo", "nrefs", "equal", "to", "0", "(", "don", "'", "t", "change", "the", "pseudo", "in", "this", "case", ")", ".", "Otherwise", "return", "false", "." ]
static bool remove_pseudos (rtx *loc, rtx_insn *insn) { int i; rtx hard_reg; const char *fmt; enum rtx_code code; bool res = false; if (*loc == NULL_RTX) return res; code = GET_CODE (*loc); if (code == REG && (i = REGNO (*loc)) >= FIRST_PSEUDO_REGISTER && lra_get_regno_hard_regno (i) < 0 && ! lra_former_scratch_p (i)) { if (lra_reg_info[i].nrefs == 0 && pseudo_slots[i].mem == NULL && spill_hard_reg[i] == NULL) return true; if ((hard_reg = spill_hard_reg[i]) != NULL_RTX) *loc = copy_rtx (hard_reg); else { rtx x = lra_eliminate_regs_1 (insn, pseudo_slots[i].mem, GET_MODE (pseudo_slots[i].mem), false, false, 0, true); *loc = x != pseudo_slots[i].mem ? x : copy_rtx (x); } return res; } fmt = GET_RTX_FORMAT (code); for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') res = remove_pseudos (&XEXP (*loc, i), insn) || res; else if (fmt[i] == 'E') { int j; for (j = XVECLEN (*loc, i) - 1; j >= 0; j--) res = remove_pseudos (&XVECEXP (*loc, i, j), insn) || res; } } return res; }
[ "static", "bool", "remove_pseudos", "(", "rtx", "*", "loc", ",", "rtx_insn", "*", "insn", ")", "{", "int", "i", ";", "rtx", "hard_reg", ";", "const", "char", "*", "fmt", ";", "enum", "rtx_code", "code", ";", "bool", "res", "=", "false", ";", "if", "(", "*", "loc", "==", "NULL_RTX", ")", "return", "res", ";", "code", "=", "GET_CODE", "(", "*", "loc", ")", ";", "if", "(", "code", "==", "REG", "&&", "(", "i", "=", "REGNO", "(", "*", "loc", ")", ")", ">=", "FIRST_PSEUDO_REGISTER", "&&", "lra_get_regno_hard_regno", "(", "i", ")", "<", "0", "&&", "!", "lra_former_scratch_p", "(", "i", ")", ")", "{", "if", "(", "lra_reg_info", "[", "i", "]", ".", "nrefs", "==", "0", "&&", "pseudo_slots", "[", "i", "]", ".", "mem", "==", "NULL", "&&", "spill_hard_reg", "[", "i", "]", "==", "NULL", ")", "return", "true", ";", "if", "(", "(", "hard_reg", "=", "spill_hard_reg", "[", "i", "]", ")", "!=", "NULL_RTX", ")", "*", "loc", "=", "copy_rtx", "(", "hard_reg", ")", ";", "else", "{", "rtx", "x", "=", "lra_eliminate_regs_1", "(", "insn", ",", "pseudo_slots", "[", "i", "]", ".", "mem", ",", "GET_MODE", "(", "pseudo_slots", "[", "i", "]", ".", "mem", ")", ",", "false", ",", "false", ",", "0", ",", "true", ")", ";", "*", "loc", "=", "x", "!=", "pseudo_slots", "[", "i", "]", ".", "mem", "?", "x", ":", "copy_rtx", "(", "x", ")", ";", "}", "return", "res", ";", "}", "fmt", "=", "GET_RTX_FORMAT", "(", "code", ")", ";", "for", "(", "i", "=", "GET_RTX_LENGTH", "(", "code", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "fmt", "[", "i", "]", "==", "'", "'", ")", "res", "=", "remove_pseudos", "(", "&", "XEXP", "(", "*", "loc", ",", "i", ")", ",", "insn", ")", "||", "res", ";", "else", "if", "(", "fmt", "[", "i", "]", "==", "'", "'", ")", "{", "int", "j", ";", "for", "(", "j", "=", "XVECLEN", "(", "*", "loc", ",", "i", ")", "-", "1", ";", "j", ">=", "0", ";", "j", "--", ")", "res", "=", "remove_pseudos", "(", "&", "XVECEXP", "(", "*", "loc", ",", "i", ",", "j", ")", ",", "insn", ")", "||", "res", ";", "}", "}", "return", "res", ";", "}" ]
Recursively process LOC in INSN and change spilled pseudos to the corresponding memory or spilled hard reg.
[ "Recursively", "process", "LOC", "in", "INSN", "and", "change", "spilled", "pseudos", "to", "the", "corresponding", "memory", "or", "spilled", "hard", "reg", "." ]
[ "/* We do not want to assign memory for former scratches because\n\t it might result in an address reload for some targets.\t In\n\t any case we transform such pseudos not getting hard registers\n\t into scratches back. */" ]
[ { "param": "loc", "type": "rtx" }, { "param": "insn", "type": "rtx_insn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loc", "type": "rtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "insn", "type": "rtx_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
lra_need_for_spills_p
bool
bool lra_need_for_spills_p (void) { int i; max_regno = max_reg_num (); for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (lra_reg_info[i].nrefs != 0 && lra_get_regno_hard_regno (i) < 0 && ! lra_former_scratch_p (i)) return true; return false; }
/* Return true if we need to change some pseudos into memory. */
Return true if we need to change some pseudos into memory.
[ "Return", "true", "if", "we", "need", "to", "change", "some", "pseudos", "into", "memory", "." ]
bool lra_need_for_spills_p (void) { int i; max_regno = max_reg_num (); for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (lra_reg_info[i].nrefs != 0 && lra_get_regno_hard_regno (i) < 0 && ! lra_former_scratch_p (i)) return true; return false; }
[ "bool", "lra_need_for_spills_p", "(", "void", ")", "{", "int", "i", ";", "max_regno", "=", "max_reg_num", "(", ")", ";", "for", "(", "i", "=", "FIRST_PSEUDO_REGISTER", ";", "i", "<", "max_regno", ";", "i", "++", ")", "if", "(", "lra_reg_info", "[", "i", "]", ".", "nrefs", "!=", "0", "&&", "lra_get_regno_hard_regno", "(", "i", ")", "<", "0", "&&", "!", "lra_former_scratch_p", "(", "i", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Return true if we need to change some pseudos into memory.
[ "Return", "true", "if", "we", "need", "to", "change", "some", "pseudos", "into", "memory", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
alter_subregs
bool
static bool alter_subregs (rtx *loc, bool final_p) { int i; rtx x = *loc; bool res; const char *fmt; enum rtx_code code; if (x == NULL_RTX) return false; code = GET_CODE (x); if (code == SUBREG && REG_P (SUBREG_REG (x))) { lra_assert (REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER); alter_subreg (loc, final_p); return true; } fmt = GET_RTX_FORMAT (code); res = false; for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') { if (alter_subregs (&XEXP (x, i), final_p)) res = true; } else if (fmt[i] == 'E') { int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) if (alter_subregs (&XVECEXP (x, i, j), final_p)) res = true; } } return res; }
/* Apply alter_subreg for subregs of regs in *LOC. Use FINAL_P for alter_subreg calls. Return true if any subreg of reg is processed. */
Apply alter_subreg for subregs of regs in *LOC.
[ "Apply", "alter_subreg", "for", "subregs", "of", "regs", "in", "*", "LOC", "." ]
static bool alter_subregs (rtx *loc, bool final_p) { int i; rtx x = *loc; bool res; const char *fmt; enum rtx_code code; if (x == NULL_RTX) return false; code = GET_CODE (x); if (code == SUBREG && REG_P (SUBREG_REG (x))) { lra_assert (REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER); alter_subreg (loc, final_p); return true; } fmt = GET_RTX_FORMAT (code); res = false; for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) { if (fmt[i] == 'e') { if (alter_subregs (&XEXP (x, i), final_p)) res = true; } else if (fmt[i] == 'E') { int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) if (alter_subregs (&XVECEXP (x, i, j), final_p)) res = true; } } return res; }
[ "static", "bool", "alter_subregs", "(", "rtx", "*", "loc", ",", "bool", "final_p", ")", "{", "int", "i", ";", "rtx", "x", "=", "*", "loc", ";", "bool", "res", ";", "const", "char", "*", "fmt", ";", "enum", "rtx_code", "code", ";", "if", "(", "x", "==", "NULL_RTX", ")", "return", "false", ";", "code", "=", "GET_CODE", "(", "x", ")", ";", "if", "(", "code", "==", "SUBREG", "&&", "REG_P", "(", "SUBREG_REG", "(", "x", ")", ")", ")", "{", "lra_assert", "(", "REGNO", "(", "SUBREG_REG", "(", "x", ")", ")", "<", "FIRST_PSEUDO_REGISTER", ")", ";", "alter_subreg", "(", "loc", ",", "final_p", ")", ";", "return", "true", ";", "}", "fmt", "=", "GET_RTX_FORMAT", "(", "code", ")", ";", "res", "=", "false", ";", "for", "(", "i", "=", "GET_RTX_LENGTH", "(", "code", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "fmt", "[", "i", "]", "==", "'", "'", ")", "{", "if", "(", "alter_subregs", "(", "&", "XEXP", "(", "x", ",", "i", ")", ",", "final_p", ")", ")", "res", "=", "true", ";", "}", "else", "if", "(", "fmt", "[", "i", "]", "==", "'", "'", ")", "{", "int", "j", ";", "for", "(", "j", "=", "XVECLEN", "(", "x", ",", "i", ")", "-", "1", ";", "j", ">=", "0", ";", "j", "--", ")", "if", "(", "alter_subregs", "(", "&", "XVECEXP", "(", "x", ",", "i", ",", "j", ")", ",", "final_p", ")", ")", "res", "=", "true", ";", "}", "}", "return", "res", ";", "}" ]
Apply alter_subreg for subregs of regs in *LOC.
[ "Apply", "alter_subreg", "for", "subregs", "of", "regs", "in", "*", "LOC", "." ]
[]
[ { "param": "loc", "type": "rtx" }, { "param": "final_p", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loc", "type": "rtx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "final_p", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
return_regno_p
bool
static bool return_regno_p (unsigned int regno) { rtx outgoing = crtl->return_rtx; if (! outgoing) return false; if (REG_P (outgoing)) return REGNO (outgoing) == regno; else if (GET_CODE (outgoing) == PARALLEL) { int i; for (i = 0; i < XVECLEN (outgoing, 0); i++) { rtx x = XEXP (XVECEXP (outgoing, 0, i), 0); if (REG_P (x) && REGNO (x) == regno) return true; } } return false; }
/* Return true if REGNO is used for return in the current function. */
Return true if REGNO is used for return in the current function.
[ "Return", "true", "if", "REGNO", "is", "used", "for", "return", "in", "the", "current", "function", "." ]
static bool return_regno_p (unsigned int regno) { rtx outgoing = crtl->return_rtx; if (! outgoing) return false; if (REG_P (outgoing)) return REGNO (outgoing) == regno; else if (GET_CODE (outgoing) == PARALLEL) { int i; for (i = 0; i < XVECLEN (outgoing, 0); i++) { rtx x = XEXP (XVECEXP (outgoing, 0, i), 0); if (REG_P (x) && REGNO (x) == regno) return true; } } return false; }
[ "static", "bool", "return_regno_p", "(", "unsigned", "int", "regno", ")", "{", "rtx", "outgoing", "=", "crtl", "->", "return_rtx", ";", "if", "(", "!", "outgoing", ")", "return", "false", ";", "if", "(", "REG_P", "(", "outgoing", ")", ")", "return", "REGNO", "(", "outgoing", ")", "==", "regno", ";", "else", "if", "(", "GET_CODE", "(", "outgoing", ")", "==", "PARALLEL", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "XVECLEN", "(", "outgoing", ",", "0", ")", ";", "i", "++", ")", "{", "rtx", "x", "=", "XEXP", "(", "XVECEXP", "(", "outgoing", ",", "0", ",", "i", ")", ",", "0", ")", ";", "if", "(", "REG_P", "(", "x", ")", "&&", "REGNO", "(", "x", ")", "==", "regno", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return true if REGNO is used for return in the current function.
[ "Return", "true", "if", "REGNO", "is", "used", "for", "return", "in", "the", "current", "function", "." ]
[]
[ { "param": "regno", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "regno", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
regno_in_use_p
bool
static bool regno_in_use_p (rtx_insn *insn, unsigned int regno) { static lra_insn_recog_data_t id; static struct lra_static_insn_data *static_id; struct lra_insn_reg *reg; int i, arg_regno; basic_block bb = BLOCK_FOR_INSN (insn); while ((insn = next_nondebug_insn (insn)) != NULL_RTX) { if (BARRIER_P (insn) || bb != BLOCK_FOR_INSN (insn)) return false; if (! INSN_P (insn)) continue; if (GET_CODE (PATTERN (insn)) == USE && REG_P (XEXP (PATTERN (insn), 0)) && regno == REGNO (XEXP (PATTERN (insn), 0))) return true; /* Check that the regno is not modified. */ id = lra_get_insn_recog_data (insn); for (reg = id->regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN && reg->regno == (int) regno) return false; static_id = id->insn_static_data; for (reg = static_id->hard_regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN && reg->regno == (int) regno) return false; if (id->arg_hard_regs != NULL) for (i = 0; (arg_regno = id->arg_hard_regs[i]) >= 0; i++) if ((int) regno == (arg_regno >= FIRST_PSEUDO_REGISTER ? arg_regno : arg_regno - FIRST_PSEUDO_REGISTER)) return false; } return false; }
/* Return true if REGNO is in one of subsequent USE after INSN in the same BB. */
Return true if REGNO is in one of subsequent USE after INSN in the same BB.
[ "Return", "true", "if", "REGNO", "is", "in", "one", "of", "subsequent", "USE", "after", "INSN", "in", "the", "same", "BB", "." ]
static bool regno_in_use_p (rtx_insn *insn, unsigned int regno) { static lra_insn_recog_data_t id; static struct lra_static_insn_data *static_id; struct lra_insn_reg *reg; int i, arg_regno; basic_block bb = BLOCK_FOR_INSN (insn); while ((insn = next_nondebug_insn (insn)) != NULL_RTX) { if (BARRIER_P (insn) || bb != BLOCK_FOR_INSN (insn)) return false; if (! INSN_P (insn)) continue; if (GET_CODE (PATTERN (insn)) == USE && REG_P (XEXP (PATTERN (insn), 0)) && regno == REGNO (XEXP (PATTERN (insn), 0))) return true; id = lra_get_insn_recog_data (insn); for (reg = id->regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN && reg->regno == (int) regno) return false; static_id = id->insn_static_data; for (reg = static_id->hard_regs; reg != NULL; reg = reg->next) if (reg->type != OP_IN && reg->regno == (int) regno) return false; if (id->arg_hard_regs != NULL) for (i = 0; (arg_regno = id->arg_hard_regs[i]) >= 0; i++) if ((int) regno == (arg_regno >= FIRST_PSEUDO_REGISTER ? arg_regno : arg_regno - FIRST_PSEUDO_REGISTER)) return false; } return false; }
[ "static", "bool", "regno_in_use_p", "(", "rtx_insn", "*", "insn", ",", "unsigned", "int", "regno", ")", "{", "static", "lra_insn_recog_data_t", "id", ";", "static", "struct", "lra_static_insn_data", "*", "static_id", ";", "struct", "lra_insn_reg", "*", "reg", ";", "int", "i", ",", "arg_regno", ";", "basic_block", "bb", "=", "BLOCK_FOR_INSN", "(", "insn", ")", ";", "while", "(", "(", "insn", "=", "next_nondebug_insn", "(", "insn", ")", ")", "!=", "NULL_RTX", ")", "{", "if", "(", "BARRIER_P", "(", "insn", ")", "||", "bb", "!=", "BLOCK_FOR_INSN", "(", "insn", ")", ")", "return", "false", ";", "if", "(", "!", "INSN_P", "(", "insn", ")", ")", "continue", ";", "if", "(", "GET_CODE", "(", "PATTERN", "(", "insn", ")", ")", "==", "USE", "&&", "REG_P", "(", "XEXP", "(", "PATTERN", "(", "insn", ")", ",", "0", ")", ")", "&&", "regno", "==", "REGNO", "(", "XEXP", "(", "PATTERN", "(", "insn", ")", ",", "0", ")", ")", ")", "return", "true", ";", "id", "=", "lra_get_insn_recog_data", "(", "insn", ")", ";", "for", "(", "reg", "=", "id", "->", "regs", ";", "reg", "!=", "NULL", ";", "reg", "=", "reg", "->", "next", ")", "if", "(", "reg", "->", "type", "!=", "OP_IN", "&&", "reg", "->", "regno", "==", "(", "int", ")", "regno", ")", "return", "false", ";", "static_id", "=", "id", "->", "insn_static_data", ";", "for", "(", "reg", "=", "static_id", "->", "hard_regs", ";", "reg", "!=", "NULL", ";", "reg", "=", "reg", "->", "next", ")", "if", "(", "reg", "->", "type", "!=", "OP_IN", "&&", "reg", "->", "regno", "==", "(", "int", ")", "regno", ")", "return", "false", ";", "if", "(", "id", "->", "arg_hard_regs", "!=", "NULL", ")", "for", "(", "i", "=", "0", ";", "(", "arg_regno", "=", "id", "->", "arg_hard_regs", "[", "i", "]", ")", ">=", "0", ";", "i", "++", ")", "if", "(", "(", "int", ")", "regno", "==", "(", "arg_regno", ">=", "FIRST_PSEUDO_REGISTER", "?", "arg_regno", ":", "arg_regno", "-", "FIRST_PSEUDO_REGISTER", ")", ")", "return", "false", ";", "}", "return", "false", ";", "}" ]
Return true if REGNO is in one of subsequent USE after INSN in the same BB.
[ "Return", "true", "if", "REGNO", "is", "in", "one", "of", "subsequent", "USE", "after", "INSN", "in", "the", "same", "BB", "." ]
[ "/* Check that the regno is not modified. */" ]
[ { "param": "insn", "type": "rtx_insn" }, { "param": "regno", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "insn", "type": "rtx_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "regno", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
33caf9f4564953c9e0bdc78ee00fcfbfa7aa2ed1
atrens/DragonFlyBSD-src
contrib/gcc-8.0/gcc/lra-spills.c
[ "BSD-3-Clause" ]
C
lra_final_code_change
void
void lra_final_code_change (void) { int i, hard_regno; basic_block bb; rtx_insn *insn, *curr; int max_regno = max_reg_num (); for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (lra_reg_info[i].nrefs != 0 && (hard_regno = lra_get_regno_hard_regno (i)) >= 0) SET_REGNO (regno_reg_rtx[i], hard_regno); FOR_EACH_BB_FN (bb, cfun) FOR_BB_INSNS_SAFE (bb, insn, curr) if (INSN_P (insn)) { rtx pat = PATTERN (insn); if (GET_CODE (pat) == CLOBBER && LRA_TEMP_CLOBBER_P (pat)) { /* Remove clobbers temporarily created in LRA. We don't need them anymore and don't want to waste compiler time processing them in a few subsequent passes. */ lra_invalidate_insn_data (insn); delete_insn (insn); continue; } /* IRA can generate move insns involving pseudos. It is better remove them earlier to speed up compiler a bit. It is also better to do it here as they might not pass final RTL check in LRA, (e.g. insn moving a control register into itself). So remove an useless move insn unless next insn is USE marking the return reg (we should save this as some subsequent optimizations assume that such original insns are saved). */ if (NONJUMP_INSN_P (insn) && GET_CODE (pat) == SET && REG_P (SET_SRC (pat)) && REG_P (SET_DEST (pat)) && REGNO (SET_SRC (pat)) == REGNO (SET_DEST (pat)) && (! return_regno_p (REGNO (SET_SRC (pat))) || ! regno_in_use_p (insn, REGNO (SET_SRC (pat))))) { lra_invalidate_insn_data (insn); delete_insn (insn); continue; } lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); struct lra_insn_reg *reg; for (reg = id->regs; reg != NULL; reg = reg->next) if (reg->regno >= FIRST_PSEUDO_REGISTER && lra_reg_info [reg->regno].nrefs == 0) break; if (reg != NULL) { /* Pseudos still can be in debug insns in some very rare and complicated cases, e.g. the pseudo was removed by inheritance and the debug insn is not EBBs where the inheritance happened. It is difficult and time consuming to find what hard register corresponds the pseudo -- so just remove the debug insn. Another solution could be assigning hard reg/memory but it would be a misleading info. It is better not to have info than have it wrong. */ lra_assert (DEBUG_INSN_P (insn)); lra_invalidate_insn_data (insn); delete_insn (insn); continue; } struct lra_static_insn_data *static_id = id->insn_static_data; bool insn_change_p = false; for (i = id->insn_static_data->n_operands - 1; i >= 0; i--) if ((DEBUG_INSN_P (insn) || ! static_id->operand[i].is_operator) && alter_subregs (id->operand_loc[i], ! DEBUG_INSN_P (insn))) { lra_update_dup (id, i); insn_change_p = true; } if (insn_change_p) lra_update_operator_dups (id); } }
/* Final change of pseudos got hard registers into the corresponding hard registers and removing temporary clobbers. */
Final change of pseudos got hard registers into the corresponding hard registers and removing temporary clobbers.
[ "Final", "change", "of", "pseudos", "got", "hard", "registers", "into", "the", "corresponding", "hard", "registers", "and", "removing", "temporary", "clobbers", "." ]
void lra_final_code_change (void) { int i, hard_regno; basic_block bb; rtx_insn *insn, *curr; int max_regno = max_reg_num (); for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (lra_reg_info[i].nrefs != 0 && (hard_regno = lra_get_regno_hard_regno (i)) >= 0) SET_REGNO (regno_reg_rtx[i], hard_regno); FOR_EACH_BB_FN (bb, cfun) FOR_BB_INSNS_SAFE (bb, insn, curr) if (INSN_P (insn)) { rtx pat = PATTERN (insn); if (GET_CODE (pat) == CLOBBER && LRA_TEMP_CLOBBER_P (pat)) { lra_invalidate_insn_data (insn); delete_insn (insn); continue; } if (NONJUMP_INSN_P (insn) && GET_CODE (pat) == SET && REG_P (SET_SRC (pat)) && REG_P (SET_DEST (pat)) && REGNO (SET_SRC (pat)) == REGNO (SET_DEST (pat)) && (! return_regno_p (REGNO (SET_SRC (pat))) || ! regno_in_use_p (insn, REGNO (SET_SRC (pat))))) { lra_invalidate_insn_data (insn); delete_insn (insn); continue; } lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); struct lra_insn_reg *reg; for (reg = id->regs; reg != NULL; reg = reg->next) if (reg->regno >= FIRST_PSEUDO_REGISTER && lra_reg_info [reg->regno].nrefs == 0) break; if (reg != NULL) { lra_assert (DEBUG_INSN_P (insn)); lra_invalidate_insn_data (insn); delete_insn (insn); continue; } struct lra_static_insn_data *static_id = id->insn_static_data; bool insn_change_p = false; for (i = id->insn_static_data->n_operands - 1; i >= 0; i--) if ((DEBUG_INSN_P (insn) || ! static_id->operand[i].is_operator) && alter_subregs (id->operand_loc[i], ! DEBUG_INSN_P (insn))) { lra_update_dup (id, i); insn_change_p = true; } if (insn_change_p) lra_update_operator_dups (id); } }
[ "void", "lra_final_code_change", "(", "void", ")", "{", "int", "i", ",", "hard_regno", ";", "basic_block", "bb", ";", "rtx_insn", "*", "insn", ",", "*", "curr", ";", "int", "max_regno", "=", "max_reg_num", "(", ")", ";", "for", "(", "i", "=", "FIRST_PSEUDO_REGISTER", ";", "i", "<", "max_regno", ";", "i", "++", ")", "if", "(", "lra_reg_info", "[", "i", "]", ".", "nrefs", "!=", "0", "&&", "(", "hard_regno", "=", "lra_get_regno_hard_regno", "(", "i", ")", ")", ">=", "0", ")", "SET_REGNO", "(", "regno_reg_rtx", "[", "i", "]", ",", "hard_regno", ")", ";", "FOR_EACH_BB_FN", "(", "bb", ",", "cfun", ")", "", "FOR_BB_INSNS_SAFE", "(", "bb", ",", "insn", ",", "curr", ")", "", "if", "(", "INSN_P", "(", "insn", ")", ")", "{", "rtx", "pat", "=", "PATTERN", "(", "insn", ")", ";", "if", "(", "GET_CODE", "(", "pat", ")", "==", "CLOBBER", "&&", "LRA_TEMP_CLOBBER_P", "(", "pat", ")", ")", "{", "lra_invalidate_insn_data", "(", "insn", ")", ";", "delete_insn", "(", "insn", ")", ";", "continue", ";", "}", "if", "(", "NONJUMP_INSN_P", "(", "insn", ")", "&&", "GET_CODE", "(", "pat", ")", "==", "SET", "&&", "REG_P", "(", "SET_SRC", "(", "pat", ")", ")", "&&", "REG_P", "(", "SET_DEST", "(", "pat", ")", ")", "&&", "REGNO", "(", "SET_SRC", "(", "pat", ")", ")", "==", "REGNO", "(", "SET_DEST", "(", "pat", ")", ")", "&&", "(", "!", "return_regno_p", "(", "REGNO", "(", "SET_SRC", "(", "pat", ")", ")", ")", "||", "!", "regno_in_use_p", "(", "insn", ",", "REGNO", "(", "SET_SRC", "(", "pat", ")", ")", ")", ")", ")", "{", "lra_invalidate_insn_data", "(", "insn", ")", ";", "delete_insn", "(", "insn", ")", ";", "continue", ";", "}", "lra_insn_recog_data_t", "id", "=", "lra_get_insn_recog_data", "(", "insn", ")", ";", "struct", "lra_insn_reg", "*", "reg", ";", "for", "(", "reg", "=", "id", "->", "regs", ";", "reg", "!=", "NULL", ";", "reg", "=", "reg", "->", "next", ")", "if", "(", "reg", "->", "regno", ">=", "FIRST_PSEUDO_REGISTER", "&&", "lra_reg_info", "[", "reg", "->", "regno", "]", ".", "nrefs", "==", "0", ")", "break", ";", "if", "(", "reg", "!=", "NULL", ")", "{", "lra_assert", "(", "DEBUG_INSN_P", "(", "insn", ")", ")", ";", "lra_invalidate_insn_data", "(", "insn", ")", ";", "delete_insn", "(", "insn", ")", ";", "continue", ";", "}", "struct", "lra_static_insn_data", "*", "static_id", "=", "id", "->", "insn_static_data", ";", "bool", "insn_change_p", "=", "false", ";", "for", "(", "i", "=", "id", "->", "insn_static_data", "->", "n_operands", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "if", "(", "(", "DEBUG_INSN_P", "(", "insn", ")", "||", "!", "static_id", "->", "operand", "[", "i", "]", ".", "is_operator", ")", "&&", "alter_subregs", "(", "id", "->", "operand_loc", "[", "i", "]", ",", "!", "DEBUG_INSN_P", "(", "insn", ")", ")", ")", "{", "lra_update_dup", "(", "id", ",", "i", ")", ";", "insn_change_p", "=", "true", ";", "}", "if", "(", "insn_change_p", ")", "lra_update_operator_dups", "(", "id", ")", ";", "}", "}" ]
Final change of pseudos got hard registers into the corresponding hard registers and removing temporary clobbers.
[ "Final", "change", "of", "pseudos", "got", "hard", "registers", "into", "the", "corresponding", "hard", "registers", "and", "removing", "temporary", "clobbers", "." ]
[ "/* Remove clobbers temporarily created in LRA. We don't\n\t\t need them anymore and don't want to waste compiler\n\t\t time processing them in a few subsequent passes. */", "/* IRA can generate move insns involving pseudos. It is\n\t better remove them earlier to speed up compiler a bit.\n\t It is also better to do it here as they might not pass\n\t final RTL check in LRA, (e.g. insn moving a control\n\t register into itself). So remove an useless move insn\n\t unless next insn is USE marking the return reg (we should\n\t save this as some subsequent optimizations assume that\n\t such original insns are saved). */", "/* Pseudos still can be in debug insns in some very rare\n\t\t and complicated cases, e.g. the pseudo was removed by\n\t\t inheritance and the debug insn is not EBBs where the\n\t\t inheritance happened. It is difficult and time\n\t\t consuming to find what hard register corresponds the\n\t\t pseudo -- so just remove the debug insn. Another\n\t\t solution could be assigning hard reg/memory but it\n\t\t would be a misleading info. It is better not to have\n\t\t info than have it wrong. */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
begin_bc_block
tree
static tree begin_bc_block (enum bc_t bc) { tree label = create_artificial_label (input_location); DECL_CHAIN (label) = bc_label[bc]; bc_label[bc] = label; return label; }
/* Begin a scope which can be exited by a break or continue statement. BC indicates which. Just creates a label and pushes it into the current context. */
Begin a scope which can be exited by a break or continue statement. BC indicates which. Just creates a label and pushes it into the current context.
[ "Begin", "a", "scope", "which", "can", "be", "exited", "by", "a", "break", "or", "continue", "statement", ".", "BC", "indicates", "which", ".", "Just", "creates", "a", "label", "and", "pushes", "it", "into", "the", "current", "context", "." ]
static tree begin_bc_block (enum bc_t bc) { tree label = create_artificial_label (input_location); DECL_CHAIN (label) = bc_label[bc]; bc_label[bc] = label; return label; }
[ "static", "tree", "begin_bc_block", "(", "enum", "bc_t", "bc", ")", "{", "tree", "label", "=", "create_artificial_label", "(", "input_location", ")", ";", "DECL_CHAIN", "(", "label", ")", "=", "bc_label", "[", "bc", "]", ";", "bc_label", "[", "bc", "]", "=", "label", ";", "return", "label", ";", "}" ]
Begin a scope which can be exited by a break or continue statement.
[ "Begin", "a", "scope", "which", "can", "be", "exited", "by", "a", "break", "or", "continue", "statement", "." ]
[]
[ { "param": "bc", "type": "enum bc_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bc", "type": "enum bc_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
finish_bc_block
gimple_seq
static gimple_seq finish_bc_block (enum bc_t bc, tree label, gimple_seq body) { gcc_assert (label == bc_label[bc]); if (TREE_USED (label)) { gimple_seq_add_stmt (&body, gimple_build_label (label)); } bc_label[bc] = DECL_CHAIN (label); DECL_CHAIN (label) = NULL_TREE; return body; }
/* Finish a scope which can be exited by a break or continue statement. LABEL was returned from the most recent call to begin_bc_block. BODY is an expression for the contents of the scope. If we saw a break (or continue) in the scope, append a LABEL_EXPR to body. Otherwise, just forget the label. */
Finish a scope which can be exited by a break or continue statement. LABEL was returned from the most recent call to begin_bc_block. BODY is an expression for the contents of the scope. If we saw a break (or continue) in the scope, append a LABEL_EXPR to body. Otherwise, just forget the label.
[ "Finish", "a", "scope", "which", "can", "be", "exited", "by", "a", "break", "or", "continue", "statement", ".", "LABEL", "was", "returned", "from", "the", "most", "recent", "call", "to", "begin_bc_block", ".", "BODY", "is", "an", "expression", "for", "the", "contents", "of", "the", "scope", ".", "If", "we", "saw", "a", "break", "(", "or", "continue", ")", "in", "the", "scope", "append", "a", "LABEL_EXPR", "to", "body", ".", "Otherwise", "just", "forget", "the", "label", "." ]
static gimple_seq finish_bc_block (enum bc_t bc, tree label, gimple_seq body) { gcc_assert (label == bc_label[bc]); if (TREE_USED (label)) { gimple_seq_add_stmt (&body, gimple_build_label (label)); } bc_label[bc] = DECL_CHAIN (label); DECL_CHAIN (label) = NULL_TREE; return body; }
[ "static", "gimple_seq", "finish_bc_block", "(", "enum", "bc_t", "bc", ",", "tree", "label", ",", "gimple_seq", "body", ")", "{", "gcc_assert", "(", "label", "==", "bc_label", "[", "bc", "]", ")", ";", "if", "(", "TREE_USED", "(", "label", ")", ")", "{", "gimple_seq_add_stmt", "(", "&", "body", ",", "gimple_build_label", "(", "label", ")", ")", ";", "}", "bc_label", "[", "bc", "]", "=", "DECL_CHAIN", "(", "label", ")", ";", "DECL_CHAIN", "(", "label", ")", "=", "NULL_TREE", ";", "return", "body", ";", "}" ]
Finish a scope which can be exited by a break or continue statement.
[ "Finish", "a", "scope", "which", "can", "be", "exited", "by", "a", "break", "or", "continue", "statement", "." ]
[]
[ { "param": "bc", "type": "enum bc_t" }, { "param": "label", "type": "tree" }, { "param": "body", "type": "gimple_seq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bc", "type": "enum bc_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "label", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "body", "type": "gimple_seq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
genericize_catch_block
void
static void genericize_catch_block (tree *stmt_p) { tree type = HANDLER_TYPE (*stmt_p); tree body = HANDLER_BODY (*stmt_p); /* FIXME should the caught type go in TREE_TYPE? */ *stmt_p = build2 (CATCH_EXPR, void_type_node, type, body); }
/* Genericize a HANDLER by converting to a CATCH_EXPR. */
Genericize a HANDLER by converting to a CATCH_EXPR.
[ "Genericize", "a", "HANDLER", "by", "converting", "to", "a", "CATCH_EXPR", "." ]
static void genericize_catch_block (tree *stmt_p) { tree type = HANDLER_TYPE (*stmt_p); tree body = HANDLER_BODY (*stmt_p); *stmt_p = build2 (CATCH_EXPR, void_type_node, type, body); }
[ "static", "void", "genericize_catch_block", "(", "tree", "*", "stmt_p", ")", "{", "tree", "type", "=", "HANDLER_TYPE", "(", "*", "stmt_p", ")", ";", "tree", "body", "=", "HANDLER_BODY", "(", "*", "stmt_p", ")", ";", "*", "stmt_p", "=", "build2", "(", "CATCH_EXPR", ",", "void_type_node", ",", "type", ",", "body", ")", ";", "}" ]
Genericize a HANDLER by converting to a CATCH_EXPR.
[ "Genericize", "a", "HANDLER", "by", "converting", "to", "a", "CATCH_EXPR", "." ]
[ "/* FIXME should the caught type go in TREE_TYPE? */" ]
[ { "param": "stmt_p", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
genericize_if_stmt
void
static void genericize_if_stmt (tree *stmt_p) { tree stmt, cond, then_, else_; location_t locus = EXPR_LOCATION (*stmt_p); stmt = *stmt_p; cond = IF_COND (stmt); then_ = THEN_CLAUSE (stmt); else_ = ELSE_CLAUSE (stmt); if (!then_) then_ = build_empty_stmt (locus); if (!else_) else_ = build_empty_stmt (locus); if (integer_nonzerop (cond) && !TREE_SIDE_EFFECTS (else_)) stmt = then_; else if (integer_zerop (cond) && !TREE_SIDE_EFFECTS (then_)) stmt = else_; else stmt = build3 (COND_EXPR, void_type_node, cond, then_, else_); if (CAN_HAVE_LOCATION_P (stmt) && !EXPR_HAS_LOCATION (stmt)) SET_EXPR_LOCATION (stmt, locus); *stmt_p = stmt; }
/* Genericize an IF_STMT by turning it into a COND_EXPR. */
Genericize an IF_STMT by turning it into a COND_EXPR.
[ "Genericize", "an", "IF_STMT", "by", "turning", "it", "into", "a", "COND_EXPR", "." ]
static void genericize_if_stmt (tree *stmt_p) { tree stmt, cond, then_, else_; location_t locus = EXPR_LOCATION (*stmt_p); stmt = *stmt_p; cond = IF_COND (stmt); then_ = THEN_CLAUSE (stmt); else_ = ELSE_CLAUSE (stmt); if (!then_) then_ = build_empty_stmt (locus); if (!else_) else_ = build_empty_stmt (locus); if (integer_nonzerop (cond) && !TREE_SIDE_EFFECTS (else_)) stmt = then_; else if (integer_zerop (cond) && !TREE_SIDE_EFFECTS (then_)) stmt = else_; else stmt = build3 (COND_EXPR, void_type_node, cond, then_, else_); if (CAN_HAVE_LOCATION_P (stmt) && !EXPR_HAS_LOCATION (stmt)) SET_EXPR_LOCATION (stmt, locus); *stmt_p = stmt; }
[ "static", "void", "genericize_if_stmt", "(", "tree", "*", "stmt_p", ")", "{", "tree", "stmt", ",", "cond", ",", "then_", ",", "else_", ";", "location_t", "locus", "=", "EXPR_LOCATION", "(", "*", "stmt_p", ")", ";", "stmt", "=", "*", "stmt_p", ";", "cond", "=", "IF_COND", "(", "stmt", ")", ";", "then_", "=", "THEN_CLAUSE", "(", "stmt", ")", ";", "else_", "=", "ELSE_CLAUSE", "(", "stmt", ")", ";", "if", "(", "!", "then_", ")", "then_", "=", "build_empty_stmt", "(", "locus", ")", ";", "if", "(", "!", "else_", ")", "else_", "=", "build_empty_stmt", "(", "locus", ")", ";", "if", "(", "integer_nonzerop", "(", "cond", ")", "&&", "!", "TREE_SIDE_EFFECTS", "(", "else_", ")", ")", "stmt", "=", "then_", ";", "else", "if", "(", "integer_zerop", "(", "cond", ")", "&&", "!", "TREE_SIDE_EFFECTS", "(", "then_", ")", ")", "stmt", "=", "else_", ";", "else", "stmt", "=", "build3", "(", "COND_EXPR", ",", "void_type_node", ",", "cond", ",", "then_", ",", "else_", ")", ";", "if", "(", "CAN_HAVE_LOCATION_P", "(", "stmt", ")", "&&", "!", "EXPR_HAS_LOCATION", "(", "stmt", ")", ")", "SET_EXPR_LOCATION", "(", "stmt", ",", "locus", ")", ";", "*", "stmt_p", "=", "stmt", ";", "}" ]
Genericize an IF_STMT by turning it into a COND_EXPR.
[ "Genericize", "an", "IF_STMT", "by", "turning", "it", "into", "a", "COND_EXPR", "." ]
[]
[ { "param": "stmt_p", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
gimplify_cp_loop
gimple_seq
static gimple_seq gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first) { gimple top, entry, stmt; gimple_seq stmt_list, body_seq, incr_seq, exit_seq; tree cont_block, break_block; location_t stmt_locus; stmt_locus = input_location; stmt_list = NULL; body_seq = NULL; incr_seq = NULL; exit_seq = NULL; entry = NULL; break_block = begin_bc_block (bc_break); cont_block = begin_bc_block (bc_continue); /* If condition is zero don't generate a loop construct. */ if (cond && integer_zerop (cond)) { top = NULL; if (cond_is_first) { stmt = gimple_build_goto (get_bc_label (bc_break)); gimple_set_location (stmt, stmt_locus); gimple_seq_add_stmt (&stmt_list, stmt); } } else { /* If we use a LOOP_EXPR here, we have to feed the whole thing back through the main gimplifier to lower it. Given that we have to gimplify the loop body NOW so that we can resolve break/continue stmts, seems easier to just expand to gotos. */ top = gimple_build_label (create_artificial_label (stmt_locus)); /* If we have an exit condition, then we build an IF with gotos either out of the loop, or to the top of it. If there's no exit condition, then we just build a jump back to the top. */ if (cond && !integer_nonzerop (cond)) { if (cond != error_mark_node) { gimplify_expr (&cond, &exit_seq, NULL, is_gimple_val, fb_rvalue); stmt = gimple_build_cond (NE_EXPR, cond, build_int_cst (TREE_TYPE (cond), 0), gimple_label_label (top), get_bc_label (bc_break)); gimple_seq_add_stmt (&exit_seq, stmt); } if (cond_is_first) { if (incr) { entry = gimple_build_label (create_artificial_label (stmt_locus)); stmt = gimple_build_goto (gimple_label_label (entry)); } else stmt = gimple_build_goto (get_bc_label (bc_continue)); gimple_set_location (stmt, stmt_locus); gimple_seq_add_stmt (&stmt_list, stmt); } } else { stmt = gimple_build_goto (gimple_label_label (top)); gimple_seq_add_stmt (&exit_seq, stmt); } } gimplify_stmt (&body, &body_seq); gimplify_stmt (&incr, &incr_seq); body_seq = finish_bc_block (bc_continue, cont_block, body_seq); gimple_seq_add_stmt (&stmt_list, top); gimple_seq_add_seq (&stmt_list, body_seq); gimple_seq_add_seq (&stmt_list, incr_seq); gimple_seq_add_stmt (&stmt_list, entry); gimple_seq_add_seq (&stmt_list, exit_seq); annotate_all_with_location (stmt_list, stmt_locus); return finish_bc_block (bc_break, break_block, stmt_list); }
/* Build a generic representation of one of the C loop forms. COND is the loop condition or NULL_TREE. BODY is the (possibly compound) statement controlled by the loop. INCR is the increment expression of a for-loop, or NULL_TREE. COND_IS_FIRST indicates whether the condition is evaluated before the loop body as in while and for loops, or after the loop body as in do-while loops. */
Build a generic representation of one of the C loop forms. COND is the loop condition or NULL_TREE. BODY is the (possibly compound) statement controlled by the loop. INCR is the increment expression of a for-loop, or NULL_TREE. COND_IS_FIRST indicates whether the condition is evaluated before the loop body as in while and for loops, or after the loop body as in do-while loops.
[ "Build", "a", "generic", "representation", "of", "one", "of", "the", "C", "loop", "forms", ".", "COND", "is", "the", "loop", "condition", "or", "NULL_TREE", ".", "BODY", "is", "the", "(", "possibly", "compound", ")", "statement", "controlled", "by", "the", "loop", ".", "INCR", "is", "the", "increment", "expression", "of", "a", "for", "-", "loop", "or", "NULL_TREE", ".", "COND_IS_FIRST", "indicates", "whether", "the", "condition", "is", "evaluated", "before", "the", "loop", "body", "as", "in", "while", "and", "for", "loops", "or", "after", "the", "loop", "body", "as", "in", "do", "-", "while", "loops", "." ]
static gimple_seq gimplify_cp_loop (tree cond, tree body, tree incr, bool cond_is_first) { gimple top, entry, stmt; gimple_seq stmt_list, body_seq, incr_seq, exit_seq; tree cont_block, break_block; location_t stmt_locus; stmt_locus = input_location; stmt_list = NULL; body_seq = NULL; incr_seq = NULL; exit_seq = NULL; entry = NULL; break_block = begin_bc_block (bc_break); cont_block = begin_bc_block (bc_continue); if (cond && integer_zerop (cond)) { top = NULL; if (cond_is_first) { stmt = gimple_build_goto (get_bc_label (bc_break)); gimple_set_location (stmt, stmt_locus); gimple_seq_add_stmt (&stmt_list, stmt); } } else { top = gimple_build_label (create_artificial_label (stmt_locus)); if (cond && !integer_nonzerop (cond)) { if (cond != error_mark_node) { gimplify_expr (&cond, &exit_seq, NULL, is_gimple_val, fb_rvalue); stmt = gimple_build_cond (NE_EXPR, cond, build_int_cst (TREE_TYPE (cond), 0), gimple_label_label (top), get_bc_label (bc_break)); gimple_seq_add_stmt (&exit_seq, stmt); } if (cond_is_first) { if (incr) { entry = gimple_build_label (create_artificial_label (stmt_locus)); stmt = gimple_build_goto (gimple_label_label (entry)); } else stmt = gimple_build_goto (get_bc_label (bc_continue)); gimple_set_location (stmt, stmt_locus); gimple_seq_add_stmt (&stmt_list, stmt); } } else { stmt = gimple_build_goto (gimple_label_label (top)); gimple_seq_add_stmt (&exit_seq, stmt); } } gimplify_stmt (&body, &body_seq); gimplify_stmt (&incr, &incr_seq); body_seq = finish_bc_block (bc_continue, cont_block, body_seq); gimple_seq_add_stmt (&stmt_list, top); gimple_seq_add_seq (&stmt_list, body_seq); gimple_seq_add_seq (&stmt_list, incr_seq); gimple_seq_add_stmt (&stmt_list, entry); gimple_seq_add_seq (&stmt_list, exit_seq); annotate_all_with_location (stmt_list, stmt_locus); return finish_bc_block (bc_break, break_block, stmt_list); }
[ "static", "gimple_seq", "gimplify_cp_loop", "(", "tree", "cond", ",", "tree", "body", ",", "tree", "incr", ",", "bool", "cond_is_first", ")", "{", "gimple", "top", ",", "entry", ",", "stmt", ";", "gimple_seq", "stmt_list", ",", "body_seq", ",", "incr_seq", ",", "exit_seq", ";", "tree", "cont_block", ",", "break_block", ";", "location_t", "stmt_locus", ";", "stmt_locus", "=", "input_location", ";", "stmt_list", "=", "NULL", ";", "body_seq", "=", "NULL", ";", "incr_seq", "=", "NULL", ";", "exit_seq", "=", "NULL", ";", "entry", "=", "NULL", ";", "break_block", "=", "begin_bc_block", "(", "bc_break", ")", ";", "cont_block", "=", "begin_bc_block", "(", "bc_continue", ")", ";", "if", "(", "cond", "&&", "integer_zerop", "(", "cond", ")", ")", "{", "top", "=", "NULL", ";", "if", "(", "cond_is_first", ")", "{", "stmt", "=", "gimple_build_goto", "(", "get_bc_label", "(", "bc_break", ")", ")", ";", "gimple_set_location", "(", "stmt", ",", "stmt_locus", ")", ";", "gimple_seq_add_stmt", "(", "&", "stmt_list", ",", "stmt", ")", ";", "}", "}", "else", "{", "top", "=", "gimple_build_label", "(", "create_artificial_label", "(", "stmt_locus", ")", ")", ";", "if", "(", "cond", "&&", "!", "integer_nonzerop", "(", "cond", ")", ")", "{", "if", "(", "cond", "!=", "error_mark_node", ")", "{", "gimplify_expr", "(", "&", "cond", ",", "&", "exit_seq", ",", "NULL", ",", "is_gimple_val", ",", "fb_rvalue", ")", ";", "stmt", "=", "gimple_build_cond", "(", "NE_EXPR", ",", "cond", ",", "build_int_cst", "(", "TREE_TYPE", "(", "cond", ")", ",", "0", ")", ",", "gimple_label_label", "(", "top", ")", ",", "get_bc_label", "(", "bc_break", ")", ")", ";", "gimple_seq_add_stmt", "(", "&", "exit_seq", ",", "stmt", ")", ";", "}", "if", "(", "cond_is_first", ")", "{", "if", "(", "incr", ")", "{", "entry", "=", "gimple_build_label", "(", "create_artificial_label", "(", "stmt_locus", ")", ")", ";", "stmt", "=", "gimple_build_goto", "(", "gimple_label_label", "(", "entry", ")", ")", ";", "}", "else", "stmt", "=", "gimple_build_goto", "(", "get_bc_label", "(", "bc_continue", ")", ")", ";", "gimple_set_location", "(", "stmt", ",", "stmt_locus", ")", ";", "gimple_seq_add_stmt", "(", "&", "stmt_list", ",", "stmt", ")", ";", "}", "}", "else", "{", "stmt", "=", "gimple_build_goto", "(", "gimple_label_label", "(", "top", ")", ")", ";", "gimple_seq_add_stmt", "(", "&", "exit_seq", ",", "stmt", ")", ";", "}", "}", "gimplify_stmt", "(", "&", "body", ",", "&", "body_seq", ")", ";", "gimplify_stmt", "(", "&", "incr", ",", "&", "incr_seq", ")", ";", "body_seq", "=", "finish_bc_block", "(", "bc_continue", ",", "cont_block", ",", "body_seq", ")", ";", "gimple_seq_add_stmt", "(", "&", "stmt_list", ",", "top", ")", ";", "gimple_seq_add_seq", "(", "&", "stmt_list", ",", "body_seq", ")", ";", "gimple_seq_add_seq", "(", "&", "stmt_list", ",", "incr_seq", ")", ";", "gimple_seq_add_stmt", "(", "&", "stmt_list", ",", "entry", ")", ";", "gimple_seq_add_seq", "(", "&", "stmt_list", ",", "exit_seq", ")", ";", "annotate_all_with_location", "(", "stmt_list", ",", "stmt_locus", ")", ";", "return", "finish_bc_block", "(", "bc_break", ",", "break_block", ",", "stmt_list", ")", ";", "}" ]
Build a generic representation of one of the C loop forms.
[ "Build", "a", "generic", "representation", "of", "one", "of", "the", "C", "loop", "forms", "." ]
[ "/* If condition is zero don't generate a loop construct. */", "/* If we use a LOOP_EXPR here, we have to feed the whole thing\n\t back through the main gimplifier to lower it. Given that we\n\t have to gimplify the loop body NOW so that we can resolve\n\t break/continue stmts, seems easier to just expand to gotos. */", "/* If we have an exit condition, then we build an IF with gotos either\n\t out of the loop, or to the top of it. If there's no exit condition,\n\t then we just build a jump back to the top. */" ]
[ { "param": "cond", "type": "tree" }, { "param": "body", "type": "tree" }, { "param": "incr", "type": "tree" }, { "param": "cond_is_first", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cond", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "body", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "incr", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cond_is_first", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
gimplify_for_stmt
void
static void gimplify_for_stmt (tree *stmt_p, gimple_seq *pre_p) { tree stmt = *stmt_p; if (FOR_INIT_STMT (stmt)) gimplify_and_add (FOR_INIT_STMT (stmt), pre_p); gimple_seq_add_seq (pre_p, gimplify_cp_loop (FOR_COND (stmt), FOR_BODY (stmt), FOR_EXPR (stmt), 1)); *stmt_p = NULL_TREE; }
/* Gimplify a FOR_STMT node. Move the stuff in the for-init-stmt into the prequeue and hand off to gimplify_cp_loop. */
Gimplify a FOR_STMT node. Move the stuff in the for-init-stmt into the prequeue and hand off to gimplify_cp_loop.
[ "Gimplify", "a", "FOR_STMT", "node", ".", "Move", "the", "stuff", "in", "the", "for", "-", "init", "-", "stmt", "into", "the", "prequeue", "and", "hand", "off", "to", "gimplify_cp_loop", "." ]
static void gimplify_for_stmt (tree *stmt_p, gimple_seq *pre_p) { tree stmt = *stmt_p; if (FOR_INIT_STMT (stmt)) gimplify_and_add (FOR_INIT_STMT (stmt), pre_p); gimple_seq_add_seq (pre_p, gimplify_cp_loop (FOR_COND (stmt), FOR_BODY (stmt), FOR_EXPR (stmt), 1)); *stmt_p = NULL_TREE; }
[ "static", "void", "gimplify_for_stmt", "(", "tree", "*", "stmt_p", ",", "gimple_seq", "*", "pre_p", ")", "{", "tree", "stmt", "=", "*", "stmt_p", ";", "if", "(", "FOR_INIT_STMT", "(", "stmt", ")", ")", "gimplify_and_add", "(", "FOR_INIT_STMT", "(", "stmt", ")", ",", "pre_p", ")", ";", "gimple_seq_add_seq", "(", "pre_p", ",", "gimplify_cp_loop", "(", "FOR_COND", "(", "stmt", ")", ",", "FOR_BODY", "(", "stmt", ")", ",", "FOR_EXPR", "(", "stmt", ")", ",", "1", ")", ")", ";", "*", "stmt_p", "=", "NULL_TREE", ";", "}" ]
Gimplify a FOR_STMT node.
[ "Gimplify", "a", "FOR_STMT", "node", "." ]
[]
[ { "param": "stmt_p", "type": "tree" }, { "param": "pre_p", "type": "gimple_seq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pre_p", "type": "gimple_seq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
gimplify_switch_stmt
void
static void gimplify_switch_stmt (tree *stmt_p, gimple_seq *pre_p) { tree stmt = *stmt_p; tree break_block, body, t; location_t stmt_locus = input_location; gimple_seq seq = NULL; break_block = begin_bc_block (bc_break); body = SWITCH_STMT_BODY (stmt); if (!body) body = build_empty_stmt (stmt_locus); t = build3 (SWITCH_EXPR, SWITCH_STMT_TYPE (stmt), SWITCH_STMT_COND (stmt), body, NULL_TREE); SET_EXPR_LOCATION (t, stmt_locus); gimplify_and_add (t, &seq); seq = finish_bc_block (bc_break, break_block, seq); gimple_seq_add_seq (pre_p, seq); *stmt_p = NULL_TREE; }
/* Genericize a SWITCH_STMT by turning it into a SWITCH_EXPR. */
Genericize a SWITCH_STMT by turning it into a SWITCH_EXPR.
[ "Genericize", "a", "SWITCH_STMT", "by", "turning", "it", "into", "a", "SWITCH_EXPR", "." ]
static void gimplify_switch_stmt (tree *stmt_p, gimple_seq *pre_p) { tree stmt = *stmt_p; tree break_block, body, t; location_t stmt_locus = input_location; gimple_seq seq = NULL; break_block = begin_bc_block (bc_break); body = SWITCH_STMT_BODY (stmt); if (!body) body = build_empty_stmt (stmt_locus); t = build3 (SWITCH_EXPR, SWITCH_STMT_TYPE (stmt), SWITCH_STMT_COND (stmt), body, NULL_TREE); SET_EXPR_LOCATION (t, stmt_locus); gimplify_and_add (t, &seq); seq = finish_bc_block (bc_break, break_block, seq); gimple_seq_add_seq (pre_p, seq); *stmt_p = NULL_TREE; }
[ "static", "void", "gimplify_switch_stmt", "(", "tree", "*", "stmt_p", ",", "gimple_seq", "*", "pre_p", ")", "{", "tree", "stmt", "=", "*", "stmt_p", ";", "tree", "break_block", ",", "body", ",", "t", ";", "location_t", "stmt_locus", "=", "input_location", ";", "gimple_seq", "seq", "=", "NULL", ";", "break_block", "=", "begin_bc_block", "(", "bc_break", ")", ";", "body", "=", "SWITCH_STMT_BODY", "(", "stmt", ")", ";", "if", "(", "!", "body", ")", "body", "=", "build_empty_stmt", "(", "stmt_locus", ")", ";", "t", "=", "build3", "(", "SWITCH_EXPR", ",", "SWITCH_STMT_TYPE", "(", "stmt", ")", ",", "SWITCH_STMT_COND", "(", "stmt", ")", ",", "body", ",", "NULL_TREE", ")", ";", "SET_EXPR_LOCATION", "(", "t", ",", "stmt_locus", ")", ";", "gimplify_and_add", "(", "t", ",", "&", "seq", ")", ";", "seq", "=", "finish_bc_block", "(", "bc_break", ",", "break_block", ",", "seq", ")", ";", "gimple_seq_add_seq", "(", "pre_p", ",", "seq", ")", ";", "*", "stmt_p", "=", "NULL_TREE", ";", "}" ]
Genericize a SWITCH_STMT by turning it into a SWITCH_EXPR.
[ "Genericize", "a", "SWITCH_STMT", "by", "turning", "it", "into", "a", "SWITCH_EXPR", "." ]
[]
[ { "param": "stmt_p", "type": "tree" }, { "param": "pre_p", "type": "gimple_seq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pre_p", "type": "gimple_seq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cp_gimplify_omp_for
null
static enum gimplify_status cp_gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { tree for_stmt = *expr_p; tree cont_block; gimple stmt; gimple_seq seq = NULL; /* Protect ourselves from recursion. */ if (OMP_FOR_GIMPLIFYING_P (for_stmt)) return GS_UNHANDLED; OMP_FOR_GIMPLIFYING_P (for_stmt) = 1; /* Note that while technically the continue label is enabled too soon here, we should have already diagnosed invalid continues nested within statement expressions within the INIT, COND, or INCR expressions. */ cont_block = begin_bc_block (bc_continue); gimplify_and_add (for_stmt, &seq); stmt = gimple_seq_last_stmt (seq); if (gimple_code (stmt) == GIMPLE_OMP_FOR) gimple_omp_set_body (stmt, finish_bc_block (bc_continue, cont_block, gimple_omp_body (stmt))); else seq = finish_bc_block (bc_continue, cont_block, seq); gimple_seq_add_seq (pre_p, seq); OMP_FOR_GIMPLIFYING_P (for_stmt) = 0; return GS_ALL_DONE; }
/* Hook into the middle of gimplifying an OMP_FOR node. This is required in order to properly gimplify CONTINUE statements. Here we merely manage the continue stack; the rest of the job is performed by the regular gimplifier. */
Hook into the middle of gimplifying an OMP_FOR node. This is required in order to properly gimplify CONTINUE statements. Here we merely manage the continue stack; the rest of the job is performed by the regular gimplifier.
[ "Hook", "into", "the", "middle", "of", "gimplifying", "an", "OMP_FOR", "node", ".", "This", "is", "required", "in", "order", "to", "properly", "gimplify", "CONTINUE", "statements", ".", "Here", "we", "merely", "manage", "the", "continue", "stack", ";", "the", "rest", "of", "the", "job", "is", "performed", "by", "the", "regular", "gimplifier", "." ]
static enum gimplify_status cp_gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) { tree for_stmt = *expr_p; tree cont_block; gimple stmt; gimple_seq seq = NULL; if (OMP_FOR_GIMPLIFYING_P (for_stmt)) return GS_UNHANDLED; OMP_FOR_GIMPLIFYING_P (for_stmt) = 1; cont_block = begin_bc_block (bc_continue); gimplify_and_add (for_stmt, &seq); stmt = gimple_seq_last_stmt (seq); if (gimple_code (stmt) == GIMPLE_OMP_FOR) gimple_omp_set_body (stmt, finish_bc_block (bc_continue, cont_block, gimple_omp_body (stmt))); else seq = finish_bc_block (bc_continue, cont_block, seq); gimple_seq_add_seq (pre_p, seq); OMP_FOR_GIMPLIFYING_P (for_stmt) = 0; return GS_ALL_DONE; }
[ "static", "enum", "gimplify_status", "cp_gimplify_omp_for", "(", "tree", "*", "expr_p", ",", "gimple_seq", "*", "pre_p", ")", "{", "tree", "for_stmt", "=", "*", "expr_p", ";", "tree", "cont_block", ";", "gimple", "stmt", ";", "gimple_seq", "seq", "=", "NULL", ";", "if", "(", "OMP_FOR_GIMPLIFYING_P", "(", "for_stmt", ")", ")", "return", "GS_UNHANDLED", ";", "OMP_FOR_GIMPLIFYING_P", "(", "for_stmt", ")", "=", "1", ";", "cont_block", "=", "begin_bc_block", "(", "bc_continue", ")", ";", "gimplify_and_add", "(", "for_stmt", ",", "&", "seq", ")", ";", "stmt", "=", "gimple_seq_last_stmt", "(", "seq", ")", ";", "if", "(", "gimple_code", "(", "stmt", ")", "==", "GIMPLE_OMP_FOR", ")", "gimple_omp_set_body", "(", "stmt", ",", "finish_bc_block", "(", "bc_continue", ",", "cont_block", ",", "gimple_omp_body", "(", "stmt", ")", ")", ")", ";", "else", "seq", "=", "finish_bc_block", "(", "bc_continue", ",", "cont_block", ",", "seq", ")", ";", "gimple_seq_add_seq", "(", "pre_p", ",", "seq", ")", ";", "OMP_FOR_GIMPLIFYING_P", "(", "for_stmt", ")", "=", "0", ";", "return", "GS_ALL_DONE", ";", "}" ]
Hook into the middle of gimplifying an OMP_FOR node.
[ "Hook", "into", "the", "middle", "of", "gimplifying", "an", "OMP_FOR", "node", "." ]
[ "/* Protect ourselves from recursion. */", "/* Note that while technically the continue label is enabled too soon\n here, we should have already diagnosed invalid continues nested within\n statement expressions within the INIT, COND, or INCR expressions. */" ]
[ { "param": "expr_p", "type": "tree" }, { "param": "pre_p", "type": "gimple_seq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "expr_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pre_p", "type": "gimple_seq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cp_gimplify_init_expr
void
static void cp_gimplify_init_expr (tree *expr_p) { tree from = TREE_OPERAND (*expr_p, 1); tree to = TREE_OPERAND (*expr_p, 0); tree t; /* What about code that pulls out the temp and uses it elsewhere? I think that such code never uses the TARGET_EXPR as an initializer. If I'm wrong, we'll abort because the temp won't have any RTL. In that case, I guess we'll need to replace references somehow. */ if (TREE_CODE (from) == TARGET_EXPR) from = TARGET_EXPR_INITIAL (from); /* Look through any COMPOUND_EXPRs, since build_compound_expr pushes them inside the TARGET_EXPR. */ for (t = from; t; ) { tree sub = TREE_CODE (t) == COMPOUND_EXPR ? TREE_OPERAND (t, 0) : t; /* If we are initializing from an AGGR_INIT_EXPR, drop the INIT_EXPR and replace the slot operand with our target. Should we add a target parm to gimplify_expr instead? No, as in this case we want to replace the INIT_EXPR. */ if (TREE_CODE (sub) == AGGR_INIT_EXPR || TREE_CODE (sub) == VEC_INIT_EXPR) { if (TREE_CODE (sub) == AGGR_INIT_EXPR) AGGR_INIT_EXPR_SLOT (sub) = to; else VEC_INIT_EXPR_SLOT (sub) = to; *expr_p = from; /* The initialization is now a side-effect, so the container can become void. */ if (from != sub) TREE_TYPE (from) = void_type_node; } if (t == sub) break; else t = TREE_OPERAND (t, 1); } }
/* Gimplify initialization from an AGGR_INIT_EXPR. */
Gimplify initialization from an AGGR_INIT_EXPR.
[ "Gimplify", "initialization", "from", "an", "AGGR_INIT_EXPR", "." ]
static void cp_gimplify_init_expr (tree *expr_p) { tree from = TREE_OPERAND (*expr_p, 1); tree to = TREE_OPERAND (*expr_p, 0); tree t; if (TREE_CODE (from) == TARGET_EXPR) from = TARGET_EXPR_INITIAL (from); for (t = from; t; ) { tree sub = TREE_CODE (t) == COMPOUND_EXPR ? TREE_OPERAND (t, 0) : t; if (TREE_CODE (sub) == AGGR_INIT_EXPR || TREE_CODE (sub) == VEC_INIT_EXPR) { if (TREE_CODE (sub) == AGGR_INIT_EXPR) AGGR_INIT_EXPR_SLOT (sub) = to; else VEC_INIT_EXPR_SLOT (sub) = to; *expr_p = from; if (from != sub) TREE_TYPE (from) = void_type_node; } if (t == sub) break; else t = TREE_OPERAND (t, 1); } }
[ "static", "void", "cp_gimplify_init_expr", "(", "tree", "*", "expr_p", ")", "{", "tree", "from", "=", "TREE_OPERAND", "(", "*", "expr_p", ",", "1", ")", ";", "tree", "to", "=", "TREE_OPERAND", "(", "*", "expr_p", ",", "0", ")", ";", "tree", "t", ";", "if", "(", "TREE_CODE", "(", "from", ")", "==", "TARGET_EXPR", ")", "from", "=", "TARGET_EXPR_INITIAL", "(", "from", ")", ";", "for", "(", "t", "=", "from", ";", "t", ";", ")", "{", "tree", "sub", "=", "TREE_CODE", "(", "t", ")", "==", "COMPOUND_EXPR", "?", "TREE_OPERAND", "(", "t", ",", "0", ")", ":", "t", ";", "if", "(", "TREE_CODE", "(", "sub", ")", "==", "AGGR_INIT_EXPR", "||", "TREE_CODE", "(", "sub", ")", "==", "VEC_INIT_EXPR", ")", "{", "if", "(", "TREE_CODE", "(", "sub", ")", "==", "AGGR_INIT_EXPR", ")", "AGGR_INIT_EXPR_SLOT", "(", "sub", ")", "=", "to", ";", "else", "VEC_INIT_EXPR_SLOT", "(", "sub", ")", "=", "to", ";", "*", "expr_p", "=", "from", ";", "if", "(", "from", "!=", "sub", ")", "TREE_TYPE", "(", "from", ")", "=", "void_type_node", ";", "}", "if", "(", "t", "==", "sub", ")", "break", ";", "else", "t", "=", "TREE_OPERAND", "(", "t", ",", "1", ")", ";", "}", "}" ]
Gimplify initialization from an AGGR_INIT_EXPR.
[ "Gimplify", "initialization", "from", "an", "AGGR_INIT_EXPR", "." ]
[ "/* What about code that pulls out the temp and uses it elsewhere? I\n think that such code never uses the TARGET_EXPR as an initializer. If\n I'm wrong, we'll abort because the temp won't have any RTL. In that\n case, I guess we'll need to replace references somehow. */", "/* Look through any COMPOUND_EXPRs, since build_compound_expr pushes them\n inside the TARGET_EXPR. */", "/* If we are initializing from an AGGR_INIT_EXPR, drop the INIT_EXPR and\n\t replace the slot operand with our target.\n\n\t Should we add a target parm to gimplify_expr instead? No, as in this\n\t case we want to replace the INIT_EXPR. */", "/* The initialization is now a side-effect, so the container can\n\t become void. */" ]
[ { "param": "expr_p", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "expr_p", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
splay_tree_compare_decl_uid
int
static int splay_tree_compare_decl_uid (splay_tree_key xa, splay_tree_key xb) { tree a = (tree) xa; tree b = (tree) xb; return DECL_UID (a) - DECL_UID (b); }
/* A stable comparison routine for use with splay trees and DECLs. */
A stable comparison routine for use with splay trees and DECLs.
[ "A", "stable", "comparison", "routine", "for", "use", "with", "splay", "trees", "and", "DECLs", "." ]
static int splay_tree_compare_decl_uid (splay_tree_key xa, splay_tree_key xb) { tree a = (tree) xa; tree b = (tree) xb; return DECL_UID (a) - DECL_UID (b); }
[ "static", "int", "splay_tree_compare_decl_uid", "(", "splay_tree_key", "xa", ",", "splay_tree_key", "xb", ")", "{", "tree", "a", "=", "(", "tree", ")", "xa", ";", "tree", "b", "=", "(", "tree", ")", "xb", ";", "return", "DECL_UID", "(", "a", ")", "-", "DECL_UID", "(", "b", ")", ";", "}" ]
A stable comparison routine for use with splay trees and DECLs.
[ "A", "stable", "comparison", "routine", "for", "use", "with", "splay", "trees", "and", "DECLs", "." ]
[]
[ { "param": "xa", "type": "splay_tree_key" }, { "param": "xb", "type": "splay_tree_key" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "xa", "type": "splay_tree_key", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "xb", "type": "splay_tree_key", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
omp_var_to_track
bool
static bool omp_var_to_track (tree decl) { tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); if (type == error_mark_node || !CLASS_TYPE_P (type)) return false; if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) return false; if (cxx_omp_predetermined_sharing (decl) != OMP_CLAUSE_DEFAULT_UNSPECIFIED) return false; return true; }
/* Return true if genericization should try to determine if DECL is firstprivate or shared within task regions. */
Return true if genericization should try to determine if DECL is firstprivate or shared within task regions.
[ "Return", "true", "if", "genericization", "should", "try", "to", "determine", "if", "DECL", "is", "firstprivate", "or", "shared", "within", "task", "regions", "." ]
static bool omp_var_to_track (tree decl) { tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); if (type == error_mark_node || !CLASS_TYPE_P (type)) return false; if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) return false; if (cxx_omp_predetermined_sharing (decl) != OMP_CLAUSE_DEFAULT_UNSPECIFIED) return false; return true; }
[ "static", "bool", "omp_var_to_track", "(", "tree", "decl", ")", "{", "tree", "type", "=", "TREE_TYPE", "(", "decl", ")", ";", "if", "(", "is_invisiref_parm", "(", "decl", ")", ")", "type", "=", "TREE_TYPE", "(", "type", ")", ";", "while", "(", "TREE_CODE", "(", "type", ")", "==", "ARRAY_TYPE", ")", "type", "=", "TREE_TYPE", "(", "type", ")", ";", "if", "(", "type", "==", "error_mark_node", "||", "!", "CLASS_TYPE_P", "(", "type", ")", ")", "return", "false", ";", "if", "(", "TREE_CODE", "(", "decl", ")", "==", "VAR_DECL", "&&", "DECL_THREAD_LOCAL_P", "(", "decl", ")", ")", "return", "false", ";", "if", "(", "cxx_omp_predetermined_sharing", "(", "decl", ")", "!=", "OMP_CLAUSE_DEFAULT_UNSPECIFIED", ")", "return", "false", ";", "return", "true", ";", "}" ]
Return true if genericization should try to determine if DECL is firstprivate or shared within task regions.
[ "Return", "true", "if", "genericization", "should", "try", "to", "determine", "if", "DECL", "is", "firstprivate", "or", "shared", "within", "task", "regions", "." ]
[]
[ { "param": "decl", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "decl", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
omp_cxx_notice_variable
void
static void omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl) { splay_tree_node n = splay_tree_lookup (omp_ctx->variables, (splay_tree_key) decl); if (n == NULL) { int flags = OMP_CLAUSE_DEFAULT_SHARED; if (omp_ctx->outer) omp_cxx_notice_variable (omp_ctx->outer, decl); if (!omp_ctx->default_shared) { struct cp_genericize_omp_taskreg *octx; for (octx = omp_ctx->outer; octx; octx = octx->outer) { n = splay_tree_lookup (octx->variables, (splay_tree_key) decl); if (n && n->value != OMP_CLAUSE_DEFAULT_SHARED) { flags = OMP_CLAUSE_DEFAULT_FIRSTPRIVATE; break; } if (octx->is_parallel) break; } if (octx == NULL && (TREE_CODE (decl) == PARM_DECL || (!(TREE_STATIC (decl) || DECL_EXTERNAL (decl)) && DECL_CONTEXT (decl) == current_function_decl))) flags = OMP_CLAUSE_DEFAULT_FIRSTPRIVATE; if (flags == OMP_CLAUSE_DEFAULT_FIRSTPRIVATE) { /* DECL is implicitly determined firstprivate in the current task construct. Ensure copy ctor and dtor are instantiated, because during gimplification it will be already too late. */ tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); get_copy_ctor (type, tf_none); get_dtor (type, tf_none); } } splay_tree_insert (omp_ctx->variables, (splay_tree_key) decl, flags); } }
/* Note DECL use in OpenMP region OMP_CTX during genericization. */
Note DECL use in OpenMP region OMP_CTX during genericization.
[ "Note", "DECL", "use", "in", "OpenMP", "region", "OMP_CTX", "during", "genericization", "." ]
static void omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl) { splay_tree_node n = splay_tree_lookup (omp_ctx->variables, (splay_tree_key) decl); if (n == NULL) { int flags = OMP_CLAUSE_DEFAULT_SHARED; if (omp_ctx->outer) omp_cxx_notice_variable (omp_ctx->outer, decl); if (!omp_ctx->default_shared) { struct cp_genericize_omp_taskreg *octx; for (octx = omp_ctx->outer; octx; octx = octx->outer) { n = splay_tree_lookup (octx->variables, (splay_tree_key) decl); if (n && n->value != OMP_CLAUSE_DEFAULT_SHARED) { flags = OMP_CLAUSE_DEFAULT_FIRSTPRIVATE; break; } if (octx->is_parallel) break; } if (octx == NULL && (TREE_CODE (decl) == PARM_DECL || (!(TREE_STATIC (decl) || DECL_EXTERNAL (decl)) && DECL_CONTEXT (decl) == current_function_decl))) flags = OMP_CLAUSE_DEFAULT_FIRSTPRIVATE; if (flags == OMP_CLAUSE_DEFAULT_FIRSTPRIVATE) { tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); get_copy_ctor (type, tf_none); get_dtor (type, tf_none); } } splay_tree_insert (omp_ctx->variables, (splay_tree_key) decl, flags); } }
[ "static", "void", "omp_cxx_notice_variable", "(", "struct", "cp_genericize_omp_taskreg", "*", "omp_ctx", ",", "tree", "decl", ")", "{", "splay_tree_node", "n", "=", "splay_tree_lookup", "(", "omp_ctx", "->", "variables", ",", "(", "splay_tree_key", ")", "decl", ")", ";", "if", "(", "n", "==", "NULL", ")", "{", "int", "flags", "=", "OMP_CLAUSE_DEFAULT_SHARED", ";", "if", "(", "omp_ctx", "->", "outer", ")", "omp_cxx_notice_variable", "(", "omp_ctx", "->", "outer", ",", "decl", ")", ";", "if", "(", "!", "omp_ctx", "->", "default_shared", ")", "{", "struct", "cp_genericize_omp_taskreg", "*", "octx", ";", "for", "(", "octx", "=", "omp_ctx", "->", "outer", ";", "octx", ";", "octx", "=", "octx", "->", "outer", ")", "{", "n", "=", "splay_tree_lookup", "(", "octx", "->", "variables", ",", "(", "splay_tree_key", ")", "decl", ")", ";", "if", "(", "n", "&&", "n", "->", "value", "!=", "OMP_CLAUSE_DEFAULT_SHARED", ")", "{", "flags", "=", "OMP_CLAUSE_DEFAULT_FIRSTPRIVATE", ";", "break", ";", "}", "if", "(", "octx", "->", "is_parallel", ")", "break", ";", "}", "if", "(", "octx", "==", "NULL", "&&", "(", "TREE_CODE", "(", "decl", ")", "==", "PARM_DECL", "||", "(", "!", "(", "TREE_STATIC", "(", "decl", ")", "||", "DECL_EXTERNAL", "(", "decl", ")", ")", "&&", "DECL_CONTEXT", "(", "decl", ")", "==", "current_function_decl", ")", ")", ")", "flags", "=", "OMP_CLAUSE_DEFAULT_FIRSTPRIVATE", ";", "if", "(", "flags", "==", "OMP_CLAUSE_DEFAULT_FIRSTPRIVATE", ")", "{", "tree", "type", "=", "TREE_TYPE", "(", "decl", ")", ";", "if", "(", "is_invisiref_parm", "(", "decl", ")", ")", "type", "=", "TREE_TYPE", "(", "type", ")", ";", "while", "(", "TREE_CODE", "(", "type", ")", "==", "ARRAY_TYPE", ")", "type", "=", "TREE_TYPE", "(", "type", ")", ";", "get_copy_ctor", "(", "type", ",", "tf_none", ")", ";", "get_dtor", "(", "type", ",", "tf_none", ")", ";", "}", "}", "splay_tree_insert", "(", "omp_ctx", "->", "variables", ",", "(", "splay_tree_key", ")", "decl", ",", "flags", ")", ";", "}", "}" ]
Note DECL use in OpenMP region OMP_CTX during genericization.
[ "Note", "DECL", "use", "in", "OpenMP", "region", "OMP_CTX", "during", "genericization", "." ]
[ "/* DECL is implicitly determined firstprivate in\n\t\t the current task construct. Ensure copy ctor and\n\t\t dtor are instantiated, because during gimplification\n\t\t it will be already too late. */" ]
[ { "param": "omp_ctx", "type": "struct cp_genericize_omp_taskreg" }, { "param": "decl", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "omp_ctx", "type": "struct cp_genericize_omp_taskreg", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "decl", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_clause_apply_fn
tree
static tree cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) { tree defparm, parm, t; int i = 0; int nargs; tree *argarray; if (fn == NULL) return NULL; nargs = list_length (DECL_ARGUMENTS (fn)); argarray = XALLOCAVEC (tree, nargs); defparm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn))); if (arg2) defparm = TREE_CHAIN (defparm); if (TREE_CODE (TREE_TYPE (arg1)) == ARRAY_TYPE) { tree inner_type = TREE_TYPE (arg1); tree start1, end1, p1; tree start2 = NULL, p2 = NULL; tree ret = NULL, lab; start1 = arg1; start2 = arg2; do { inner_type = TREE_TYPE (inner_type); start1 = build4 (ARRAY_REF, inner_type, start1, size_zero_node, NULL, NULL); if (arg2) start2 = build4 (ARRAY_REF, inner_type, start2, size_zero_node, NULL, NULL); } while (TREE_CODE (inner_type) == ARRAY_TYPE); start1 = build_fold_addr_expr_loc (input_location, start1); if (arg2) start2 = build_fold_addr_expr_loc (input_location, start2); end1 = TYPE_SIZE_UNIT (TREE_TYPE (arg1)); end1 = fold_build_pointer_plus (start1, end1); p1 = create_tmp_var (TREE_TYPE (start1), NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, start1); append_to_statement_list (t, &ret); if (arg2) { p2 = create_tmp_var (TREE_TYPE (start2), NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (p2), p2, start2); append_to_statement_list (t, &ret); } lab = create_artificial_label (input_location); t = build1 (LABEL_EXPR, void_type_node, lab); append_to_statement_list (t, &ret); argarray[i++] = p1; if (arg2) argarray[i++] = p2; /* Handle default arguments. */ for (parm = defparm; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++) argarray[i] = convert_default_arg (TREE_VALUE (parm), TREE_PURPOSE (parm), fn, i); t = build_call_a (fn, i, argarray); t = fold_convert (void_type_node, t); t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); append_to_statement_list (t, &ret); t = fold_build_pointer_plus (p1, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, t); append_to_statement_list (t, &ret); if (arg2) { t = fold_build_pointer_plus (p2, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p2), p2, t); append_to_statement_list (t, &ret); } t = build2 (NE_EXPR, boolean_type_node, p1, end1); t = build3 (COND_EXPR, void_type_node, t, build_and_jump (&lab), NULL); append_to_statement_list (t, &ret); return ret; } else { argarray[i++] = build_fold_addr_expr_loc (input_location, arg1); if (arg2) argarray[i++] = build_fold_addr_expr_loc (input_location, arg2); /* Handle default arguments. */ for (parm = defparm; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++) argarray[i] = convert_default_arg (TREE_VALUE (parm), TREE_PURPOSE (parm), fn, i); t = build_call_a (fn, i, argarray); t = fold_convert (void_type_node, t); return fold_build_cleanup_point_expr (TREE_TYPE (t), t); } }
/* Build code to apply FN to each member of ARG1 and ARG2. FN may be NULL if there is in fact nothing to do. ARG2 may be null if FN actually only takes one argument. */
Build code to apply FN to each member of ARG1 and ARG2. FN may be NULL if there is in fact nothing to do. ARG2 may be null if FN actually only takes one argument.
[ "Build", "code", "to", "apply", "FN", "to", "each", "member", "of", "ARG1", "and", "ARG2", ".", "FN", "may", "be", "NULL", "if", "there", "is", "in", "fact", "nothing", "to", "do", ".", "ARG2", "may", "be", "null", "if", "FN", "actually", "only", "takes", "one", "argument", "." ]
static tree cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) { tree defparm, parm, t; int i = 0; int nargs; tree *argarray; if (fn == NULL) return NULL; nargs = list_length (DECL_ARGUMENTS (fn)); argarray = XALLOCAVEC (tree, nargs); defparm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn))); if (arg2) defparm = TREE_CHAIN (defparm); if (TREE_CODE (TREE_TYPE (arg1)) == ARRAY_TYPE) { tree inner_type = TREE_TYPE (arg1); tree start1, end1, p1; tree start2 = NULL, p2 = NULL; tree ret = NULL, lab; start1 = arg1; start2 = arg2; do { inner_type = TREE_TYPE (inner_type); start1 = build4 (ARRAY_REF, inner_type, start1, size_zero_node, NULL, NULL); if (arg2) start2 = build4 (ARRAY_REF, inner_type, start2, size_zero_node, NULL, NULL); } while (TREE_CODE (inner_type) == ARRAY_TYPE); start1 = build_fold_addr_expr_loc (input_location, start1); if (arg2) start2 = build_fold_addr_expr_loc (input_location, start2); end1 = TYPE_SIZE_UNIT (TREE_TYPE (arg1)); end1 = fold_build_pointer_plus (start1, end1); p1 = create_tmp_var (TREE_TYPE (start1), NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, start1); append_to_statement_list (t, &ret); if (arg2) { p2 = create_tmp_var (TREE_TYPE (start2), NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (p2), p2, start2); append_to_statement_list (t, &ret); } lab = create_artificial_label (input_location); t = build1 (LABEL_EXPR, void_type_node, lab); append_to_statement_list (t, &ret); argarray[i++] = p1; if (arg2) argarray[i++] = p2; for (parm = defparm; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++) argarray[i] = convert_default_arg (TREE_VALUE (parm), TREE_PURPOSE (parm), fn, i); t = build_call_a (fn, i, argarray); t = fold_convert (void_type_node, t); t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); append_to_statement_list (t, &ret); t = fold_build_pointer_plus (p1, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p1), p1, t); append_to_statement_list (t, &ret); if (arg2) { t = fold_build_pointer_plus (p2, TYPE_SIZE_UNIT (inner_type)); t = build2 (MODIFY_EXPR, TREE_TYPE (p2), p2, t); append_to_statement_list (t, &ret); } t = build2 (NE_EXPR, boolean_type_node, p1, end1); t = build3 (COND_EXPR, void_type_node, t, build_and_jump (&lab), NULL); append_to_statement_list (t, &ret); return ret; } else { argarray[i++] = build_fold_addr_expr_loc (input_location, arg1); if (arg2) argarray[i++] = build_fold_addr_expr_loc (input_location, arg2); for (parm = defparm; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++) argarray[i] = convert_default_arg (TREE_VALUE (parm), TREE_PURPOSE (parm), fn, i); t = build_call_a (fn, i, argarray); t = fold_convert (void_type_node, t); return fold_build_cleanup_point_expr (TREE_TYPE (t), t); } }
[ "static", "tree", "cxx_omp_clause_apply_fn", "(", "tree", "fn", ",", "tree", "arg1", ",", "tree", "arg2", ")", "{", "tree", "defparm", ",", "parm", ",", "t", ";", "int", "i", "=", "0", ";", "int", "nargs", ";", "tree", "*", "argarray", ";", "if", "(", "fn", "==", "NULL", ")", "return", "NULL", ";", "nargs", "=", "list_length", "(", "DECL_ARGUMENTS", "(", "fn", ")", ")", ";", "argarray", "=", "XALLOCAVEC", "(", "tree", ",", "nargs", ")", ";", "defparm", "=", "TREE_CHAIN", "(", "TYPE_ARG_TYPES", "(", "TREE_TYPE", "(", "fn", ")", ")", ")", ";", "if", "(", "arg2", ")", "defparm", "=", "TREE_CHAIN", "(", "defparm", ")", ";", "if", "(", "TREE_CODE", "(", "TREE_TYPE", "(", "arg1", ")", ")", "==", "ARRAY_TYPE", ")", "{", "tree", "inner_type", "=", "TREE_TYPE", "(", "arg1", ")", ";", "tree", "start1", ",", "end1", ",", "p1", ";", "tree", "start2", "=", "NULL", ",", "p2", "=", "NULL", ";", "tree", "ret", "=", "NULL", ",", "lab", ";", "start1", "=", "arg1", ";", "start2", "=", "arg2", ";", "do", "{", "inner_type", "=", "TREE_TYPE", "(", "inner_type", ")", ";", "start1", "=", "build4", "(", "ARRAY_REF", ",", "inner_type", ",", "start1", ",", "size_zero_node", ",", "NULL", ",", "NULL", ")", ";", "if", "(", "arg2", ")", "start2", "=", "build4", "(", "ARRAY_REF", ",", "inner_type", ",", "start2", ",", "size_zero_node", ",", "NULL", ",", "NULL", ")", ";", "}", "while", "(", "TREE_CODE", "(", "inner_type", ")", "==", "ARRAY_TYPE", ")", ";", "start1", "=", "build_fold_addr_expr_loc", "(", "input_location", ",", "start1", ")", ";", "if", "(", "arg2", ")", "start2", "=", "build_fold_addr_expr_loc", "(", "input_location", ",", "start2", ")", ";", "end1", "=", "TYPE_SIZE_UNIT", "(", "TREE_TYPE", "(", "arg1", ")", ")", ";", "end1", "=", "fold_build_pointer_plus", "(", "start1", ",", "end1", ")", ";", "p1", "=", "create_tmp_var", "(", "TREE_TYPE", "(", "start1", ")", ",", "NULL", ")", ";", "t", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "p1", ")", ",", "p1", ",", "start1", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "if", "(", "arg2", ")", "{", "p2", "=", "create_tmp_var", "(", "TREE_TYPE", "(", "start2", ")", ",", "NULL", ")", ";", "t", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "p2", ")", ",", "p2", ",", "start2", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "}", "lab", "=", "create_artificial_label", "(", "input_location", ")", ";", "t", "=", "build1", "(", "LABEL_EXPR", ",", "void_type_node", ",", "lab", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "argarray", "[", "i", "++", "]", "=", "p1", ";", "if", "(", "arg2", ")", "argarray", "[", "i", "++", "]", "=", "p2", ";", "for", "(", "parm", "=", "defparm", ";", "parm", "&&", "parm", "!=", "void_list_node", ";", "parm", "=", "TREE_CHAIN", "(", "parm", ")", ",", "i", "++", ")", "argarray", "[", "i", "]", "=", "convert_default_arg", "(", "TREE_VALUE", "(", "parm", ")", ",", "TREE_PURPOSE", "(", "parm", ")", ",", "fn", ",", "i", ")", ";", "t", "=", "build_call_a", "(", "fn", ",", "i", ",", "argarray", ")", ";", "t", "=", "fold_convert", "(", "void_type_node", ",", "t", ")", ";", "t", "=", "fold_build_cleanup_point_expr", "(", "TREE_TYPE", "(", "t", ")", ",", "t", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "t", "=", "fold_build_pointer_plus", "(", "p1", ",", "TYPE_SIZE_UNIT", "(", "inner_type", ")", ")", ";", "t", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "p1", ")", ",", "p1", ",", "t", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "if", "(", "arg2", ")", "{", "t", "=", "fold_build_pointer_plus", "(", "p2", ",", "TYPE_SIZE_UNIT", "(", "inner_type", ")", ")", ";", "t", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "p2", ")", ",", "p2", ",", "t", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "}", "t", "=", "build2", "(", "NE_EXPR", ",", "boolean_type_node", ",", "p1", ",", "end1", ")", ";", "t", "=", "build3", "(", "COND_EXPR", ",", "void_type_node", ",", "t", ",", "build_and_jump", "(", "&", "lab", ")", ",", "NULL", ")", ";", "append_to_statement_list", "(", "t", ",", "&", "ret", ")", ";", "return", "ret", ";", "}", "else", "{", "argarray", "[", "i", "++", "]", "=", "build_fold_addr_expr_loc", "(", "input_location", ",", "arg1", ")", ";", "if", "(", "arg2", ")", "argarray", "[", "i", "++", "]", "=", "build_fold_addr_expr_loc", "(", "input_location", ",", "arg2", ")", ";", "for", "(", "parm", "=", "defparm", ";", "parm", "&&", "parm", "!=", "void_list_node", ";", "parm", "=", "TREE_CHAIN", "(", "parm", ")", ",", "i", "++", ")", "argarray", "[", "i", "]", "=", "convert_default_arg", "(", "TREE_VALUE", "(", "parm", ")", ",", "TREE_PURPOSE", "(", "parm", ")", ",", "fn", ",", "i", ")", ";", "t", "=", "build_call_a", "(", "fn", ",", "i", ",", "argarray", ")", ";", "t", "=", "fold_convert", "(", "void_type_node", ",", "t", ")", ";", "return", "fold_build_cleanup_point_expr", "(", "TREE_TYPE", "(", "t", ")", ",", "t", ")", ";", "}", "}" ]
Build code to apply FN to each member of ARG1 and ARG2.
[ "Build", "code", "to", "apply", "FN", "to", "each", "member", "of", "ARG1", "and", "ARG2", "." ]
[ "/* Handle default arguments. */", "/* Handle default arguments. */" ]
[ { "param": "fn", "type": "tree" }, { "param": "arg1", "type": "tree" }, { "param": "arg2", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg1", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg2", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_clause_copy_ctor
tree
tree cxx_omp_clause_copy_ctor (tree clause, tree dst, tree src) { tree info = CP_OMP_CLAUSE_INFO (clause); tree ret = NULL; if (info) ret = cxx_omp_clause_apply_fn (TREE_VEC_ELT (info, 0), dst, src); if (ret == NULL) ret = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); return ret; }
/* Return code to initialize DST with a copy constructor from SRC. */
Return code to initialize DST with a copy constructor from SRC.
[ "Return", "code", "to", "initialize", "DST", "with", "a", "copy", "constructor", "from", "SRC", "." ]
tree cxx_omp_clause_copy_ctor (tree clause, tree dst, tree src) { tree info = CP_OMP_CLAUSE_INFO (clause); tree ret = NULL; if (info) ret = cxx_omp_clause_apply_fn (TREE_VEC_ELT (info, 0), dst, src); if (ret == NULL) ret = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); return ret; }
[ "tree", "cxx_omp_clause_copy_ctor", "(", "tree", "clause", ",", "tree", "dst", ",", "tree", "src", ")", "{", "tree", "info", "=", "CP_OMP_CLAUSE_INFO", "(", "clause", ")", ";", "tree", "ret", "=", "NULL", ";", "if", "(", "info", ")", "ret", "=", "cxx_omp_clause_apply_fn", "(", "TREE_VEC_ELT", "(", "info", ",", "0", ")", ",", "dst", ",", "src", ")", ";", "if", "(", "ret", "==", "NULL", ")", "ret", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "dst", ")", ",", "dst", ",", "src", ")", ";", "return", "ret", ";", "}" ]
Return code to initialize DST with a copy constructor from SRC.
[ "Return", "code", "to", "initialize", "DST", "with", "a", "copy", "constructor", "from", "SRC", "." ]
[]
[ { "param": "clause", "type": "tree" }, { "param": "dst", "type": "tree" }, { "param": "src", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "clause", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dst", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_clause_assign_op
tree
tree cxx_omp_clause_assign_op (tree clause, tree dst, tree src) { tree info = CP_OMP_CLAUSE_INFO (clause); tree ret = NULL; if (info) ret = cxx_omp_clause_apply_fn (TREE_VEC_ELT (info, 2), dst, src); if (ret == NULL) ret = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); return ret; }
/* Similarly, except use an assignment operator instead. */
Similarly, except use an assignment operator instead.
[ "Similarly", "except", "use", "an", "assignment", "operator", "instead", "." ]
tree cxx_omp_clause_assign_op (tree clause, tree dst, tree src) { tree info = CP_OMP_CLAUSE_INFO (clause); tree ret = NULL; if (info) ret = cxx_omp_clause_apply_fn (TREE_VEC_ELT (info, 2), dst, src); if (ret == NULL) ret = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); return ret; }
[ "tree", "cxx_omp_clause_assign_op", "(", "tree", "clause", ",", "tree", "dst", ",", "tree", "src", ")", "{", "tree", "info", "=", "CP_OMP_CLAUSE_INFO", "(", "clause", ")", ";", "tree", "ret", "=", "NULL", ";", "if", "(", "info", ")", "ret", "=", "cxx_omp_clause_apply_fn", "(", "TREE_VEC_ELT", "(", "info", ",", "2", ")", ",", "dst", ",", "src", ")", ";", "if", "(", "ret", "==", "NULL", ")", "ret", "=", "build2", "(", "MODIFY_EXPR", ",", "TREE_TYPE", "(", "dst", ")", ",", "dst", ",", "src", ")", ";", "return", "ret", ";", "}" ]
Similarly, except use an assignment operator instead.
[ "Similarly", "except", "use", "an", "assignment", "operator", "instead", "." ]
[]
[ { "param": "clause", "type": "tree" }, { "param": "dst", "type": "tree" }, { "param": "src", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "clause", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dst", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "src", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_privatize_by_reference
bool
bool cxx_omp_privatize_by_reference (const_tree decl) { return is_invisiref_parm (decl); }
/* True if OpenMP should privatize what this DECL points to rather than the DECL itself. */
True if OpenMP should privatize what this DECL points to rather than the DECL itself.
[ "True", "if", "OpenMP", "should", "privatize", "what", "this", "DECL", "points", "to", "rather", "than", "the", "DECL", "itself", "." ]
bool cxx_omp_privatize_by_reference (const_tree decl) { return is_invisiref_parm (decl); }
[ "bool", "cxx_omp_privatize_by_reference", "(", "const_tree", "decl", ")", "{", "return", "is_invisiref_parm", "(", "decl", ")", ";", "}" ]
True if OpenMP should privatize what this DECL points to rather than the DECL itself.
[ "True", "if", "OpenMP", "should", "privatize", "what", "this", "DECL", "points", "to", "rather", "than", "the", "DECL", "itself", "." ]
[]
[ { "param": "decl", "type": "const_tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "decl", "type": "const_tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_const_qual_no_mutable
bool
bool cxx_omp_const_qual_no_mutable (tree decl) { tree type = TREE_TYPE (decl); if (TREE_CODE (type) == REFERENCE_TYPE) { if (!is_invisiref_parm (decl)) return false; type = TREE_TYPE (type); if (TREE_CODE (decl) == RESULT_DECL && DECL_NAME (decl)) { /* NVR doesn't preserve const qualification of the variable's type. */ tree outer = outer_curly_brace_block (current_function_decl); tree var; if (outer) for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var)) if (DECL_NAME (decl) == DECL_NAME (var) && (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (var)))) { if (TYPE_READONLY (TREE_TYPE (var))) type = TREE_TYPE (var); break; } } } if (type == error_mark_node) return false; /* Variables with const-qualified type having no mutable member are predetermined shared. */ if (TYPE_READONLY (type) && !cp_has_mutable_p (type)) return true; return false; }
/* Return true if DECL is const qualified var having no mutable member. */
Return true if DECL is const qualified var having no mutable member.
[ "Return", "true", "if", "DECL", "is", "const", "qualified", "var", "having", "no", "mutable", "member", "." ]
bool cxx_omp_const_qual_no_mutable (tree decl) { tree type = TREE_TYPE (decl); if (TREE_CODE (type) == REFERENCE_TYPE) { if (!is_invisiref_parm (decl)) return false; type = TREE_TYPE (type); if (TREE_CODE (decl) == RESULT_DECL && DECL_NAME (decl)) { tree outer = outer_curly_brace_block (current_function_decl); tree var; if (outer) for (var = BLOCK_VARS (outer); var; var = DECL_CHAIN (var)) if (DECL_NAME (decl) == DECL_NAME (var) && (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (var)))) { if (TYPE_READONLY (TREE_TYPE (var))) type = TREE_TYPE (var); break; } } } if (type == error_mark_node) return false; if (TYPE_READONLY (type) && !cp_has_mutable_p (type)) return true; return false; }
[ "bool", "cxx_omp_const_qual_no_mutable", "(", "tree", "decl", ")", "{", "tree", "type", "=", "TREE_TYPE", "(", "decl", ")", ";", "if", "(", "TREE_CODE", "(", "type", ")", "==", "REFERENCE_TYPE", ")", "{", "if", "(", "!", "is_invisiref_parm", "(", "decl", ")", ")", "return", "false", ";", "type", "=", "TREE_TYPE", "(", "type", ")", ";", "if", "(", "TREE_CODE", "(", "decl", ")", "==", "RESULT_DECL", "&&", "DECL_NAME", "(", "decl", ")", ")", "{", "tree", "outer", "=", "outer_curly_brace_block", "(", "current_function_decl", ")", ";", "tree", "var", ";", "if", "(", "outer", ")", "for", "(", "var", "=", "BLOCK_VARS", "(", "outer", ")", ";", "var", ";", "var", "=", "DECL_CHAIN", "(", "var", ")", ")", "if", "(", "DECL_NAME", "(", "decl", ")", "==", "DECL_NAME", "(", "var", ")", "&&", "(", "TYPE_MAIN_VARIANT", "(", "type", ")", "==", "TYPE_MAIN_VARIANT", "(", "TREE_TYPE", "(", "var", ")", ")", ")", ")", "{", "if", "(", "TYPE_READONLY", "(", "TREE_TYPE", "(", "var", ")", ")", ")", "type", "=", "TREE_TYPE", "(", "var", ")", ";", "break", ";", "}", "}", "}", "if", "(", "type", "==", "error_mark_node", ")", "return", "false", ";", "if", "(", "TYPE_READONLY", "(", "type", ")", "&&", "!", "cp_has_mutable_p", "(", "type", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Return true if DECL is const qualified var having no mutable member.
[ "Return", "true", "if", "DECL", "is", "const", "qualified", "var", "having", "no", "mutable", "member", "." ]
[ "/* NVR doesn't preserve const qualification of the\n\t variable's type. */", "/* Variables with const-qualified type having no mutable member\n are predetermined shared. */" ]
[ { "param": "decl", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "decl", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_predetermined_sharing
null
enum omp_clause_default_kind cxx_omp_predetermined_sharing (tree decl) { /* Static data members are predetermined shared. */ if (TREE_STATIC (decl)) { tree ctx = CP_DECL_CONTEXT (decl); if (TYPE_P (ctx) && MAYBE_CLASS_TYPE_P (ctx)) return OMP_CLAUSE_DEFAULT_SHARED; } /* Const qualified vars having no mutable member are predetermined shared. */ if (cxx_omp_const_qual_no_mutable (decl)) return OMP_CLAUSE_DEFAULT_SHARED; return OMP_CLAUSE_DEFAULT_UNSPECIFIED; }
/* True if OpenMP sharing attribute of DECL is predetermined. */
True if OpenMP sharing attribute of DECL is predetermined.
[ "True", "if", "OpenMP", "sharing", "attribute", "of", "DECL", "is", "predetermined", "." ]
enum omp_clause_default_kind cxx_omp_predetermined_sharing (tree decl) { if (TREE_STATIC (decl)) { tree ctx = CP_DECL_CONTEXT (decl); if (TYPE_P (ctx) && MAYBE_CLASS_TYPE_P (ctx)) return OMP_CLAUSE_DEFAULT_SHARED; } if (cxx_omp_const_qual_no_mutable (decl)) return OMP_CLAUSE_DEFAULT_SHARED; return OMP_CLAUSE_DEFAULT_UNSPECIFIED; }
[ "enum", "omp_clause_default_kind", "cxx_omp_predetermined_sharing", "(", "tree", "decl", ")", "{", "if", "(", "TREE_STATIC", "(", "decl", ")", ")", "{", "tree", "ctx", "=", "CP_DECL_CONTEXT", "(", "decl", ")", ";", "if", "(", "TYPE_P", "(", "ctx", ")", "&&", "MAYBE_CLASS_TYPE_P", "(", "ctx", ")", ")", "return", "OMP_CLAUSE_DEFAULT_SHARED", ";", "}", "if", "(", "cxx_omp_const_qual_no_mutable", "(", "decl", ")", ")", "return", "OMP_CLAUSE_DEFAULT_SHARED", ";", "return", "OMP_CLAUSE_DEFAULT_UNSPECIFIED", ";", "}" ]
True if OpenMP sharing attribute of DECL is predetermined.
[ "True", "if", "OpenMP", "sharing", "attribute", "of", "DECL", "is", "predetermined", "." ]
[ "/* Static data members are predetermined shared. */", "/* Const qualified vars having no mutable member are predetermined\n shared. */" ]
[ { "param": "decl", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "decl", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e06c5454c7e23613e91b57560917272a57917bf5
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/cp/cp-gimplify.c
[ "BSD-3-Clause" ]
C
cxx_omp_finish_clause
void
void cxx_omp_finish_clause (tree c) { tree decl, inner_type; bool make_shared = false; if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE) return; decl = OMP_CLAUSE_DECL (c); decl = require_complete_type (decl); inner_type = TREE_TYPE (decl); if (decl == error_mark_node) make_shared = true; else if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE) { if (is_invisiref_parm (decl)) inner_type = TREE_TYPE (inner_type); else { error ("%qE implicitly determined as %<firstprivate%> has reference type", decl); make_shared = true; } } /* We're interested in the base element, not arrays. */ while (TREE_CODE (inner_type) == ARRAY_TYPE) inner_type = TREE_TYPE (inner_type); /* Check for special function availability by building a call to one. Save the results, because later we won't be in the right context for making these queries. */ if (!make_shared && CLASS_TYPE_P (inner_type) && cxx_omp_create_clause_info (c, inner_type, false, true, false)) make_shared = true; if (make_shared) OMP_CLAUSE_CODE (c) = OMP_CLAUSE_SHARED; }
/* Finalize an implicitly determined clause. */
Finalize an implicitly determined clause.
[ "Finalize", "an", "implicitly", "determined", "clause", "." ]
void cxx_omp_finish_clause (tree c) { tree decl, inner_type; bool make_shared = false; if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_FIRSTPRIVATE) return; decl = OMP_CLAUSE_DECL (c); decl = require_complete_type (decl); inner_type = TREE_TYPE (decl); if (decl == error_mark_node) make_shared = true; else if (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE) { if (is_invisiref_parm (decl)) inner_type = TREE_TYPE (inner_type); else { error ("%qE implicitly determined as %<firstprivate%> has reference type", decl); make_shared = true; } } while (TREE_CODE (inner_type) == ARRAY_TYPE) inner_type = TREE_TYPE (inner_type); if (!make_shared && CLASS_TYPE_P (inner_type) && cxx_omp_create_clause_info (c, inner_type, false, true, false)) make_shared = true; if (make_shared) OMP_CLAUSE_CODE (c) = OMP_CLAUSE_SHARED; }
[ "void", "cxx_omp_finish_clause", "(", "tree", "c", ")", "{", "tree", "decl", ",", "inner_type", ";", "bool", "make_shared", "=", "false", ";", "if", "(", "OMP_CLAUSE_CODE", "(", "c", ")", "!=", "OMP_CLAUSE_FIRSTPRIVATE", ")", "return", ";", "decl", "=", "OMP_CLAUSE_DECL", "(", "c", ")", ";", "decl", "=", "require_complete_type", "(", "decl", ")", ";", "inner_type", "=", "TREE_TYPE", "(", "decl", ")", ";", "if", "(", "decl", "==", "error_mark_node", ")", "make_shared", "=", "true", ";", "else", "if", "(", "TREE_CODE", "(", "TREE_TYPE", "(", "decl", ")", ")", "==", "REFERENCE_TYPE", ")", "{", "if", "(", "is_invisiref_parm", "(", "decl", ")", ")", "inner_type", "=", "TREE_TYPE", "(", "inner_type", ")", ";", "else", "{", "error", "(", "\"", "\"", ",", "decl", ")", ";", "make_shared", "=", "true", ";", "}", "}", "while", "(", "TREE_CODE", "(", "inner_type", ")", "==", "ARRAY_TYPE", ")", "inner_type", "=", "TREE_TYPE", "(", "inner_type", ")", ";", "if", "(", "!", "make_shared", "&&", "CLASS_TYPE_P", "(", "inner_type", ")", "&&", "cxx_omp_create_clause_info", "(", "c", ",", "inner_type", ",", "false", ",", "true", ",", "false", ")", ")", "make_shared", "=", "true", ";", "if", "(", "make_shared", ")", "OMP_CLAUSE_CODE", "(", "c", ")", "=", "OMP_CLAUSE_SHARED", ";", "}" ]
Finalize an implicitly determined clause.
[ "Finalize", "an", "implicitly", "determined", "clause", "." ]
[ "/* We're interested in the base element, not arrays. */", "/* Check for special function availability by building a call to one.\n Save the results, because later we won't be in the right context\n for making these queries. */" ]
[ { "param": "c", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "c", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a725ea530667594f19003000718a8fe1e1c81828
atrens/DragonFlyBSD-src
sys/netbt/hci_socket.c
[ "BSD-3-Clause" ]
C
hci_security_check_opcode
int
static int hci_security_check_opcode(struct hci_unit *unit, uint16_t opcode) { int i; for (i = 0 ; i < NELEM(hci_cmds); i++) { if (opcode != hci_cmds[i].opcode) continue; if (unit == NULL || (unit->hci_cmds[hci_cmds[i].offs] & hci_cmds[i].mask)) return hci_cmds[i].length; break; } return -1; }
/* * Security filter routines for unprivileged users. * Allow all but a few critical events, and only permit read commands. * If a unit is given, verify the command is supported. */
Security filter routines for unprivileged users. Allow all but a few critical events, and only permit read commands. If a unit is given, verify the command is supported.
[ "Security", "filter", "routines", "for", "unprivileged", "users", ".", "Allow", "all", "but", "a", "few", "critical", "events", "and", "only", "permit", "read", "commands", ".", "If", "a", "unit", "is", "given", "verify", "the", "command", "is", "supported", "." ]
static int hci_security_check_opcode(struct hci_unit *unit, uint16_t opcode) { int i; for (i = 0 ; i < NELEM(hci_cmds); i++) { if (opcode != hci_cmds[i].opcode) continue; if (unit == NULL || (unit->hci_cmds[hci_cmds[i].offs] & hci_cmds[i].mask)) return hci_cmds[i].length; break; } return -1; }
[ "static", "int", "hci_security_check_opcode", "(", "struct", "hci_unit", "*", "unit", ",", "uint16_t", "opcode", ")", "{", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NELEM", "(", "hci_cmds", ")", ";", "i", "++", ")", "{", "if", "(", "opcode", "!=", "hci_cmds", "[", "i", "]", ".", "opcode", ")", "continue", ";", "if", "(", "unit", "==", "NULL", "||", "(", "unit", "->", "hci_cmds", "[", "hci_cmds", "[", "i", "]", ".", "offs", "]", "&", "hci_cmds", "[", "i", "]", ".", "mask", ")", ")", "return", "hci_cmds", "[", "i", "]", ".", "length", ";", "break", ";", "}", "return", "-1", ";", "}" ]
Security filter routines for unprivileged users.
[ "Security", "filter", "routines", "for", "unprivileged", "users", "." ]
[]
[ { "param": "unit", "type": "struct hci_unit" }, { "param": "opcode", "type": "uint16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "unit", "type": "struct hci_unit", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "uint16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a725ea530667594f19003000718a8fe1e1c81828
atrens/DragonFlyBSD-src
sys/netbt/hci_socket.c
[ "BSD-3-Clause" ]
C
hci_drop
void
void hci_drop(void *arg) { struct socket *so = arg; sbdroprecord(&so->so_snd.sb); sowwakeup(so); }
/* * When command packet reaches the device, we can drop * it from the socket buffer (called from hci_output_acl) */
When command packet reaches the device, we can drop it from the socket buffer (called from hci_output_acl)
[ "When", "command", "packet", "reaches", "the", "device", "we", "can", "drop", "it", "from", "the", "socket", "buffer", "(", "called", "from", "hci_output_acl", ")" ]
void hci_drop(void *arg) { struct socket *so = arg; sbdroprecord(&so->so_snd.sb); sowwakeup(so); }
[ "void", "hci_drop", "(", "void", "*", "arg", ")", "{", "struct", "socket", "*", "so", "=", "arg", ";", "sbdroprecord", "(", "&", "so", "->", "so_snd", ".", "sb", ")", ";", "sowwakeup", "(", "so", ")", ";", "}" ]
When command packet reaches the device, we can drop it from the socket buffer (called from hci_output_acl)
[ "When", "command", "packet", "reaches", "the", "device", "we", "can", "drop", "it", "from", "the", "socket", "buffer", "(", "called", "from", "hci_output_acl", ")" ]
[]
[ { "param": "arg", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a725ea530667594f19003000718a8fe1e1c81828
atrens/DragonFlyBSD-src
sys/netbt/hci_socket.c
[ "BSD-3-Clause" ]
C
hci_send
int
static int hci_send(struct hci_pcb *pcb, struct mbuf *m, bdaddr_t *addr) { struct hci_unit *unit; struct mbuf *m0; hci_cmd_hdr_t hdr; int err; KKASSERT(m != NULL); KKASSERT(addr != NULL); /* wants at least a header to start with */ if (m->m_pkthdr.len < sizeof(hdr)) { err = EMSGSIZE; goto bad; } m_copydata(m, 0, sizeof(hdr), (caddr_t)&hdr); hdr.opcode = letoh16(hdr.opcode); /* only allows CMD packets to be sent */ if (hdr.type != HCI_CMD_PKT) { err = EINVAL; goto bad; } /* validates packet length */ if (m->m_pkthdr.len != sizeof(hdr) + hdr.length) { err = EMSGSIZE; goto bad; } /* finds destination */ unit = hci_unit_lookup(addr); if (unit == NULL) { err = ENETDOWN; goto bad; } /* security checks for unprivileged users */ if ((pcb->hp_flags & HCI_PRIVILEGED) == 0 && hci_security_check_opcode(unit, hdr.opcode) != hdr.length) { err = EPERM; goto bad; } /* makes a copy for precious to keep */ m0 = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (m0 == NULL) { err = ENOMEM; goto bad; } sbappendrecord(&pcb->hp_socket->so_snd.sb, m0); M_SETCTX(m, pcb->hp_socket); /* enable drop callback */ DPRINTFN(2, "(%s) opcode (%03x|%04x)\n", device_get_nameunit(unit->hci_dev), HCI_OGF(hdr.opcode), HCI_OCF(hdr.opcode)); /* Sendss it */ if (unit->hci_num_cmd_pkts == 0) IF_ENQUEUE(&unit->hci_cmdwait, m); else hci_output_cmd(unit, m); return 0; bad: DPRINTF("packet (%d bytes) not sent (error %d)\n", m->m_pkthdr.len, err); if (m) m_freem(m); return err; }
/* * HCI send packet * This came from userland, so check it out. */
HCI send packet This came from userland, so check it out.
[ "HCI", "send", "packet", "This", "came", "from", "userland", "so", "check", "it", "out", "." ]
static int hci_send(struct hci_pcb *pcb, struct mbuf *m, bdaddr_t *addr) { struct hci_unit *unit; struct mbuf *m0; hci_cmd_hdr_t hdr; int err; KKASSERT(m != NULL); KKASSERT(addr != NULL); if (m->m_pkthdr.len < sizeof(hdr)) { err = EMSGSIZE; goto bad; } m_copydata(m, 0, sizeof(hdr), (caddr_t)&hdr); hdr.opcode = letoh16(hdr.opcode); if (hdr.type != HCI_CMD_PKT) { err = EINVAL; goto bad; } if (m->m_pkthdr.len != sizeof(hdr) + hdr.length) { err = EMSGSIZE; goto bad; } unit = hci_unit_lookup(addr); if (unit == NULL) { err = ENETDOWN; goto bad; } if ((pcb->hp_flags & HCI_PRIVILEGED) == 0 && hci_security_check_opcode(unit, hdr.opcode) != hdr.length) { err = EPERM; goto bad; } m0 = m_copym(m, 0, M_COPYALL, M_NOWAIT); if (m0 == NULL) { err = ENOMEM; goto bad; } sbappendrecord(&pcb->hp_socket->so_snd.sb, m0); M_SETCTX(m, pcb->hp_socket); DPRINTFN(2, "(%s) opcode (%03x|%04x)\n", device_get_nameunit(unit->hci_dev), HCI_OGF(hdr.opcode), HCI_OCF(hdr.opcode)); if (unit->hci_num_cmd_pkts == 0) IF_ENQUEUE(&unit->hci_cmdwait, m); else hci_output_cmd(unit, m); return 0; bad: DPRINTF("packet (%d bytes) not sent (error %d)\n", m->m_pkthdr.len, err); if (m) m_freem(m); return err; }
[ "static", "int", "hci_send", "(", "struct", "hci_pcb", "*", "pcb", ",", "struct", "mbuf", "*", "m", ",", "bdaddr_t", "*", "addr", ")", "{", "struct", "hci_unit", "*", "unit", ";", "struct", "mbuf", "*", "m0", ";", "hci_cmd_hdr_t", "hdr", ";", "int", "err", ";", "KKASSERT", "(", "m", "!=", "NULL", ")", ";", "KKASSERT", "(", "addr", "!=", "NULL", ")", ";", "if", "(", "m", "->", "m_pkthdr", ".", "len", "<", "sizeof", "(", "hdr", ")", ")", "{", "err", "=", "EMSGSIZE", ";", "goto", "bad", ";", "}", "m_copydata", "(", "m", ",", "0", ",", "sizeof", "(", "hdr", ")", ",", "(", "caddr_t", ")", "&", "hdr", ")", ";", "hdr", ".", "opcode", "=", "letoh16", "(", "hdr", ".", "opcode", ")", ";", "if", "(", "hdr", ".", "type", "!=", "HCI_CMD_PKT", ")", "{", "err", "=", "EINVAL", ";", "goto", "bad", ";", "}", "if", "(", "m", "->", "m_pkthdr", ".", "len", "!=", "sizeof", "(", "hdr", ")", "+", "hdr", ".", "length", ")", "{", "err", "=", "EMSGSIZE", ";", "goto", "bad", ";", "}", "unit", "=", "hci_unit_lookup", "(", "addr", ")", ";", "if", "(", "unit", "==", "NULL", ")", "{", "err", "=", "ENETDOWN", ";", "goto", "bad", ";", "}", "if", "(", "(", "pcb", "->", "hp_flags", "&", "HCI_PRIVILEGED", ")", "==", "0", "&&", "hci_security_check_opcode", "(", "unit", ",", "hdr", ".", "opcode", ")", "!=", "hdr", ".", "length", ")", "{", "err", "=", "EPERM", ";", "goto", "bad", ";", "}", "m0", "=", "m_copym", "(", "m", ",", "0", ",", "M_COPYALL", ",", "M_NOWAIT", ")", ";", "if", "(", "m0", "==", "NULL", ")", "{", "err", "=", "ENOMEM", ";", "goto", "bad", ";", "}", "sbappendrecord", "(", "&", "pcb", "->", "hp_socket", "->", "so_snd", ".", "sb", ",", "m0", ")", ";", "M_SETCTX", "(", "m", ",", "pcb", "->", "hp_socket", ")", ";", "DPRINTFN", "(", "2", ",", "\"", "\\n", "\"", ",", "device_get_nameunit", "(", "unit", "->", "hci_dev", ")", ",", "HCI_OGF", "(", "hdr", ".", "opcode", ")", ",", "HCI_OCF", "(", "hdr", ".", "opcode", ")", ")", ";", "if", "(", "unit", "->", "hci_num_cmd_pkts", "==", "0", ")", "IF_ENQUEUE", "(", "&", "unit", "->", "hci_cmdwait", ",", "m", ")", ";", "else", "hci_output_cmd", "(", "unit", ",", "m", ")", ";", "return", "0", ";", "bad", ":", "DPRINTF", "(", "\"", "\\n", "\"", ",", "m", "->", "m_pkthdr", ".", "len", ",", "err", ")", ";", "if", "(", "m", ")", "m_freem", "(", "m", ")", ";", "return", "err", ";", "}" ]
HCI send packet This came from userland, so check it out.
[ "HCI", "send", "packet", "This", "came", "from", "userland", "so", "check", "it", "out", "." ]
[ "/* wants at least a header to start with */", "/* only allows CMD packets to be sent */", "/* validates packet length */", "/* finds destination */", "/* security checks for unprivileged users */", "/* makes a copy for precious to keep */", "/* enable drop callback */", "/* Sendss it */" ]
[ { "param": "pcb", "type": "struct hci_pcb" }, { "param": "m", "type": "struct mbuf" }, { "param": "addr", "type": "bdaddr_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pcb", "type": "struct hci_pcb", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "struct mbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "addr", "type": "bdaddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a7296c0513ec10b24c9473b9d8b880c95e45fee2
atrens/DragonFlyBSD-src
sys/netinet6/raw_ip6.c
[ "BSD-3-Clause" ]
C
rip6_ctloutput
void
void rip6_ctloutput(netmsg_t msg) { struct socket *so = msg->ctloutput.base.nm_so; struct sockopt *sopt = msg->ctloutput.nm_sopt; int error; if (sopt->sopt_level == IPPROTO_ICMPV6) { /* * XXX: is it better to call icmp6_ctloutput() directly * from protosw? */ icmp6_ctloutput(msg); /* msg invalid now */ return; } if (sopt->sopt_level != IPPROTO_IPV6) { error = EINVAL; goto out; } error = 0; switch (sopt->sopt_dir) { case SOPT_GET: switch (sopt->sopt_name) { case MRT6_INIT: case MRT6_DONE: case MRT6_ADD_MIF: case MRT6_DEL_MIF: case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: error = ip6_mrouter_get(so, sopt); break; case IPV6_CHECKSUM: error = ip6_raw_ctloutput(so, sopt); break; default: error = ip6_ctloutput(so, sopt); break; } break; case SOPT_SET: switch (sopt->sopt_name) { case MRT6_INIT: case MRT6_DONE: case MRT6_ADD_MIF: case MRT6_DEL_MIF: case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: error = ip6_mrouter_set(so, sopt); break; case IPV6_CHECKSUM: error = ip6_raw_ctloutput(so, sopt); break; default: error = ip6_ctloutput(so, sopt); break; } break; } out: lwkt_replymsg(&msg->ctloutput.base.lmsg, error); }
/* * Raw IPv6 socket option processing. */
Raw IPv6 socket option processing.
[ "Raw", "IPv6", "socket", "option", "processing", "." ]
void rip6_ctloutput(netmsg_t msg) { struct socket *so = msg->ctloutput.base.nm_so; struct sockopt *sopt = msg->ctloutput.nm_sopt; int error; if (sopt->sopt_level == IPPROTO_ICMPV6) { icmp6_ctloutput(msg); return; } if (sopt->sopt_level != IPPROTO_IPV6) { error = EINVAL; goto out; } error = 0; switch (sopt->sopt_dir) { case SOPT_GET: switch (sopt->sopt_name) { case MRT6_INIT: case MRT6_DONE: case MRT6_ADD_MIF: case MRT6_DEL_MIF: case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: error = ip6_mrouter_get(so, sopt); break; case IPV6_CHECKSUM: error = ip6_raw_ctloutput(so, sopt); break; default: error = ip6_ctloutput(so, sopt); break; } break; case SOPT_SET: switch (sopt->sopt_name) { case MRT6_INIT: case MRT6_DONE: case MRT6_ADD_MIF: case MRT6_DEL_MIF: case MRT6_ADD_MFC: case MRT6_DEL_MFC: case MRT6_PIM: error = ip6_mrouter_set(so, sopt); break; case IPV6_CHECKSUM: error = ip6_raw_ctloutput(so, sopt); break; default: error = ip6_ctloutput(so, sopt); break; } break; } out: lwkt_replymsg(&msg->ctloutput.base.lmsg, error); }
[ "void", "rip6_ctloutput", "(", "netmsg_t", "msg", ")", "{", "struct", "socket", "*", "so", "=", "msg", "->", "ctloutput", ".", "base", ".", "nm_so", ";", "struct", "sockopt", "*", "sopt", "=", "msg", "->", "ctloutput", ".", "nm_sopt", ";", "int", "error", ";", "if", "(", "sopt", "->", "sopt_level", "==", "IPPROTO_ICMPV6", ")", "{", "icmp6_ctloutput", "(", "msg", ")", ";", "return", ";", "}", "if", "(", "sopt", "->", "sopt_level", "!=", "IPPROTO_IPV6", ")", "{", "error", "=", "EINVAL", ";", "goto", "out", ";", "}", "error", "=", "0", ";", "switch", "(", "sopt", "->", "sopt_dir", ")", "{", "case", "SOPT_GET", ":", "switch", "(", "sopt", "->", "sopt_name", ")", "{", "case", "MRT6_INIT", ":", "case", "MRT6_DONE", ":", "case", "MRT6_ADD_MIF", ":", "case", "MRT6_DEL_MIF", ":", "case", "MRT6_ADD_MFC", ":", "case", "MRT6_DEL_MFC", ":", "case", "MRT6_PIM", ":", "error", "=", "ip6_mrouter_get", "(", "so", ",", "sopt", ")", ";", "break", ";", "case", "IPV6_CHECKSUM", ":", "error", "=", "ip6_raw_ctloutput", "(", "so", ",", "sopt", ")", ";", "break", ";", "default", ":", "error", "=", "ip6_ctloutput", "(", "so", ",", "sopt", ")", ";", "break", ";", "}", "break", ";", "case", "SOPT_SET", ":", "switch", "(", "sopt", "->", "sopt_name", ")", "{", "case", "MRT6_INIT", ":", "case", "MRT6_DONE", ":", "case", "MRT6_ADD_MIF", ":", "case", "MRT6_DEL_MIF", ":", "case", "MRT6_ADD_MFC", ":", "case", "MRT6_DEL_MFC", ":", "case", "MRT6_PIM", ":", "error", "=", "ip6_mrouter_set", "(", "so", ",", "sopt", ")", ";", "break", ";", "case", "IPV6_CHECKSUM", ":", "error", "=", "ip6_raw_ctloutput", "(", "so", ",", "sopt", ")", ";", "break", ";", "default", ":", "error", "=", "ip6_ctloutput", "(", "so", ",", "sopt", ")", ";", "break", ";", "}", "break", ";", "}", "out", ":", "lwkt_replymsg", "(", "&", "msg", "->", "ctloutput", ".", "base", ".", "lmsg", ",", "error", ")", ";", "}" ]
Raw IPv6 socket option processing.
[ "Raw", "IPv6", "socket", "option", "processing", "." ]
[ "/*\n\t\t * XXX: is it better to call icmp6_ctloutput() directly\n\t\t * from protosw?\n\t\t */", "/* msg invalid now */" ]
[ { "param": "msg", "type": "netmsg_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "msg", "type": "netmsg_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1e023fcdf25d1d46b80f46c61f8432ce0c4d9179
atrens/DragonFlyBSD-src
sys/netgraph7/cisco/ng_cisco.c
[ "BSD-3-Clause" ]
C
cisco_disconnect
int
static int cisco_disconnect(hook_p hook) { const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct protoent *pep; /* Check it's not the debug hook */ if ((pep = NG_HOOK_PRIVATE(hook))) { pep->hook = NULL; if (pep->af == 0xffff) /* If it is the downstream hook, stop the timers */ ng_uncallout(&sc->handle, NG_HOOK_NODE(hook)); } /* If no more hooks, remove the node */ if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) ng_rmnode_self(NG_HOOK_NODE(hook)); return (0); }
/* * Disconnection of a hook * * For this type, removal of the last link destroys the node */
Disconnection of a hook For this type, removal of the last link destroys the node
[ "Disconnection", "of", "a", "hook", "For", "this", "type", "removal", "of", "the", "last", "link", "destroys", "the", "node" ]
static int cisco_disconnect(hook_p hook) { const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); struct protoent *pep; if ((pep = NG_HOOK_PRIVATE(hook))) { pep->hook = NULL; if (pep->af == 0xffff) ng_uncallout(&sc->handle, NG_HOOK_NODE(hook)); } if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0) && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook)))) ng_rmnode_self(NG_HOOK_NODE(hook)); return (0); }
[ "static", "int", "cisco_disconnect", "(", "hook_p", "hook", ")", "{", "const", "sc_p", "sc", "=", "NG_NODE_PRIVATE", "(", "NG_HOOK_NODE", "(", "hook", ")", ")", ";", "struct", "protoent", "*", "pep", ";", "if", "(", "(", "pep", "=", "NG_HOOK_PRIVATE", "(", "hook", ")", ")", ")", "{", "pep", "->", "hook", "=", "NULL", ";", "if", "(", "pep", "->", "af", "==", "0xffff", ")", "ng_uncallout", "(", "&", "sc", "->", "handle", ",", "NG_HOOK_NODE", "(", "hook", ")", ")", ";", "}", "if", "(", "(", "NG_NODE_NUMHOOKS", "(", "NG_HOOK_NODE", "(", "hook", ")", ")", "==", "0", ")", "&&", "(", "NG_NODE_IS_VALID", "(", "NG_HOOK_NODE", "(", "hook", ")", ")", ")", ")", "ng_rmnode_self", "(", "NG_HOOK_NODE", "(", "hook", ")", ")", ";", "return", "(", "0", ")", ";", "}" ]
Disconnection of a hook For this type, removal of the last link destroys the node
[ "Disconnection", "of", "a", "hook", "For", "this", "type", "removal", "of", "the", "last", "link", "destroys", "the", "node" ]
[ "/* Check it's not the debug hook */", "/* If it is the downstream hook, stop the timers */", "/* If no more hooks, remove the node */" ]
[ { "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": [] }
1e023fcdf25d1d46b80f46c61f8432ce0c4d9179
atrens/DragonFlyBSD-src
sys/netgraph7/cisco/ng_cisco.c
[ "BSD-3-Clause" ]
C
cisco_keepalive
void
static void cisco_keepalive(node_p node, hook_p hook, void *arg1, int arg2) { const sc_p sc = arg1; cisco_send(sc, CISCO_KEEPALIVE_REQ, sc->local_seq, sc->remote_seq); if (sc->seqRetries++ > 1) cisco_notify(sc, NGM_LINK_IS_DOWN); ng_callout(&sc->handle, node, NULL, (hz * KEEPALIVE_SECS), &cisco_keepalive, (void *)sc, 0); }
/* * Send keepalive packets, every 10 seconds. */
Send keepalive packets, every 10 seconds.
[ "Send", "keepalive", "packets", "every", "10", "seconds", "." ]
static void cisco_keepalive(node_p node, hook_p hook, void *arg1, int arg2) { const sc_p sc = arg1; cisco_send(sc, CISCO_KEEPALIVE_REQ, sc->local_seq, sc->remote_seq); if (sc->seqRetries++ > 1) cisco_notify(sc, NGM_LINK_IS_DOWN); ng_callout(&sc->handle, node, NULL, (hz * KEEPALIVE_SECS), &cisco_keepalive, (void *)sc, 0); }
[ "static", "void", "cisco_keepalive", "(", "node_p", "node", ",", "hook_p", "hook", ",", "void", "*", "arg1", ",", "int", "arg2", ")", "{", "const", "sc_p", "sc", "=", "arg1", ";", "cisco_send", "(", "sc", ",", "CISCO_KEEPALIVE_REQ", ",", "sc", "->", "local_seq", ",", "sc", "->", "remote_seq", ")", ";", "if", "(", "sc", "->", "seqRetries", "++", ">", "1", ")", "cisco_notify", "(", "sc", ",", "NGM_LINK_IS_DOWN", ")", ";", "ng_callout", "(", "&", "sc", "->", "handle", ",", "node", ",", "NULL", ",", "(", "hz", "*", "KEEPALIVE_SECS", ")", ",", "&", "cisco_keepalive", ",", "(", "void", "*", ")", "sc", ",", "0", ")", ";", "}" ]
Send keepalive packets, every 10 seconds.
[ "Send", "keepalive", "packets", "every", "10", "seconds", "." ]
[]
[ { "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": [] }
1e023fcdf25d1d46b80f46c61f8432ce0c4d9179
atrens/DragonFlyBSD-src
sys/netgraph7/cisco/ng_cisco.c
[ "BSD-3-Clause" ]
C
cisco_notify
void
static void cisco_notify(sc_p sc, uint32_t cmd) { struct ng_mesg *msg; int dummy_error = 0; if (sc->inet.hook == NULL) /* nothing to notify */ return; NG_MKMESSAGE(msg, NGM_FLOW_COOKIE, cmd, 0, M_WAITOK | M_NULLOK); if (msg != NULL) NG_SEND_MSG_HOOK(dummy_error, sc->node, msg, sc->inet.hook, 0); }
/* * Send linkstate to upstream node. */
Send linkstate to upstream node.
[ "Send", "linkstate", "to", "upstream", "node", "." ]
static void cisco_notify(sc_p sc, uint32_t cmd) { struct ng_mesg *msg; int dummy_error = 0; if (sc->inet.hook == NULL) return; NG_MKMESSAGE(msg, NGM_FLOW_COOKIE, cmd, 0, M_WAITOK | M_NULLOK); if (msg != NULL) NG_SEND_MSG_HOOK(dummy_error, sc->node, msg, sc->inet.hook, 0); }
[ "static", "void", "cisco_notify", "(", "sc_p", "sc", ",", "uint32_t", "cmd", ")", "{", "struct", "ng_mesg", "*", "msg", ";", "int", "dummy_error", "=", "0", ";", "if", "(", "sc", "->", "inet", ".", "hook", "==", "NULL", ")", "return", ";", "NG_MKMESSAGE", "(", "msg", ",", "NGM_FLOW_COOKIE", ",", "cmd", ",", "0", ",", "M_WAITOK", "|", "M_NULLOK", ")", ";", "if", "(", "msg", "!=", "NULL", ")", "NG_SEND_MSG_HOOK", "(", "dummy_error", ",", "sc", "->", "node", ",", "msg", ",", "sc", "->", "inet", ".", "hook", ",", "0", ")", ";", "}" ]
Send linkstate to upstream node.
[ "Send", "linkstate", "to", "upstream", "node", "." ]
[ "/* nothing to notify */" ]
[ { "param": "sc", "type": "sc_p" }, { "param": "cmd", "type": "uint32_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sc", "type": "sc_p", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmd", "type": "uint32_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_cleanup
void
void ieee80211_ageq_cleanup(struct ieee80211_ageq *aq) { KASSERT(aq->aq_len == 0, ("%d frames on ageq", aq->aq_len)); IEEE80211_AGEQ_DESTROY(aq); /* OS-dependent cleanup */ }
/* * Cleanup an ageq initialized with ieee80211_ageq_init. Note * the queue is assumed empty; this can be done with ieee80211_ageq_drain. */
Cleanup an ageq initialized with ieee80211_ageq_init. Note the queue is assumed empty; this can be done with ieee80211_ageq_drain.
[ "Cleanup", "an", "ageq", "initialized", "with", "ieee80211_ageq_init", ".", "Note", "the", "queue", "is", "assumed", "empty", ";", "this", "can", "be", "done", "with", "ieee80211_ageq_drain", "." ]
void ieee80211_ageq_cleanup(struct ieee80211_ageq *aq) { KASSERT(aq->aq_len == 0, ("%d frames on ageq", aq->aq_len)); IEEE80211_AGEQ_DESTROY(aq); }
[ "void", "ieee80211_ageq_cleanup", "(", "struct", "ieee80211_ageq", "*", "aq", ")", "{", "KASSERT", "(", "aq", "->", "aq_len", "==", "0", ",", "(", "\"", "\"", ",", "aq", "->", "aq_len", ")", ")", ";", "IEEE80211_AGEQ_DESTROY", "(", "aq", ")", ";", "}" ]
Cleanup an ageq initialized with ieee80211_ageq_init.
[ "Cleanup", "an", "ageq", "initialized", "with", "ieee80211_ageq_init", "." ]
[ "/* OS-dependent cleanup */" ]
[ { "param": "aq", "type": "struct ieee80211_ageq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aq", "type": "struct ieee80211_ageq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ageq_mfree
void
static void ageq_mfree(struct mbuf *m) { if (m->m_flags & M_ENCAP) { struct ieee80211_node *ni = (void *) m->m_pkthdr.rcvif; ieee80211_free_node(ni); } m->m_nextpkt = NULL; m_freem(m); }
/* * Free an mbuf according to ageq rules: if marked as holding * and 802.11 frame then also reclaim a node reference from * the packet header; this handles packets q'd in the tx path. */
Free an mbuf according to ageq rules: if marked as holding and 802.11 frame then also reclaim a node reference from the packet header; this handles packets q'd in the tx path.
[ "Free", "an", "mbuf", "according", "to", "ageq", "rules", ":", "if", "marked", "as", "holding", "and", "802", ".", "11", "frame", "then", "also", "reclaim", "a", "node", "reference", "from", "the", "packet", "header", ";", "this", "handles", "packets", "q", "'", "d", "in", "the", "tx", "path", "." ]
static void ageq_mfree(struct mbuf *m) { if (m->m_flags & M_ENCAP) { struct ieee80211_node *ni = (void *) m->m_pkthdr.rcvif; ieee80211_free_node(ni); } m->m_nextpkt = NULL; m_freem(m); }
[ "static", "void", "ageq_mfree", "(", "struct", "mbuf", "*", "m", ")", "{", "if", "(", "m", "->", "m_flags", "&", "M_ENCAP", ")", "{", "struct", "ieee80211_node", "*", "ni", "=", "(", "void", "*", ")", "m", "->", "m_pkthdr", ".", "rcvif", ";", "ieee80211_free_node", "(", "ni", ")", ";", "}", "m", "->", "m_nextpkt", "=", "NULL", ";", "m_freem", "(", "m", ")", ";", "}" ]
Free an mbuf according to ageq rules: if marked as holding and 802.11 frame then also reclaim a node reference from the packet header; this handles packets q'd in the tx path.
[ "Free", "an", "mbuf", "according", "to", "ageq", "rules", ":", "if", "marked", "as", "holding", "and", "802", ".", "11", "frame", "then", "also", "reclaim", "a", "node", "reference", "from", "the", "packet", "header", ";", "this", "handles", "packets", "q", "'", "d", "in", "the", "tx", "path", "." ]
[]
[ { "param": "m", "type": "struct mbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "struct mbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_mfree
void
void ieee80211_ageq_mfree(struct mbuf *m) { struct mbuf *next; for (; m != NULL; m = next) { next = m->m_nextpkt; ageq_mfree(m); } }
/* * Free a list of mbufs using ageq rules (see above). */
Free a list of mbufs using ageq rules .
[ "Free", "a", "list", "of", "mbufs", "using", "ageq", "rules", "." ]
void ieee80211_ageq_mfree(struct mbuf *m) { struct mbuf *next; for (; m != NULL; m = next) { next = m->m_nextpkt; ageq_mfree(m); } }
[ "void", "ieee80211_ageq_mfree", "(", "struct", "mbuf", "*", "m", ")", "{", "struct", "mbuf", "*", "next", ";", "for", "(", ";", "m", "!=", "NULL", ";", "m", "=", "next", ")", "{", "next", "=", "m", "->", "m_nextpkt", ";", "ageq_mfree", "(", "m", ")", ";", "}", "}" ]
Free a list of mbufs using ageq rules (see above).
[ "Free", "a", "list", "of", "mbufs", "using", "ageq", "rules", "(", "see", "above", ")", "." ]
[]
[ { "param": "m", "type": "struct mbuf" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": "struct mbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_append
int
int ieee80211_ageq_append(struct ieee80211_ageq *aq, struct mbuf *m, int age) { IEEE80211_AGEQ_LOCK(aq); if (__predict_true(aq->aq_len < aq->aq_maxlen)) { if (aq->aq_tail == NULL) { aq->aq_head = m; } else { aq->aq_tail->m_nextpkt = m; age -= M_AGE_GET(aq->aq_head); } KASSERT(age >= 0, ("age %d", age)); M_AGE_SET(m, age); m->m_nextpkt = NULL; aq->aq_tail = m; aq->aq_len++; IEEE80211_AGEQ_UNLOCK(aq); return 0; } else { /* * No space, drop and cleanup references. */ aq->aq_drops++; IEEE80211_AGEQ_UNLOCK(aq); /* XXX tail drop? */ ageq_mfree(m); return ENOSPC; } }
/* * Append an mbuf to the ageq and mark it with the specified max age * If the frame is not removed before the age (in seconds) expires * then it is reclaimed (along with any node reference). */
Append an mbuf to the ageq and mark it with the specified max age If the frame is not removed before the age (in seconds) expires then it is reclaimed (along with any node reference).
[ "Append", "an", "mbuf", "to", "the", "ageq", "and", "mark", "it", "with", "the", "specified", "max", "age", "If", "the", "frame", "is", "not", "removed", "before", "the", "age", "(", "in", "seconds", ")", "expires", "then", "it", "is", "reclaimed", "(", "along", "with", "any", "node", "reference", ")", "." ]
int ieee80211_ageq_append(struct ieee80211_ageq *aq, struct mbuf *m, int age) { IEEE80211_AGEQ_LOCK(aq); if (__predict_true(aq->aq_len < aq->aq_maxlen)) { if (aq->aq_tail == NULL) { aq->aq_head = m; } else { aq->aq_tail->m_nextpkt = m; age -= M_AGE_GET(aq->aq_head); } KASSERT(age >= 0, ("age %d", age)); M_AGE_SET(m, age); m->m_nextpkt = NULL; aq->aq_tail = m; aq->aq_len++; IEEE80211_AGEQ_UNLOCK(aq); return 0; } else { aq->aq_drops++; IEEE80211_AGEQ_UNLOCK(aq); ageq_mfree(m); return ENOSPC; } }
[ "int", "ieee80211_ageq_append", "(", "struct", "ieee80211_ageq", "*", "aq", ",", "struct", "mbuf", "*", "m", ",", "int", "age", ")", "{", "IEEE80211_AGEQ_LOCK", "(", "aq", ")", ";", "if", "(", "__predict_true", "(", "aq", "->", "aq_len", "<", "aq", "->", "aq_maxlen", ")", ")", "{", "if", "(", "aq", "->", "aq_tail", "==", "NULL", ")", "{", "aq", "->", "aq_head", "=", "m", ";", "}", "else", "{", "aq", "->", "aq_tail", "->", "m_nextpkt", "=", "m", ";", "age", "-=", "M_AGE_GET", "(", "aq", "->", "aq_head", ")", ";", "}", "KASSERT", "(", "age", ">=", "0", ",", "(", "\"", "\"", ",", "age", ")", ")", ";", "M_AGE_SET", "(", "m", ",", "age", ")", ";", "m", "->", "m_nextpkt", "=", "NULL", ";", "aq", "->", "aq_tail", "=", "m", ";", "aq", "->", "aq_len", "++", ";", "IEEE80211_AGEQ_UNLOCK", "(", "aq", ")", ";", "return", "0", ";", "}", "else", "{", "aq", "->", "aq_drops", "++", ";", "IEEE80211_AGEQ_UNLOCK", "(", "aq", ")", ";", "ageq_mfree", "(", "m", ")", ";", "return", "ENOSPC", ";", "}", "}" ]
Append an mbuf to the ageq and mark it with the specified max age If the frame is not removed before the age (in seconds) expires then it is reclaimed (along with any node reference).
[ "Append", "an", "mbuf", "to", "the", "ageq", "and", "mark", "it", "with", "the", "specified", "max", "age", "If", "the", "frame", "is", "not", "removed", "before", "the", "age", "(", "in", "seconds", ")", "expires", "then", "it", "is", "reclaimed", "(", "along", "with", "any", "node", "reference", ")", "." ]
[ "/*\n\t\t * No space, drop and cleanup references.\n\t\t */", "/* XXX tail drop? */" ]
[ { "param": "aq", "type": "struct ieee80211_ageq" }, { "param": "m", "type": "struct mbuf" }, { "param": "age", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aq", "type": "struct ieee80211_ageq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "m", "type": "struct mbuf", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "age", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_drain
void
void ieee80211_ageq_drain(struct ieee80211_ageq *aq) { ieee80211_ageq_mfree(ieee80211_ageq_remove(aq, NULL)); }
/* * Drain/reclaim all frames from an ageq. */
Drain/reclaim all frames from an ageq.
[ "Drain", "/", "reclaim", "all", "frames", "from", "an", "ageq", "." ]
void ieee80211_ageq_drain(struct ieee80211_ageq *aq) { ieee80211_ageq_mfree(ieee80211_ageq_remove(aq, NULL)); }
[ "void", "ieee80211_ageq_drain", "(", "struct", "ieee80211_ageq", "*", "aq", ")", "{", "ieee80211_ageq_mfree", "(", "ieee80211_ageq_remove", "(", "aq", ",", "NULL", ")", ")", ";", "}" ]
Drain/reclaim all frames from an ageq.
[ "Drain", "/", "reclaim", "all", "frames", "from", "an", "ageq", "." ]
[]
[ { "param": "aq", "type": "struct ieee80211_ageq" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aq", "type": "struct ieee80211_ageq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_drain_node
void
void ieee80211_ageq_drain_node(struct ieee80211_ageq *aq, struct ieee80211_node *ni) { ieee80211_ageq_mfree(ieee80211_ageq_remove(aq, ni)); }
/* * Drain/reclaim frames associated with a specific node from an ageq. */
Drain/reclaim frames associated with a specific node from an ageq.
[ "Drain", "/", "reclaim", "frames", "associated", "with", "a", "specific", "node", "from", "an", "ageq", "." ]
void ieee80211_ageq_drain_node(struct ieee80211_ageq *aq, struct ieee80211_node *ni) { ieee80211_ageq_mfree(ieee80211_ageq_remove(aq, ni)); }
[ "void", "ieee80211_ageq_drain_node", "(", "struct", "ieee80211_ageq", "*", "aq", ",", "struct", "ieee80211_node", "*", "ni", ")", "{", "ieee80211_ageq_mfree", "(", "ieee80211_ageq_remove", "(", "aq", ",", "ni", ")", ")", ";", "}" ]
Drain/reclaim frames associated with a specific node from an ageq.
[ "Drain", "/", "reclaim", "frames", "associated", "with", "a", "specific", "node", "from", "an", "ageq", "." ]
[]
[ { "param": "aq", "type": "struct ieee80211_ageq" }, { "param": "ni", "type": "struct ieee80211_node" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aq", "type": "struct ieee80211_ageq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ni", "type": "struct ieee80211_node", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e0cd0c38552022eaa5b1bf56db513154cffd2d1c
atrens/DragonFlyBSD-src
sys/netproto/802_11/wlan/ieee80211_ageq.c
[ "BSD-3-Clause" ]
C
ieee80211_ageq_age
null
struct mbuf * ieee80211_ageq_age(struct ieee80211_ageq *aq, int quanta) { struct mbuf *head, **phead; struct mbuf *m; phead = &head; if (aq->aq_len != 0) { IEEE80211_AGEQ_LOCK(aq); while ((m = aq->aq_head) != NULL && M_AGE_GET(m) < quanta) { if ((aq->aq_head = m->m_nextpkt) == NULL) aq->aq_tail = NULL; KASSERT(aq->aq_len > 0, ("aq len %d", aq->aq_len)); aq->aq_len--; /* add to private list for return */ *phead = m; phead = &m->m_nextpkt; } if (m != NULL) M_AGE_SUB(m, quanta); IEEE80211_AGEQ_UNLOCK(aq); } *phead = NULL; return head; }
/* * Age frames on the age queue. Ages are stored as time * deltas (in seconds) relative to the head so we can check * and/or adjust only the head of the list. If a frame's age * exceeds the time quanta then remove it. The list of removed * frames is returned to the caller joined by m_nextpkt. */
Age frames on the age queue. Ages are stored as time deltas (in seconds) relative to the head so we can check and/or adjust only the head of the list. If a frame's age exceeds the time quanta then remove it. The list of removed frames is returned to the caller joined by m_nextpkt.
[ "Age", "frames", "on", "the", "age", "queue", ".", "Ages", "are", "stored", "as", "time", "deltas", "(", "in", "seconds", ")", "relative", "to", "the", "head", "so", "we", "can", "check", "and", "/", "or", "adjust", "only", "the", "head", "of", "the", "list", ".", "If", "a", "frame", "'", "s", "age", "exceeds", "the", "time", "quanta", "then", "remove", "it", ".", "The", "list", "of", "removed", "frames", "is", "returned", "to", "the", "caller", "joined", "by", "m_nextpkt", "." ]
struct mbuf * ieee80211_ageq_age(struct ieee80211_ageq *aq, int quanta) { struct mbuf *head, **phead; struct mbuf *m; phead = &head; if (aq->aq_len != 0) { IEEE80211_AGEQ_LOCK(aq); while ((m = aq->aq_head) != NULL && M_AGE_GET(m) < quanta) { if ((aq->aq_head = m->m_nextpkt) == NULL) aq->aq_tail = NULL; KASSERT(aq->aq_len > 0, ("aq len %d", aq->aq_len)); aq->aq_len--; *phead = m; phead = &m->m_nextpkt; } if (m != NULL) M_AGE_SUB(m, quanta); IEEE80211_AGEQ_UNLOCK(aq); } *phead = NULL; return head; }
[ "struct", "mbuf", "*", "ieee80211_ageq_age", "(", "struct", "ieee80211_ageq", "*", "aq", ",", "int", "quanta", ")", "{", "struct", "mbuf", "*", "head", ",", "*", "*", "phead", ";", "struct", "mbuf", "*", "m", ";", "phead", "=", "&", "head", ";", "if", "(", "aq", "->", "aq_len", "!=", "0", ")", "{", "IEEE80211_AGEQ_LOCK", "(", "aq", ")", ";", "while", "(", "(", "m", "=", "aq", "->", "aq_head", ")", "!=", "NULL", "&&", "M_AGE_GET", "(", "m", ")", "<", "quanta", ")", "{", "if", "(", "(", "aq", "->", "aq_head", "=", "m", "->", "m_nextpkt", ")", "==", "NULL", ")", "aq", "->", "aq_tail", "=", "NULL", ";", "KASSERT", "(", "aq", "->", "aq_len", ">", "0", ",", "(", "\"", "\"", ",", "aq", "->", "aq_len", ")", ")", ";", "aq", "->", "aq_len", "--", ";", "*", "phead", "=", "m", ";", "phead", "=", "&", "m", "->", "m_nextpkt", ";", "}", "if", "(", "m", "!=", "NULL", ")", "M_AGE_SUB", "(", "m", ",", "quanta", ")", ";", "IEEE80211_AGEQ_UNLOCK", "(", "aq", ")", ";", "}", "*", "phead", "=", "NULL", ";", "return", "head", ";", "}" ]
Age frames on the age queue.
[ "Age", "frames", "on", "the", "age", "queue", "." ]
[ "/* add to private list for return */" ]
[ { "param": "aq", "type": "struct ieee80211_ageq" }, { "param": "quanta", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "aq", "type": "struct ieee80211_ageq", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "quanta", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f22a872c9b68f7feaa267b9a108687293a3277b4
atrens/DragonFlyBSD-src
sys/netgraph7/netgraph/ng_parse.c
[ "BSD-3-Clause" ]
C
ng_parse
int
int ng_parse(const struct ng_parse_type *type, const char *string, int *off, u_char *buf, int *buflen) { return INVOKE(type, parse)(type, string, off, buf, buf, buflen); }
/* * Convert an ASCII string to binary according to the supplied type descriptor */
Convert an ASCII string to binary according to the supplied type descriptor
[ "Convert", "an", "ASCII", "string", "to", "binary", "according", "to", "the", "supplied", "type", "descriptor" ]
int ng_parse(const struct ng_parse_type *type, const char *string, int *off, u_char *buf, int *buflen) { return INVOKE(type, parse)(type, string, off, buf, buf, buflen); }
[ "int", "ng_parse", "(", "const", "struct", "ng_parse_type", "*", "type", ",", "const", "char", "*", "string", ",", "int", "*", "off", ",", "u_char", "*", "buf", ",", "int", "*", "buflen", ")", "{", "return", "INVOKE", "(", "type", ",", "parse", ")", "(", "type", ",", "string", ",", "off", ",", "buf", ",", "buf", ",", "buflen", ")", ";", "}" ]
Convert an ASCII string to binary according to the supplied type descriptor
[ "Convert", "an", "ASCII", "string", "to", "binary", "according", "to", "the", "supplied", "type", "descriptor" ]
[]
[ { "param": "type", "type": "struct ng_parse_type" }, { "param": "string", "type": "char" }, { "param": "off", "type": "int" }, { "param": "buf", "type": "u_char" }, { "param": "buflen", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "struct ng_parse_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "string", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "off", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buflen", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f22a872c9b68f7feaa267b9a108687293a3277b4
atrens/DragonFlyBSD-src
sys/netgraph7/netgraph/ng_parse.c
[ "BSD-3-Clause" ]
C
ng_parse_getDefault
int
int ng_parse_getDefault(const struct ng_parse_type *type, u_char *buf, int *buflen) { ng_getDefault_t *const func = METHOD(type, getDefault); if (func == NULL) return (EOPNOTSUPP); return (*func)(type, buf, buf, buflen); }
/* * Fill in the default value according to the supplied type descriptor */
Fill in the default value according to the supplied type descriptor
[ "Fill", "in", "the", "default", "value", "according", "to", "the", "supplied", "type", "descriptor" ]
int ng_parse_getDefault(const struct ng_parse_type *type, u_char *buf, int *buflen) { ng_getDefault_t *const func = METHOD(type, getDefault); if (func == NULL) return (EOPNOTSUPP); return (*func)(type, buf, buf, buflen); }
[ "int", "ng_parse_getDefault", "(", "const", "struct", "ng_parse_type", "*", "type", ",", "u_char", "*", "buf", ",", "int", "*", "buflen", ")", "{", "ng_getDefault_t", "*", "const", "func", "=", "METHOD", "(", "type", ",", "getDefault", ")", ";", "if", "(", "func", "==", "NULL", ")", "return", "(", "EOPNOTSUPP", ")", ";", "return", "(", "*", "func", ")", "(", "type", ",", "buf", ",", "buf", ",", "buflen", ")", ";", "}" ]
Fill in the default value according to the supplied type descriptor
[ "Fill", "in", "the", "default", "value", "according", "to", "the", "supplied", "type", "descriptor" ]
[]
[ { "param": "type", "type": "struct ng_parse_type" }, { "param": "buf", "type": "u_char" }, { "param": "buflen", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "struct ng_parse_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buflen", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f22a872c9b68f7feaa267b9a108687293a3277b4
atrens/DragonFlyBSD-src
sys/netgraph7/netgraph/ng_parse.c
[ "BSD-3-Clause" ]
C
ng_parse_bytearray_subtype_getLength
int
static int ng_parse_bytearray_subtype_getLength(const struct ng_parse_type *type, const u_char *start, const u_char *buf) { ng_parse_array_getLength_t *const getLength = type->private; return (*getLength)(type, start, buf); }
/* Get the length of a byte array */
Get the length of a byte array
[ "Get", "the", "length", "of", "a", "byte", "array" ]
static int ng_parse_bytearray_subtype_getLength(const struct ng_parse_type *type, const u_char *start, const u_char *buf) { ng_parse_array_getLength_t *const getLength = type->private; return (*getLength)(type, start, buf); }
[ "static", "int", "ng_parse_bytearray_subtype_getLength", "(", "const", "struct", "ng_parse_type", "*", "type", ",", "const", "u_char", "*", "start", ",", "const", "u_char", "*", "buf", ")", "{", "ng_parse_array_getLength_t", "*", "const", "getLength", "=", "type", "->", "private", ";", "return", "(", "*", "getLength", ")", "(", "type", ",", "start", ",", "buf", ")", ";", "}" ]
Get the length of a byte array
[ "Get", "the", "length", "of", "a", "byte", "array" ]
[]
[ { "param": "type", "type": "struct ng_parse_type" }, { "param": "start", "type": "u_char" }, { "param": "buf", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "struct ng_parse_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f22a872c9b68f7feaa267b9a108687293a3277b4
atrens/DragonFlyBSD-src
sys/netgraph7/netgraph/ng_parse.c
[ "BSD-3-Clause" ]
C
ng_get_composite_elem_default
int
static int ng_get_composite_elem_default(const struct ng_parse_type *type, int index, const u_char *const start, u_char *buf, int *buflen, const enum comptype ctype) { const struct ng_parse_type *etype; ng_getDefault_t *func; switch (ctype) { case CT_STRUCT: break; case CT_ARRAY: { const struct ng_parse_array_info *const ai = type->info; if (ai->getDefault != NULL) { return (*ai->getDefault)(type, index, start, buf, buflen); } break; } case CT_FIXEDARRAY: { const struct ng_parse_fixedarray_info *const fi = type->info; if (*fi->getDefault != NULL) { return (*fi->getDefault)(type, index, start, buf, buflen); } break; } default: panic("%s", __func__); } /* Default to element type default */ etype = ng_get_composite_etype(type, index, ctype); func = METHOD(etype, getDefault); if (func == NULL) return (EOPNOTSUPP); return (*func)(etype, start, buf, buflen); }
/* * Generate the default value for an element of an array or structure * Returns EOPNOTSUPP if default value is unspecified. */
Generate the default value for an element of an array or structure Returns EOPNOTSUPP if default value is unspecified.
[ "Generate", "the", "default", "value", "for", "an", "element", "of", "an", "array", "or", "structure", "Returns", "EOPNOTSUPP", "if", "default", "value", "is", "unspecified", "." ]
static int ng_get_composite_elem_default(const struct ng_parse_type *type, int index, const u_char *const start, u_char *buf, int *buflen, const enum comptype ctype) { const struct ng_parse_type *etype; ng_getDefault_t *func; switch (ctype) { case CT_STRUCT: break; case CT_ARRAY: { const struct ng_parse_array_info *const ai = type->info; if (ai->getDefault != NULL) { return (*ai->getDefault)(type, index, start, buf, buflen); } break; } case CT_FIXEDARRAY: { const struct ng_parse_fixedarray_info *const fi = type->info; if (*fi->getDefault != NULL) { return (*fi->getDefault)(type, index, start, buf, buflen); } break; } default: panic("%s", __func__); } etype = ng_get_composite_etype(type, index, ctype); func = METHOD(etype, getDefault); if (func == NULL) return (EOPNOTSUPP); return (*func)(etype, start, buf, buflen); }
[ "static", "int", "ng_get_composite_elem_default", "(", "const", "struct", "ng_parse_type", "*", "type", ",", "int", "index", ",", "const", "u_char", "*", "const", "start", ",", "u_char", "*", "buf", ",", "int", "*", "buflen", ",", "const", "enum", "comptype", "ctype", ")", "{", "const", "struct", "ng_parse_type", "*", "etype", ";", "ng_getDefault_t", "*", "func", ";", "switch", "(", "ctype", ")", "{", "case", "CT_STRUCT", ":", "break", ";", "case", "CT_ARRAY", ":", "{", "const", "struct", "ng_parse_array_info", "*", "const", "ai", "=", "type", "->", "info", ";", "if", "(", "ai", "->", "getDefault", "!=", "NULL", ")", "{", "return", "(", "*", "ai", "->", "getDefault", ")", "(", "type", ",", "index", ",", "start", ",", "buf", ",", "buflen", ")", ";", "}", "break", ";", "}", "case", "CT_FIXEDARRAY", ":", "{", "const", "struct", "ng_parse_fixedarray_info", "*", "const", "fi", "=", "type", "->", "info", ";", "if", "(", "*", "fi", "->", "getDefault", "!=", "NULL", ")", "{", "return", "(", "*", "fi", "->", "getDefault", ")", "(", "type", ",", "index", ",", "start", ",", "buf", ",", "buflen", ")", ";", "}", "break", ";", "}", "default", ":", "panic", "(", "\"", "\"", ",", "__func__", ")", ";", "}", "etype", "=", "ng_get_composite_etype", "(", "type", ",", "index", ",", "ctype", ")", ";", "func", "=", "METHOD", "(", "etype", ",", "getDefault", ")", ";", "if", "(", "func", "==", "NULL", ")", "return", "(", "EOPNOTSUPP", ")", ";", "return", "(", "*", "func", ")", "(", "etype", ",", "start", ",", "buf", ",", "buflen", ")", ";", "}" ]
Generate the default value for an element of an array or structure Returns EOPNOTSUPP if default value is unspecified.
[ "Generate", "the", "default", "value", "for", "an", "element", "of", "an", "array", "or", "structure", "Returns", "EOPNOTSUPP", "if", "default", "value", "is", "unspecified", "." ]
[ "/* Default to element type default */" ]
[ { "param": "type", "type": "struct ng_parse_type" }, { "param": "index", "type": "int" }, { "param": "start", "type": "u_char" }, { "param": "buf", "type": "u_char" }, { "param": "buflen", "type": "int" }, { "param": "ctype", "type": "enum comptype" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "struct ng_parse_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buflen", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctype", "type": "enum comptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f22a872c9b68f7feaa267b9a108687293a3277b4
atrens/DragonFlyBSD-src
sys/netgraph7/netgraph/ng_parse.c
[ "BSD-3-Clause" ]
C
ng_get_composite_len
int
static int ng_get_composite_len(const struct ng_parse_type *type, const u_char *const start, const u_char *buf, const enum comptype ctype) { switch (ctype) { case CT_STRUCT: { const struct ng_parse_struct_field *const fields = type->info; int numFields = 0; for (numFields = 0; ; numFields++) { const struct ng_parse_struct_field *const fi = &fields[numFields]; if (fi->name == NULL) break; } return (numFields); } case CT_ARRAY: { const struct ng_parse_array_info *const ai = type->info; return (*ai->getLength)(type, start, buf); } case CT_FIXEDARRAY: { const struct ng_parse_fixedarray_info *const fi = type->info; return fi->length; } default: panic("%s", __func__); } return (0); }
/* * Get the number of elements in a struct, variable or fixed array. */
Get the number of elements in a struct, variable or fixed array.
[ "Get", "the", "number", "of", "elements", "in", "a", "struct", "variable", "or", "fixed", "array", "." ]
static int ng_get_composite_len(const struct ng_parse_type *type, const u_char *const start, const u_char *buf, const enum comptype ctype) { switch (ctype) { case CT_STRUCT: { const struct ng_parse_struct_field *const fields = type->info; int numFields = 0; for (numFields = 0; ; numFields++) { const struct ng_parse_struct_field *const fi = &fields[numFields]; if (fi->name == NULL) break; } return (numFields); } case CT_ARRAY: { const struct ng_parse_array_info *const ai = type->info; return (*ai->getLength)(type, start, buf); } case CT_FIXEDARRAY: { const struct ng_parse_fixedarray_info *const fi = type->info; return fi->length; } default: panic("%s", __func__); } return (0); }
[ "static", "int", "ng_get_composite_len", "(", "const", "struct", "ng_parse_type", "*", "type", ",", "const", "u_char", "*", "const", "start", ",", "const", "u_char", "*", "buf", ",", "const", "enum", "comptype", "ctype", ")", "{", "switch", "(", "ctype", ")", "{", "case", "CT_STRUCT", ":", "{", "const", "struct", "ng_parse_struct_field", "*", "const", "fields", "=", "type", "->", "info", ";", "int", "numFields", "=", "0", ";", "for", "(", "numFields", "=", "0", ";", ";", "numFields", "++", ")", "{", "const", "struct", "ng_parse_struct_field", "*", "const", "fi", "=", "&", "fields", "[", "numFields", "]", ";", "if", "(", "fi", "->", "name", "==", "NULL", ")", "break", ";", "}", "return", "(", "numFields", ")", ";", "}", "case", "CT_ARRAY", ":", "{", "const", "struct", "ng_parse_array_info", "*", "const", "ai", "=", "type", "->", "info", ";", "return", "(", "*", "ai", "->", "getLength", ")", "(", "type", ",", "start", ",", "buf", ")", ";", "}", "case", "CT_FIXEDARRAY", ":", "{", "const", "struct", "ng_parse_fixedarray_info", "*", "const", "fi", "=", "type", "->", "info", ";", "return", "fi", "->", "length", ";", "}", "default", ":", "panic", "(", "\"", "\"", ",", "__func__", ")", ";", "}", "return", "(", "0", ")", ";", "}" ]
Get the number of elements in a struct, variable or fixed array.
[ "Get", "the", "number", "of", "elements", "in", "a", "struct", "variable", "or", "fixed", "array", "." ]
[]
[ { "param": "type", "type": "struct ng_parse_type" }, { "param": "start", "type": "u_char" }, { "param": "buf", "type": "u_char" }, { "param": "ctype", "type": "enum comptype" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "struct ng_parse_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "start", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctype", "type": "enum comptype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }