nengel@2: /* nengel@2: * Copyright (c) 2005 Luca Barbato nengel@2: * nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: #ifndef AVUTIL_PPC_TIMER_H nengel@2: #define AVUTIL_PPC_TIMER_H nengel@2: nengel@2: #include nengel@2: nengel@2: #define AV_READ_TIME read_time nengel@2: nengel@2: static inline uint64_t read_time(void) nengel@2: { nengel@2: uint32_t tbu, tbl, temp; nengel@2: nengel@2: /* from section 2.2.1 of the 32-bit PowerPC PEM */ nengel@2: __asm__ volatile( nengel@2: "1:\n" nengel@2: "mftbu %2\n" nengel@2: "mftb %0\n" nengel@2: "mftbu %1\n" nengel@2: "cmpw %2,%1\n" nengel@2: "bne 1b\n" nengel@2: : "=r"(tbl), "=r"(tbu), "=r"(temp) nengel@2: : nengel@2: : "cc"); nengel@2: nengel@2: return (((uint64_t)tbu)<<32) | (uint64_t)tbl; nengel@2: } nengel@2: nengel@2: #endif /* AVUTIL_PPC_TIMER_H */