public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* Suggestions for a 64bit bitmap api
@ 2008-07-16 12:12 Goswin von Brederlow
  2008-07-16 13:41 ` Theodore Tso
  0 siblings, 1 reply; 5+ messages in thread
From: Goswin von Brederlow @ 2008-07-16 12:12 UTC (permalink / raw)
  To: linux-ext4

Hi,

which api would you prefer?

Option 1
========

typedef enum {TYPE1, TYPE2} bitmap_type;

struct ext2fs_abstract_bitmap {
  bitmap_type type;
};

struct ext2fs_type1_bitmap {
  bitmap_type type;
  type1_data data;
};

struct ext2fs_type2_bitmap {
  bitmap_type type;
  type2_data data;
};

int ext2fs_fast_test_block_type1_bitmap(ext2fs_type1_bitmap *map, blk64_t i);
int ext2fs_fast_test_block_type2_bitmap(ext2fs_type2_bitmap *map, blk64_t i);
int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
  switch(map->type) {
    case TYPE1: return ext2fs_fast_test_block_type1_bitmap((ext2fs_type1_bitmap*)map, i);
    case TYPE2: return ext2fs_fast_test_block_type2_bitmap((ext2fs_type2_bitmap*)map, i);
  };
  return 0;
}


Option 2
========

struct ext2fs_abstract_bitmap {
  int (*fast_test_block)(void *map, blk64_t i);
  void *map;
};

int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
  return map->fast_test_block(map->map, i);
}


Option 3
========

struct ext2fs_bitmap_ops {
  int (*fast_test_block)(ext2fs_abstract_bitmap *map, blk64_t i); 
};

struct ext2fs_abstract_bitmap {
  ext2fs_bitmap_ops *ops;
};

struct ext2fs_type1_bitmap {
  ext2fs_bitmap_ops *ops;
  type1_data data;
};

struct ext2fs_type2_bitmap {
  ext2fs_bitmap_ops *ops;
  type2_data data;
};

int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
  return map->ops->fast_test_block(map, i);
}


Or something completly different?

MfG
        Goswin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-16 16:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-16 12:12 Suggestions for a 64bit bitmap api Goswin von Brederlow
2008-07-16 13:41 ` Theodore Tso
2008-07-16 14:05   ` Goswin von Brederlow
2008-07-16 14:51     ` Theodore Tso
2008-07-16 16:33       ` Goswin von Brederlow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox