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