Message ID | 1383303307-1280-5-git-send-email-vgupta@synopsys.com |
---|---|
State | Superseded |
Headers | show |
On Fri, Nov 01, 2013 at 04:25:05PM +0530, Vineet Gupta wrote: >Signed-off-by: Vineet Gupta <vgupta@synopsys.com> >--- > .../linuxthreads.old/sysdeps/arc/pt-machine.h | 48 ++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > create mode 100644 libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h > >diff --git a/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h >new file mode 100644 >index 000000000000..59a490ba1357 >--- /dev/null >+++ b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h >@@ -0,0 +1,48 @@ >+/* Machine-dependent pthreads configuration and inline functions. >+ This file is part of the GNU C Library. >+ >+ The GNU C Library is free software; you can redistribute it and/or >+ modify it under the terms of the GNU Lesser General Public License as >+ published by the Free Software Foundation; either version 2.1 of the >+ License, or (at your option) any later version. >+ >+ The GNU C Library is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >+ Lesser General Public License for more details. >+ >+ You should have received a copy of the GNU Lesser General Public >+ License along with the GNU C Library; see the file COPYING.LIB. If not, >+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, >+ Boston, MA 02111-1307, USA. */ >+#ifndef _PT_MACHINE_H >+#define _PT_MACHINE_H 1 >+#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. 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 :) >+ 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. >+({ char *__sp; __asm__ ("mov %0,sp" : "=r" (__sp)); __sp; }) no CAS ? :( >+ >+#else >+#error PT_MACHINE already defined >+#endif /* pt-machine.h */
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@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
diff --git a/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h new file mode 100644 index 000000000000..59a490ba1357 --- /dev/null +++ b/libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h @@ -0,0 +1,48 @@ +/* Machine-dependent pthreads configuration and inline functions. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ +#ifndef _PT_MACHINE_H +#define _PT_MACHINE_H 1 +#include <features.h> + +#ifndef PT_EI +# define PT_EI __extern_always_inline /* ARC LOCAL: was: extern inline */ +#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)); + 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 \ +({ char *__sp; __asm__ ("mov %0,sp" : "=r" (__sp)); __sp; }) + +#else +#error PT_MACHINE already defined +#endif /* pt-machine.h */
Signed-off-by: Vineet Gupta <vgupta@synopsys.com> --- .../linuxthreads.old/sysdeps/arc/pt-machine.h | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 libpthread/linuxthreads.old/sysdeps/arc/pt-machine.h