• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

bitmap.h

00001 /*
00002  * Copyright © 2009 CNRS
00003  * Copyright © 2009-2010 INRIA
00004  * Copyright © 2009-2010 Université Bordeaux 1
00005  * Copyright © 2009-2010 Cisco Systems, Inc.  All rights reserved.
00006  * See COPYING in top-level directory.
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 
00039 typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
00040 typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
00041 
00042 
00043 /*
00044  * Bitmap allocation, freeing and copying.
00045  */
00046 
00053 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc(void) __hwloc_attribute_malloc;
00054 
00056 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_alloc_full(void) __hwloc_attribute_malloc;
00057 
00059 HWLOC_DECLSPEC void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
00060 
00062 HWLOC_DECLSPEC hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) __hwloc_attribute_malloc;
00063 
00065 HWLOC_DECLSPEC void hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
00066 
00067 
00068 /*
00069  * Bitmap/String Conversion
00070  */
00071 
00079 HWLOC_DECLSPEC int hwloc_bitmap_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
00080 
00086 HWLOC_DECLSPEC int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
00087 
00092 HWLOC_DECLSPEC int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
00093 
00099 HWLOC_DECLSPEC int hwloc_bitmap_taskset_snprintf(char * __hwloc_restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
00100 
00103 HWLOC_DECLSPEC int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
00104 
00107 HWLOC_DECLSPEC int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * __hwloc_restrict string);
00108 
00109 
00110 /*
00111  * Building bitmaps.
00112  */
00113 
00115 HWLOC_DECLSPEC void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
00116 
00118 HWLOC_DECLSPEC void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
00119 
00121 HWLOC_DECLSPEC void hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
00122 
00124 HWLOC_DECLSPEC void hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
00125 
00127 HWLOC_DECLSPEC void hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
00128 
00130 HWLOC_DECLSPEC void hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
00131 
00132 
00133 /*
00134  * Modifying bitmaps.
00135  */
00136 
00138 HWLOC_DECLSPEC void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
00139 
00141 HWLOC_DECLSPEC void hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, unsigned end);
00142 
00144 HWLOC_DECLSPEC void hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
00145 
00147 HWLOC_DECLSPEC void hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
00148 
00150 HWLOC_DECLSPEC void hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, unsigned end);
00151 
00158 HWLOC_DECLSPEC void hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
00159 
00160 
00161 /*
00162  * Consulting bitmaps.
00163  */
00164 
00166 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00167 
00169 HWLOC_DECLSPEC unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) __hwloc_attribute_pure;
00170 
00172 HWLOC_DECLSPEC int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) __hwloc_attribute_pure;
00173 
00175 HWLOC_DECLSPEC int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00176 
00178 HWLOC_DECLSPEC int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00179 
00184 HWLOC_DECLSPEC int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00185 
00190 HWLOC_DECLSPEC int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, unsigned prev) __hwloc_attribute_pure;
00191 
00196 HWLOC_DECLSPEC int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00197 
00203 HWLOC_DECLSPEC int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) __hwloc_attribute_pure;
00204 
00216 #define hwloc_bitmap_foreach_begin(id, bitmap) \
00217 do { \
00218         assert(hwloc_bitmap_weight(bitmap) != -1); \
00219         for (id = hwloc_bitmap_first(bitmap); \
00220              (unsigned) id != (unsigned) -1; \
00221              id = hwloc_bitmap_next(bitmap, id)) { \
00222 
00226 #define hwloc_bitmap_foreach_end() \
00227         } \
00228 } while (0)
00229 
00230 
00231 /*
00232  * Combining bitmaps.
00233  */
00234 
00236 HWLOC_DECLSPEC void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00237 
00239 HWLOC_DECLSPEC void hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00240 
00242 HWLOC_DECLSPEC void hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00243 
00245 HWLOC_DECLSPEC void hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
00246 
00248 HWLOC_DECLSPEC void hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
00249 
00250 
00251 /*
00252  * Comparing bitmaps.
00253  */
00254 
00256 HWLOC_DECLSPEC int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
00257 
00259 HWLOC_DECLSPEC int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) __hwloc_attribute_pure;
00260 
00262 HWLOC_DECLSPEC int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
00263 
00269 HWLOC_DECLSPEC int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
00270 
00276 HWLOC_DECLSPEC int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) __hwloc_attribute_pure;
00277 
00281 #ifdef __cplusplus
00282 } /* extern "C" */
00283 #endif
00284 
00285 
00286 #endif /* HWLOC_BITMAP_H */

Generated on Thu Dec 16 2010 16:48:29 for Hardware Locality (hwloc) by  doxygen 1.7.1