scripts/unifdef.c
Source file repositories/reference/linux-study-clean/scripts/unifdef.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/unifdef.c- Extension
.c- Size
- 35672 bytes
- Lines
- 1226
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/types.hsys/stat.hctype.herr.herrno.hstdarg.hstdbool.hstdio.hstdlib.hstring.hunistd.h
Detected Declarations
struct opsstruct opfunction mainfunction versionfunction usagefunction Eeliffunction Eelsefunction Eendiffunction Eeoffunction Eiocccfunction printfunction dropfunction Struefunction Sfalsefunction Selsefunction Peliffunction Pelsefunction Pendiffunction Dfalsefunction Deliffunction Delsefunction Dendiffunction Fdropfunction Fpassfunction Ftruefunction Ffalsefunction Oiffyfunction Oiffunction Oeliffunction Idropfunction Itruefunction Ifalsefunction Mpassfunction Mtruefunction Meliffunction Melsefunction ignoreofffunction ignoreonfunction keywordeditfunction nestfunction unnestfunction statefunction flushlinefunction processfunction closeoutfunction donefunction skipcommentfunction op_strict
Annotated Snippet
struct op {
const char *str;
Linetype (*fn)(int *, Linetype, int, Linetype, int);
} op[5];
} eval_ops[] = {
{ eval_table, { { "||", op_or } } },
{ eval_table, { { "&&", op_and } } },
{ eval_table, { { "==", op_eq },
{ "!=", op_ne } } },
{ eval_unary, { { "<=", op_le },
{ ">=", op_ge },
{ "<", op_lt },
{ ">", op_gt } } }
};
/*
* Function for evaluating the innermost parts of expressions,
* viz. !expr (expr) number defined(symbol) symbol
* We reset the constexpression flag in the last two cases.
*/
static Linetype
eval_unary(const struct ops *ops, int *valp, const char **cpp)
{
const char *cp;
char *ep;
int sym;
bool defparen;
Linetype lt;
cp = skipcomment(*cpp);
if (*cp == '!') {
debug("eval%d !", ops - eval_ops);
cp++;
lt = eval_unary(ops, valp, &cp);
if (lt == LT_ERROR)
return (LT_ERROR);
if (lt != LT_IF) {
*valp = !*valp;
lt = *valp ? LT_TRUE : LT_FALSE;
}
} else if (*cp == '(') {
cp++;
debug("eval%d (", ops - eval_ops);
lt = eval_table(eval_ops, valp, &cp);
if (lt == LT_ERROR)
return (LT_ERROR);
cp = skipcomment(cp);
if (*cp++ != ')')
return (LT_ERROR);
} else if (isdigit((unsigned char)*cp)) {
debug("eval%d number", ops - eval_ops);
*valp = strtol(cp, &ep, 0);
if (ep == cp)
return (LT_ERROR);
lt = *valp ? LT_TRUE : LT_FALSE;
cp = skipsym(cp);
} else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
cp = skipcomment(cp+7);
debug("eval%d defined", ops - eval_ops);
if (*cp == '(') {
cp = skipcomment(cp+1);
defparen = true;
} else {
defparen = false;
}
sym = findsym(cp);
if (sym < 0) {
lt = LT_IF;
} else {
*valp = (value[sym] != NULL);
lt = *valp ? LT_TRUE : LT_FALSE;
}
cp = skipsym(cp);
cp = skipcomment(cp);
if (defparen && *cp++ != ')')
return (LT_ERROR);
constexpression = false;
} else if (!endsym(*cp)) {
debug("eval%d symbol", ops - eval_ops);
sym = findsym(cp);
cp = skipsym(cp);
if (sym < 0) {
lt = LT_IF;
cp = skipargs(cp);
} else if (value[sym] == NULL) {
*valp = 0;
lt = LT_FALSE;
} else {
*valp = strtol(value[sym], &ep, 0);
if (*ep != '\0' || ep == value[sym])
Annotation
- Immediate include surface: `sys/types.h`, `sys/stat.h`, `ctype.h`, `err.h`, `errno.h`, `stdarg.h`, `stdbool.h`, `stdio.h`.
- Detected declarations: `struct ops`, `struct op`, `function main`, `function version`, `function usage`, `function Eelif`, `function Eelse`, `function Eendif`, `function Eeof`, `function Eioccc`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.