bitmap.h
/*
* Copyright © 2009 CNRS
* Copyright © 2009-2011 inria. All rights reserved.
* Copyright © 2009-2012 Université Bordeaux 1
* Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
*/
#ifndef HWLOC_BITMAP_H
#define HWLOC_BITMAP_H
#include <hwloc/autogen/config.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct hwloc_bitmap_s * hwloc_bitmap_t;
typedef const struct hwloc_bitmap_s * hwloc_const_bitmap_t;
/*
* Bitmap allocation, freeing and copying.
*/
hwloc_bitmap_t hwloc_bitmap_alloc(void) ;
hwloc_bitmap_t hwloc_bitmap_alloc_full(void) ;
void hwloc_bitmap_free(hwloc_bitmap_t bitmap);
hwloc_bitmap_t hwloc_bitmap_dup(hwloc_const_bitmap_t bitmap) ;
void hwloc_bitmap_copy(hwloc_bitmap_t dst, hwloc_const_bitmap_t src);
/*
* Bitmap/String Conversion
*/
int hwloc_bitmap_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
int hwloc_bitmap_list_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_list_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_list_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
int hwloc_bitmap_taskset_snprintf(char * restrict buf, size_t buflen, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_taskset_asprintf(char ** strp, hwloc_const_bitmap_t bitmap);
int hwloc_bitmap_taskset_sscanf(hwloc_bitmap_t bitmap, const char * restrict string);
/*
* Building bitmaps.
*/
void hwloc_bitmap_zero(hwloc_bitmap_t bitmap);
void hwloc_bitmap_fill(hwloc_bitmap_t bitmap);
void hwloc_bitmap_only(hwloc_bitmap_t bitmap, unsigned id);
void hwloc_bitmap_allbut(hwloc_bitmap_t bitmap, unsigned id);
void hwloc_bitmap_from_ulong(hwloc_bitmap_t bitmap, unsigned long mask);
void hwloc_bitmap_from_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
/*
* Modifying bitmaps.
*/
void hwloc_bitmap_set(hwloc_bitmap_t bitmap, unsigned id);
void hwloc_bitmap_set_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
void hwloc_bitmap_set_ith_ulong(hwloc_bitmap_t bitmap, unsigned i, unsigned long mask);
void hwloc_bitmap_clr(hwloc_bitmap_t bitmap, unsigned id);
void hwloc_bitmap_clr_range(hwloc_bitmap_t bitmap, unsigned begin, int end);
void hwloc_bitmap_singlify(hwloc_bitmap_t bitmap);
/*
* Consulting bitmaps.
*/
unsigned long hwloc_bitmap_to_ulong(hwloc_const_bitmap_t bitmap) ;
unsigned long hwloc_bitmap_to_ith_ulong(hwloc_const_bitmap_t bitmap, unsigned i) ;
int hwloc_bitmap_isset(hwloc_const_bitmap_t bitmap, unsigned id) ;
int hwloc_bitmap_iszero(hwloc_const_bitmap_t bitmap) ;
int hwloc_bitmap_isfull(hwloc_const_bitmap_t bitmap) ;
int hwloc_bitmap_first(hwloc_const_bitmap_t bitmap) ;
int hwloc_bitmap_next(hwloc_const_bitmap_t bitmap, int prev) ;
int hwloc_bitmap_last(hwloc_const_bitmap_t bitmap) ;
int hwloc_bitmap_weight(hwloc_const_bitmap_t bitmap) ;
#define hwloc_bitmap_foreach_begin(id, bitmap) \
do { \
assert(hwloc_bitmap_weight(bitmap) != -1); \
for (id = hwloc_bitmap_first(bitmap); \
(unsigned) id != (unsigned) -1; \
id = hwloc_bitmap_next(bitmap, id)) { \
#define hwloc_bitmap_foreach_end() \
} \
} while (0)
/*
* Combining bitmaps.
*/
void hwloc_bitmap_or (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
void hwloc_bitmap_and (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
void hwloc_bitmap_andnot (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
void hwloc_bitmap_xor (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2);
void hwloc_bitmap_not (hwloc_bitmap_t res, hwloc_const_bitmap_t bitmap);
/*
* Comparing bitmaps.
*/
int hwloc_bitmap_intersects (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
int hwloc_bitmap_isincluded (hwloc_const_bitmap_t sub_bitmap, hwloc_const_bitmap_t super_bitmap) ;
int hwloc_bitmap_isequal (hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
int hwloc_bitmap_compare_first(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
int hwloc_bitmap_compare(hwloc_const_bitmap_t bitmap1, hwloc_const_bitmap_t bitmap2) ;
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* HWLOC_BITMAP_H */