0001-libuuid-src-gen_uuid.c-fix-cs_min-declaration.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From bcd11dece7d278bb0b76b138d08dedea80fa8262 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Tue, 7 Nov 2023 18:43:57 +0100
  4. Subject: [PATCH] libuuid/src/gen_uuid.c: fix cs_min declaration
  5. Define cs_min through a define and not a const int to avoid the
  6. following build failure with -O0 raised since version 2.39 and
  7. https://github.com/util-linux/util-linux/commit/2fa4168c8bc9d5438bc1dfadda293c7c21b6fa59:
  8. libuuid/src/gen_uuid.c: In function 'uuid_generate_time_generic':
  9. libuuid/src/gen_uuid.c:536:33: error: initializer element is not constant
  10. THREAD_LOCAL int cache_size = cs_min;
  11. ^~~~~~
  12. For consistency, also use define for cs_max and cs_factor
  13. Fixes:
  14. - http://autobuild.buildroot.org/results/2f80a5cdb523cc3c8c0f3693607a1be036b2ae98
  15. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  16. Upstream: https://github.com/util-linux/util-linux/commit/07e5c29d501c19e7af84fecb5915e0f9f94cb49f
  17. ---
  18. libuuid/src/gen_uuid.c | 19 ++++++++++---------
  19. 1 file changed, 10 insertions(+), 9 deletions(-)
  20. diff --git a/libuuid/src/gen_uuid.c b/libuuid/src/gen_uuid.c
  21. index 619ef0131..db793c374 100644
  22. --- a/libuuid/src/gen_uuid.c
  23. +++ b/libuuid/src/gen_uuid.c
  24. @@ -518,6 +518,10 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
  25. return __uuid_generate_time_internal(out, num, cont_offset);
  26. }
  27. +#define CS_MIN (1<<6)
  28. +#define CS_MAX (1<<18)
  29. +#define CS_FACTOR 2
  30. +
  31. /*
  32. * Generate time-based UUID and store it to @out
  33. *
  34. @@ -529,11 +533,8 @@ int __uuid_generate_time_cont(uuid_t out, int *num, uint32_t cont_offset)
  35. static int uuid_generate_time_generic(uuid_t out) {
  36. #ifdef HAVE_TLS
  37. /* thread local cache for uuidd based requests */
  38. - const int cs_min = (1<<6);
  39. - const int cs_max = (1<<18);
  40. - const int cs_factor = 2;
  41. THREAD_LOCAL int num = 0;
  42. - THREAD_LOCAL int cache_size = cs_min;
  43. + THREAD_LOCAL int cache_size = CS_MIN;
  44. THREAD_LOCAL int last_used = 0;
  45. THREAD_LOCAL struct uuid uu;
  46. THREAD_LOCAL time_t last_time = 0;
  47. @@ -552,10 +553,10 @@ static int uuid_generate_time_generic(uuid_t out) {
  48. * Start with a small cache size to cover short running applications
  49. * and adjust the cache size over the runntime.
  50. */
  51. - if ((last_used == cache_size) && (cache_size < cs_max))
  52. - cache_size *= cs_factor;
  53. - else if ((last_used < (cache_size / cs_factor)) && (cache_size > cs_min))
  54. - cache_size /= cs_factor;
  55. + if ((last_used == cache_size) && (cache_size < CS_MAX))
  56. + cache_size *= CS_FACTOR;
  57. + else if ((last_used < (cache_size / CS_FACTOR)) && (cache_size > CS_MIN))
  58. + cache_size /= CS_FACTOR;
  59. num = cache_size;
  60. @@ -568,7 +569,7 @@ static int uuid_generate_time_generic(uuid_t out) {
  61. }
  62. /* request to daemon failed, reset cache */
  63. num = 0;
  64. - cache_size = cs_min;
  65. + cache_size = CS_MIN;
  66. }
  67. if (num > 0) { /* serve uuid from cache */
  68. uu.time_low++;
  69. --
  70. 2.43.0