2009-06-21 18:21:41

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH] unifdef: teach it about defined(FOO) syntax

Hi,

uclibc project patched unifdef.c (which we stole from kernel)
so that it understands defined(FOO) in addition to defined FOO,
and also taught it to understand short-circuited evaluation
of && and ||

The patch is attached. (Sorry, not inline, I fear Google
web mail interface may mangle it).

I ran these commands in unpatched and patched tree:

make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- defconfig
ln -s asm-x86 include/asm
make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- headers_install

and then diffed usr/*. The difference clearly shows that
new unifdef works better than old one:


linux-2.6.30.test/usr/include/linux/acct.h:
@@ -59,9 +59,7 @@ struct acct
comp_t ac_majflt; /* Major Pagefaults */
comp_t ac_swaps; /* Number of Swaps */
/* m68k had no padding here. */
-#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
__u16 ac_ahz; /* AHZ */
-#endif
__u32 ac_exitcode; /* Exitcode */
char ac_comm[ACCT_COMM + 1]; /* Command Name */
__u8 ac_etime_hi; /* Elapsed Time MSB */


linux-2.6.30.test/usr/include/linux/soundcard.h:
@@ -1033,7 +1033,6 @@ typedef struct mixer_vol_table {
*/
#define LOCL_STARTAUDIO 1

-#if !defined(__KERNEL__) || defined(USE_SEQ_MACROS)
/*
* Some convenience macros to simplify programming of the
* /dev/sequencer interface
@@ -1275,4 +1274,3 @@ void seqbuf_dump(void); /* This function
(SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))

#endif
-#endif


linux-2.6.30.test/usr/include/linux/videodev.h:
@@ -16,24 +16,6 @@
#include <linux/ioctl.h>
#include <linux/videodev2.h>

-#if defined(__MIN_V4L1) && defined (__KERNEL__)
-
-/*
- * Used by those V4L2 core functions that need a minimum V4L1 support,
- * in order to allow V4L1 Compatibilty code compilation.
- */
-
-struct video_mbuf
-{
- int size; /* Total memory to map */
- int frames; /* Frames */
- int offsets[VIDEO_MAX_FRAME];
-};
-
-#define VIDIOCGMBUF _IOR('v',20, struct video_mbuf) /* Memory map
buffer info */
-
-#else
-#if defined(CONFIG_VIDEO_V4L1_COMPAT) || !defined (__KERNEL__)

#define VID_TYPE_CAPTURE 1 /* Can capture */
#define VID_TYPE_TUNER 2 /* Can tune */
@@ -328,8 +310,6 @@ struct video_code
#define VID_PLAY_RESET 13
#define VID_PLAY_END_MARK 14

-#endif /* CONFIG_VIDEO_V4L1_COMPAT */
-#endif /* __MIN_V4L1 */

#endif /* __LINUX_VIDEODEV_H */


+++ linux-2.6.30.test/usr/include/video/edid.h:
@@ -1,13 +1,11 @@
#ifndef __linux_video_edid_h__
#define __linux_video_edid_h__

-#if !defined(__KERNEL__) || defined(CONFIG_X86)

struct edid_info {
unsigned char dummy[128];
};


-#endif

#endif /* __linux_video_edid_h__ */



Please apply.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
linux-2.6.30_unifdef.patch (6.88 kB)

2009-06-26 22:05:04

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] unifdef: teach it about defined(FOO) syntax

On Sun, 21 Jun 2009 20:21:32 +0200
Denys Vlasenko <[email protected]> wrote:

