summaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/bits/sched.h35
-rw-r--r--sysdeps/generic/sched_getaffinity.c7
-rw-r--r--sysdeps/generic/sched_setaffinity.c5
3 files changed, 39 insertions, 8 deletions
diff --git a/sysdeps/generic/bits/sched.h b/sysdeps/generic/bits/sched.h
index d0d655d48e..fc754bff51 100644
--- a/sysdeps/generic/bits/sched.h
+++ b/sysdeps/generic/bits/sched.h
@@ -1,6 +1,6 @@
/* Definitions of constants and data structure for POSIX 1003.1b-1993
scheduling interface.
- Copyright (C) 1996, 1997, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 2001, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -33,3 +33,36 @@ struct sched_param
{
int __sched_priority;
};
+
+
+/* Size definition for CPU sets. */
+#define __CPU_SETSIZE 1024
+#define __NCPUBITS (8 * sizeof (__cpu_mask))
+
+/* Type for array elements in 'cpu_set'. */
+typedef unsigned long int __cpu_mask;
+
+/* Basic access functions. */
+#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
+#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
+
+/* Data structure to describe CPU mask. */
+typedef struct
+{
+ __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+
+/* Access functions for CPU masks. */
+#define __CPU_ZERO(cpusetp) \
+ do { \
+ unsigned int __i; \
+ cpu_set *__arr = (cpusetp); \
+ for (__i = 0; __i < sizeof (cpu_set) / sizeof (__cpu_mask); ++__i) \
+ __arr->__bits[__i] = 0; \
+ } while (0)
+#define __CPU_SET(cpu, cpusetp) \
+ ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu))
+#define __CPU_CLR(cpu, cpusetp) \
+ ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu))
+#define __CPU_ISSET(cpu, cpusetp) \
+ (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0)
diff --git a/sysdeps/generic/sched_getaffinity.c b/sysdeps/generic/sched_getaffinity.c
index 5c444cb5c8..b9b7207d3f 100644
--- a/sysdeps/generic/sched_getaffinity.c
+++ b/sysdeps/generic/sched_getaffinity.c
@@ -17,16 +17,15 @@
02111-1307 USA. */
#include <errno.h>
-#include <sys/types.h>
#include <sched.h>
+#include <sys/types.h>
/* Retrieve the CPU affinity mask for a particular process. */
int
-sched_getaffinity (pid, len, mask)
+sched_getaffinity (pid, cpuset)
pid_t pid;
- unsigned int len;
- unsigned long int *mask;
+ cpu_set_t *cpuset;
{
__set_errno (ENOSYS);
return -1;
diff --git a/sysdeps/generic/sched_setaffinity.c b/sysdeps/generic/sched_setaffinity.c
index e734e70b91..4f85c54a6f 100644
--- a/sysdeps/generic/sched_setaffinity.c
+++ b/sysdeps/generic/sched_setaffinity.c
@@ -23,10 +23,9 @@
/* Retrieve the CPU affinity mask for a particular process. */
int
-sched_setaffinity (pid, len, mask)
+sched_setaffinity (pid, mask)
pid_t pid;
- unsigned int len;
- unsigned long int *mask;
+ const cpu_set_t *cpuset;
{
__set_errno (ENOSYS);
return -1;