1 Star 0 Fork 5

Rastus/ras-tools

forked from anolis/ras-tools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
proc_interrupt.c 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
Tony Luck 提交于 2022-09-21 08:00 . ras-tools: Add SPDX license tags
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2015 Intel Corporation
* Author: Tony Luck
*
* This software may be redistributed and/or modified under the terms of
* the GNU General Public License ("GPL") version 2 only as published by the
* Free Software Foundation.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
static long sumint(char *s)
{
long total = 0;
char *se;
for (;;) {
total += strtol(s, &se, 10);
if (s == se)
break;
s = se;
}
return total;
}
/*
* Parse /proc/interrupts to sum the number of observed
* machine checks and corrected machine check interrupts
* across all cpus
*/
void proc_interrupts(long *nmce, long *ncmci)
{
FILE *fp = fopen("/proc/interrupts", "r");
char *p, line[4096];
*ncmci = *nmce = -1;
if (fp == NULL)
return;
while (fgets(line, sizeof(line), fp) != NULL) {
for (p = line; isspace(*p); p++)
;
if (strncmp(p, "MCE:", 4) == 0)
*nmce = sumint(p+4);
else if (strncmp(p, "THR:", 4) == 0)
*ncmci = sumint(p+4);
}
fclose(fp);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rastus/ras-tools.git
git@gitee.com:rastus/ras-tools.git
rastus
ras-tools
ras-tools
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385