bitops.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * bitops.h --- Bitmap frobbing code. The byte swapping routines are
  4. * also included here.
  5. *
  6. * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
  7. *
  8. * %Begin-Header%
  9. * This file may be redistributed under the terms of the GNU Public
  10. * License.
  11. * %End-Header%
  12. *
  13. * i386 bitops operations taken from <asm/bitops.h>, Copyright 1992,
  14. * Linus Torvalds.
  15. */
  16. #include <string.h>
  17. //#include <strings.h>
  18. extern int ext2fs_set_bit(unsigned int nr,void * addr);
  19. extern int ext2fs_clear_bit(unsigned int nr, void * addr);
  20. extern int ext2fs_test_bit(unsigned int nr, const void * addr);
  21. extern __u16 ext2fs_swab16(__u16 val);
  22. extern __u32 ext2fs_swab32(__u32 val);
  23. #ifdef WORDS_BIGENDIAN
  24. #define ext2fs_cpu_to_le32(x) ext2fs_swab32((x))
  25. #define ext2fs_le32_to_cpu(x) ext2fs_swab32((x))
  26. #define ext2fs_cpu_to_le16(x) ext2fs_swab16((x))
  27. #define ext2fs_le16_to_cpu(x) ext2fs_swab16((x))
  28. #define ext2fs_cpu_to_be32(x) ((__u32)(x))
  29. #define ext2fs_be32_to_cpu(x) ((__u32)(x))
  30. #define ext2fs_cpu_to_be16(x) ((__u16)(x))
  31. #define ext2fs_be16_to_cpu(x) ((__u16)(x))
  32. #else
  33. #define ext2fs_cpu_to_le32(x) ((__u32)(x))
  34. #define ext2fs_le32_to_cpu(x) ((__u32)(x))
  35. #define ext2fs_cpu_to_le16(x) ((__u16)(x))
  36. #define ext2fs_le16_to_cpu(x) ((__u16)(x))
  37. #define ext2fs_cpu_to_be32(x) ext2fs_swab32((x))
  38. #define ext2fs_be32_to_cpu(x) ext2fs_swab32((x))
  39. #define ext2fs_cpu_to_be16(x) ext2fs_swab16((x))
  40. #define ext2fs_be16_to_cpu(x) ext2fs_swab16((x))
  41. #endif
  42. /*
  43. * EXT2FS bitmap manipulation routines.
  44. */
  45. /* Support for sending warning messages from the inline subroutines */
  46. extern const char *ext2fs_block_string;
  47. extern const char *ext2fs_inode_string;
  48. extern const char *ext2fs_mark_string;
  49. extern const char *ext2fs_unmark_string;
  50. extern const char *ext2fs_test_string;
  51. extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
  52. const char *description);
  53. extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
  54. int code, unsigned long arg);
  55. extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
  56. extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
  57. blk_t block);
  58. extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
  59. extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
  60. extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
  61. ext2_ino_t inode);
  62. extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
  63. extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
  64. blk_t block);
  65. extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
  66. blk_t block);
  67. extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
  68. blk_t block);
  69. extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
  70. ext2_ino_t inode);
  71. extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
  72. ext2_ino_t inode);
  73. extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
  74. ext2_ino_t inode);
  75. extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
  76. extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
  77. extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
  78. extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
  79. extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
  80. blk_t block, int num);
  81. extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
  82. blk_t block, int num);
  83. extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
  84. blk_t block, int num);
  85. extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
  86. blk_t block, int num);
  87. extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
  88. blk_t block, int num);
  89. extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
  90. blk_t block, int num);
  91. extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
  92. /* These two routines moved to gen_bitmap.c */
  93. extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  94. __u32 bitno);
  95. extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
  96. blk_t bitno);