Home | History | Annotate | Download | only in linux
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef __LINUX_NODEMASK_H
     13 #define __LINUX_NODEMASK_H
     14 
     15 #include <linux/kernel.h>
     16 #include <linux/threads.h>
     17 #include <linux/bitmap.h>
     18 #include <linux/numa.h>
     19 
     20 typedef struct { DECLARE_BITMAP(bits, MAX_NUMNODES); } nodemask_t;
     21 
     22 #define node_set(node, dst) __node_set((node), &(dst))
     23 #define node_clear(node, dst) __node_clear((node), &(dst))
     24 #define nodes_setall(dst) __nodes_setall(&(dst), MAX_NUMNODES)
     25 #define nodes_clear(dst) __nodes_clear(&(dst), MAX_NUMNODES)
     26 #define node_isset(node, nodemask) test_bit((node), (nodemask).bits)
     27 #define node_test_and_set(node, nodemask)   __node_test_and_set((node), &(nodemask))
     28 #define nodes_and(dst, src1, src2)   __nodes_and(&(dst), &(src1), &(src2), MAX_NUMNODES)
     29 #define nodes_or(dst, src1, src2)   __nodes_or(&(dst), &(src1), &(src2), MAX_NUMNODES)
     30 #define nodes_xor(dst, src1, src2)   __nodes_xor(&(dst), &(src1), &(src2), MAX_NUMNODES)
     31 #define nodes_andnot(dst, src1, src2)   __nodes_andnot(&(dst), &(src1), &(src2), MAX_NUMNODES)
     32 #define nodes_complement(dst, src)   __nodes_complement(&(dst), &(src), MAX_NUMNODES)
     33 #define nodes_equal(src1, src2)   __nodes_equal(&(src1), &(src2), MAX_NUMNODES)
     34 #define nodes_intersects(src1, src2)   __nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
     35 #define nodes_subset(src1, src2)   __nodes_subset(&(src1), &(src2), MAX_NUMNODES)
     36 #define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
     37 #define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
     38 #define nodes_weight(nodemask) __nodes_weight(&(nodemask), MAX_NUMNODES)
     39 #define nodes_shift_right(dst, src, n)   __nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
     40 #define nodes_shift_left(dst, src, n)   __nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
     41 #define first_node(src) __first_node(&(src))
     42 #define next_node(n, src) __next_node((n), &(src))
     43 #define nodemask_of_node(node)  ({   typeof(_unused_nodemask_arg_) m;   if (sizeof(m) == sizeof(unsigned long)) {   m.bits[0] = 1UL<<(node);   } else {   nodes_clear(m);   node_set((node), m);   }   m;  })
     44 #define first_unset_node(mask) __first_unset_node(&(mask))
     45 #define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES)
     46 #if MAX_NUMNODES <= BITS_PER_LONG
     47 #define NODE_MASK_ALL  ((nodemask_t) { {   [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD  } })
     48 #else
     49 #define NODE_MASK_ALL  ((nodemask_t) { {   [0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL,   [BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD  } })
     50 #endif
     51 #define NODE_MASK_NONE  ((nodemask_t) { {   [0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] = 0UL  } })
     52 #define nodes_addr(src) ((src).bits)
     53 #define nodemask_scnprintf(buf, len, src)   __nodemask_scnprintf((buf), (len), &(src), MAX_NUMNODES)
     54 #define nodemask_parse(ubuf, ulen, dst)   __nodemask_parse((ubuf), (ulen), &(dst), MAX_NUMNODES)
     55 #define nodelist_scnprintf(buf, len, src)   __nodelist_scnprintf((buf), (len), &(src), MAX_NUMNODES)
     56 #define nodelist_parse(buf, dst) __nodelist_parse((buf), &(dst), MAX_NUMNODES)
     57 #define node_remap(oldbit, old, new)   __node_remap((oldbit), &(old), &(new), MAX_NUMNODES)
     58 #define nodes_remap(dst, src, old, new)   __nodes_remap(&(dst), &(src), &(old), &(new), MAX_NUMNODES)
     59 #if MAX_NUMNODES > 1
     60 #define for_each_node_mask(node, mask)   for ((node) = first_node(mask);   (node) < MAX_NUMNODES;   (node) = next_node((node), (mask)))
     61 #else
     62 #define for_each_node_mask(node, mask)   if (!nodes_empty(mask))   for ((node) = 0; (node) < 1; (node)++)
     63 #endif
     64 
     65 #if MAX_NUMNODES > 1
     66 #define num_online_nodes() nodes_weight(node_online_map)
     67 #define num_possible_nodes() nodes_weight(node_possible_map)
     68 #define node_online(node) node_isset((node), node_online_map)
     69 #define node_possible(node) node_isset((node), node_possible_map)
     70 #define first_online_node first_node(node_online_map)
     71 #define next_online_node(nid) next_node((nid), node_online_map)
     72 #else
     73 #define num_online_nodes() 1
     74 #define num_possible_nodes() 1
     75 #define node_online(node) ((node) == 0)
     76 #define node_possible(node) ((node) == 0)
     77 #define first_online_node 0
     78 #define next_online_node(nid) (MAX_NUMNODES)
     79 #endif
     80 
     81 #define any_online_node(mask)  ({   int node;   for_each_node_mask(node, (mask))   if (node_online(node))   break;   node;  })
     82 
     83 #define node_set_online(node) set_bit((node), node_online_map.bits)
     84 #define node_set_offline(node) clear_bit((node), node_online_map.bits)
     85 
     86 #define for_each_node(node) for_each_node_mask((node), node_possible_map)
     87 #define for_each_online_node(node) for_each_node_mask((node), node_online_map)
     88 
     89 #endif
     90