linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remove #ifdef __KERNEL__ from atomic.h
@ 2002-09-25  5:11 Ben Stanley
  2002-09-25  7:12 ` Ethan Benson
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ben Stanley @ 2002-09-25  5:11 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

Hi,

I was trying to compile sumji (formerly xtunes), which requires
libCommonC++. I found that libCommonC++ would not compile, because it
needs to use the atomic functions declared in include/asm-ppc/atomic.h .
However, this file does not declare these functions unless __KERNEL__ is
defined. I believe that this is incorrect.

I have checked the i386 and s390 versions of atomic.h and they declare
the atomic functions regardless of the status of the __KERNEL__ macro.
Therefore I propose that it should be removed from asm-ppc/atomic.h, and
have attached a patch to effect this.

With this patch applied, I am able to compile libCommonC++.

Ben Stanley.


[-- Attachment #2: atomic_ppc.patch --]
[-- Type: text/plain, Size: 449 bytes --]

--- include/asm-ppc/atomic.h.orig	Wed Sep 25 07:49:12 2002
+++ include/asm-ppc/atomic.h	Wed Sep 25 07:49:32 2002
@@ -10,8 +10,6 @@

 typedef struct { volatile int counter; } atomic_t;

-#ifdef __KERNEL__
-
 #define ATOMIC_INIT(i)	{ (i) }

 #define atomic_read(v)		((v)->counter)
@@ -181,5 +179,4 @@
 #define smp_mb__before_atomic_inc()	smp_mb()
 #define smp_mb__after_atomic_inc()	smp_mb()

-#endif /* __KERNEL__ */
 #endif /* _ASM_PPC_ATOMIC_H_ */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] remove #ifdef __KERNEL__ from atomic.h
  2002-09-25  5:11 [PATCH] remove #ifdef __KERNEL__ from atomic.h Ben Stanley
@ 2002-09-25  7:12 ` Ethan Benson
  2002-09-25  7:44 ` Paul Mackerras
  2002-09-25  8:45 ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 5+ messages in thread
From: Ethan Benson @ 2002-09-25  7:12 UTC (permalink / raw)
  To: linuxppc-dev


On Wed, Sep 25, 2002 at 03:11:16PM +1000, Ben Stanley wrote:
> Hi,
>
> I was trying to compile sumji (formerly xtunes), which requires
> libCommonC++. I found that libCommonC++ would not compile, because it
> needs to use the atomic functions declared in include/asm-ppc/atomic.h .
> However, this file does not declare these functions unless __KERNEL__ is
> defined. I believe that this is incorrect.

no libcommonc++ is broken for using kernel headers.

i think this has been discussed before, specically the atomic stuff.

--
Ethan Benson
http://www.alaska.net/~erbenson/

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] remove #ifdef __KERNEL__ from atomic.h
  2002-09-25  5:11 [PATCH] remove #ifdef __KERNEL__ from atomic.h Ben Stanley
  2002-09-25  7:12 ` Ethan Benson
@ 2002-09-25  7:44 ` Paul Mackerras
  2002-09-26  0:47   ` Ben Stanley
  2002-09-25  8:45 ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2002-09-25  7:44 UTC (permalink / raw)
  To: Ben Stanley; +Cc: linuxppc-dev


Ben Stanley writes:

> I was trying to compile sumji (formerly xtunes), which requires
> libCommonC++. I found that libCommonC++ would not compile, because it
> needs to use the atomic functions declared in include/asm-ppc/atomic.h .
> However, this file does not declare these functions unless __KERNEL__ is
> defined. I believe that this is incorrect.

This has been gone over many times, user programs shouldn't be using
kernel headers.  I don't mind if you change /usr/include/asm/atomic.h,
that's a glibc header not a kernel header, but the #ifdef __KERNEL__
in the kernel header is there precisely to catch this sort of error.

(And of course /usr/include/asm should NOT be a symlink into the
kernel sources.)

Paul.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] remove #ifdef __KERNEL__ from atomic.h
  2002-09-25  5:11 [PATCH] remove #ifdef __KERNEL__ from atomic.h Ben Stanley
  2002-09-25  7:12 ` Ethan Benson
  2002-09-25  7:44 ` Paul Mackerras
@ 2002-09-25  8:45 ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2002-09-25  8:45 UTC (permalink / raw)
  To: Ben Stanley, linuxppc-dev


>I was trying to compile sumji (formerly xtunes), which requires
>libCommonC++. I found that libCommonC++ would not compile, because it
>needs to use the atomic functions declared in include/asm-ppc/atomic.h .
>However, this file does not declare these functions unless __KERNEL__ is
>defined. I believe that this is incorrect.
>
>I have checked the i386 and s390 versions of atomic.h and they declare
>the atomic functions regardless of the status of the __KERNEL__ macro.
>Therefore I propose that it should be removed from asm-ppc/atomic.h, and
>have attached a patch to effect this.
>
>With this patch applied, I am able to compile libCommonC++.

This is wrong. The definitions in asm-ppc/atomic.h belong to the
kernel only and are not guaranteed to work outside of the kernel
environement. Typically, the 4xx version use some errata workaround
macros that rely on some of the kernel's CONFIG_xxx.

You should implement your own version of the atomic ops in userland
(and you should do that for i386 and s390 as well, it's just wrong
to use the kernel versions like this). Also your implementation
should probably add the sync that is needed for workaround of some
PPC 4xx bugs (see the version in the linuxppc_2_4_devel tree)

Ben.


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] remove #ifdef __KERNEL__ from atomic.h
  2002-09-25  7:44 ` Paul Mackerras
@ 2002-09-26  0:47   ` Ben Stanley
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Stanley @ 2002-09-26  0:47 UTC (permalink / raw)
  To: linuxppc-dev


To everybody who replied,

Thanks for the gentle explanations. I'll hassle the glibc people instead.

Ben Stanley.


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-09-26  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-25  5:11 [PATCH] remove #ifdef __KERNEL__ from atomic.h Ben Stanley
2002-09-25  7:12 ` Ethan Benson
2002-09-25  7:44 ` Paul Mackerras
2002-09-26  0:47   ` Ben Stanley
2002-09-25  8:45 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).