public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: bitops.h ifdef __KERNEL__ cleanup.
@ 2001-07-19 19:21 Petr Vandrovec
  2001-07-19 18:37 ` Russell King
  2001-07-19 21:53 ` David Woodhouse
  0 siblings, 2 replies; 9+ messages in thread
From: Petr Vandrovec @ 2001-07-19 19:21 UTC (permalink / raw)
  To: Russell King; +Cc: David Woodhouse, linux-kernel, torvalds

On 19 Jul 01 at 12:48, Russell King wrote:
> 
> I totally disagree here.  We already say "user space should not include
> kernel headers".  Why should bitops.h be any different?  Why should atomic.h
> be any different?  They contain architecture specific code, yes, which
> may not work in user space.

Maybe because of I do not know ARM assembler? If you do not want
kernel headers to be used in apps, just move them from asm and linux
into msa and xunil. Then you can simple remove all #ifdef __KERNEL__
from them...

> Oh, and thanks for pointing out ncpfs breaks - I hope the authors will
> fix up their sloppy coding before Davids patch makes it into the kernel.

It will still work. Only resulting binary will be slower. That's what
autoconf is for. If ncpfs does not compile for you, better to contact
me directly, as I'm ncpfs maintainer...
                                            Best regards,
                                                Petr Vandrovec
                                                vandrove@vc.cvut.cz
                                                
P.S.: Part of ncpfs's configure.ac. I do not think that it is that
hard...

  AC_CACHE_CHECK(for working asm/atomic.h,
      ncp_cv_asm_atomic_h,
    AC_TRY_LINK([#define __SMP__
#include <asm/atomic.h>],
      [atomic_t a;
       atomic_set(&a,2);
       atomic_dec(&a);
       if (atomic_read(&a)) {
         if (!atomic_dec_and_test(&a)) {
       atomic_inc(&a);
     }
       }],
      [ncp_cv_asm_atomic_h="yes"],
      [ncp_cv_asm_atomic_h="no"]
    )
  )
  if test "$ncp_cv_asm_atomic_h" = "yes"
  then
    AC_DEFINE(HAVE_ASM_ATOMIC_H, 1, [Define if we have working asm/atomic.h])
  fi

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: bitops.h ifdef __KERNEL__ cleanup.
@ 2001-07-19 12:54 Petr Vandrovec
  2001-07-19 11:48 ` Russell King
  0 siblings, 1 reply; 9+ messages in thread
From: Petr Vandrovec @ 2001-07-19 12:54 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-kernel, torvalds

On 18 Jul 01 at 23:54, David Woodhouse wrote:

> Not all architectures put clear_bit et al in asm/bitops.h in a form which 
> is usable from userspace. Yet because it happens to work on a PeeCee, 
> people do it anyway. 

Please do not do this. At least ncpfs checks for usability of these
ops from its configure script, and if they are not available/usable, 
it reverts to pthread mutex based implementation, which is slower 
dozen of times. Same applies for atomic_* functions.

I think that you should complain to userspace authors who do not
check for bitops existence and not force other to distrbute 8+ versions
of bitops.h with their application, together with infrastructure for
selecting correct version...

Just my 0.02c.
                                            Petr Vandrovec
                                            vandrove@vc.cvut.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread
* bitops.h ifdef __KERNEL__ cleanup.
@ 2001-07-18 22:54 David Woodhouse
  0 siblings, 0 replies; 9+ messages in thread
From: David Woodhouse @ 2001-07-18 22:54 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Not all architectures put clear_bit et al in asm/bitops.h in a form which 
is usable from userspace. Yet because it happens to work on a PeeCee, 
people do it anyway. 

There's a simple way to fix that :)

Index: include/asm-i386/bitops.h
===================================================================
RCS file: /inst/cvs/linux/include/asm-i386/bitops.h,v
retrieving revision 1.2.2.7
diff -u -r1.2.2.7 bitops.h
--- include/asm-i386/bitops.h	2001/06/02 16:27:54	1.2.2.7
+++ include/asm-i386/bitops.h	2001/07/18 22:52:11
@@ -7,6 +7,8 @@
 
 #include <linux/config.h>
 
+#ifdef __KERNEL__
+
 /*
  * These have to be done with inline assembly: that way the bit-setting
  * is guaranteed to be atomic. All bit operations return 0 if the bit
@@ -329,8 +331,6 @@
 		:"r" (~word));
 	return word;
 }
-
-#ifdef __KERNEL__
 
 /**
  * ffs - find first bit set

--
dwmw2



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

end of thread, other threads:[~2001-07-27  5:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-19 19:21 bitops.h ifdef __KERNEL__ cleanup Petr Vandrovec
2001-07-19 18:37 ` Russell King
2001-07-19 21:53 ` David Woodhouse
2001-07-20  4:18   ` H. Peter Anvin
2001-07-21  6:41     ` Jeff Garzik
2001-07-27  5:05       ` Eric W. Biederman
  -- strict thread matches above, loose matches on Subject: below --
2001-07-19 12:54 Petr Vandrovec
2001-07-19 11:48 ` Russell King
2001-07-18 22:54 David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox