Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/timing.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * timing.h - Provide access to the Pentium/Athlon TSC timer register | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2001 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: timing.h,v 1.14 2009/09/04 14:38:47 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 #if !defined(_SPANDSP_TIMING_H_) | |
| 29 #define _SPANDSP_TIMING_H_ | |
| 30 | |
| 31 #if defined(__cplusplus) | |
| 32 extern "C" | |
| 33 { | |
| 34 #endif | |
| 35 | |
| 36 #if defined(__MSVC__) | |
| 37 __declspec(naked) unsigned __int64 __cdecl rdtscll(void) | |
| 38 { | |
| 39 __asm | |
| 40 { | |
| 41 rdtsc | |
| 42 ret ; return value at EDX:EAX | |
| 43 } | |
| 44 } | |
| 45 /*- End of function --------------------------------------------------------*/ | |
| 46 #elif defined(__GNUC__) | |
| 47 #if defined(__i386__) | |
| 48 static __inline__ uint64_t rdtscll(void) | |
| 49 { | |
| 50 uint64_t now; | |
| 51 | |
| 52 __asm__ __volatile__(" rdtsc\n" : "=A" (now)); | |
| 53 return now; | |
| 54 } | |
| 55 /*- End of function --------------------------------------------------------*/ | |
| 56 #elif defined(__x86_64__) | |
| 57 static __inline__ uint64_t rdtscll(void) | |
| 58 { | |
| 59 uint32_t a; | |
| 60 uint32_t d; | |
| 61 | |
| 62 /* For x86_64 we need to merge the result in 2 32 bit registers | |
| 63 into one clean 64 bit result. */ | |
| 64 __asm__ __volatile__(" rdtsc\n" : "=a" (a), "=d" (d)); | |
| 65 return ((uint64_t) a) | (((uint64_t) d) << 32); | |
| 66 } | |
| 67 /*- End of function --------------------------------------------------------*/ | |
| 68 #else | |
| 69 static __inline__ uint64_t rdtscll(void) | |
| 70 { | |
| 71 /* This architecture doesn't have a suitable timer */ | |
| 72 return 0llu; | |
| 73 } | |
| 74 /*- End of function --------------------------------------------------------*/ | |
| 75 #endif | |
| 76 #endif | |
| 77 | |
| 78 #if defined(__cplusplus) | |
| 79 } | |
| 80 #endif | |
| 81 | |
| 82 #endif | |
| 83 /*- End of file ------------------------------------------------------------*/ |
