-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos-windows-xp.h
70 lines (55 loc) · 1.44 KB
/
os-windows-xp.h
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
#define FIO_MAX_CPUS MAXIMUM_PROCESSORS
typedef DWORD_PTR os_cpu_mask_t;
static inline int fio_setaffinity(int pid, os_cpu_mask_t cpumask)
{
HANDLE h;
BOOL bSuccess = FALSE;
h = OpenThread(THREAD_QUERY_INFORMATION | THREAD_SET_INFORMATION, TRUE, pid);
if (h != NULL) {
bSuccess = SetThreadAffinityMask(h, cpumask);
if (!bSuccess)
log_err("fio_setaffinity failed: failed to set thread affinity (pid %d, mask %.16llx)\n", pid, cpumask);
CloseHandle(h);
} else {
log_err("fio_setaffinity failed: failed to get handle for pid %d\n", pid);
}
return (bSuccess)? 0 : -1;
}
static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask)
{
os_cpu_mask_t systemMask;
HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, TRUE, pid);
if (h != NULL) {
GetProcessAffinityMask(h, mask, &systemMask);
CloseHandle(h);
} else {
log_err("fio_getaffinity failed: failed to get handle for pid %d\n", pid);
return -1;
}
return 0;
}
static inline void fio_cpu_clear(os_cpu_mask_t *mask, int cpu)
{
*mask &= ~(1ULL << cpu);
}
static inline void fio_cpu_set(os_cpu_mask_t *mask, int cpu)
{
*mask |= 1ULL << cpu;
}
static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
{
return (*mask & (1ULL << cpu)) != 0;
}
static inline int fio_cpu_count(os_cpu_mask_t *mask)
{
return hweight64(*mask);
}
static inline int fio_cpuset_init(os_cpu_mask_t *mask)
{
*mask = 0;
return 0;
}
static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
{
return 0;
}