jevents.c (8e69ae1c97e26811a15e0428a1e4e70f74e0c9f4) | jevents.c (b3d01a2ad7f16bb20f6fb58bb34f9339396c0075) |
---|---|
1#define _XOPEN_SOURCE 500 /* needed for nftw() */ 2#define __BSD_VISIBLE 1 /* needed for asprintf() */ | |
3/* Parse event JSON files */ 4 5/* 6 * Copyright (c) 2014, Intel Corporation 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are met: --- 17 unchanged lines hidden (view full) --- 28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 * OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * $FreeBSD$ 33 * 34*/ 35 | 1/* Parse event JSON files */ 2 3/* 4 * Copyright (c) 2014, Intel Corporation 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: --- 17 unchanged lines hidden (view full) --- 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 * OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * $FreeBSD$ 31 * 32*/ 33 |
36 | 34#include <sys/param.h> 35#include <sys/resource.h> /* getrlimit */ 36#include <sys/stat.h> 37#include <sys/time.h> /* getrlimit */ 38#include <ctype.h> 39#include <dirent.h> 40#include <errno.h> 41#include <libgen.h> 42#include <limits.h> 43#include <stdarg.h> |
37#include <stddef.h> 38#include <stdio.h> 39#include <stdlib.h> | 44#include <stddef.h> 45#include <stdio.h> 46#include <stdlib.h> |
40#include <errno.h> | |
41#include <string.h> | 47#include <string.h> |
42#include <ctype.h> | |
43#include <unistd.h> | 48#include <unistd.h> |
44#include <stdarg.h> 45#include <libgen.h> 46#include <limits.h> 47#include <dirent.h> 48#include <sys/time.h> /* getrlimit */ 49#include <sys/resource.h> /* getrlimit */ | |
50#include <ftw.h> | 49#include <ftw.h> |
51#include <sys/stat.h> | |
52#include "list.h" 53#include "jsmn.h" 54#include "json.h" 55#include "jevents.h" 56 57static int 58nftw_ordered(const char *path, int (*fn)(const char *, const struct stat *, int, 59 struct FTW *), int nfds, int ftwflags); --- 576 unchanged lines hidden (view full) --- 636 if (precise && desc && !strstr(desc, "(Precise Event)")) { 637 if (json_streq(map, precise, "2")) 638 addfield(map, &extra_desc, " ", 639 "(Must be precise)", NULL); 640 else 641 addfield(map, &extra_desc, " ", 642 "(Precise event)", NULL); 643 } | 50#include "list.h" 51#include "jsmn.h" 52#include "json.h" 53#include "jevents.h" 54 55static int 56nftw_ordered(const char *path, int (*fn)(const char *, const struct stat *, int, 57 struct FTW *), int nfds, int ftwflags); --- 576 unchanged lines hidden (view full) --- 634 if (precise && desc && !strstr(desc, "(Precise Event)")) { 635 if (json_streq(map, precise, "2")) 636 addfield(map, &extra_desc, " ", 637 "(Must be precise)", NULL); 638 else 639 addfield(map, &extra_desc, " ", 640 "(Precise event)", NULL); 641 } |
644 snprintf(buf, sizeof buf, "event=%#llx", eventcode); | 642 snprintf(buf, sizeof(buf), "event=%#llx", eventcode); |
645 addfield(map, &event, ",", buf, NULL); 646 if (desc && extra_desc) 647 addfield(map, &desc, " ", extra_desc, NULL); 648 if (long_desc && extra_desc) 649 addfield(map, &long_desc, " ", extra_desc, NULL); 650 if (filter) 651 addfield(map, &event, ",", filter, NULL); 652 if (msr != NULL) --- 208 unchanged lines hidden (view full) --- 861 862static int get_maxfds(void) 863{ 864 struct rlimit rlim; 865 866 if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { 867 if (rlim.rlim_max == RLIM_INFINITY) 868 return 512; | 643 addfield(map, &event, ",", buf, NULL); 644 if (desc && extra_desc) 645 addfield(map, &desc, " ", extra_desc, NULL); 646 if (long_desc && extra_desc) 647 addfield(map, &long_desc, " ", extra_desc, NULL); 648 if (filter) 649 addfield(map, &event, ",", filter, NULL); 650 if (msr != NULL) --- 208 unchanged lines hidden (view full) --- 859 860static int get_maxfds(void) 861{ 862 struct rlimit rlim; 863 864 if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { 865 if (rlim.rlim_max == RLIM_INFINITY) 866 return 512; |
869 return min((unsigned)rlim.rlim_max / 2, 512); | 867 return MIN(rlim.rlim_max / 2, 512); |
870 } 871 872 return 512; 873} 874 875/* 876 * nftw() doesn't let us pass an argument to the processing function, 877 * so use a global variables. --- 385 unchanged lines hidden --- | 868 } 869 870 return 512; 871} 872 873/* 874 * nftw() doesn't let us pass an argument to the processing function, 875 * so use a global variables. --- 385 unchanged lines hidden --- |