public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: "Smith, Stan" <stan.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: "Hefty,
	Sean" <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	'Sasha Khapyorsky'
	<sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>,
	"ofw-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5@public.gmane.org"
	<ofw-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5@public.gmane.org>,
	'linux-rdma' <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [ofw] [PATCH] typeof() not supported in Windows WDK compiler
Date: Thu, 1 Oct 2009 20:04:40 -0600	[thread overview]
Message-ID: <20091002020440.GD22310@obsidianresearch.com> (raw)
In-Reply-To: <3F6F638B8D880340AB536D29CD4C1E1912C86E8C4A-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>

On Thu, Oct 01, 2009 at 05:29:45PM -0700, Smith, Stan wrote:

> Do the Sun guys use gcc?

gcc is commonly available on Solaris and it would be a pretty
pointless waste of time to compile opensm with sun studio :)

> > #define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \
> >   (void *)((uint8_t*)item_ptr - ((uintptr_t)(&(obj_ptr)->item_field) -
> >   ((uintptr_t)&(obj_ptr))))
> > #endif
> 
> Interesting, worth a try.
> 
> >
> > And rely on the C implicit cast from void* to an object type, and rely
> > on compiles with gcc to do the extra type checking.
> 
> 'compiles with gcc' ?

The use of typeof in cl_item_obj (and typically container_of too) is
just a correctness checking feature.
  struct bar *foo = cl_item_obj(..);
Does not compile if 'struct bar' is the wrong type, deduced
automatically from the arguments. By changing it to not use typeof the
runtime functionality is the same but you loose the static
checking. This is a poor mans way to implement C++ templates :)

So 'relying on compiles with gcc' means you rely on builds with gcc to
do the check and detect incorrect code. Since VS C cannot implement
typeof it cannot provide the check, so lets just toss out the
functionality. No big deal.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2009-10-02  2:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01 22:41 [PATCH] typeof() not supported in Windows WDK compiler Stan C. Smith
2009-10-01 22:59 ` Sean Hefty
2009-10-01 23:14   ` Smith, Stan
2009-10-01 23:38     ` Sean Hefty
     [not found]   ` <2A3759D0AB7F46D59DF8820EFCFAF1F8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-01 23:47     ` [ofw] " Jason Gunthorpe
     [not found]       ` <20091001234701.GD5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-02  0:29         ` Smith, Stan
     [not found]           ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8C4A-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-10-02  2:04             ` Jason Gunthorpe [this message]
2009-10-02 16:02         ` Smith, Stan

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=20091002020440.GD22310@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ofw-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5@public.gmane.org \
    --cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=stan.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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