aboutsummaryrefslogtreecommitdiff
path: root/helper/include
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@linaro.org>2018-05-14 13:10:01 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-05-14 18:47:02 +0300
commit0ee8255c2555ed68721ea5e7679f26a2e53bd8b8 (patch)
treee3e4b5b2c8836c6a4e07b69f6146e86bf2b67c17 /helper/include
parentad3417a6fd2ba93616b937f9a2d8642eceeb0bf8 (diff)
helper: thread: don't use getopt library
Don't use getopt library calls for helper options. Getopt library reset is not portable in practice. Library interface includes global variables and different internal state variables depending on POSIX version. There's no need for helper to use getopt calls or set getopt global variables at all. It's much more simple (and portable) to remove helper options from argv[] and return new value for argc. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> Reviewed-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper/include')
-rw-r--r--helper/include/odp/helper/threads.h75
1 files changed, 10 insertions, 65 deletions
diff --git a/helper/include/odp/helper/threads.h b/helper/include/odp/helper/threads.h
index ed7d7f39a..9d03c7192 100644
--- a/helper/include/odp/helper/threads.h
+++ b/helper/include/odp/helper/threads.h
@@ -146,74 +146,19 @@ int odph_odpthread_setaffinity(const int cpu);
int odph_odpthread_getaffinity(void);
/**
- * Merge getopt options
- *
- * Given two sets of getopt options (each containing possibly both short
- * options -a string- and long options -a option array-) this function
- * return a single set (i.e. a string for short and an array for long)
- * being the concatenation of the two given sets.
- * Due to the fact that the size of these arrays is unknown at compilation
- * time, this function actually mallocs the the resulting arrays.
- * The fourth and fith parameters are actually pointers where these malloc'ed
- * areas are returned.
- * This means that the caller of this function has to free the two returned
- * areas!
- *
- * @param shortopts1 first set of short options (a string)
- * @param shortopts2 second set of short options (a string)
- * @param longopts1 first set of long options (a getopt option array)
- * @param longopts2 second set of long options (a getopt option array)
- * @param shortopts a pointer where the address of the short options list
- * (a string) is returned. It contains the concatenation of
- * the two given short option strings.
- * @param longopts a pointer where the address of the long options list
- * (a getopt option array) is returned.
- * It contains the concatenation of the two given long
- * option arrays.
- * if any of shortopts1, shortopts2, longopts1, longopts2 is NULL, the
- * corresponding list as assumed to be empty.
- * if any of shortopts, longopts is NULL, the corresponding malloc is not
- * performed.
- *
- * @return On success: 0 : both shortopts and longopts are returned (assuming
- * the given pointer where not null), possibly
- * pointing to an empty string or an empty option array.
- * On success, the caller is due to free these areas.
- * On failure: -1: Nothing is malloc'ed.
- */
-int odph_merge_getopt_options(const char *shortopts1,
- const char *shortopts2,
- const struct option *longopts1,
- const struct option *longopts2,
- char **shortopts,
- struct option **longopts);
-
-/**
* Parse linux helper options
*
- * Parse the command line options. Pick up options meant for the helper itself.
- * If the caller is also having a set of option to parse, it should include
- * their description here (shortopts desribes the short options and longopts
- * describes the long options, as for getopt_long()).
- * This function will issue errors on unknown arguments, so callers failing
- * to pass their own command line options description here will see their
- * options rejected.
- * (the caller wants to set opterr to zero when parsing its own stuff
- * with getopts to avoid reacting on helper's options).
- *
- * @param argc argument count
- * @param argv argument values
- * @param caller_shortopts caller's set of short options (string). or NULL.
- * @param caller_longopts caller's set of long options (getopt option array).
- * or NULL.
- *
- * @return On success: 0
- * On failure: -1 failure occurs if a value passed for a helper
- * option is invalid, or on meeting unknown options.
+ * Parse the command line options. Pick up (--odph_ prefixed) options meant for
+ * the helper itself. When helper options are found, those are removed from
+ * argv[] and remaining options are packed to the beginning of the array.
+ *
+ * @param argc Argument count
+ * @param argv Argument vector
+ *
+ * @return New argument count. Original argument count decremented by
+ * the number of removed helper options.
*/
-int odph_parse_options(int argc, char *argv[],
- const char *caller_shortopts,
- const struct option *caller_longopts);
+int odph_parse_options(int argc, char *argv[]);
/**
* @}