Skip to content

Commit db728dc

Browse files
author
Matthias Koefferlein
committed
Merge commit 'refs/pull/2003/head' of github.com:KLayout/klayout
2 parents b748579 + b8a6d0a commit db728dc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/tl/tl/tlTimer.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
# include <mach/mach.h>
3434
# include <sys/times.h>
3535
# include <unistd.h>
36+
# include <libproc.h>
3637
#else
3738
# include <sys/times.h>
3839
# include <unistd.h>
@@ -206,8 +207,19 @@ Timer::memory_size ()
206207

207208
return mem;
208209

209-
#else
210+
#elif defined(__APPLE__)
210211

212+
pid_t pid = getpid();
213+
struct proc_taskinfo taskinfo;
214+
if (proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &taskinfo, sizeof(taskinfo)) <= 0) {
215+
perror("proc_pidinfo failed");
216+
return 0;
217+
}
218+
219+
return taskinfo.pti_resident_size;
220+
221+
#elif defined(__linux__)
222+
211223
unsigned long memsize = 0;
212224
FILE *procfile = fopen ("/proc/self/stat", "r");
213225
if (procfile != NULL) {
@@ -258,9 +270,10 @@ Timer::memory_size ()
258270
memsize = 0;
259271
}
260272
}
261-
262273
return size_t (memsize);
263274

275+
#else
276+
# error Unsupported platform
264277
#endif
265278
}
266279

0 commit comments

Comments
 (0)