bitmask.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef __CPUPOWER_BITMASK__
  2. #define __CPUPOWER_BITMASK__
  3. /* Taken over from libbitmask, a project initiated from sgi:
  4. * Url: http://oss.sgi.com/projects/cpusets/
  5. * Unfortunately it's not very widespread, therefore relevant parts are
  6. * pasted here.
  7. */
  8. struct bitmask {
  9. unsigned int size;
  10. unsigned long *maskp;
  11. };
  12. struct bitmask *bitmask_alloc(unsigned int n);
  13. void bitmask_free(struct bitmask *bmp);
  14. struct bitmask *bitmask_setbit(struct bitmask *bmp, unsigned int i);
  15. struct bitmask *bitmask_setall(struct bitmask *bmp);
  16. struct bitmask *bitmask_clearall(struct bitmask *bmp);
  17. unsigned int bitmask_first(const struct bitmask *bmp);
  18. unsigned int bitmask_next(const struct bitmask *bmp, unsigned int i);
  19. unsigned int bitmask_last(const struct bitmask *bmp);
  20. int bitmask_isallclear(const struct bitmask *bmp);
  21. int bitmask_isbitset(const struct bitmask *bmp, unsigned int i);
  22. int bitmask_parselist(const char *buf, struct bitmask *bmp);
  23. int bitmask_displaylist(char *buf, int len, const struct bitmask *bmp);
  24. #endif /*__CPUPOWER_BITMASK__ */