[PATCH 4/6] LT.old: Add ARC support
Vineet Gupta
Vineet.Gupta1 at synopsys.com
Fri Nov 15 09:34:59 UTC 2013
On 11/12/2013 07:56 PM, Bernhard Reutner-Fischer wrote:
> On Fri, Nov 01, 2013 at 04:25:05PM +0530, Vineet Gupta wrote:
>> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
>> ---
>>
>> +#include <features.h>
>> +
>> +#ifndef PT_EI
>> +# define PT_EI __extern_always_inline /* ARC LOCAL: was: extern inline */
> this is ok, we changed that to __extern_always_inline a couple of years
> ago, IIRC.
I removed the comment from there though.
> My endless TODO has a note to
> #define PT_EI __extern_always_inline attribute_hidden
> everywhere, not just i386, fwiw.
>> +#endif
>> +
>> +extern long int testandset (int *spinlock);
>> +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
>> +
>> +PT_EI long int
>> +testandset (int *spinlock)
>> +{
>> + register unsigned long int old;
>> + int *m = spinlock;
>> +
>> + __asm__ ("ex %0,[%3]" : "=r" (old), "+m" (*m) : "0" (1), "ri" (m));
> I take it that you checked this and all other modifiers :)
Of course, this is all production code. But could be simplified as below for v2.
{
unsigned int old = 1;
/* Atomically exchange @spinlock with 1 */
__asm__ (
"ex %0, [%1]"
: "+r" (old)
: "r" (spinlock)
: "memory");
}
>
>> + return old;
>> +
>> +}
>> +
>> +/* Get some notion of the current stack. Need not be exactly the top
>> + of the stack, just something somewhere in the current frame.
>> + I don't trust register variables, so let's do this the safe way. */
>> +#define CURRENT_STACK_FRAME \
> __extension__ please.
OK.
>> +({ char *__sp; __asm__ ("mov %0,sp" : "=r" (__sp)); __sp; })
> no CAS ? :(
We do have exclusive load/stores but not all ARC cores have it. So the basic port
doesn't rely on them.
NPTL however will only be enabled if we have LLOCK/SCOND which is used to build
__arch_compare_and_exchange_val_32_acq() primitive.
-Vineet
More information about the uClibc
mailing list