Blame sysdeps/powerpc/powerpc32/power4/hp-timing.h

Packit Service 82fcde
/* High precision, low overhead timing functions.  powerpc64 version.
Packit Service 82fcde
   Copyright (C) 2005-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#ifndef _HP_TIMING_H
Packit Service 82fcde
#define _HP_TIMING_H	1
Packit Service 82fcde
Packit Service 82fcde
/* We always assume having the timestamp register.  */
Packit Service 82fcde
#define HP_TIMING_AVAIL		(1)
Packit Service 82fcde
#define HP_SMALL_TIMING_AVAIL	(1)
Packit Service 82fcde
Packit Service 82fcde
/* We indeed have inlined functions.  */
Packit Service 82fcde
#define HP_TIMING_INLINE	(1)
Packit Service 82fcde
Packit Service 82fcde
/* We use 64bit values for the times.  */
Packit Service 82fcde
typedef unsigned long long int hp_timing_t;
Packit Service 82fcde
Packit Service 82fcde
/* That's quite simple.  Use the `mftb' instruction.  Note that the value
Packit Service 82fcde
   might not be 100% accurate since there might be some more instructions
Packit Service 82fcde
   running in this moment.  This could be changed by using a barrier like
Packit Service 82fcde
   'lwsync' right before the `mftb' instruction.  But we are not interested
Packit Service 82fcde
   in accurate clock cycles here so we don't do this.  */
Packit Service 82fcde
Packit Service 82fcde
#define HP_TIMING_NOW(Var)						\
Packit Service 82fcde
  do {									\
Packit Service 82fcde
    unsigned int hi, lo, tmp;						\
Packit Service 82fcde
    __asm__ __volatile__ ("1:	mfspr	%0,269;"			\
Packit Service 82fcde
			  "	mfspr	%1,268;"			\
Packit Service 82fcde
			  "	mfspr	%2,269;"			\
Packit Service 82fcde
			  "	cmpw	%0,%2;"				\
Packit Service 82fcde
			  "	bne	1b;"				\
Packit Service 82fcde
			  : "=&r" (hi), "=&r" (lo), "=&r" (tmp)		\
Packit Service 82fcde
			  : : "cr0");					\
Packit Service 82fcde
    Var = ((hp_timing_t) hi << 32) | lo;				\
Packit Service 82fcde
  } while (0)
Packit Service 82fcde
Packit Service 82fcde
#include <hp-timing-common.h>
Packit Service 82fcde
Packit Service 82fcde
#endif	/* hp-timing.h */