static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)

{

    unsigned int i;

    const sparc_def_t *def = NULL;

    char *s = strdup(cpu_model);

    char *featurestr, *name = strtok(s, ",");

    uint32_t plus_features = 0;

    uint32_t minus_features = 0;

    uint64_t iu_version;

    uint32_t fpu_version, mmu_version, nwindows;



    for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {

        if (strcasecmp(name, sparc_defs[i].name) == 0) {

            def = &sparc_defs[i];

        }

    }

    if (!def) {

        goto error;

    }

    memcpy(cpu_def, def, sizeof(*def));



    featurestr = strtok(NULL, ",");

    while (featurestr) {

        char *val;



        if (featurestr[0] == '+') {

            add_flagname_to_bitmaps(featurestr + 1, &plus_features);

        } else if (featurestr[0] == '-') {

            add_flagname_to_bitmaps(featurestr + 1, &minus_features);

        } else if ((val = strchr(featurestr, '='))) {

            *val = 0; val++;

            if (!strcmp(featurestr, "iu_version")) {

                char *err;



                iu_version = strtoll(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->iu_version = iu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version);

#endif

            } else if (!strcmp(featurestr, "fpu_version")) {

                char *err;



                fpu_version = strtol(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->fpu_version = fpu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "fpu_version %x\n", fpu_version);

#endif

            } else if (!strcmp(featurestr, "mmu_version")) {

                char *err;



                mmu_version = strtol(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->mmu_version = mmu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "mmu_version %x\n", mmu_version);

#endif

            } else if (!strcmp(featurestr, "nwindows")) {

                char *err;



                nwindows = strtol(val, &err, 0);

                if (!*val || *err || nwindows > MAX_NWINDOWS ||

                    nwindows < MIN_NWINDOWS) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->nwindows = nwindows;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "nwindows %d\n", nwindows);

#endif

            } else {

                fprintf(stderr, "unrecognized feature %s\n", featurestr);

                goto error;

            }

        } else {

            fprintf(stderr, "feature string `%s' not in format "

                    "(+feature|-feature|feature=xyz)\n", featurestr);

            goto error;

        }

        featurestr = strtok(NULL, ",");

    }

    cpu_def->features |= plus_features;

    cpu_def->features &= ~minus_features;

#ifdef DEBUG_FEATURES

    print_features(stderr, fprintf, cpu_def->features, NULL);

#endif

    free(s);

    return 0;



 error:

    free(s);

    return -1;

}

static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)

{

    unsigned int i;

    const sparc_def_t *def = NULL;

    char *s = strdup(cpu_model);

    char *featurestr, *name = strtok(s, ",");

    uint32_t plus_features = 0;

    uint32_t minus_features = 0;

    uint64_t iu_version;

    uint32_t fpu_version, mmu_version, nwindows;



    for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {

        if (strcasecmp(name, sparc_defs[i].name) == 0) {

            def = &sparc_defs[i];

        }

    }

    if (!def) {

        goto error;

    }

    memcpy(cpu_def, def, sizeof(*def));



    featurestr = strtok(NULL, ",");

    while (featurestr) {

        char *val;



        if (featurestr[0] == '+') {

            add_flagname_to_bitmaps(featurestr + 1, &plus_features);

        } else if (featurestr[0] == '-') {

            add_flagname_to_bitmaps(featurestr + 1, &minus_features);

        } else if ((val = strchr(featurestr, '='))) {

            *val = 0; val++;

            if (!strcmp(featurestr, "iu_version")) {

                char *err;



                iu_version = strtoll(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->iu_version = iu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version);

#endif

            } else if (!strcmp(featurestr, "fpu_version")) {

                char *err;



                fpu_version = strtol(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->fpu_version = fpu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "fpu_version %x\n", fpu_version);

#endif

            } else if (!strcmp(featurestr, "mmu_version")) {

                char *err;



                mmu_version = strtol(val, &err, 0);

                if (!*val || *err) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->mmu_version = mmu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "mmu_version %x\n", mmu_version);

#endif

            } else if (!strcmp(featurestr, "nwindows")) {

                char *err;



                nwindows = strtol(val, &err, 0);

                if (!*val || *err || nwindows > MAX_NWINDOWS ||

                    nwindows < MIN_NWINDOWS) {

                    fprintf(stderr, "bad numerical value %s\n", val);

                    goto error;

                }

                cpu_def->nwindows = nwindows;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "nwindows %d\n", nwindows);

#endif

            } else {

                fprintf(stderr, "unrecognized feature %s\n", featurestr);

                goto error;

            }

        } else {

            fprintf(stderr, "feature string `%s' not in format "

                    "(+feature|-feature|feature=xyz)\n", featurestr);

            goto error;

        }

        featurestr = strtok(NULL, ",");

    }

    cpu_def->features |= plus_features;

    cpu_def->features &= ~minus_features;

