#ifndef _SYS_CPUSET_H_
#define _SYS_CPUSET_H_
-#include <stdlib.h>
-#include <string.h>
+#include <sys/features.h>
#ifdef __cplusplus
extern "C" {
}
#define CPU_ALLOC(num) __cpuset_alloc (num)
-static __inline cpu_set_t *
-__cpuset_alloc (int num)
-{
- return (cpu_set_t *) malloc (CPU_ALLOC_SIZE(num));
-}
+extern cpu_set_t * __cpuset_alloc (int);
#define CPU_FREE(set) __cpuset_free (set)
-static __inline void
-__cpuset_free (cpu_set_t *set)
-{
- free (set);
-}
+void __cpuset_free (cpu_set_t *);
/* These _S macros operate on dynamically-sized cpu sets of size 'siz' bytes */
#define CPU_ZERO_S(siz, set) __cpuset_zero_s (siz, set)
-static __inline void
+static __inline
__cpuset_zero_s (size_t siz, cpu_set_t *set)
{
- (void) memset (set, 0, siz);
+#if __GNUC_PREREQ (2, 91)
+ __builtin_memset (set, 0, siz);
+#else
+ siz /= sizeof (__cpu_mask);
+ while (siz > 0)
+ set->_bits[--siz] = 0;
+#endif
}
#define CPU_SET_S(cpu, siz, set) __cpuset_set_s (cpu, siz, set)