File: libproc-2.patch

package info (click to toggle)
apitrace 11.1%2Brepack-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,672 kB
  • sloc: cpp: 183,112; python: 33,685; ansic: 25,073; sh: 143; makefile: 88
file content (88 lines) | stat: -rw-r--r-- 2,832 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Description: Build for libproc2
 Replace libprocps with libproc2
Author: Craig Small <csmall@debian.org>
Reviewed-by: Craig Small <csmall@debian.org>
Last-Update: 2022-11-16
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
Index: apitrace-11.1+repack/lib/os/os_memory.hpp
===================================================================
--- apitrace-11.1+repack.orig/lib/os/os_memory.hpp
+++ apitrace-11.1+repack/lib/os/os_memory.hpp
@@ -30,13 +30,46 @@
 
 #pragma once
 
-#ifdef HAVE_READPROC_H
+#ifdef HAVE_LIBPROC2_PIDS_H
+#include <libproc2/pids.h>
+#elif defined(HAVE_READPROC_H)
 #include <proc/readproc.h>
 #endif
 
 namespace os {
 
-#if defined(HAVE_READPROC_H)
+#ifdef HAVE_LIBPROC2_PIDS_H
+    inline long long
+    getVsize(void) {
+        enum pids_item Item[] = {PIDS_VSIZE_BYTES};
+        struct pids_info *info = NULL;
+        struct pids_stack *stack;
+        unsigned long value=0;
+        if (
+            (procps_pids_new(&info, Item, 1) == 0) &&
+            ((stack = fatal_proc_unmounted(info, 1)) == NULL)) {
+            value = PIDS_VAL(0, ul_int, stack, info);
+        }
+        procps_pids_unref(&info);
+        return value;
+    }
+
+    inline long long
+    getRss(void) {
+        enum pids_item Item[] = {PIDS_RSS};
+        struct pids_info *info = NULL;
+        struct pids_stack *stack;
+        unsigned long value=0;
+        if (
+            (procps_pids_new(&info, Item, 1) == 0) &&
+            ((stack = fatal_proc_unmounted(info, 1)) == NULL)) {
+            value = PIDS_VAL(0, ul_int, stack, info);
+        }
+        procps_pids_unref(&info);
+        return value;
+    }
+
+#elif defined(HAVE_READPROC_H)
 
     inline long long
     getVsize(void) {
Index: apitrace-11.1+repack/CMakeLists.txt
===================================================================
--- apitrace-11.1+repack.orig/CMakeLists.txt
+++ apitrace-11.1+repack/CMakeLists.txt
@@ -490,6 +490,10 @@ if (NOT WIN32 AND NOT ENABLE_STATIC_EXE)
     if (PKG_CONFIG_FOUND)
         pkg_check_modules (BROTLIDEC IMPORTED_TARGET libbrotlidec>=1.0.7)
         pkg_check_modules (BROTLIENC IMPORTED_TARGET libbrotlienc>=1.0.7)
+        pkg_check_modules (LIBPROC2 IMPORTED_TARGET libproc2)
+        if (LIBPROC2_FOUND)
+            add_definitions (-DHAVE_LIBPROC2_PIDS_H)
+        endif ()
     endif ()
 
     find_package (GTest)
Index: apitrace-11.1+repack/lib/os/CMakeLists.txt
===================================================================
--- apitrace-11.1+repack.orig/lib/os/CMakeLists.txt
+++ apitrace-11.1+repack/lib/os/CMakeLists.txt
@@ -38,3 +38,8 @@ if (BUILD_TESTING)
     add_gtest (os_thread_test os_thread_test.cpp)
     target_link_libraries (os_thread_test os)
 endif ()
+
+if (LIBPROC2_FOUND)
+    target_link_libraries(os PUBLIC PkgConfig::LIBPROC2)
+endif ()
+