diff options
Diffstat (limited to 'payloads/libpayload')
-rw-r--r-- | payloads/libpayload/libc/Makefile.inc | 1 | ||||
-rw-r--r-- | payloads/libpayload/libc/getopt_long.c | 22 |
2 files changed, 3 insertions, 20 deletions
diff --git a/payloads/libpayload/libc/Makefile.inc b/payloads/libpayload/libc/Makefile.inc index bc706ae5a7..2d277da3b5 100644 --- a/payloads/libpayload/libc/Makefile.inc +++ b/payloads/libpayload/libc/Makefile.inc @@ -46,4 +46,5 @@ endif ifeq ($(CONFIG_LP_LIBC),y) libc-srcs += $(coreboottop)/src/commonlib/bsd/elog.c +libc-srcs += $(coreboottop)/src/commonlib/bsd/gcd.c endif diff --git a/payloads/libpayload/libc/getopt_long.c b/payloads/libpayload/libc/getopt_long.c index 365bc4a85a..822ce96904 100644 --- a/payloads/libpayload/libc/getopt_long.c +++ b/payloads/libpayload/libc/getopt_long.c @@ -54,6 +54,7 @@ #include <err.h> #include <errno.h> */ +#include <commonlib/bsd/gcd.h> #include <libpayload.h> #include <getopt.h> #define warnx(x...) printf(x) @@ -88,7 +89,6 @@ static int getopt_internal(int, char * const *, const char *, const struct option *, int *, int); static int parse_long_options(char * const *, const char *, const struct option *, int *, int); -static int gcd(int, int); static void permute_args(int, int, int, char * const *); static char *place = EMSG; /* option letter processing */ @@ -106,24 +106,6 @@ static const char illoptchar[] = "unknown option -- %c"; static const char illoptstring[] = "unknown option -- %s"; /* - * Compute the greatest common divisor of a and b. - */ -static int -gcd(int a, int b) -{ - int c; - - c = a % b; - while (c != 0) { - a = b; - b = c; - c = a % b; - } - - return (b); -} - -/* * Exchange the block from nonopt_start to nonopt_end with the block * from nonopt_end to opt_end (keeping the same order of arguments * in each block). @@ -140,7 +122,7 @@ permute_args(int panonopt_start, int panonopt_end, int opt_end, */ nnonopts = panonopt_end - panonopt_start; nopts = opt_end - panonopt_end; - ncycle = gcd(nnonopts, nopts); + ncycle = gcd32(nnonopts, nopts); cyclelen = (opt_end - panonopt_start) / ncycle; for (i = 0; i < ncycle; i++) { |