File: cpuset.c

package info (click to toggle)
nsd 4.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,260 kB
  • sloc: ansic: 64,435; sh: 4,351; python: 2,085; yacc: 1,344; makefile: 688
file content (80 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (4)
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
/*
 * cpuset.c -- CPU affinity.
 *
 * Copyright (c) 2020, NLnet Labs. All rights reserved.
 *
 * See LICENSE for the license.
 *
 */
#include "config.h"
#include "cpuset.h"

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

#ifndef HAVE_CPUSET_CREATE
cpuset_t *cpuset_create(void)
{
  cpuset_t *set = calloc(1, sizeof(*set));
  return set;
}
#endif /* !HAVE_CPUSET_CREATE */

#ifndef HAVE_CPUSET_DESTROY
void cpuset_destroy(cpuset_t *set)
{
  free(set);
}
#endif /* !HAVE_CPUSET_DESTROY */

#ifndef HAVE_CPUSET_ZERO
void cpuset_zero(cpuset_t *set)
{
  CPU_ZERO(set);
}
#endif /* !HAVE_CPUSET_ZERO */

#ifndef HAVE_CPUSET_SET
int cpuset_set(cpuid_t cpu, cpuset_t *set)
{
  CPU_SET(cpu, set);
  return 0;
}
#endif /* !HAVE_CPUSET_SET */

#ifndef HAVE_CPUSET_CLR
int cpuset_clr(cpuid_t cpu, cpuset_t *set)
{
  CPU_CLR(cpu, set);
  return 0;
}
#endif /* !HAVE_CPUSET_CLR */

#ifndef HAVE_CPUSET_ISSET
int cpuset_isset(cpuid_t cpu, const cpuset_t *set)
{
  return CPU_ISSET(cpu, set);
}
#endif /* !HAVE_CPUSET_ISSET */

#ifndef HAVE_CPUSET_SIZE
size_t cpuset_size(const cpuset_t *set)
{
  return sizeof(*set);
}
#endif /* !HAVE_CPUSET_SIZE */

#ifdef CPU_OR_THREE_ARGS
/* for Linux, use three arguments */
void cpuset_or(cpuset_t *destset, const cpuset_t *srcset)
{
  CPU_OR(destset, destset, srcset);
}
#else
/* for FreeBSD, use two arguments */
void cpuset_or(cpuset_t *destset, const cpuset_t *srcset)
{
  CPU_OR(destset, srcset);
}
#endif