logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0009-Use-static-inline-function-for-cmp_numbers.patch (970B)


  1. From f9e192ecdbfd369fe42da4c9b8a3ab90cfa6f10f Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Tue, 25 Jun 2019 00:13:43 -0700
  4. Subject: [PATCH] Use static inline function for cmp_numbers
  5. All callers use it with an unsigned type, so just specialize for
  6. uintmax_t.
  7. ---
  8. include/c.h | 12 +++++-------
  9. 1 file changed, 5 insertions(+), 7 deletions(-)
  10. diff --git a/include/c.h b/include/c.h
  11. index fe82a8847..eb48e7f77 100644
  12. --- a/include/c.h
  13. +++ b/include/c.h
  14. @@ -153,13 +153,11 @@ umin(uintmax_t x, uintmax_t y)
  15. return x < y ? x : y;
  16. }
  17. -#ifndef cmp_numbers
  18. -# define cmp_numbers(x, y) __extension__ ({ \
  19. - __typeof__(x) _a = (x); \
  20. - __typeof__(y) _b = (y); \
  21. - (void) (&_a == &_b); \
  22. - _a == _b ? 0 : _a > _b ? 1 : -1; })
  23. -#endif
  24. +static inline uintmax_t
  25. +cmp_numbers(uintmax_t x, uintmax_t y)
  26. +{
  27. + return x == y ? 0 : x > y ? 1 : -1;
  28. +}
  29. #ifndef offsetof
  30. #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  31. --
  32. 2.31.1