Print this page
11972 resync smatch

*** 1,7 **** --- 1,8 ---- /* * Copyright (C) 2018 Oracle. + * Copyright 2019 Joyent, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version.
*** 16,34 **** */ #include "smatch.h" #include <fcntl.h> #include <unistd.h> #include <sys/procfs.h> static int my_id; - static int my_fd = -2; static unsigned long max_size; unsigned long get_mem_kb(void) { prpsinfo_t pbuf; if (my_fd == -2) { /* Do not repeatedly attempt this if it fails. */ my_fd = open("/proc/self/psinfo", O_RDONLY); --- 17,38 ---- */ #include "smatch.h" #include <fcntl.h> #include <unistd.h> + #ifdef __sun #include <sys/procfs.h> + #endif static int my_id; static unsigned long max_size; + #ifdef __sun unsigned long get_mem_kb(void) { + static int my_fd = -2; prpsinfo_t pbuf; if (my_fd == -2) { /* Do not repeatedly attempt this if it fails. */ my_fd = open("/proc/self/psinfo", O_RDONLY);
*** 41,51 **** --- 45,73 ---- return (0); } return (pbuf.pr_rssize); } + #else + unsigned long get_mem_kb(void) + { + FILE *file; + char buf[1024] = "0"; + unsigned long size; + file = fopen("/proc/self/statm", "r"); + if (!file) + return 0; + fread(buf, 1, sizeof(buf), file); + fclose(file); + + size = strtoul(buf, NULL, 10); + size = size * sysconf(_SC_PAGESIZE) / 1024; + return size; + } + #endif + static void match_end_func(struct symbol *sym) { unsigned long size; if (option_mem) {