#ifdef DEBUG_FEATURES

    print_features(stderr, fprintf, cpu_def->features, NULL);

#endif

    free(s);

    return 0;



 error:

    free(s);

    return -1;

}

    char *s = strdup(cpu_model);     free(s);
static int FUNC_0(sparc_def_t *VAR_0, const char *VAR_1)

{

    unsigned int VAR_2;

    const sparc_def_t *VAR_3 = NULL;

    char *VAR_4 = strdup(VAR_1);

    char *VAR_5, *VAR_6 = strtok(VAR_4, ",");

    uint32_t plus_features = 0;

    uint32_t minus_features = 0;

    uint64_t iu_version;

    uint32_t fpu_version, mmu_version, nwindows;



    for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(sparc_defs); VAR_2++) {

        if (strcasecmp(VAR_6, sparc_defs[VAR_2].VAR_6) == 0) {

            VAR_3 = &sparc_defs[VAR_2];

        }

    }

    if (!VAR_3) {

        goto error;

    }

    memcpy(VAR_0, VAR_3, sizeof(*VAR_3));



    VAR_5 = strtok(NULL, ",");

    while (VAR_5) {

        char *VAR_7;



        if (VAR_5[0] == '+') {

            add_flagname_to_bitmaps(VAR_5 + 1, &plus_features);

        } else if (VAR_5[0] == '-') {

            add_flagname_to_bitmaps(VAR_5 + 1, &minus_features);

        } else if ((VAR_7 = strchr(VAR_5, '='))) {

            *VAR_7 = 0; VAR_7++;

            if (!strcmp(VAR_5, "iu_version")) {

                char *VAR_9;



                iu_version = strtoll(VAR_7, &VAR_9, 0);

                if (!*VAR_7 || *VAR_9) {

                    fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7);

                    goto error;

                }

                VAR_0->iu_version = iu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version);

#endif

            } else if (!strcmp(VAR_5, "fpu_version")) {

                char *VAR_9;



                fpu_version = strtol(VAR_7, &VAR_9, 0);

                if (!*VAR_7 || *VAR_9) {

                    fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7);

                    goto error;

                }

                VAR_0->fpu_version = fpu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "fpu_version %x\n", fpu_version);

#endif

            } else if (!strcmp(VAR_5, "mmu_version")) {

                char *VAR_9;



                mmu_version = strtol(VAR_7, &VAR_9, 0);

                if (!*VAR_7 || *VAR_9) {

                    fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7);

                    goto error;

                }

                VAR_0->mmu_version = mmu_version;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "mmu_version %x\n", mmu_version);

#endif

            } else if (!strcmp(VAR_5, "nwindows")) {

                char *VAR_9;



                nwindows = strtol(VAR_7, &VAR_9, 0);

                if (!*VAR_7 || *VAR_9 || nwindows > MAX_NWINDOWS ||

                    nwindows < MIN_NWINDOWS) {

                    fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7);

                    goto error;

                }

                VAR_0->nwindows = nwindows;

#ifdef DEBUG_FEATURES

                fprintf(stderr, "nwindows %d\n", nwindows);

