blob: a8236fb3c42345c22f4e9b92339f9014836a7725 (
plain)
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
34
35
36
37
38
|
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
#include <sys/utsname.h>
static void oom(void)
{
fprintf(stderr, "out of virtual memory\n");
exit(2);
}
void *xmalloc(size_t sz)
{
void *p = calloc(sz,1);
if (!p)
oom();
return p;
}
void *xrealloc(void *oldp, size_t sz)
{
void *p = realloc(oldp,sz);
if (!p)
oom();
return p;
}
int kernel_version(void)
{
struct utsname uts;
int major, minor, patch;
if (uname(&uts) < 0)
return -1;
if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3)
return -1;
return KRELEASE(major,minor,patch);
}
|