public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: linux-ext4@vger.kernel.org
Subject: Suggestions for a 64bit bitmap api
Date: Wed, 16 Jul 2008 14:12:02 +0200	[thread overview]
Message-ID: <87y742110t.fsf@frosties.localdomain> (raw)

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

             reply	other threads:[~2008-07-16 12:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-16 12:12 Goswin von Brederlow [this message]
2008-07-16 13:41 ` Suggestions for a 64bit bitmap api 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y742110t.fsf@frosties.localdomain \
    --to=goswin-v-b@web.de \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox