diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-03-03 20:58:42 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-03-03 20:58:42 +0000 |
commit | 67eff66438688fddebe41f77fd252a3b2b135271 (patch) | |
tree | 18dbee3e9afe50d27095140198e2aa34df1de061 /libpthread/linuxthreads/sysdeps/i386/pt-machine.h | |
parent | 2229d0fa131387b9b8ad16ac88347350a080aeb5 (diff) |
Initial effort at adding profiling support.
Diffstat (limited to 'libpthread/linuxthreads/sysdeps/i386/pt-machine.h')
-rw-r--r-- | libpthread/linuxthreads/sysdeps/i386/pt-machine.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h index 79c69b549..e8a9b4e67 100644 --- a/libpthread/linuxthreads/sysdeps/i386/pt-machine.h +++ b/libpthread/linuxthreads/sysdeps/i386/pt-machine.h @@ -35,6 +35,52 @@ 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__ + +/* 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 __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 */ + + + /* Spinlock implementation; required. */ PT_EI long int testandset (int *spinlock) @@ -103,6 +149,8 @@ compare_and_swap_is_available (void) Otherwise, it's a 486 or above and it has cmpxchg. */ return changed != 0; } +#endif /* Generic i386 implementation */ + #endif /* __ASSEMBLER__ */ #endif /* pt-machine.h */ |