~ubuntu-branches/ubuntu/precise/util-linux/precise-proposed

« back to all changes in this revision

Viewing changes to include/cpuset.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-06-20 22:31:50 UTC
  • mfrom: (1.6.3 upstream) (4.5.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110620223150-lz8wrv0946ihcz3z
Tags: 2.19.1-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
* Dropped changes:
  - mount.preinst: lsb_release has been fixed in lucid and above to be
    usable without configuration, so we don't have to diverge from Debian
    here anymore.
* Changes merged upstream:
  - sfdisk support for '+' with '-N'
  - mount/umount.c: fix a segfault on umount with empty mtab entry
  - Fix arbitrary unmount with fuse security issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef UTIL_LINUX_CPUSET_H
 
2
#define UTIL_LINUX_CPUSET_H
 
3
 
 
4
#include <sched.h>
 
5
 
 
6
/*
 
7
 * Fallback for old or obscure libcs without dynamically allocated cpusets
 
8
 *
 
9
 * The following macros are based on code from glibc.
 
10
 *
 
11
 * The GNU C Library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Lesser General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2.1 of the License, or (at your option) any later version.
 
15
 */
 
16
#if !HAVE_DECL_CPU_ALLOC
 
17
 
 
18
# define CPU_ZERO_S(setsize, cpusetp) \
 
19
  do {                                                                        \
 
20
    size_t __i;                                                               \
 
21
    size_t __imax = (setsize) / sizeof (__cpu_mask);                          \
 
22
    __cpu_mask *__bits = (cpusetp)->__bits;                                   \
 
23
    for (__i = 0; __i < __imax; ++__i)                                        \
 
24
      __bits[__i] = 0;                                                        \
 
25
  } while (0)
 
26
 
 
27
# define CPU_SET_S(cpu, setsize, cpusetp) \
 
28
   ({ size_t __cpu = (cpu);                                                   \
 
29
      __cpu < 8 * (setsize)                                                   \
 
30
      ? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]               \
 
31
         |= __CPUMASK (__cpu))                                                \
 
32
      : 0; })
 
33
 
 
34
# define CPU_ISSET_S(cpu, setsize, cpusetp) \
 
35
   ({ size_t __cpu = (cpu);                                                   \
 
36
      __cpu < 8 * (setsize)                                                   \
 
37
      ? ((((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)]              \
 
38
          & __CPUMASK (__cpu))) != 0                                          \
 
39
      : 0; })
 
40
 
 
41
# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
 
42
   ({ __cpu_mask *__arr1 = (cpusetp1)->__bits;                                \
 
43
      __cpu_mask *__arr2 = (cpusetp2)->__bits;                                \
 
44
      size_t __imax = (setsize) / sizeof (__cpu_mask);                        \
 
45
      size_t __i;                                                             \
 
46
      for (__i = 0; __i < __imax; ++__i)                                      \
 
47
        if (__arr1[__i] != __arr2[__i])                                       \
 
48
          break;                                                              \
 
49
      __i == __imax; })
 
50
 
 
51
extern int __cpuset_count_s(size_t setsize, const cpu_set_t *set);
 
52
# define CPU_COUNT_S(setsize, cpusetp)  __cpuset_count_s(setsize, cpusetp)
 
53
 
 
54
# define CPU_ALLOC_SIZE(count) \
 
55
          ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
 
56
# define CPU_ALLOC(count)       (malloc(CPU_ALLOC_SIZE(count)))
 
57
# define CPU_FREE(cpuset)       (free(cpuset))
 
58
 
 
59
#endif /* !HAVE_DECL_CPU_ALLOC */
 
60
 
 
61
 
 
62
#define cpuset_nbits(setsize)   (8 * (setsize))
 
63
 
 
64
extern int get_max_number_of_cpus(void);
 
65
 
 
66
extern cpu_set_t *cpuset_alloc(int ncpus, size_t *setsize, size_t *nbits);
 
67
extern void cpuset_free(cpu_set_t *set);
 
68
 
 
69
extern char *cpulist_create(char *str, size_t len, cpu_set_t *set, size_t setsize);
 
70
extern int cpulist_parse(const char *str, cpu_set_t *set, size_t setsize);
 
71
 
 
72
extern char *cpumask_create(char *str, size_t len, cpu_set_t *set, size_t setsize);
 
73
extern int cpumask_parse(const char *str, cpu_set_t *set, size_t setsize);
 
74
 
 
75
#endif /* UTIL_LINUX_CPUSET_H */