summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorChristopher Michael <devilhorns@comcast.net>2021-02-25 08:25:29 -0500
committerChristopher Michael <devilhorns@comcast.net>2021-02-25 08:25:29 -0500
commitd70f9484c6e6e9a5034adb350d78f761481cb3b0 (patch)
tree9917fe3cf99f7e2af5f8f90f0772ffc88cc77083 /src/lib/ecore
parentc6f20933c61afd4732dc10adcb42ca26d6b7875e (diff)
ecore: Update to not use deprecated mallinfo
mallinfo (the structure) and mallinfo (the function) have both been deprecated in favor of mallinfo2 which has been updated to handle allocations > 4GB. This patch updates ecore usage of deprecated mallinfo to use mallinfo2. If the system does NOT have mallinfo2, then this code will fallback to using mallinfo.
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 0d79b621b2..0b4ba4a8fd 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -32,8 +32,8 @@
32#include "ecore_private.h" 32#include "ecore_private.h"
33#include "../../static_libs/buildsystem/buildsystem.h" 33#include "../../static_libs/buildsystem/buildsystem.h"
34 34
35#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) 35#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) || defined(HAVE_MALLINFO2)
36#include <malloc.h> 36# include <malloc.h>
37#endif 37#endif
38 38
39#ifndef O_BINARY 39#ifndef O_BINARY
@@ -45,14 +45,19 @@ EAPI Ecore_Version *ecore_version = &_version;
45 45
46EAPI double _efl_startup_time = 0; 46EAPI double _efl_startup_time = 0;
47 47
48#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) 48#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) || defined(HAVE_MALLINFO2)
49#define KEEP_MAX(Global, Local) \ 49# define KEEP_MAX(Global, Local) \
50 if (Global < (Local)) \ 50 if (Global < (Local)) \
51 Global = Local; 51 Global = Local;
52 52
53static Eina_Bool _ecore_memory_statistic(void *data); 53static Eina_Bool _ecore_memory_statistic(void *data);
54# ifdef HAVE_MALLINFO2
55static size_t _ecore_memory_max_total = 0;
56static size_t _ecore_memory_max_free = 0;
57# else
54static int _ecore_memory_max_total = 0; 58static int _ecore_memory_max_total = 0;
55static int _ecore_memory_max_free = 0; 59static int _ecore_memory_max_free = 0;
60# endif
56static pid_t _ecore_memory_pid = 0; 61static pid_t _ecore_memory_pid = 0;
57#ifdef HAVE_MALLOC_INFO 62#ifdef HAVE_MALLOC_INFO
58static FILE *_ecore_memory_statistic_file = NULL; 63static FILE *_ecore_memory_statistic_file = NULL;
@@ -291,7 +296,7 @@ ecore_init(void)
291 if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate(); 296 if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate();
292#endif 297#endif
293 298
294#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) 299#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) || defined(HAVE_MALLINFO2)
295 if (getenv("ECORE_MEM_STAT")) 300 if (getenv("ECORE_MEM_STAT"))
296 { 301 {
297#ifdef HAVE_MALLOC_INFO 302#ifdef HAVE_MALLOC_INFO
@@ -432,16 +437,22 @@ ecore_shutdown(void)
432 437
433 _ecore_main_loop_shutdown(); 438 _ecore_main_loop_shutdown();
434 439
435#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) 440#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) || defined(HAVE_MALLINFO2)
436 if (getenv("ECORE_MEM_STAT")) 441 if (getenv("ECORE_MEM_STAT"))
437 { 442 {
438 _ecore_memory_statistic(NULL); 443 _ecore_memory_statistic(NULL);
439 444
445 #ifdef HAVE_MALLINFO2
446 ERR("[%i] Memory MAX total: %lu, free: %lu",
447 _ecore_memory_pid,
448 _ecore_memory_max_total,
449 _ecore_memory_max_free);
450 #else
440 ERR("[%i] Memory MAX total: %i, free: %i", 451 ERR("[%i] Memory MAX total: %i, free: %i",
441 _ecore_memory_pid, 452 _ecore_memory_pid,
442 _ecore_memory_max_total, 453 _ecore_memory_max_total,
443 _ecore_memory_max_free); 454 _ecore_memory_max_free);
444 455 #endif
445 456
446#ifdef HAVE_MALLOC_INFO 457#ifdef HAVE_MALLOC_INFO
447 fclose(_ecore_memory_statistic_file); 458 fclose(_ecore_memory_statistic_file);
@@ -963,20 +974,30 @@ _systemd_watchdog_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
963} 974}
964#endif 975#endif
965 976
966#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) 977#if defined(HAVE_MALLINFO) || defined(HAVE_MALLOC_INFO) || defined(HAVE_MALLINFO2)
967static Eina_Bool 978static Eina_Bool
968_ecore_memory_statistic(EINA_UNUSED void *data) 979_ecore_memory_statistic(EINA_UNUSED void *data)
969{ 980{
970#ifdef HAVE_MALLOC_INFO 981#ifdef HAVE_MALLOC_INFO
971 static int frame = 0; 982 static int frame = 0;
972#endif 983#endif
973#ifdef HAVE_MALLINFO 984
985#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
986 Eina_Bool changed = EINA_FALSE;
987
988# if defined(HAVE_MALLINFO2)
989 struct mallinfo2 mi;
990 static size_t uordblks = 0;
991 static size_t fordblks = 0;
992
993 mi = mallinfo2();
994# else
974 struct mallinfo mi; 995 struct mallinfo mi;
975 static int uordblks = 0; 996 static int uordblks = 0;
976 static int fordblks = 0; 997 static int fordblks = 0;
977 Eina_Bool changed = EINA_FALSE;
978 998
979 mi = mallinfo(); 999 mi = mallinfo();
1000# endif
980 1001
981#define HAS_CHANGED(Global, Local) \ 1002#define HAS_CHANGED(Global, Local) \
982 if (Global != Local) \ 1003 if (Global != Local) \
@@ -989,14 +1010,24 @@ _ecore_memory_statistic(EINA_UNUSED void *data)
989 HAS_CHANGED(fordblks, mi.fordblks); 1010 HAS_CHANGED(fordblks, mi.fordblks);
990 1011
991 if (changed) 1012 if (changed)
992 ERR("[%i] Memory total: %i, free: %i", 1013 {
993 _ecore_memory_pid, 1014#ifdef HAVE_MALLINFO2
994 mi.uordblks, 1015 ERR("[%i] Memory total: %lu, free: %lu",
995 mi.fordblks); 1016 _ecore_memory_pid,
1017 mi.uordblks,
1018 mi.fordblks);
1019#else
1020 ERR("[%i] Memory total: %i, free: %i",
1021 _ecore_memory_pid,
1022 mi.uordblks,
1023 mi.fordblks);
1024#endif
1025 }
996 1026
997 KEEP_MAX(_ecore_memory_max_total, mi.uordblks); 1027 KEEP_MAX(_ecore_memory_max_total, mi.uordblks);
998 KEEP_MAX(_ecore_memory_max_free, mi.fordblks); 1028 KEEP_MAX(_ecore_memory_max_free, mi.fordblks);
999#endif 1029#endif
1030
1000#ifdef HAVE_MALLOC_INFO 1031#ifdef HAVE_MALLOC_INFO
1001 if (frame) fputs("\n", _ecore_memory_statistic_file); 1032 if (frame) fputs("\n", _ecore_memory_statistic_file);
1002 malloc_info(0, _ecore_memory_statistic_file); 1033 malloc_info(0, _ecore_memory_statistic_file);