Possible problem in asm/bitops.h

5 messages, 3 authors, 2002-12-17 · open the first message on its own page

Possible problem in asm/bitops.h

From: Georg Klug <hidden>
Date: 2002-12-11 15:31:14

Hi all,

today I tried to compile the iproute2-2.4.7-now-ss010824 for my walnut-like
custom board. But unfortunately it fails: (original make output below)

The reason seems to be that linux/inetdevice.h uses the inline function ffz()
to define another inline function inet_mask_len(). The ffz() function is
defined in the include file asm/bitops.h. But now there is some inconsistency
between the asm-i386/ and the asm-ppc/ directory: while the asm-i386/bitops.h
defines the ffz function for all includes, the asm-ppc/bitops.h restricts the
ffz function (and also some others) to kernel files (with #ifdef __KERNEL__).

 I then tried to remove the #ifdef __KERNEL__ from the first significant line
of the asm-ppc/bitops.h file, but now the compiler complained about the missing
macro definition of PPC405_ERR77(). This one is defined in the asm-ppc/atomic.h
as well as in asm-ppc/ppc_asm.h, but - unfortunately - differently. (One has
double quotes, the other not.) The definition in atomic.h is only for kernel
files, but I moved it out of the #ifdef __KERNEL__ and could successfully
compile
iproute2.

 But here are my questions:
Q: Is the ffz() function desgined to work in a user space application, too? If
   yes, the file asm-ppc/bitops.h would need a change.
Q: Does it make any sense to define one single macro (PPC405_ERR77()) in
different
   ways in different include files?

What is your opinion?
Kind regards,
Georg Klug


------------- output of the make ---------------------------------
make KERNEL_INCLUDE=/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl21/include
CC=ppc_405-gcc
make[1]: Entering directory
`/var/samba/Users/gklug/Work/linux/tools/net/iproute2/lib'
ppc_405-gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -Werror -g -I../include-
glibc -include
../include-glibc/glibc-bugs.h -I/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl
21/include -I../include -DRESOLVE_HOSTNAMES   -c -o ll_map.o ll_map.c
ppc_405-gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -Werror -g -I../include-
glibc -include
../include-glibc/glibc-bugs.h -I/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl
21/include -I../include -DRESOLVE_HOSTNAMES   -c -o libnetlink.o libnetlink.c
ar rcs libnetlink.a ll_map.o libnetlink.o
ppc_405-gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -Werror -g -I../include-
glibc -include
../include-glibc/glibc-bugs.h -I/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl
21/include -I../include -DRESOLVE_HOSTNAMES   -c -o utils.o utils.c
cc1: warnings being treated as errors
In file included from ../include/utils.h:6,
                 from utils.c:30:
/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl21/include/linux/inetdevice.h:
In function `inet_mask_len':
/var/samba/Users/gklug/Work/tmp/linux-2.4.17_mvl21/include/linux/inetdevice.h:16
3: warning: implicit declaration of function `ffz'
make[1]: *** [utils.o] Error 1
make[1]: Leaving directory
`/var/samba/Users/gklug/Work/linux/tools/net/iproute2/lib'
make: *** [all] Error 2
------------------------------------------------------------------


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: Possible problem in asm/bitops.h

From: Tom Rini <hidden>
Date: 2002-12-12 15:28:51

On Wed, Dec 11, 2002 at 04:31:14PM +0100, Georg Klug wrote:
Q: Is the ffz() function desgined to work in a user space application, too? If
   yes, the file asm-ppc/bitops.h would need a change.
Q: Does it make any sense to define one single macro (PPC405_ERR77()) in
different
   ways in different include files?
The problem here is that userland programs are _not_ allowed to use
kernel headers, iirc, even programs which are tied to the kernel in some
way.  They _must_ make a local copy of the include file which they
actually need.  I suspect the actual problem is that iproute2 only needs
a very small amount of what is in include/linux/inetdev.h

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

AW: Possible problem in asm/bitops.h

From: Georg Klug <hidden>
Date: 2002-12-17 09:10:09

Hi Tom,
On Wed, Dec 11, 2002 at 04:31:14PM +0100, Georg Klug wrote:
quoted
Q: Is the ffz() function desgined to work in a user space
application, too? If
quoted
   yes, the file asm-ppc/bitops.h would need a change.
Q: Does it make any sense to define one single macro (PPC405_ERR77()) in
different
   ways in different include files?
The problem here is that userland programs are _not_ allowed to use
kernel headers, iirc, even programs which are tied to the kernel in some
way. They _must_ make a local copy of the include file which they
actually need.
Oops, I thought, that the directories /usr/include/linux as well as
/usr/include/asm should come directly from the kernel (either as a copy
or symbolically linked). In that case those include files should always
be prepared to be included in a userland application. Am I right with this?

I also thought, that the asm-ppc/bitops.h should provide the same
functionality as its pendant in asm-i386/ which lets userland applications
use some static inline functions like set_bit() clear_bit() and change_bit().
I actually don't know whether those functions are needed outside the kernel,
so I cannot tell whether it is correct or not. But IMO it should be done
the same way on all plattforms. Would you agree?
I suspect the actual problem is that iproute2 only needs
a very small amount of what is in include/linux/inetdev.h
That might be true. But would the solution be to copy the linux/inetdev.h
to a local directory and change that file until it doesn't need the file
asm/bitops.h anymore?

Sorry for asking a little bit pedantic, but I want to set-up a complete
environment for building a kernel as well as all the needed userland
applications for our custom ppc_405 (walnut based) boards.

Thanks in advance for answering my questions,
Georg Klug


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: AW: Possible problem in asm/bitops.h

From: Paul Mackerras <hidden>
Date: 2002-12-17 10:16:03

Georg Klug writes:
Oops, I thought, that the directories /usr/include/linux as well as
/usr/include/asm should come directly from the kernel (either as a copy
That is how it used to be done, but that way of doing things has been
deprecated for a long time now.  /usr/include/{linux,asm} are part of
glibc these days.
or symbolically linked). In that case those include files should always
be prepared to be included in a userland application. Am I right with this?

I also thought, that the asm-ppc/bitops.h should provide the same
functionality as its pendant in asm-i386/ which lets userland applications
use some static inline functions like set_bit() clear_bit() and change_bit().
I actually don't know whether those functions are needed outside the kernel,
so I cannot tell whether it is correct or not. But IMO it should be done
the same way on all plattforms. Would you agree?
The policy is the same on all architectures: userland programs should
not include kernel headers.  The architectures differ in the extent to
which this is enforced, that's all.

Paul.

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

Re: Possible problem in asm/bitops.h

From: Tom Rini <hidden>
Date: 2002-12-17 14:59:01

On Tue, Dec 17, 2002 at 10:10:09AM +0100, Georg Klug wrote:
quoted
I suspect the actual problem is that iproute2 only needs
a very small amount of what is in include/linux/inetdev.h
That might be true. But would the solution be to copy the linux/inetdev.h
to a local directory and change that file until it doesn't need the file
asm/bitops.h anymore?
Correct.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help