7 Star 0 Fork 2

OpenCloudOS Stream/python-cpuinfo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-pycpuinfo-9.0.0-add-loongarch-support.patch 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
streamlet_hy 提交于 2024-05-10 01:28 . add loongarch support
From e167c73cf7fc6b93e72a8de1f2c31805587e31bb Mon Sep 17 00:00:00 2001
From: Huang Yang <huangyang@loongson.cn>
Date: Thu, 9 May 2024 12:28:55 +0000
Subject: [PATCH] init
---
cpuinfo/cpuinfo.py | 11 +++++++++--
tests/test_invalid_cpu.py | 2 +-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/cpuinfo/cpuinfo.py b/cpuinfo/cpuinfo.py
index ea2f90e..a8ebefd 100644
--- a/cpuinfo/cpuinfo.py
+++ b/cpuinfo/cpuinfo.py
@@ -362,9 +362,9 @@ def _check_arch():
arch, bits = _parse_arch(DataSource.arch_string_raw)
if not arch in ['X86_32', 'X86_64', 'ARM_7', 'ARM_8',
'PPC_64', 'S390X', 'MIPS_32', 'MIPS_64',
- "RISCV_32", "RISCV_64"]:
+ "RISCV_32", "RISCV_64","LOONGARCH_32","LOONGARCH_64"]:
raise Exception("py-cpuinfo currently only works on X86 "
- "and some ARM/PPC/S390X/MIPS/RISCV CPUs.")
+ "and some ARM/PPC/S390X/MIPS/RISCV/LOONGARCH CPUs.")
def _obj_to_b64(thing):
import pickle
@@ -829,6 +829,13 @@ def _parse_arch(arch_string_raw):
elif re.match(r'^riscv64$|^riscv64be$', arch_string_raw):
arch = 'RISCV_64'
bits = 64
+ # LoongArch
+ elif arch_string_raw == 'loongarch32':
+ arch = 'LOONGARCH_32'
+ bits = 32
+ elif arch_string_raw == 'loongarch64':
+ arch = 'LOONGARCH_64'
+ bits = 64
return (arch, bits)
diff --git a/tests/test_invalid_cpu.py b/tests/test_invalid_cpu.py
index d4e75a0..f413d64 100644
--- a/tests/test_invalid_cpu.py
+++ b/tests/test_invalid_cpu.py
@@ -33,4 +33,4 @@ class TestInvalidCPU(unittest.TestCase):
cpuinfo._check_arch()
self.fail('Failed to raise Exception')
except Exception as err:
- self.assertEqual('py-cpuinfo currently only works on X86 and some ARM/PPC/S390X/MIPS/RISCV CPUs.', err.args[0])
+ self.assertEqual('py-cpuinfo currently only works on X86 and some ARM/PPC/S390X/MIPS/RISCV/LOONGARCH CPUs.', err.args[0])
--
2.43.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opencloudos-stream/python-cpuinfo.git
git@gitee.com:opencloudos-stream/python-cpuinfo.git
opencloudos-stream
python-cpuinfo
python-cpuinfo
master

搜索帮助