All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: "Smith,
	Stan" <stan.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	'Sasha Khapyorsky'
	<sashak-smomgflXvOZWk0Htik3J/w@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 17:47:01 -0600	[thread overview]
Message-ID: <20091001234701.GD5191@obsidianresearch.com> (raw)
In-Reply-To: <2A3759D0AB7F46D59DF8820EFCFAF1F8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>

On Thu, Oct 01, 2009 at 03:59:00PM -0700, Sean Hefty wrote:
> >diff --git a/opensm/opensm/osm_drop_mgr.c b/opensm/opensm/osm_drop_mgr.c
> >index 4f98cc9..8fe5129 100644
> >+++ b/opensm/opensm/osm_drop_mgr.c
> >@@ -209,8 +209,13 @@ static void drop_mgr_remove_port(osm_sm_t * sm, IN
> >osm_port_t * p_port)
> > 	drop_mgr_clean_physp(sm, p_port->p_physp);
> >
> > 	while (!cl_is_qlist_empty(&p_port->mcm_list)) {
> >+#ifndef __WIN__
> > 		mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
> > 				       mcm_port, list_item);
> >+#else
> >+		mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
> >+				       mcm_port, list_item, (osm_mcm_port_t*) );
> >+#endif
> 
> I'd find this more readable if it were #ifdef rather than #ifndef.
> 
> That said, I've got to believe that there's a better way to handle these
> changes.  I just don't know what it is.

Hmm

How about

#ifdef __GCC_
#define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \
        ((void *)item_ptr - (unsigned long)&((typeof(obj_ptr))0)->item_field)
#else
#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

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.

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-01 23:47 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     ` Jason Gunthorpe [this message]
     [not found]       ` <20091001234701.GD5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-02  0:29         ` [ofw] " Smith, Stan
     [not found]           ` <3F6F638B8D880340AB536D29CD4C1E1912C86E8C4A-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-10-02  2:04             ` Jason Gunthorpe
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=20091001234701.GD5191@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.