From e1e46622ac0fce73d802fa4a8a2e83cc25cd9e7a Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sat, 14 Feb 2015 23:04:02 -0600 Subject: Revert "resolve merge" This reverts commit 6b6ede3d15f04fe825cfa9f697507457e3640344. --- libpthread/linuxthreads/sysdeps/i386/pt-machine.h | 93 ++++++++--------------- 1 file changed, 32 insertions(+), 61 deletions(-) (limited to 'libpthread/linuxthreads/sysdeps/i386/pt-machine.h') diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h index 24c5e6c7c..82a5cf077 100644 --- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h @@ -18,14 +18,17 @@ License along with the GNU C Library; see the file COPYING.LIB. If not, see . */ +#if defined __pentiumpro__ || defined __pentium4__ || defined __athlon__ || \ + defined __k8__ +# include "i686/pt-machine.h" +#else + #ifndef _PT_MACHINE_H #define _PT_MACHINE_H 1 -#include - #ifndef __ASSEMBLER__ #ifndef PT_EI -# define PT_EI __extern_always_inline __attribute__((visibility("hidden"))) +# define PT_EI __extern_always_inline #endif extern long int testandset (int *spinlock); @@ -36,54 +39,6 @@ extern int __compare_and_swap (long int *p, long int oldval, long int newval); #define CURRENT_STACK_FRAME __builtin_frame_address (0) -/* See if we can optimize for newer cpus... */ -#if defined __GNUC__ && __GNUC__ >= 2 && \ - (defined __i486__ || defined __pentium__ || defined __pentiumpro__ || defined __pentium4__ || \ - defined __athlon__ || defined __k8__) - -/* Spinlock implementation; required. */ -PT_EI long int -testandset (int *spinlock) -{ - long int ret; - - __asm__ __volatile__ ( - "xchgl %0, %1" - : "=r" (ret), "=m" (*spinlock) - : "0" (1), "m" (*spinlock) - : "memory"); - - return ret; -} - -/* Compare-and-swap for semaphores. It's always available on i686. */ -#define HAS_COMPARE_AND_SWAP - -PT_EI int -__compare_and_swap (long int *p, long int oldval, long int newval) -{ - char ret; - long int readval; - - __asm__ __volatile__ ("lock; cmpxchgl %3, %1; sete %0" - : "=q" (ret), "=m" (*p), "=a" (readval) - : "r" (newval), "m" (*p), "a" (oldval) - : "memory"); - return ret; -} - -#if defined(__ASSUME_LDT_WORKS) && __ASSUME_LDT_WORKS > 0 -#include "useldt.h" -#endif - -/* The P4 and above really want some help to prevent overheating. */ -#define BUSY_WAIT_NOP __asm__ ("rep; nop") - - -#else /* Generic i386 implementation */ - -extern int compare_and_swap_is_available (void); - /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) @@ -120,27 +75,43 @@ __compare_and_swap (long int *p, long int oldval, long int newval) return ret; } + +PT_EI int get_eflags (void); +PT_EI int +get_eflags (void) +{ + int res; + __asm__ __volatile__ ("pushfl; popl %0" : "=r" (res) : ); + return res; +} + + +PT_EI void set_eflags (int newflags); +PT_EI void +set_eflags (int newflags) +{ + __asm__ __volatile__ ("pushl %0; popfl" : : "r" (newflags) : "cc"); +} + + +PT_EI int compare_and_swap_is_available (void); PT_EI int compare_and_swap_is_available (void) { + int oldflags = get_eflags (); int changed; - int oldflags; - /* get EFLAGS */ - __asm__ __volatile__ ("pushfl; popl %0" : "=r" (oldflags) : ); /* Flip AC bit in EFLAGS. */ - __asm__ __volatile__ ("pushl %0; popfl" : : "r" (oldflags ^ 0x40000) : "cc"); - /* reread EFLAGS */ - __asm__ __volatile__ ("pushfl; popl %0" : "=r" (changed) : ); + set_eflags (oldflags ^ 0x40000); /* See if bit changed. */ - changed = (changed ^ oldflags) & 0x40000; + changed = (get_eflags () ^ oldflags) & 0x40000; /* Restore EFLAGS. */ - __asm__ __volatile__ ("pushl %0; popfl" : : "r" (oldflags) : "cc"); + set_eflags (oldflags); /* If the AC flag did not change, it's a 386 and it lacks cmpxchg. Otherwise, it's a 486 or above and it has cmpxchg. */ return changed != 0; } -#endif /* Generic i386 implementation */ - #endif /* __ASSEMBLER__ */ #endif /* pt-machine.h */ + +#endif -- cgit v1.2.3