From d72d86263baa2386096b8599df9def85599ab2b3 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Fri, 22 Apr 2011 17:32:38 +0200 Subject: [PATCH] removed ticks.h --- src/ticks.h | 161 --------------------------------------------------------- src/timespec.h | 9 ++++ 2 files changed, 9 insertions(+), 161 deletions(-) delete mode 100644 src/ticks.h diff --git a/src/ticks.h b/src/ticks.h deleted file mode 100644 index d43f4c35..00000000 --- a/src/ticks.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * netsniff-ng - the packet sniffing beast - * By Daniel Borkmann - * Copyright 2009, 2010 Daniel Borkmann. - * Subject to the GPL. - */ - -/* - * The following API for netsniff-ng will be provided (e.g. for benchmarking - * purpose, debugging or high-pres (but arch dependent!) time): - * ticks_t getticks(void); - * double elapsed(ticks_t t1, ticks_t t0); - */ - -/* - * Copyright (c) 2003, 2007-8 Matteo Frigo - * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef TICKS_H -#define TICKS_H - -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - -/* Intel Pentium / AMD Time Stamp Counter register */ -#if (defined(__GNUC__) || defined(__ICC)) && defined(__i386__) && \ - !defined(HAVE_TICK_COUNTER) -typedef unsigned long long ticks_t; - -static __inline__ ticks_t getticks(void) -{ - ticks_t ret; - __asm__ __volatile__("rdtsc":"=A"(ret)); - return ret; -} - -static __inline__ double elapsed(ticks_t t1, ticks_t t0) -{ - return (double)t1 - (double)t0; -} - -# define HAVE_TICK_COUNTER -# define TIME_MIN 5000.0 /* Unreliable Pentium IV cycle counter */ -#endif /* Intel Pentium / AMD Time Stamp Counter register */ - -/* PowerPC */ -#if ((((defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))) || \ - (defined(__MWERKS__) && defined(macintosh)))) || \ - (defined(__IBM_GCC_ASM) && (defined(__powerpc__) || \ - defined(__ppc__)))) && \ - !defined(HAVE_TICK_COUNTER) -typedef unsigned long long ticks_t; - -static __inline__ ticks_t getticks(void) -{ - unsigned int tbl, tbu0, tbu1; - - do { - __asm__ __volatile__("mftbu %0":"=r"(tbu0)); - __asm__ __volatile__("mftb %0":"=r"(tbl)); - __asm__ __volatile__("mftbu %0":"=r"(tbu1)); - } while (tbu0 != tbu1); - - return (((unsigned long long)tbu0) << 32) | tbl; -} - -static __inline__ double elapsed(ticks_t t1, ticks_t t0) -{ - return (double)t1 - (double)t0; -} - -# define HAVE_TICK_COUNTER -#endif /* PowerPC */ - -/* Intel Pentium / AMD, 64 Bit Time Stamp Counter register */ -#if (defined(__GNUC__) || defined(__ICC) || defined(__SUNPRO_C)) && \ - defined(__x86_64__) && !defined(HAVE_TICK_COUNTER) -typedef unsigned long long ticks_t; - -static __inline__ ticks_t getticks(void) -{ - unsigned a, d; - __asm__ __volatile__("rdtsc":"=a"(a), "=d"(d)); - return ((ticks_t) a) | (((ticks_t) d) << 32); -} - -static __inline__ double elapsed(ticks_t t1, ticks_t t0) -{ - return (double)t1 - (double)t0; -} - -# define HAVE_TICK_COUNTER -#endif /* Intel Pentium / AMD, 64 Bit Time Stamp Counter register */ - -/* IA64 cycle counter, gcc version */ -#if defined(__GNUC__) && defined(__ia64__) && !defined(HAVE_TICK_COUNTER) -typedef unsigned long ticks_t; - -static __inline__ ticks_t getticks(void) -{ - ticks_t ret; - __asm__ __volatile__("mov %0=ar.itc":"=r"(ret)); - return ret; -} - -static __inline__ double elapsed(ticks_t t1, ticks_t t0) -{ - return (double)t1 - (double)t0; -} - -# define HAVE_TICK_COUNTER -#endif /* IA64 cycle counter, gcc version */ - -/* SPARC */ -#if defined(__GNUC__) && defined(__sparc_v9__) && !defined(HAVE_TICK_COUNTER) -typedef unsigned long ticks_t; - -static __inline__ ticks_t getticks(void) -{ - ticks_t ret; - __asm__ __volatile__("rd %%tick, %0":"=r"(ret)); - return ret; -} - -static __inline__ double elapsed(ticks_t t1, ticks_t t0) -{ - return (double)t1 - (double)t0; -} - -# define HAVE_TICK_COUNTER -#endif /* SPARC */ - -#endif /* TICKS_H */ diff --git a/src/timespec.h b/src/timespec.h index fff000fe..c11dad8c 100644 --- a/src/timespec.h +++ b/src/timespec.h @@ -167,4 +167,13 @@ static inline int set_timeout(struct timeval *timeval, unsigned int msec) return 0; } +/* x86 ticks */ +static unsigned long long getticks(void) +{ + unsigned int __a,__d; + + __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); + return ((long long)__a) | (((long long)__d)<<32); +} + #endif /* TIMESPEC_H */ -- 2.11.4.GIT