blob: 2c9a2f4e013ac647143e880fec81fb43d3fc6e29 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef NOMMU_H
#define NOMMU_H
#include <stdio.h>
#include <string.h>
/* Returns 1 for NOMMU, 0 for MMU, and -1 if /proc/meminfo is unavailable. */
static inline int ksft_is_nommu(void)
{
FILE *fp;
char line[256];
int nommu = 0;
fp = fopen("/proc/meminfo", "r");
if (!fp)
return -1;
while (fgets(line, sizeof(line), fp)) {
if (strncmp(line, "MmapCopy:", sizeof("MmapCopy:") - 1) == 0) {
nommu = 1;
break;
}
}
if (ferror(fp))
nommu = -1;
fclose(fp);
return nommu;
}
#endif
|