logo

oasis

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

0011-Use-static-inline-function-for-min.patch (930B)


  1. From eb780d31a912363846e54266db7395a82f14ebb2 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Mon, 24 Jun 2019 17:38:56 -0700
  4. Subject: [PATCH] Use static inline function for min()
  5. It is only called to calculate a minimum `int`, so specialize for
  6. `int`.
  7. ---
  8. include/utils.h | 11 ++++-------
  9. 1 file changed, 4 insertions(+), 7 deletions(-)
  10. diff --git a/include/utils.h b/include/utils.h
  11. index 9ba129b8..a8a56fca 100644
  12. --- a/include/utils.h
  13. +++ b/include/utils.h
  14. @@ -279,13 +279,10 @@ unsigned int print_name_and_link(const char *fmt,
  15. # define offsetof(type, member) ((size_t) &((type *)0)->member)
  16. #endif
  17. -#ifndef min
  18. -# define min(x, y) ({ \
  19. - typeof(x) _min1 = (x); \
  20. - typeof(y) _min2 = (y); \
  21. - (void) (&_min1 == &_min2); \
  22. - _min1 < _min2 ? _min1 : _min2; })
  23. -#endif
  24. +static inline int min(int a, int b)
  25. +{
  26. + return a < b ? a : b;
  27. +}
  28. #ifndef max
  29. # define max(x, y) ({ \
  30. --
  31. 2.44.0