All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Question on atomic_inc/dec
@ 2003-10-14 21:17 Perez-Gonzalez, Inaky
  2003-10-14 21:34 ` sankar
  2003-10-14 21:44 ` Tim Hockin
  0 siblings, 2 replies; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-14 21:17 UTC (permalink / raw)
  To: sankar, linux-kernel

> From: sankar
> 
> Hi,
> I have a question concerning the macro atomic_inc on REDHAT 9.0. I had used
> atomic_inc on REDHAT 7.2 earlier. I installed redhat 9.0 and tried to run my
> old code on this. I got the error saying atomic_inc not declared.
> 
> I tried to search the header file in which this is defined but with failure.

Seems you were using a kernel definition of a function (this 
normally happens only because it was out there by mistake,
or because you had __KERNEL__ #defined).

It will be in include/asm/atomic.h; however, it is not wise to
use directly the kernel stuff unless you are coding kernel stuff.

You can always strip them, of course :)

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)

^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: Question on atomic_inc/dec
@ 2003-10-15 17:38 Perez-Gonzalez, Inaky
  0 siblings, 0 replies; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-15 17:38 UTC (permalink / raw)
  To: sankar, Tim Hockin; +Cc: linux-kernel

> From: sankar [mailto:san_madhav@hotmail.com]

>  any solution to the original problem???
> (atomic_inc() defintion not there in redhat 9.0 asm/atomic.h)

Create an atomic.h header file in your source tree with the code
below, but bear in mind that porting to other arches might be painful:

struct atomic
{
  volatile int i;
}

  /* Simple atomic increment. */

static inline
void atomic_inc (struct atomic *a)
{
    asm volatile (
      "lock; incl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

  /* Simple atomic decrement. */

static inline
void atomic_dec (struct atomic *a)
{
    asm volatile (
      "lock; decl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)


^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: Question on atomic_inc/dec
@ 2003-10-14 22:29 Perez-Gonzalez, Inaky
  2003-10-15 17:28 ` sankar
  0 siblings, 1 reply; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-14 22:29 UTC (permalink / raw)
  To: Tim Hockin; +Cc: sankar, linux-kernel

> From: Tim Hockin [mailto:thockin@hockin.org]
> 
> On Tue, Oct 14, 2003 at 02:17:49PM -0700, Perez-Gonzalez, Inaky wrote:
> > It will be in include/asm/atomic.h; however, it is not wise to
> > use directly the kernel stuff unless you are coding kernel stuff.
> 
> Is there any reason NOT to use the atomic ops in user-space?  I mean, are
> they privileged on some architectures, or ...?  It seems like some
> user-space apps might really benefit from simple atomic ops.  Or at least,
> kernel-coders writing in userspace could sure use simple atomic ops :)

Well, you are right; functionally speaking, there are no concerns,
however, there are problems.

Not all architectures have really simple atomic operations like
for example, ia32 or PPC. For example, Sparc has to do this ugly 
spinlock thinguie and that's why you can only count on 24 bits 
out of the whole atomic data type; another example is ARM,
you just disables irqs and preemption, I guess, and operates), there
is no way they will work in user space

When you have implementations like this, where ia32 is one of the 
lucky exceptions because you can do it with a couple of asm opcodes,
it is really impossible to offer something that can float up to
user space.

PS: hey, how's Mike doing? Say hi from me, pls

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Question on atomic_inc/dec
@ 2003-10-14 18:38 sankar
  0 siblings, 0 replies; 9+ messages in thread
From: sankar @ 2003-10-14 18:38 UTC (permalink / raw)
  To: linux-kernel

Hi,
I have a question concerning the macro atomic_inc on REDHAT 9.0. I had used
atomic_inc on REDHAT 7.2 earlier. I installed redhat 9.0 and tried to run my
old code on this. I got the error saying atomic_inc not declared.

I tried to search the header file in which this is defined but with failure.

If any of u guys know about this problem pls help me ...

thx in advance
Sankarshana M

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

end of thread, other threads:[~2003-10-15 17:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 21:17 Question on atomic_inc/dec Perez-Gonzalez, Inaky
2003-10-14 21:34 ` sankar
2003-10-14 21:44 ` Tim Hockin
2003-10-14 22:35   ` David S. Miller
2003-10-15  7:57   ` Arjan van de Ven
  -- strict thread matches above, loose matches on Subject: below --
2003-10-15 17:38 Perez-Gonzalez, Inaky
2003-10-14 22:29 Perez-Gonzalez, Inaky
2003-10-15 17:28 ` sankar
2003-10-14 18:38 sankar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.