00001
00002
00003
00004
00005
00006
00007
00008
00013 #ifndef HWLOC_BITMAP_H
00014 #define HWLOC_BITMAP_H
00015
00016 #include <hwloc/config.h>
00017 #include <assert.h>
00018
00019
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023
00024
00045 typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
00047 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
00048
00049
00050
00051
00052
00053
00060 hwloc_bitmap_t hwloc_bitmap_alloc(void) ;
00061
00063 hwloc_bitmap_t hwloc_bitmap_alloc_full(void) ;
00064
00066 void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
00067
00069 hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) ;
00070
00072 void hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
00073
00074
00075
00076
00077
00078
00088 int hwloc_bitmap_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
00089
00092 int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
00093
00096 int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
00097
00110 int hwloc_bitmap_taskset_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
00111
00114 int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
00115
00118 int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
00119
00120
00121
00122
00123
00124
00126 void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
00127
00129 void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
00130
00132 void hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
00133
00135 void hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
00136
00138 void hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
00139
00141 void hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
00142
00143
00144
00145
00146
00147
00149 void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
00150
00152 void hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, unsigned end);
00153
00155 void hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
00156
00158 void hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
00159
00161 void hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, unsigned end);
00162
00169 void hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
00170
00171
00172
00173
00174
00175
00177 unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) ;
00178
00180 unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) ;
00181
00183 int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) ;
00184
00186 int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) ;
00187
00189 int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) ;
00190
00195 int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) ;
00196
00201 int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, unsigned prev) ;
00202
00207 int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) ;
00208
00214 int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) ;
00215
00227 #define hwloc_bitmap_foreach_begin(id, bitmap) \
00228 do { \
00229 assert(hwloc_bitmap_weight(bitmap) != -1); \
00230 for (id = hwloc_bitmap_first(bitmap); \
00231 (unsigned) id != (unsigned) -1; \
00232 id = hwloc_bitmap_next(bitmap, id)) { \
00233
00237 #define hwloc_bitmap_foreach_end() \
00238 } \
00239 } while (0)
00240
00241
00242
00243
00244
00245
00247 void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00248
00250 void hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00251
00253 void hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00254
00256 void hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00257
00259 void hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
00260
00261
00262
00263
00264
00265
00267 int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
00268
00270 int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) ;
00271
00273 int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
00274
00280 int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
00281
00287 int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
00288
00292 #ifdef __cplusplus
00293 }
00294 #endif
00295
00296
00297 #endif