From 870764dfad8df0ffe6d3d449e7a8e296cfee8ef5 Mon Sep 17 00:00:00 2001 From: Arlin Davis Date: Tue, 2 Oct 2007 11:35:21 -0700 Subject: [PATCH] Change DT_Mdep_GetTime to use gettimeofday() which has more resolution than times(). Signed-off-by: Anton Blanchard --- dapl/udapl/linux/dapl_osd.h | 36 ++++++++++++++++------- test/dapltest/mdep/linux/dapl_mdep_user.c | 2 +- test/dapltest/mdep/linux/dapl_mdep_user.h | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/dapl/udapl/linux/dapl_osd.h b/dapl/udapl/linux/dapl_osd.h index cfc85d1..e932ae0 100644 --- a/dapl/udapl/linux/dapl_osd.h +++ b/dapl/udapl/linux/dapl_osd.h @@ -49,7 +49,7 @@ #error UNDEFINED OS TYPE #endif /* __linux__ */ -#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) && !defined(__PPC64__) +#if !defined (__i386__) && !defined (__ia64__) && !defined(__x86_64__) && !defined(__PPC__) && !defined(__PPC64__) #error UNDEFINED ARCH #endif @@ -78,12 +78,9 @@ #include #include -#if !defined(REDHAT_EL5) && (defined(__ia64__) || defined(__PPC64__)) +#if !defined(REDHAT_EL5) && (defined(__ia64__)) #include #endif -#if defined(__PPC64__) -#include -#endif /* Useful debug definitions */ #ifndef STATIC @@ -163,8 +160,17 @@ dapl_os_atomic_inc ( #else IA64_FETCHADD(old_value,v,1,4); #endif -#elif defined(__PPC64__) - atomic_inc((atomic_t *) v); +#elif defined(__PPC__) || defined(__PPC64__) + int tmp; + + __asm__ __volatile__( + "1: lwarx %0,0,%2\n\ + addic %0,%0,1\n\ + stwcx. %0,0,%2\n\ + bne- 1b" + : "=&r" (tmp), "+m" (v) + : "r" (&v) + : "cc"); #else /* !__ia64__ */ __asm__ __volatile__ ( "lock;" "incl %0" @@ -193,9 +199,17 @@ dapl_os_atomic_dec ( #else IA64_FETCHADD(old_value,v,-1,4); #endif -#elif defined (__PPC64__) - atomic_dec((atomic_t *)v); - +#elif defined (__PPC__) || defined(__PPC64__) + int tmp; + + __asm__ __volatile__( + "1: lwarx %0,0,%2\n\ + addic %0,%0,-1\n\ + stwcx. %0,0,%2\n\ + bne- 1b" + : "=&r" (tmp), "+m" (v) + : "r" (&v) + : "cc"); #else /* !__ia64__ */ __asm__ __volatile__ ( "lock;" "decl %0" @@ -240,7 +254,7 @@ dapl_os_atomic_assign ( #else current_value = ia64_cmpxchg(acq,v,match_value,new_value,4); #endif /* __ia64__ */ -#elif defined(__PPC64__) +#elif defined(__PPC__) || defined(__PPC64__) __asm__ __volatile__ ( " lwsync\n\ 1: lwarx %0,0,%2 # __cmpxchg_u32\n\ diff --git a/test/dapltest/mdep/linux/dapl_mdep_user.c b/test/dapltest/mdep/linux/dapl_mdep_user.c index 1e2d44b..91e45b9 100644 --- a/test/dapltest/mdep/linux/dapl_mdep_user.c +++ b/test/dapltest/mdep/linux/dapl_mdep_user.c @@ -186,7 +186,7 @@ DT_Mdep_GetCpuMhz ( void ) { #define DT_CPU_MHZ_BUFFER_SIZE 128 -#if defined (__PPC64__) +#if defined (__PPC__) || defined (__PPC64__) #define DT_CPU_MHZ_MHZ "clock" #else #define DT_CPU_MHZ_MHZ "cpu MHz" diff --git a/test/dapltest/mdep/linux/dapl_mdep_user.h b/test/dapltest/mdep/linux/dapl_mdep_user.h index ea4e4e0..6dec6b5 100755 --- a/test/dapltest/mdep/linux/dapl_mdep_user.h +++ b/test/dapltest/mdep/linux/dapl_mdep_user.h @@ -129,7 +129,7 @@ DT_Mdep_GetTimeStamp ( void ) x = get_cycles (); return x; #else -#if defined(__PPC64__) +#if defined(__PPC__) || defined(__PPC64__) unsigned int tbl, tbu0, tbu1; do { __asm__ __volatile__ ("mftbu %0" : "=r"(tbu0)); -- 2.41.0