#endif

            } else {

                fprintf(stderr, "unrecognized feature %VAR_4\n", VAR_5);

                goto error;

            }

        } else {

            fprintf(stderr, "feature string `%VAR_4' not in format "

                    "(+feature|-feature|feature=xyz)\n", VAR_5);

            goto error;

        }

        VAR_5 = strtok(NULL, ",");

    }

    VAR_0->features |= plus_features;

    VAR_0->features &= ~minus_features;

#ifdef DEBUG_FEATURES

    print_features(stderr, fprintf, VAR_0->features, NULL);

#endif

    free(VAR_4);

    return 0;



 error:

    free(VAR_4);

    return -1;

}

static int FUNC_0(sparc_def_t *VAR_0, const char *VAR_1)
{ unsigned int VAR_2; const sparc_def_t *VAR_3 = NULL; char *VAR_4 = strdup(VAR_1); char *VAR_5, *VAR_6 = strtok(VAR_4, ","); uint32_t plus_features = 0; uint32_t minus_features = 0; uint64_t iu_version; uint32_t fpu_version, mmu_version, nwindows; for (VAR_2 = 0; VAR_2 < ARRAY_SIZE(sparc_defs); VAR_2++) { if (strcasecmp(VAR_6, sparc_defs[VAR_2].VAR_6) == 0) { VAR_3 = &sparc_defs[VAR_2]; } } if (!VAR_3) { goto error; } memcpy(VAR_0, VAR_3, sizeof(*VAR_3)); VAR_5 = strtok(NULL, ","); while (VAR_5) { char *VAR_7; if (VAR_5[0] == '+') { add_flagname_to_bitmaps(VAR_5 + 1, &plus_features); } else if (VAR_5[0] == '-') { add_flagname_to_bitmaps(VAR_5 + 1, &minus_features); } else if ((VAR_7 = strchr(VAR_5, '='))) { *VAR_7 = 0; VAR_7++; if (!strcmp(VAR_5, "iu_version")) { char *VAR_9; iu_version = strtoll(VAR_7, &VAR_9, 0); if (!*VAR_7 || *VAR_9) { fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7); goto error; } VAR_0->iu_version = iu_version; #ifdef DEBUG_FEATURES
fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version); #endif
} else if (!strcmp(VAR_5, "fpu_version")) { char *VAR_9; fpu_version = strtol(VAR_7, &VAR_9, 0); if (!*VAR_7 || *VAR_9) { fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7); goto error; } VAR_0->fpu_version = fpu_version; #ifdef DEBUG_FEATURES
fprintf(stderr, "fpu_version %x\n", fpu_version); #endif
} else if (!strcmp(VAR_5, "mmu_version")) { char *VAR_9; mmu_version = strtol(VAR_7, &VAR_9, 0); if (!*VAR_7 || *VAR_9) { fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7); goto error; } VAR_0->mmu_version = mmu_version; #ifdef DEBUG_FEATURES
fprintf(stderr, "mmu_version %x\n", mmu_version); #endif
} else if (!strcmp(VAR_5, "nwindows")) { char *VAR_9; nwindows = strtol(VAR_7, &VAR_9, 0); if (!*VAR_7 || *VAR_9 || nwindows > MAX_NWINDOWS ||
nwindows < MIN_NWINDOWS) { fprintf(stderr, "bad numerical value %VAR_4\n", VAR_7); goto error; } VAR_0->nwindows = nwindows; #ifdef DEBUG_FEATURES
fprintf(stderr, "nwindows %d\n", nwindows); #endif
} else { fprintf(stderr, "unrecognized feature %VAR_4\n", VAR_5); goto error; } } else { fprintf(stderr, "feature string `%VAR_4' not in format "
"(+feature|-feature|feature=xyz)\n", VAR_5); goto error; } VAR_5 = strtok(NULL, ","); } VAR_0->features |= plus_features; VAR_0->features &= ~minus_features; #ifdef DEBUG_FEATURES
print_features(stderr, fprintf, VAR_0->features, NULL); #endif
free(VAR_4); return 0; error:
free(VAR_4); return -1; }