Commit bb0139c9 authored by Paul Bakker's avatar Paul Bakker
Browse files

- Moved to more flexible define structure

 - Added exception for OpenBSD on Sparc64 (no privilege for call)
parent 35a7fe52
...@@ -54,9 +54,11 @@ struct _hr_time ...@@ -54,9 +54,11 @@ struct _hr_time
#endif #endif
#if defined(POLARSSL_HAVE_ASM) && \ #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
(defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
unsigned long tsc; unsigned long tsc;
...@@ -64,9 +66,12 @@ unsigned long hardclock( void ) ...@@ -64,9 +66,12 @@ unsigned long hardclock( void )
__asm mov [tsc], eax __asm mov [tsc], eax
return( tsc ); return( tsc );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) defined(__GNUC__) && defined(__i386__)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -74,10 +79,12 @@ unsigned long hardclock( void ) ...@@ -74,10 +79,12 @@ unsigned long hardclock( void )
asm( "rdtsc" : "=a" (lo), "=d" (hi) ); asm( "rdtsc" : "=a" (lo), "=d" (hi) );
return( lo ); return( lo );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
(defined(__amd64__) || defined(__x86_64__))
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -85,10 +92,12 @@ unsigned long hardclock( void ) ...@@ -85,10 +92,12 @@ unsigned long hardclock( void )
asm( "rdtsc" : "=a" (lo), "=d" (hi) ); asm( "rdtsc" : "=a" (lo), "=d" (hi) );
return( lo | (hi << 32) ); return( lo | (hi << 32) );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && \ defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
(defined(__powerpc__) || defined(__ppc__))
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -104,9 +113,29 @@ unsigned long hardclock( void ) ...@@ -104,9 +113,29 @@ unsigned long hardclock( void )
return( tbl ); return( tbl );
} }
#endif
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
defined(__GNUC__) && defined(__sparc64__)
#if defined(__OpenBSD__)
#warning OpenBSD does not allow access to tick register using software version instead
#else #else
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__sparc__) #define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void )
{
unsigned long tick;
asm( "rdpr %%tick, %0;" : "=&r" (tick) );
return( tick );
}
#endif
#endif
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
defined(__GNUC__) && defined(__sparc__) && !defined(__sparc64__)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -115,9 +144,12 @@ unsigned long hardclock( void ) ...@@ -115,9 +144,12 @@ unsigned long hardclock( void )
asm( "mov %%g1, %0" : "=r" (tick) ); asm( "mov %%g1, %0" : "=r" (tick) );
return( tick ); return( tick );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__alpha__) defined(__GNUC__) && defined(__alpha__)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -125,9 +157,12 @@ unsigned long hardclock( void ) ...@@ -125,9 +157,12 @@ unsigned long hardclock( void )
asm( "rpcc %0" : "=r" (cc) ); asm( "rpcc %0" : "=r" (cc) );
return( cc & 0xFFFFFFFF ); return( cc & 0xFFFFFFFF );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(POLARSSL_HAVE_ASM) && \
#if defined(POLARSSL_HAVE_ASM) && defined(__GNUC__) && defined(__ia64__) defined(__GNUC__) && defined(__ia64__)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -135,9 +170,11 @@ unsigned long hardclock( void ) ...@@ -135,9 +170,11 @@ unsigned long hardclock( void )
asm( "mov %0 = ar.itc" : "=r" (itc) ); asm( "mov %0 = ar.itc" : "=r" (itc) );
return( itc ); return( itc );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER)
#if defined(_MSC_VER)
#define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
...@@ -147,8 +184,11 @@ unsigned long hardclock( void ) ...@@ -147,8 +184,11 @@ unsigned long hardclock( void )
return (unsigned long)( offset.QuadPart ); return (unsigned long)( offset.QuadPart );
} }
#endif
#else #if !defined(POLARSSL_HAVE_HARDCLOCK)
#define POLARSSL_HAVE_HARDCLOCK
static int hardclock_init = 0; static int hardclock_init = 0;
static struct timeval tv_init; static struct timeval tv_init;
...@@ -167,15 +207,7 @@ unsigned long hardclock( void ) ...@@ -167,15 +207,7 @@ unsigned long hardclock( void )
return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000 return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000
+ ( tv_cur.tv_usec - tv_init.tv_usec ) ); + ( tv_cur.tv_usec - tv_init.tv_usec ) );
} }
#endif
#endif /* generic */
#endif /* WIN32 */
#endif /* IA-64 */
#endif /* Alpha */
#endif /* SPARC8 */
#endif /* PowerPC */
#endif /* AMD64 */
#endif /* i586+ */
volatile int alarmed = 0; volatile int alarmed = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment