Re: include file problem (with patch)

From: Khimenko Victor (khim@sch57.msk.ru)
Date: Mon May 29 2000 - 04:20:47 EST


In <Pine.LNX.4.21.0005282057560.11765-200000@studebaker.erols.com> S. Baker (sbaker@erols.com) wrote:
> While trying to compile the following sample program using
> 'gcc -o testbo testbo.c' I encountered a problem in
> include/linux/byteorder/swab.h that causes testbo not to
> compile.

As it should.

> testbo:
> #include <asm/byteorder.h>

> main()
> {
> int b;
> __u32 y = 5;

> b = __cpu_to_be32(y);
> }

> An interesting thing to note is that
> gcc -O -o testbo testbo.c works fine, which I believe
> is why this bug has gone undiscovered.

It's not bug. It's feature. In fact even two features:
  1. Any program with kernel header usage is broken by definition. If it does
     not compile - it's program bug, not kernel one.
  2. extern inline will be inlined ONLY when optimization is enabled - do not
     even try to compile them without optimization (it's even in some man pages).

> The following is a patch to fix this erroneous behavior:

The folliowing patch make kernel slower and solves non-existing problem.

> diff -rc linux/include/linux/byteorder/swab.h patch/include/linux/byteorder/swab.h
> *** linux/include/linux/byteorder/swab.h Mon May 15 17:06:32 2000
> --- patch/include/linux/byteorder/swab.h Sun May 28 20:49:34 2000
> ***************
> *** 90,98 ****
> ___swab64((x)) : \
> __fswab64((x)))
> #else
> ! # define __swab16(x) __fswab16(x)
> ! # define __swab32(x) __fswab32(x)
> ! # define __swab64(x) __fswab64(x)
> #endif /* OPTIMIZE */

> --- 90,98 ----
> ___swab64((x)) : \
> __fswab64((x)))
> #else
> ! # define __swab16(x) ___swab16(x)
> ! # define __swab32(x) ___swab32(x)
> ! # define __swab64(x) ___swab64(x)
> #endif /* OPTIMIZE */

> --ATTACHMENT-- text file <patchfile>
> Description: swab patch

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:20 EST