[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20070126165712.GA21098@Krystal>
Date: Fri, 26 Jan 2007 11:57:12 -0500
From: Mathieu Desnoyers <compudj@...stal.dyndns.org>
To: Ralf Baechle <ralf@...ux-mips.org>
Cc: linux-kernel@...r.kernel.org, Andrew Morton <akpm@...l.org>,
linux-mips@...ux-mips.org
Subject: Re: [PATCH 05/10] local_t : mips extension
* Mathieu Desnoyers (mathieu.desnoyers@...ymtl.ca) wrote:
> > What I generally dislike about this patch is that several fairly large
> > functions have been duplicated with only little change.
> >
>
> Yeah, I know. Until we find some way to share atomic operation code for
> both operation on local and shared data, we have to duplicate this. We
> could think about a header that would support multiple inclusion and
> behave differently (different function prefix and LOCKing/memory
> barriers) depending on defines set by the top level header.
>
> Something like
>
> asm/atomic.h
> #define ATOMIC_SHARED
> #include <asm/atomic-ops.h> /* shared */
> #undef ATOMIC_SHARED
> #include <asm/atomic-ops.h> /* local */
>
> asm/atomic-ops.h
> #ifdef ATOMIC_SHARED
> #define ATOMIC_PREFIX atomic
> #define ATOMIC_BARRIER() smp_mb()
> #define ATOMIC_TYPE atomic_t
> #define ATOMIC_VAR (v->counter)
> #else
> #define ATOMIC_PREFIX local
> #define ATOMIC_BARRIER()
> #define ATOMIC_TYPE local_t
> #define ATOMIC_VAR (v->a.counter)
> #endif
>
> static __inline__ ATOMIC_PREFIX##_add_return(int i, ATOMIC_TYPE *v)
> .....
> #undef ATOMIC_PREFIX
> #undef ATOMIC_BARRIER
> #undef ATOMIC_TYPE
> #undef ATOMIC_VAR
>
More prefisely, for this to work, we should change :
#define ATOMIC_PREFIX atomic
and
#define ATOMIC_PREFIX local
for
#define ATOMICF(fctname) atomic_##fctname
and
#define ATOMICF(fctname) local_##fctname
which would make de declaration look like :
static __inline__ ATOMICF(add_return)(int i, ATOMIC_TYPE *v)
Which starts to look a little odd to me, doesn't it ?
Regards,
Mathieu
--
OpenPGP public key: http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists