Attention is currently required from: Yidi Lin, Yu-Ping Wu.
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/78798?usp=email )
Change subject: lib: Add GCD function ......................................................................
Patch Set 1:
(2 comments)
File src/lib/gcd.c:
https://review.coreboot.org/c/coreboot/+/78798/comment/1b8583d5_6eb6b62e : PS1, Line 1: /* SPDX-License-Identifier: GPL-2.0-only */ Since we need to solve the same problem in libpayload, please put this in commonlib/bsd, and use a GCD implementation that is BSD-licensed. (In the majority of cases, at least for the timer problem, we'll just be trying to find the GCD between 1MHz and a multiple of 1MHz. So we probably don't need the most sophisticated GCD algorithm in the world, the simple modulus one should be good enough, it'll only take one iteration.)
https://review.coreboot.org/c/coreboot/+/78798/comment/8fb939cc_75e170da : PS1, Line 20: *a ^= *b; This hasn't been a good swap algorithm in 20+ years (see https://en.wikipedia.org/wiki/Register_renaming). Just use a temp variable, and I don't think this is worth factoring out into a separate function for a single use.
Oh, actually, looks like we already have a SWAP() in commonlib/helpers.h (part of <stdlib.h>) that you can use.