1
0

003-no-mallinfo.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --- a/lib/mm/memlock.c
  2. +++ b/lib/mm/memlock.c
  3. @@ -174,12 +174,15 @@ static void _allocate_memory(void)
  4. * memory on free(), this is good enough for our purposes.
  5. */
  6. while (missing > 0) {
  7. +#ifdef __GLIBC__
  8. struct mallinfo inf = mallinfo();
  9. hblks = inf.hblks;
  10. +#endif
  11. if ((areas[area] = malloc(_size_malloc_tmp)))
  12. _touch_memory(areas[area], _size_malloc_tmp);
  13. +#ifdef __GLIBC__
  14. inf = mallinfo();
  15. if (hblks < inf.hblks) {
  16. @@ -189,9 +192,12 @@ static void _allocate_memory(void)
  17. free(areas[area]);
  18. _size_malloc_tmp /= 2;
  19. } else {
  20. +#endif
  21. ++ area;
  22. missing -= _size_malloc_tmp;
  23. +#ifdef __GLIBC__
  24. }
  25. +#endif
  26. if (area == max_areas && missing > 0) {
  27. /* Too bad. Warn the user and proceed, as things are
  28. @@ -480,8 +486,13 @@ static void _lock_mem(struct cmd_context
  29. * will not block memory locked thread
  30. * Note: assuming _memlock_count_daemon is updated before _memlock_count
  31. */
  32. +#ifdef __GLIBC__
  33. _use_mlockall = _memlock_count_daemon ? 1 :
  34. find_config_tree_bool(cmd, activation_use_mlockall_CFG, NULL);
  35. +#else
  36. + /* always use mlockall on musl */
  37. + _use_mlockall = 1;
  38. +#endif
  39. if (!_use_mlockall) {
  40. if (!*_procselfmaps &&