📄 gr_cpu.cc
字号:
/* -*- c++ -*- *//* * Copyright 2002 Free Software Foundation, Inc. * * This file is part of GNU Radio * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * GNU Radio 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#include <gr_cpu.h>/* * execute CPUID instruction, return EAX, EBX, ECX and EDX values in result */extern "C" {void cpuid_x86 (unsigned int op, unsigned int result[4]);};/* * CPUID functions returning a single datum */static inline unsigned int cpuid_eax(unsigned int op){ unsigned int regs[4]; cpuid_x86 (op, regs); return regs[0];}static inline unsigned int cpuid_ebx(unsigned int op){ unsigned int regs[4]; cpuid_x86 (op, regs); return regs[1];}static inline unsigned int cpuid_ecx(unsigned int op){ unsigned int regs[4]; cpuid_x86 (op, regs); return regs[2];}static inline unsigned int cpuid_edx(unsigned int op){ unsigned int regs[4]; cpuid_x86 (op, regs); return regs[3];}// ----------------------------------------------------------------boolgr_cpu::has_mmx (){ unsigned int edx = cpuid_edx (1); // standard features return (edx & (1 << 23)) != 0;}boolgr_cpu::has_sse (){ unsigned int edx = cpuid_edx (1); // standard features return (edx & (1 << 25)) != 0;}boolgr_cpu::has_sse2 (){ unsigned int edx = cpuid_edx (1); // standard features return (edx & (1 << 26)) != 0;}boolgr_cpu::has_3dnow (){ unsigned int extended_fct_count = cpuid_eax (0x80000000); if (extended_fct_count < 0x80000001) return false; unsigned int extended_features = cpuid_edx (0x80000001); return (extended_features & (1 << 31)) != 0;}boolgr_cpu::has_3dnowext (){ unsigned int extended_fct_count = cpuid_eax (0x80000000); if (extended_fct_count < 0x80000001) return false; unsigned int extended_features = cpuid_edx (0x80000001); return (extended_features & (1 << 30)) != 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -