Changeset 9f43919


Ignore:
Timestamp:
09/05/14 02:57:44 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
08f5060, a7c8f4a
Parents:
6c3b3d7
Message:

A terrible fix to allow nesting of getopts, because DPDK uses this internally.
This is probably going to break for someone, but it is the best solution I can think of for now.
In the future hopefully DPDK will have a programming interface for all these settings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dpdk.c

    r6c3b3d7 r9f43919  
    446446#endif
    447447
     448/**
     449 * XXX This is very bad XXX
     450 * But we have to do something to allow getopts nesting
     451 * Luckly normally the format is last so it doesn't matter
     452 * DPDK only supports modern systems so hopefully this
     453 * will continue to work
     454 */
     455struct saved_getopts {
     456        char *optarg;
     457        int optind;
     458        int opterr;
     459        int optopt;
     460};
     461
     462static void save_getopts(struct saved_getopts *opts) {
     463        opts->optarg = optarg;
     464        opts->optind = optind;
     465        opts->opterr = opterr;
     466        opts->optopt = optopt;
     467}
     468
     469static void restore_getopts(struct saved_getopts *opts) {
     470        optarg = opts->optarg;
     471        optind = opts->optind;
     472        opterr = opts->opterr;
     473        optopt = opts->optopt;
     474}
     475
    448476static inline int dpdk_init_environment(char * uridata, struct dpdk_format_data_t * format_data,
    449477                                        char * err, int errlen) {
     
    454482    long nb_cpu; /* The number of CPUs in the system */
    455483    long my_cpu; /* The CPU number we want to bind to */
     484        struct saved_getopts save_opts;
    456485   
    457486#if DEBUG
     
    519548    /* rte_eal_init it makes a call to getopt so we need to reset the
    520549     * global optind variable of getopt otherwise this fails */
     550        save_getopts(&save_opts);
    521551    optind = 1;
    522552    if ((ret = rte_eal_init(argc, argv)) < 0) {
     
    525555        return -1;
    526556    }
     557        restore_getopts(&save_opts);
     558
    527559#if DEBUG
    528560    dump_configuration();
Note: See TracChangeset for help on using the changeset viewer.