> Hi,
>
> uclibc project patched unifdef.c (which we stole from kernel)
> so that it understands defined(FOO) in addition to defined FOO,
> and also taught it to understand short-circuited evaluation
> of && and ||
>
> The patch is attached. (Sorry, not inline, I fear Google
> web mail interface may mangle it).
>
> I ran these commands in unpatched and patched tree:
>
> make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- defconfig
> ln -s asm-x86 include/asm
> make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- headers_install
>
> and then diffed usr/*. The difference clearly shows that
> new unifdef works better than old one:
>
>
> linux-2.6.30.test/usr/include/linux/acct.h:
> @@ -59,9 +59,7 @@ struct acct
> comp_t ac_majflt; /* Major Pagefaults */
> comp_t ac_swaps; /* Number of Swaps */
> /* m68k had no padding here. */
> -#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
> __u16 ac_ahz; /* AHZ */
> -#endif
> __u32 ac_exitcode; /* Exitcode */
> char ac_comm[ACCT_COMM + 1]; /* Command Name */
> __u8 ac_etime_hi; /* Elapsed Time MSB */
>
>
> linux-2.6.30.test/usr/include/linux/soundcard.h:
> @@ -1033,7 +1033,6 @@ typedef struct mixer_vol_table {
> */
> #define LOCL_STARTAUDIO 1
>
> -#if !defined(__KERNEL__) || defined(USE_SEQ_MACROS)
> /*
> * Some convenience macros to simplify programming of the
> * /dev/sequencer interface
> @@ -1275,4 +1274,3 @@ void seqbuf_dump(void); /* This function
> (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
>
> #endif
> -#endif
>
> ...
>

eek. Please avoid quoting anything which looks like a patch in the
changelog. Because when some poor schmuck comes along and tries to
apply it, patch(1) goes sniffing around in the changelog, thinks it
sees a patch and makes a huge mess of everything.


> Please apply.

Unfortunately unifdef.c got changed after 2.6.30 and this patch throws
more rejects than I am comfortable about fixing.

2009-06-26 22:10:10

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] unifdef: teach it about defined(FOO) syntax

On Fri, Jun 26, 2009 at 03:04:53PM -0700, Andrew Morton wrote:
> On Sun, 21 Jun 2009 20:21:32 +0200
> Denys Vlasenko <[email protected]> wrote:
>
> > Hi,
> >
> > uclibc project patched unifdef.c (which we stole from kernel)
> > so that it understands defined(FOO) in addition to defined FOO,
> > and also taught it to understand short-circuited evaluation
> > of && and ||
> >
> > The patch is attached. (Sorry, not inline, I fear Google
> > web mail interface may mangle it).
> >
> > I ran these commands in unpatched and patched tree:
> >
> > make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- defconfig
> > ln -s asm-x86 include/asm
> > make ARCH=i386 CROSS_COMPILE=i486-linux-uclibc- headers_install
> >
> > and then diffed usr/*. The difference clearly shows that
> > new unifdef works better than old one:
> >
> >
> > linux-2.6.30.test/usr/include/linux/acct.h:
> > @@ -59,9 +59,7 @@ struct acct
> > comp_t ac_majflt; /* Major Pagefaults */
> > comp_t ac_swaps; /* Number of Swaps */
> > /* m68k had no padding here. */
> > -#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
> > __u16 ac_ahz; /* AHZ */
> > -#endif
> > __u32 ac_exitcode; /* Exitcode */
> > char ac_comm[ACCT_COMM + 1]; /* Command Name */
> > __u8 ac_etime_hi; /* Elapsed Time MSB */
> >
> >
> > linux-2.6.30.test/usr/include/linux/soundcard.h:
> > @@ -1033,7 +1033,6 @@ typedef struct mixer_vol_table {
> > */
> > #define LOCL_STARTAUDIO 1
> >
> > -#if !defined(__KERNEL__) || defined(USE_SEQ_MACROS)
> > /*
> > * Some convenience macros to simplify programming of the
> > * /dev/sequencer interface
> > @@ -1275,4 +1274,3 @@ void seqbuf_dump(void); /* This function
> > (SEQ_DUMPBUF(), write(seqfd, (char*)(patchx), len))
> >
> > #endif
> > -#endif
> >
> > ...
> >
>
> eek. Please avoid quoting anything which looks like a patch in the
> changelog. Because when some poor schmuck comes along and tries to
> apply it, patch(1) goes sniffing around in the changelog, thinks it
> sees a patch and makes a huge mess of everything.
>
>
> > Please apply.
>
> Unfortunately unifdef.c got changed after 2.6.30 and this patch throws
> more rejects than I am comfortable about fixing.

Russell King actually implemented the same functionality (more or less).
Denys - could you try if the one in the kernel is better/worse
then the one you have here.

The implementation Russell did looks much simpler than this
patch and so far it has only been a win.

Sam

2009-07-05 13:03:18

by Denys Vlasenko

[permalink] [raw]
Subject: Re: [PATCH] unifdef: teach it about defined(FOO) syntax

On Saturday 27 June 2009 00:12, Sam Ravnborg wrote:
> > Unfortunately unifdef.c got changed after 2.6.30 and this patch throws
> > more rejects than I am comfortable about fixing.
>
> Russell King actually implemented the same functionality (more or less).
> Denys - could you try if the one in the kernel is better/worse
> then the one you have here.
>
> The implementation Russell did looks much simpler than this
> patch and so far it has only been a win.

I checked and linux-2.6.31-rc2 indeed has it fixed.
--
vda