mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Jamie Lokier <lk@tantalophile.demon.co.uk>
Cc: Andries.Brouwer@cwi.nl, viro@math.psu.edu,
	alan@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org,
	torvalds@transmeta.com
Subject: Re: [RFC] lazy allocation of struct block_device
Date: Sun, 02 Sep 2001 00:41:15 +0100	[thread overview]
Message-ID: <5.1.0.14.2.20010902003236.03e28740@pop.cus.cam.ac.uk> (raw)
In-Reply-To: <20010901222659.A4089@thefinal.cern.ch>
In-Reply-To: <200109012042.UAA17644@vlet.cwi.nl> <200109012042.UAA17644@vlet.cwi.nl>

At 22:26 01/09/2001, Jamie Lokier wrote:
>Andries.Brouwer@cwi.nl wrote:
> >[...]
> > However, a union is not so bad. It seems a pity to avoid unions
> > and waste 4 bytes for every inode with separate i_bdev and i_cdev
> > instead of a single i_bcdev.
>
>Please, a union of different pointer types is much nicer.  You can have
>i_bdev and i_cdev without wasting any bytes.
>
>This form works with GCC 2.96:
>
>                 union {
>                         struct char_device * i_cdev;
>                         struct block_device * i_bdev;
>                 };

It sure does. One of the nicest new gcc features IMHO!

>If you're using a really old compiler that doesn't support anonymous unions,
>(GCC 2.95 might be in this category, I'm not sure),

GCC 2.95 does NOT support this. I only found out after I had people 
complain to me that Linux-NTFS userspace tools would not compile for them 
and it turned out they were using gcc-2.95... and I 2.96. - I have since 
then verified this myself:

egcs and gcc up to 2.95 do not support unnamed structs/unions.

gcc-2.96 and gcc-3.0 support them fine.

>  then you'll need this:
>
>         #define i_bdev __i_bcdev_union.i_bdev
>         #define i_cdev __i_bcdev_union.i_cdev
>                 union {
>                         struct char_device * i_cdev;
>                         struct block_device * i_bdev;
>                 } __i_bcdev_union;

Neat trick! Thanks! I was wondering what to do with NTFS TNG driver (which 
uses unnamed structs/unions extensively) and this just might solve my 
problems without having to rewrite half the driver... (-;

Best regards,

         Anton


-- 
   "Nothing succeeds like success." - Alexandre Dumas
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/


  parent reply	other threads:[~2001-09-01 23:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-01 20:42 Andries.Brouwer
2001-09-01 21:26 ` Jamie Lokier
2001-09-01 23:41 ` Anton Altaparmakov [this message]
2001-09-01 23:54 ` Alexander Viro
  -- strict thread matches above, loose matches on Subject: below --
2001-09-02 20:05 Andries.Brouwer
2001-09-02 17:25 Andries.Brouwer
2001-09-02 18:46 ` Alexander Viro
2001-09-02 10:24 Andries.Brouwer
2001-09-02 11:38 ` Alexander Viro
2001-09-02 12:49   ` Alan Cox
2001-09-02 15:38 ` Richard Gooch
2001-09-02 16:07   ` Alexander Viro
2001-09-02 16:16   ` Richard Gooch
2001-09-01 13:30 Andries.Brouwer
2001-09-01 16:26 ` Alexander Viro
2001-08-31  4:43 Alexander Viro

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=5.1.0.14.2.20010902003236.03e28740@pop.cus.cam.ac.uk \
    --to=aia21@cam.ac.uk \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lk@tantalophile.demon.co.uk \
    --cc=torvalds@transmeta.com \
    --cc=viro@math.psu.edu \
    /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

all inboxes | Powered by JetHome®