eal: do not reset getopt lib
authorTiwei Bie <btw@mail.ustc.edu.cn>
Mon, 19 Oct 2015 13:13:10 +0000 (21:13 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 4 Nov 2015 22:18:18 +0000 (23:18 +0100)
commitbb7c5ab2e857a25b052a7f08ad33df299a8784b1
tree2f45beff5009cc5e25378d5fab16e0c18efe486e
parentd5790b03b3c440dbcf1a9951024af8b25916abb0
eal: do not reset getopt lib

Someone may need to call rte_eal_init() with a fake argc/argv array
in the middle of using getopt() to parse its own unrelated argc/argv
parameters. So getopt lib shouldn't be reset by rte_eal_init().

Now eal will always save optind, optarg and optopt (and optreset on
FreeBSD) at the beginning, initialize optind (and optreset on FreeBSD)
to 1 before calling getopt_long(), then restore all values after.

Suggested-by: Don Provan <dprovan@bivio.net>
Suggested-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Tiwei Bie <btw@mail.ustc.edu.cn>
Reviewed-by: Don Provan <dprovan@bivio.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: David Marchand <david.marchand@6wind.com>
lib/librte_eal/bsdapp/eal/eal.c
lib/librte_eal/linuxapp/eal/eal.c