X-MimeOLE: Produced By Microsoft Exchange V6.5
Received: by onstor-exch02.onstor.net 
	id <01C776F4.D7D919E3@onstor-exch02.onstor.net>; Wed, 4 Apr 2007 13:07:16 -0700
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C776F4.D7D919E3"
References: <20070403201931.17db2acb@ripper.onstor.net> <BB375AF679D4A34E9CA8DFA650E2B04E031DF302@onstor-exch02.onstor.net>
Content-class: urn:content-classes:message
Subject: RE: cougar porting: ifdefs really ARE the devil!
Date: Wed, 4 Apr 2007 13:07:16 -0700
Message-ID: <BB375AF679D4A34E9CA8DFA650E2B04E028D5F@onstor-exch02.onstor.net>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: cougar porting: ifdefs really ARE the devil!
Thread-Index: Acd2aA/ZrxptLCUIQVWLt9vKnra+8QAESBQwAB65Spc=
From: "Jeseem S" <jeseem@onstor.com>
To: "Brian DeForest" <brian.deforest@onstor.com>,
	"Andy Sharp" <andy.sharp@onstor.com>

This is a multi-part message in MIME format.

------_=_NextPart_001_01C776F4.D7D919E3
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Their is a simple coding style that linux kernel follows with ifdef.
i.e. hide ifdef inside header files

As an example,=20

consider the following code in drivers/usb/hid-core.c:

static void hid_process_event (struct hid_device *hid,
                               struct hid_field *field,
                               struct hid_usage *usage,
                               __s32 value)
{
   hid_dump_input(usage, value);
   if (hid->claimed & HID_CLAIMED_INPUT)
         hidinput_hid_event(hid, field, usage, value);
#ifdef CONFIG_USB_HIDDEV
   if (hid->claimed & HID_CLAIMED_HIDDEV)
         hiddev_hid_event(hid, usage->hid, value);
#endif
}


to remove this ifdef  ( notice the empty fn defined)

include/linux/hiddev.h:

#ifdef CONFIG_USB_HIDDEV
   extern void hiddev_hid_event (struct hid_device *,
                                 unsigned int usage,
                                 int value);
#else
   static inline void
   hiddev_hid_event (struct hid_device*hid,
                     unsigned int usage,
                     int value) { }
#endif




so new code becomes
static void hid_process_event
                           (struct hid_device *hid,
                            struct hid_field *field,
                            struct hid_usage *usage,
                            __s32 value)
{
   hid_dump_input(usage, value);
   if (hid->claimed & HID_CLAIMED_INPUT)
         hidinput_hid_event(hid, field, usage, value);
   if (hid->claimed & HID_CLAIMED_HIDDEV)
         hiddev_hid_event(hid, usage->hid, value);
}


HTH
Jeseem
-----Original Message-----
From: Brian DeForest
Sent: Wed 4/4/2007 10:08 AM
To: Andy Sharp; dl-cougar; dl-software
Subject: RE: cougar porting: ifdefs really ARE the devil!
=20
Currently our open source code changes do not use a common ifdef.    We =
should pick one (NFX?  ONSTOR?) and be consistent across the board.  =20

We also need to make a golden rule:  if you change any lines of open =
source, it gets ifdef'ed.   This is essential.  Failure to comply should =
be punishable by <fill in>. =20

-----Original Message-----
From: Andy Sharp=20
Sent: Tuesday, April 03, 2007 8:20 PM
To: dl-cougar; dl-software
Subject: cougar porting: ifdefs really ARE the devil!

Howdy folks,

Well, the ifdef thing has gotten out of the bag already.  It's my fault,
really.

Having gone through this before, and knowing where the dragons be, I
will write up a cookbook on how to handle them.  So don't panic, give
me a couple of days to whack that out before trying to tackle 'em.
Many of you are not there yet, so you aren't going to be tackling them
in the next day or so anyway.

General rules:

Read my lips*: no new ifdefs allowed.  Exceptions _might_ be: ifdefs for
compiler differences (ssc code at least will be using gcc-4.1.2-ish,
really a prerelease of 4.2; hopefully we can get NFX code onto at
least the latest sde compiler); and ifdefs not introduced by hand
but by running configure in an open source package that we have to break
apart and modify.  That's it.  Seriously.  Finito.

This generally goes for makefiles too.  I'll try to cover that briefly
as well.

Cheers,

a



*spoken by a Bush




