3029N/A/*
3029N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3029N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3029N/A *
3029N/A * This code is free software; you can redistribute it and/or modify it
3029N/A * under the terms of the GNU General Public License version 2 only, as
3029N/A * published by the Free Software Foundation.
3029N/A *
3029N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3029N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3029N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3029N/A * version 2 for more details (a copy is included in the LICENSE file that
3029N/A * accompanied this code).
3029N/A *
3029N/A * You should have received a copy of the GNU General Public License version
3029N/A * 2 along with this work; if not, write to the Free Software Foundation,
3029N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3029N/A *
3029N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3029N/A * or visit www.oracle.com if you need additional information or have any
3029N/A * questions.
3029N/A *
3029N/A */
3029N/A
3029N/A#ifndef OS_CPU_BSD_X86_VM_OS_BSD_X86_INLINE_HPP
3029N/A#define OS_CPU_BSD_X86_VM_OS_BSD_X86_INLINE_HPP
3029N/A
3029N/A#include "runtime/os.hpp"
3029N/A
3029N/A// See http://www.technovelty.org/code/c/reading-rdtsc.htl for details
3029N/Ainline jlong os::rdtsc() {
3029N/A#ifndef AMD64
3029N/A // 64 bit result in edx:eax
3029N/A uint64_t res;
3029N/A __asm__ __volatile__ ("rdtsc" : "=A" (res));
3029N/A return (jlong)res;
3029N/A#else
3029N/A uint64_t res;
3029N/A uint32_t ts1, ts2;
3029N/A __asm__ __volatile__ ("rdtsc" : "=a" (ts1), "=d" (ts2));
3029N/A res = ((uint64_t)ts1 | (uint64_t)ts2 << 32);
3029N/A return (jlong)res;
3029N/A#endif // AMD64
3029N/A}
3029N/A
3029N/A#endif // OS_CPU_BSD_X86_VM_OS_BSD_X86_INLINE_HPP