chromium/third_party/ffmpeg/libavutil/timer.h

/*
 * copyright (c) 2006 Michael Niedermayer <[email protected]>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/**
 * @file
 * high precision timer, useful to profile code
 */

#ifndef AVUTIL_TIMER_H
#define AVUTIL_TIMER_H

#include "config.h"

#if CONFIG_LINUX_PERF
# ifndef _GNU_SOURCE
#define _GNU_SOURCE
# endif
# include <unistd.h> // read(3)
# include <sys/ioctl.h>
# include <asm/unistd.h>
# include <linux/perf_event.h>
#endif

#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

#if CONFIG_MACOS_KPERF
#include "macos_kperf.h"
#elif HAVE_MACH_ABSOLUTE_TIME
#include <mach/mach_time.h>
#endif

#include "common.h"
#include "log.h"

#if   ARCH_AARCH64
#   include "aarch64/timer.h"
#elif ARCH_ARM
#   include "arm/timer.h"
#elif ARCH_PPC
#   include "ppc/timer.h"
#elif ARCH_RISCV
#   include "riscv/timer.h"
#elif ARCH_X86
#   include "x86/timer.h"
#elif ARCH_LOONGARCH
#   include "loongarch/timer.h"
#endif

#if !defined(AV_READ_TIME)
#   if HAVE_GETHRTIME
#define AV_READ_TIME
#   elif HAVE_MACH_ABSOLUTE_TIME
#define AV_READ_TIME
#   endif
#endif

#ifndef FF_TIMER_UNITS
#define FF_TIMER_UNITS
#endif

#define TIMER_REPORT(id, tdiff)

#if CONFIG_LINUX_PERF

#define START_TIMER

#define STOP_TIMER

#elif CONFIG_MACOS_KPERF

#define START_TIMER

#define STOP_TIMER

#elif defined(AV_READ_TIME)
#define START_TIMER           \

#define STOP_TIMER(id)
#else
#define START_TIMER
#define STOP_TIMER
#endif

#endif /* AVUTIL_TIMER_H */