Workaround build issue: include gperf file verbatim 26/227826/2
authorMichal Bloch <m.bloch@partner.samsung.com>
Mon, 16 Mar 2020 11:38:28 +0000 (12:38 +0100)
committerMichal Bloch <m.bloch@partner.samsung.com>
Tue, 17 Mar 2020 10:47:40 +0000 (11:47 +0100)
Change-Id: Ib851cc25d9a2e53851ab22cc01f10217d8a7ef64
Signed-off-by: Michal Bloch <m.bloch@partner.samsung.com>
src/CMakeLists.txt
src/common/smaps-lookup.c [new file with mode: 0644]

index e9b1375..0de8716 100644 (file)
@@ -12,7 +12,9 @@ INCLUDE(${CMAKE_SOURCE_DIR}/cmake/InstallSymlink.cmake)
 INCLUDE(${CMAKE_SOURCE_DIR}/cmake/ProcessGPERF.cmake)
 INCLUDE(GNUInstallDirs)
 
-PROCESS_GPERF(${COMMON_SOURCE_DIR}/smaps-lookup.gperf ${COMMON_SOURCE_DIR}/smaps-lookup.c)
+# File generated once and included verbatim due to build environment issues
+# PROCESS_GPERF(${COMMON_SOURCE_DIR}/smaps-lookup.gperf ${COMMON_SOURCE_DIR}/smaps-lookup.c)
+
 PROCESS_GPERF(${COMMON_SOURCE_DIR}/cgroup-memory-stat-lookup.gperf ${COMMON_SOURCE_DIR}/cgroup-memory-stat-lookup.c)
 PROCESS_GPERF(${COMMON_SOURCE_DIR}/meminfo-lookup.gperf ${COMMON_SOURCE_DIR}/meminfo-lookup.c)
 SET(RESOURCED_SHARED_SOURCES ${RESOURCED_SHARED_SOURCES}
diff --git a/src/common/smaps-lookup.c b/src/common/smaps-lookup.c
new file mode 100644 (file)
index 0000000..9a2b3f7
--- /dev/null
@@ -0,0 +1,133 @@
+/* NOTE: this file was dynamically generated by gperf but is included verbatim (instead of
+ * being regenerated) due to various build environment issues */
+
+/* ANSI-C code produced by gperf version 3.0.4 */
+/* Command-line: gperf /home/abuild/rpmbuild/BUILD/resourced-6.0.2/src/common/smaps-lookup.gperf  */
+/* Computed positions: -k'1,$' */
+
+#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+      && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+      && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+      && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+      && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+      && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+      && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+      && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+      && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+      && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+      && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+      && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+      && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+      && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+      && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+      && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+      && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+      && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+      && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+      && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+      && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+      && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+      && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
+/* The character set is not based on ISO-646.  */
+#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
+#endif
+
+#include "smaps.h"
+#include <string.h>
+
+#define TOTAL_KEYWORDS 15
+#define MIN_WORD_LENGTH 3
+#define MAX_WORD_LENGTH 14
+#define MIN_HASH_VALUE 3
+#define MAX_HASH_VALUE 24
+/* maximum key range = 22, duplicates = 0 */
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static unsigned int
+smap_mapping_hash (register const char *str, register unsigned int len)
+{
+  static const unsigned char asso_values[] =
+    {
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 10, 25, 25, 25, 25,
+      25, 25, 25, 25, 25,  5,  0,  0, 25, 25,
+       0, 25,  5,  0, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+       0,  5, 25, 25, 25, 25, 25, 25, 25, 25,
+       5, 25,  0, 25, 25,  0, 25, 25, 25, 25,
+      25,  0, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+      25, 25, 25, 25, 25, 25
+    };
+  return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
+}
+
+#ifdef __GNUC__
+__inline
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
+#endif
+const smap_mapping *
+smap_mapping_lookup (register const char *str, register unsigned int len)
+{
+  static const smap_mapping wordlist[] =
+    {
+      {""}, {""}, {""},
+      {"Pss",            SMAPS_ID_PSS},
+      {"Swap",           SMAPS_ID_SWAP},
+      {"PSwap",          SMAPS_ID_PSWAP},
+      {"Locked",         SMAPS_ID_LOCKED},
+      {""},
+      {"Rss",            SMAPS_ID_RSS},
+      {"Size",           SMAPS_ID_SIZE},
+      {""}, {""},
+      {"Shared_Dirty",   SMAPS_ID_SHARED_DIRTY},
+      {"Private_Dirty",  SMAPS_ID_PRIVATE_DIRTY}, // patrollin' tryna catch me private dirty
+      {""},
+      {"Referenced",     SMAPS_ID_REFERENCED},
+      {"MMUPageSize",    SMAPS_ID_MMU_PAGE_SIZE},
+      {"Shared_Clean",   SMAPS_ID_SHARED_CLEAN},
+      {"Private_Clean",  SMAPS_ID_PRIVATE_CLEAN},
+      {"Anonymous",      SMAPS_ID_ANONYMOUS},
+      {""}, {""}, {""},
+      {"AnonHugePages",  SMAPS_ID_ANON_HUGE_PAGES},
+      {"KernelPageSize", SMAPS_ID_KERNEL_PAGE_SIZE}
+    };
+
+  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
+    {
+      register int key = smap_mapping_hash (str, len);
+
+      if (key <= MAX_HASH_VALUE && key >= 0)
+        {
+          register const char *s = wordlist[key].name;
+
+          if (*str == *s && !strcmp (str + 1, s + 1))
+            return &wordlist[key];
+        }
+    }
+  return 0;
+}