Merge commit 'refs/pull/2003/head' of github.com:KLayout/klayout

This commit is contained in:
Matthias Koefferlein 2025-03-23 18:38:42 +01:00
commit db728dc68a
1 changed files with 15 additions and 2 deletions

View File

@ -33,6 +33,7 @@
# include <mach/mach.h>
# include <sys/times.h>
# include <unistd.h>
# include <libproc.h>
#else
# include <sys/times.h>
# include <unistd.h>
@ -206,8 +207,19 @@ Timer::memory_size ()
return mem;
#else
#elif defined(__APPLE__)
pid_t pid = getpid();
struct proc_taskinfo taskinfo;
if (proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &taskinfo, sizeof(taskinfo)) <= 0) {
perror("proc_pidinfo failed");
return 0;
}
return taskinfo.pti_resident_size;
#elif defined(__linux__)
unsigned long memsize = 0;
FILE *procfile = fopen ("/proc/self/stat", "r");
if (procfile != NULL) {
@ -258,9 +270,10 @@ Timer::memory_size ()
memsize = 0;
}
}
return size_t (memsize);
#else
# error Unsupported platform
#endif
}