------_=_NextPart_001_01C776F4.D7D919E3
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7652.24">
<TITLE>RE: cougar porting: ifdefs really ARE the devil!</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>Their is a simple coding style that linux kernel =
follows with ifdef.<BR>
i.e. hide ifdef inside header files<BR>
<BR>
As an example,<BR>
<BR>
consider the following code in drivers/usb/hid-core.c:<BR>
<BR>
static void hid_process_event (struct hid_device *hid,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct hid_field *field,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct hid_usage *usage,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __s32 value)<BR>
{<BR>
&nbsp;&nbsp; hid_dump_input(usage, value);<BR>
&nbsp;&nbsp; if (hid-&gt;claimed &amp; HID_CLAIMED_INPUT)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidinput_hid_event(hid, =
field, usage, value);<BR>
#ifdef CONFIG_USB_HIDDEV<BR>
&nbsp;&nbsp; if (hid-&gt;claimed &amp; HID_CLAIMED_HIDDEV)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hiddev_hid_event(hid, =
usage-&gt;hid, value);<BR>
#endif<BR>
}<BR>
<BR>
<BR>
to remove this ifdef&nbsp; ( notice the empty fn defined)<BR>
<BR>
include/linux/hiddev.h:<BR>
<BR>
#ifdef CONFIG_USB_HIDDEV<BR>
&nbsp;&nbsp; extern void hiddev_hid_event (struct hid_device *,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned int usage,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int value);<BR>
#else<BR>
&nbsp;&nbsp; static inline void<BR>
&nbsp;&nbsp; hiddev_hid_event (struct hid_device*hid,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned int usage,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int value) { }<BR>
#endif<BR>
<BR>
<BR>
<BR>
<BR>
so new code becomes<BR>
static void hid_process_event<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp; (struct hid_device *hid,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; struct hid_field *field,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; struct hid_usage *usage,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp; __s32 value)<BR>
{<BR>
&nbsp;&nbsp; hid_dump_input(usage, value);<BR>
&nbsp;&nbsp; if (hid-&gt;claimed &amp; HID_CLAIMED_INPUT)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hidinput_hid_event(hid, =
field, usage, value);<BR>
&nbsp;&nbsp; if (hid-&gt;claimed &amp; HID_CLAIMED_HIDDEV)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hiddev_hid_event(hid, =
usage-&gt;hid, value);<BR>
}<BR>
<BR>
<BR>
HTH<BR>
Jeseem<BR>
-----Original Message-----<BR>
From: Brian DeForest<BR>
Sent: Wed 4/4/2007 10:08 AM<BR>
To: Andy Sharp; dl-cougar; dl-software<BR>
Subject: RE: cougar porting: ifdefs really ARE the devil!<BR>
<BR>
Currently our open source code changes do not use a common =
ifdef.&nbsp;&nbsp;&nbsp; We should pick one (NFX?&nbsp; ONSTOR?) and be =
consistent across the board.&nbsp;&nbsp;<BR>
<BR>
We also need to make a golden rule:&nbsp; if you change any lines of =
open source, it gets ifdef'ed.&nbsp;&nbsp; This is essential.&nbsp; =
Failure to comply should be punishable by &lt;fill in&gt;.&nbsp;<BR>
<BR>
-----Original Message-----<BR>
From: Andy Sharp<BR>
Sent: Tuesday, April 03, 2007 8:20 PM<BR>
To: dl-cougar; dl-software<BR>
Subject: cougar porting: ifdefs really ARE the devil!<BR>
<BR>
Howdy folks,<BR>
<BR>
Well, the ifdef thing has gotten out of the bag already.&nbsp; It's my =
fault,<BR>
really.<BR>
<BR>
Having gone through this before, and knowing where the dragons be, I<BR>
will write up a cookbook on how to handle them.&nbsp; So don't panic, =
give<BR>
me a couple of days to whack that out before trying to tackle 'em.<BR>
Many of you are not there yet, so you aren't going to be tackling =
them<BR>
in the next day or so anyway.<BR>
<BR>
General rules:<BR>
<BR>
Read my lips*: no new ifdefs allowed.&nbsp; Exceptions _might_ be: =
ifdefs for<BR>
compiler differences (ssc code at least will be using gcc-4.1.2-ish,<BR>
really a prerelease of 4.2; hopefully we can get NFX code onto at<BR>
least the latest sde compiler); and ifdefs not introduced by hand<BR>
but by running configure in an open source package that we have to =
break<BR>
apart and modify.&nbsp; That's it.&nbsp; Seriously.&nbsp; Finito.<BR>
<BR>
This generally goes for makefiles too.&nbsp; I'll try to cover that =
briefly<BR>
as well.<BR>
<BR>
Cheers,<BR>
<BR>
a<BR>
<BR>
<BR>
<BR>
*spoken by a Bush<BR>
<BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C776F4.D7D919E3--
