00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * timing.h - Provide access to the Pentium/Athlon TSC timer register 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2001 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU General Public License 00023 * along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 * 00026 * $Id: timing.h,v 1.3 2005/11/27 06:10:12 steveu Exp $ 00027 */ 00028 00029 #if !defined(_TIMING_H_) 00030 #define _TIMING_H_ 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 #if defined(__i386__) 00037 static inline uint64_t rdtscll(void) 00038 { 00039 uint64_t now; 00040 00041 __asm__ __volatile__(" rdtsc\n" : "=A" (now)); 00042 return now; 00043 } 00044 /*- End of function --------------------------------------------------------*/ 00045 #elif defined(__x86_64__) 00046 static inline uint64_t rdtscll(void) 00047 { 00048 unsigned int __a; 00049 unsigned int __d; 00050 00051 __asm__ __volatile__(" rdtsc\n" : "=a" (__a), "=d" (__d)); 00052 return ((unsigned long) __a) | (((unsigned long) __d) << 32); 00053 } 00054 /*- End of function --------------------------------------------------------*/ 00055 #endif 00056 00057 #ifdef __cplusplus 00058 } 00059 #endif 00060 00061 #endif 00062 /*- End of file ------------------------------------------------------------*/