Mercurial > minori
comparison dep/animia/src/fd.cc @ 202:71832ffe425a
animia: re-add kvm fd source
this is all being merged from my wildly out-of-date laptop. SORRY!
in other news, I edited the CI file to install the wayland client
as well, so the linux CI build might finally get wayland stuff.
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Tue, 02 Jan 2024 06:05:06 -0500 |
parents | 8f6f8dd2eb23 bc1ae1810855 |
children |
comparison
equal
deleted
inserted
replaced
201:8f6f8dd2eb23 | 202:71832ffe425a |
---|---|
1 #include "animia/fd.h" | 1 #include "animia/fd.h" |
2 | 2 |
3 #ifdef WIN32 | 3 #ifdef WIN32 |
4 # include "animia/fd/win32.h" | 4 # include "animia/fd/win32.h" |
5 #elif defined(LINUX) || defined(FREEBSD) | 5 #endif |
6 | |
7 #ifdef LINUX | |
6 # include "animia/fd/proc.h" | 8 # include "animia/fd/proc.h" |
7 #elif defined(MACOSX) | 9 #endif |
10 | |
11 #ifdef MACOSX | |
8 # include "animia/fd/xnu.h" | 12 # include "animia/fd/xnu.h" |
9 #elif defined(LIBUTIL) | 13 #endif |
10 # include "animia/fd/libutil.h" | 14 |
11 #elif defined(LIBKVM) | 15 #ifdef LIBUTIL |
12 # include "animia/fd/kvm.h" | 16 # include "animia/fd/libutil.h" |
17 #endif | |
18 | |
19 #ifdef LIBKVM | |
20 # include "animia/fd/kvm.h" | |
13 #endif | 21 #endif |
14 | 22 |
15 namespace animia::internal { | 23 namespace animia::internal { |
16 | 24 |
25 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) { | |
26 bool success = false; | |
27 | |
17 #ifdef WIN32 | 28 #ifdef WIN32 |
18 win32::Win32FdTools os_fd; | 29 success ^= win32::EnumerateOpenFiles(pids, open_file_proc); |
19 #elif defined(LINUX) || defined(FREEBSD) | |
20 proc::ProcFdTools os_fd; | |
21 #elif defined(MACOSX) | |
22 xnu::XnuFdTools os_fd; | |
23 #elif defined(LIBUTIL) | |
24 libutil::LibutilFdTools os_fd; | |
25 #elif defined(LIBKVM) | |
26 kvm::KvmFdTools os_fd; | |
27 #else | |
28 BaseFdTools os_fd; | |
29 #endif | 30 #endif |
30 | 31 |
31 BaseFdTools& fd = os_fd; | 32 #ifdef LINUX |
33 success ^= proc::EnumerateOpenFiles(pids, open_file_proc); | |
34 #endif | |
35 | |
36 #ifdef MACOSX | |
37 success ^= xnu::EnumerateOpenFiles(pids, open_file_proc); | |
38 #endif | |
39 | |
40 #ifdef LIBUTIL | |
41 success ^= libutil::EnumerateOpenFiles(pids, open_file_proc); | |
42 #endif | |
43 | |
44 #ifdef LIBKVM | |
45 success ^= kvm::EnumerateOpenFiles(pids, open_file_proc); | |
46 #endif | |
47 | |
48 return success; | |
49 } | |
50 | |
51 bool EnumerateOpenProcesses(process_proc_t process_proc) { | |
52 bool success = false; | |
53 | |
54 #ifdef WIN32 | |
55 success ^= win32::EnumerateOpenProcesses(process_proc); | |
56 #endif | |
57 | |
58 #ifdef LINUX | |
59 success ^= proc::EnumerateOpenProcesses(process_proc); | |
60 #endif | |
61 | |
62 #ifdef MACOSX | |
63 success ^= xnu::EnumerateOpenProcesses(process_proc); | |
64 #endif | |
65 | |
66 #ifdef LIBUTIL | |
67 success ^= libutil::EnumerateOpenProcesses(process_proc); | |
68 #endif | |
69 | |
70 #ifdef LIBKVM | |
71 success ^= kvm::EnumerateOpenProcesses(process_proc); | |
72 #endif | |
73 | |
74 return success; | |
75 } | |
32 | 76 |
33 } // namespace animia::internal | 77 } // namespace animia::internal |