--- lib.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib.c b/lib.c index e1454661b..c107505a7 100644 --- a/lib.c +++ b/lib.c @@ -476,6 +476,41 @@ static void handle_arch_finalize(void) } +struct mask_map { + const char *name; + unsigned long mask; +}; + +static unsigned long lookup_mask(const char *name, const struct mask_map *map) +{ + for (; map->name; map++) { + if (strcmp(name, map->name) == 0) + return map->mask; + } + return 0; +} + +inline +static unsigned long handle_suboption_mask(char *arg, const struct mask_map *map) +{ + const char *token; + unsigned long mask = 0; + + if (*arg == '\0') + return lookup_mask("$default", map); + if (*arg != '=') + return ~0UL; + arg++; + while ((token = strsep(&arg, ",+"))) { + unsigned long opt = lookup_mask(token, map); + if (!opt) + return ~0UL; + mask |= opt; + } + return mask; +} + + struct flag { const char *name; int *flag; -- 2.14.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html