View | Details | Raw Unified | Return to bug 214878
Collapse All | Expand All

(-)Makefile (-8 / +15 lines)
Lines 2-14 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	x86info
4
PORTNAME=	x86info
5
PORTVERSION=	1.30
5
PORTVERSION=	1.31snap01
6
PORTREVISION=	1
7
CATEGORIES=	sysutils
6
CATEGORIES=	sysutils
8
MASTER_SITES=	http://codemonkey.org.uk/projects/x86info/
7
MASTER_SITES=	https://github.com/kernelslacker/x86info
8
USE_GITHUB=	yes
9
GH_ACCOUNT=	kernelslacker
10
GH_PROJECT=	x86info
11
GH_TAGNAME=	636fbaa
9
12
10
MAINTAINER=	ports@FreeBSD.org
13
MAINTAINER=	ports@FreeBSD.org
11
COMMENT=	x86 CPU identification utility
14
COMMENT=	x86 CPU identification and feature display utility
12
15
13
LICENSE=	GPLv2
16
LICENSE=	GPLv2
14
17
Lines 21-35 Link Here
21
24
22
PLIST_FILES=	bin/lsmsr bin/x86info man/man8/lsmsr.8.gz man/man1/x86info.1.gz
25
PLIST_FILES=	bin/lsmsr bin/x86info man/man8/lsmsr.8.gz man/man1/x86info.1.gz
23
26
27
do-build:
28
	cd ${WRKSRC} && ${MAKE_CMD}
29
	cd ${WRKSRC}/lsmsr && ${MAKE_CMD}
30
24
do-install:
31
do-install:
25
	${INSTALL_PROGRAM} ${WRKSRC}/x86info ${STAGEDIR}${PREFIX}/bin
32
	${INSTALL_PROGRAM} ${WRKSRC}/x86info ${STAGEDIR}${PREFIX}/bin
26
	${INSTALL_PROGRAM} ${WRKSRC}/lsmsr ${STAGEDIR}${PREFIX}/bin
33
	${INSTALL_PROGRAM} ${WRKSRC}/lsmsr/lsmsr ${STAGEDIR}${PREFIX}/bin
27
	${INSTALL_MAN} ${WRKSRC}/x86info.1 ${STAGEDIR}${MAN1PREFIX}/man/man1
34
	${INSTALL_MAN} ${WRKSRC}/x86info.1 ${STAGEDIR}${MAN1PREFIX}/man/man1
28
	${INSTALL_MAN} ${WRKSRC}/lsmsr.8 ${STAGEDIR}${MAN8PREFIX}/man/man8
35
	${INSTALL_MAN} ${WRKSRC}/lsmsr/lsmsr.8 ${STAGEDIR}${MAN8PREFIX}/man/man8
29
36
30
post-patch:
37
post-patch:
31
	@${REINPLACE_CMD} \
38
	@${REINPLACE_CMD} \
32
		-e 's|python scripts/createheader.py|${PYTHON_CMD} scripts/createheader.py|' \
39
		-e 's|python createheader.py|${PYTHON_CMD} createheader.py|' \
33
		${WRKSRC}/Makefile
40
		${WRKSRC}/lsmsr/Makefile
34
41
35
.include <bsd.port.mk>
42
.include <bsd.port.mk>
(-)distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (x86info-1.30.tgz) = fe3009850e93a9c5fa38ed6bf74d72686043329fead8f1b2be4b5943d4fc9428
1
TIMESTAMP = 1480247467
2
SIZE (x86info-1.30.tgz) = 95727
2
SHA256 (kernelslacker-x86info-1.31snap01-636fbaa_GH0.tar.gz) = 86f832da6ffcb2097fb10d6bab279d15470357f2efbbf1afd647fa26cd056e8c
3
SIZE (kernelslacker-x86info-1.31snap01-636fbaa_GH0.tar.gz) = 85199
(-)files/patch-AMD_powernow.c (-13 lines)
Lines 1-13 Link Here
1
--- AMD/powernow.c.orig	2011-09-15 15:43:33.000000000 -0700
2
+++ AMD/powernow.c	2011-09-15 15:43:40.000000000 -0700
3
@@ -9,8 +9,9 @@
4
 #include <stdio.h>
5
 #include <unistd.h>
6
 #include <sys/types.h>
7
-#include <pci/pci.h>
8
 #include "../x86info.h"
9
+#define	PCI_HAVE_Uxx_TYPES
10
+#include <pci/pci.h>
11
 #include "AMD.h"
12
 #include "powernow.h"
13
 
(-)files/patch-Intel_cachesize.c (-10 lines)
Lines 1-10 Link Here
1
--- Intel/cachesize.c.orig	2008-08-09 22:04:12.000000000 +0400
2
+++ Intel/cachesize.c	2008-08-09 22:04:24.000000000 +0400
3
@@ -147,6 +147,7 @@
4
 {
5
 	{0xf0, 64, "64 byte prefetching."},
6
 	{0xf1, 64, "128 byte prefetching."},
7
+	{ 0, 0, NULL }
8
 };
9
 
10
 static unsigned char found_unknown=0;
(-)files/patch-Intel_topology.c (-18 lines)
Lines 1-18 Link Here
1
--- Intel/topology.c.orig	2011-09-15 15:36:57.000000000 -0700
2
+++ Intel/topology.c	2011-09-15 15:37:10.000000000 -0700
3
@@ -20,6 +20,7 @@
4
  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
5
  */
6
 
7
+#ifndef __FreeBSD__	/* FreeBSD has fls() in strings.h */
8
 static int fls(int x)
9
 {
10
 	int r = 32;
11
@@ -48,6 +49,7 @@
12
 	}
13
 	return r;
14
 }
15
+#endif
16
 
17
 static int get_count_order(unsigned int count)
18
 {
(-)files/patch-Makefile (-19 / +18 lines)
Lines 1-22 Link Here
1
--- Makefile.orig	2011-09-15 15:43:52.000000000 -0700
1
diff --git Makefile Makefile
2
+++ Makefile	2011-09-15 15:44:01.000000000 -0700
2
index 03bc20f..06109bb 100644
3
@@ -1,8 +1,8 @@
3
--- Makefile
4
 VERSION=1.30
4
+++ Makefile
5
@@ -18,6 +18,7 @@ CFLAGS += -Wstrict-prototypes -Wmissing-prototypes
6
 CFLAGS += -Wswitch-enum
7
 CFLAGS += -Wundef
8
 CFLAGS += -Wwrite-strings
9
+CFLAGS += `pkg-config --cflags libpci`
5
 
10
 
6
-CFLAGS = -g -O2 -Werror -Wall -Wshadow -Wextra -Wmissing-declarations -Wdeclaration-after-statement -Wredundant-decls
11
 # gcc specific
7
+CFLAGS += -Wall -Wshadow -Wextra -Wmissing-declarations -Wdeclaration-after-statement -Wredundant-decls `pkg-config --cflags libpci`
12
 ifneq ($(shell $(CC) -v 2>&1 | grep -c "clang"), 1)
8
 LDFLAGS = -Wl,-z,relro,-z,now
13
@@ -67,7 +68,7 @@ X86INFO_OBJS = $(sort $(patsubst %.c,%.o,$(wildcard *.c))) \
9
-CC = gcc
10
+CC ?= gcc
11
 
14
 
12
 SHELL = /bin/sh
15
 x86info: $(X86INFO_OBJS) $(X86INFO_HEADERS)
16
 	$(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o x86info $(X86INFO_OBJS) \
17
-	    $(LIBPCI)
18
+	    `pkg-config --libs libpci` $(LIBPCI)
13
 
19
 
14
@@ -91,7 +91,7 @@
20
 DEPDIR= .deps
15
 X86INFO_OBJS = $(X86INFO_SRC:%.c=%.o)
21
 -include $(X86INFO_SRC:%.c=$(DEPDIR)/%.d)
16
 
17
 x86info: $(X86INFO_OBJS)
18
-	$(CC) $(CFLAGS) $(LDFLAGS) -o x86info $(X86INFO_OBJS) -lpci
19
+	$(CC) $(CFLAGS) $(LDFLAGS) -o x86info $(X86INFO_OBJS) `pkg-config --libs libpci` -lpci
20
 
21
 
22
 
(-)files/patch-apic.c (-10 lines)
Lines 1-10 Link Here
1
--- apic.c.orig	2011-09-15 15:38:59.000000000 -0700
2
+++ apic.c	2011-09-15 15:39:09.000000000 -0700
3
@@ -8,6 +8,7 @@
4
  */
5
 
6
 #include <stdio.h>
7
+#include <unistd.h>
8
 #include "apic.h"
9
 #include "x86info.h"
10
 
(-)files/patch-cpuid.c (-111 lines)
Lines 1-111 Link Here
1
--- cpuid.c.orig	2011-09-15 15:43:00.000000000 -0700
2
+++ cpuid.c	2011-09-15 15:43:08.000000000 -0700
3
@@ -23,8 +23,16 @@
4
 #include <sched.h>
5
 
6
 #if defined(__FreeBSD__)
7
+# include <sys/param.h>
8
+# include <sys/cpuset.h>
9
 # include <sys/ioctl.h>
10
-# include <cpu.h>
11
+# if __FreeBSD_version < 701102
12
+#  define CPUDEV "/dev/cpu%d"
13
+#  include <cpu.h>
14
+# else
15
+#  define CPUDEV "/dev/cpuctl%d"
16
+#  include <sys/cpuctl.h>
17
+# endif
18
 #endif
19
 
20
 #include "x86info.h"
21
@@ -45,7 +53,11 @@
22
 	unsigned int *eax, unsigned int *ebx,
23
 	unsigned int *ecx, unsigned int *edx)
24
 {
25
+#if defined(__FreeBSD__)
26
+	cpuset_t set, tmp_set;
27
+#else
28
 	cpu_set_t set, tmp_set;
29
+#endif
30
 	unsigned int a = 0, b = 0, c = 0, d = 0;
31
 	int ret;
32
 
33
@@ -58,15 +70,25 @@
34
 	if (edx != NULL)
35
 		d = *edx;
36
 
37
+#if defined(__FreeBSD__)
38
+	ret = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
39
+	    -1, sizeof(set), &set);
40
+#else
41
 	ret = sched_getaffinity(getpid(), sizeof(set), &set);
42
+#endif
43
 	if (ret)
44
 		return ret;
45
 
46
 	/* man CPU_SET(3): To duplicate a CPU set, use memcpy(3) */
47
-	memcpy(&tmp_set, &set, sizeof(cpu_set_t));
48
+	memcpy(&tmp_set, &set, sizeof(tmp_set));
49
 	CPU_ZERO(&set);
50
 	CPU_SET(cpunr, &set);
51
+#if defined(__FreeBSD__)
52
+	ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
53
+	    -1, sizeof(set), &set);
54
+#else
55
 	ret = sched_setaffinity(getpid(), sizeof(set), &set);
56
+#endif
57
 	if (ret)
58
 		return ret;
59
 
60
@@ -87,7 +109,12 @@
61
 		*edx = d;
62
 
63
 	/* Restore initial sched affinity */
64
+#if defined(__FreeBSD__)
65
+	ret = cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID,
66
+	    -1, sizeof(tmp_set), &tmp_set);
67
+#else
68
 	ret = sched_setaffinity(getpid(), sizeof(tmp_set), &tmp_set);
69
+#endif
70
 	if (ret)
71
 		return ret;
72
 	return 0;
73
@@ -104,9 +131,12 @@
74
 {
75
 	static int nodriver=0;
76
 	char cpuname[20];
77
-	unsigned char buffer[16];
78
 	int fh;
79
+#if __FreeBSD_version < 701102
80
 	cpu_cpuid_args_t args;
81
+#else
82
+	cpuctl_cpuid_args_t args;
83
+#endif
84
 
85
 	if (nodriver == 1) {
86
 		if (native_cpuid(CPU_number, idx, eax,ebx,ecx,edx))
87
@@ -116,10 +146,14 @@
88
 
89
 	args.level = idx;
90
 	/* Ok, use the /dev/CPU interface in preference to the _up code. */
91
-	(void)snprintf(cpuname,18, "/dev/cpu%d", CPU_number);
92
+	(void)snprintf(cpuname,18, CPUDEV, CPU_number);
93
 	fh = open(cpuname, O_RDONLY);
94
 	if (fh != -1) {
95
+#if __FreeBSD_version < 701102
96
 		if (ioctl(fh, CPU_CPUID, &args) != 0) {
97
+#else
98
+		if (ioctl(fh, CPUCTL_CPUID, &args) != 0) {
99
+#endif
100
 			perror(cpuname);
101
 			exit(EXIT_FAILURE);
102
 		}
103
@@ -134,8 +168,6 @@
104
 	} else {
105
 		/* Something went wrong, just do UP and hope for the best. */
106
 		nodriver = 1;
107
-		if (nrCPUs != 1)
108
-			perror(cpuname);
109
 		if (native_cpuid(CPU_number, idx, eax,ebx,ecx,edx))
110
 			printf("%s", NATIVE_CPUID_FAILED_MSG);
111
 
(-)files/patch-lsmsr.c (-82 lines)
Lines 1-82 Link Here
1
--- lsmsr.c.orig	2011-04-05 15:54:04.000000000 -0700
2
+++ lsmsr.c	2011-09-15 16:44:15.000000000 -0700
3
@@ -31,6 +31,18 @@
4
 #include "AMD/fam11h.h"
5
 #include "generic_msr.h"
6
 
7
+#if defined(__FreeBSD__)
8
+# include <sys/param.h>
9
+# include <sys/ioctl.h>
10
+# if __FreeBSD_version < 701102
11
+#  define CPUDEV "/dev/cpu%d"
12
+#  include <cpu.h>
13
+# else
14
+#  define CPUDEV "/dev/cpuctl%d"
15
+#  include <sys/cpuctl.h>
16
+# endif
17
+#endif
18
+
19
 /* Todos:
20
  * - add (list and eventually write) support for write-only MSR
21
  * - add decoding support for bit fields
22
@@ -116,6 +128,33 @@
23
 	fprintf(stdout, "%s version %s\n", g.prog, VERSION);
24
 }
25
 
26
+#if defined(__FreeBSD__)
27
+
28
+static int get_msr_val(unsigned int msr, unsigned long long *val)
29
+{
30
+#if __FreeBSD_version < 701102
31
+	cpu_msr_args_t args;
32
+#else   
33
+	cpuctl_msr_args_t args;
34
+#endif
35
+
36
+	args.msr = msr;
37
+#if __FreeBSD_version < 701102
38
+	if (ioctl(g.fd, CPU_RDMSR, &args) != 0) {
39
+#else
40
+	if (ioctl(g.fd, CPUCTL_RDMSR, &args) != 0) {
41
+#endif
42
+		fflush(stdout);
43
+		fprintf(stderr,
44
+			"could not read MSR 0x%8.8x (%s): %s\n",
45
+			msr, get_reg_name(msr, g.msr_table), strerror(errno));
46
+		return 0;
47
+	}
48
+	*val = args.data;
49
+
50
+	return 0;
51
+}
52
+#else /* !__FreeBSD__ */
53
 static int get_msr_val(unsigned int msr, unsigned long long *val)
54
 {
55
 	off64_t off;
56
@@ -141,11 +180,17 @@
57
 	return 0;
58
 }
59
 
60
+#endif
61
+
62
 static int open_dev(int cpu)
63
 {
64
 	char s[20];
65
 
66
+#ifdef __FreeBSD__
67
+	snprintf(s, sizeof(s), CPUDEV, cpu);
68
+#else
69
 	snprintf(s, sizeof(s), "/dev/cpu/%d/msr", cpu);
70
+#endif
71
 	g.fd = open(s, O_RDONLY);
72
 	if (g.fd < 0)
73
 		fprintf(stderr, "could not open device %s: %s\n", s,
74
@@ -161,7 +206,7 @@
75
 
76
 static int _show_msr(struct reg_spec *reg)
77
 {
78
-	unsigned long long val;
79
+	unsigned long long val = 0;
80
 	if (!g.list)
81
 		if (get_msr_val(reg->address, &val))
82
 			return 1;
(-)files/patch-lsmsr_Makefile (+17 lines)
Line 0 Link Here
1
diff --git lsmsr/Makefile lsmsr/Makefile
2
index 1183f6e..b4d39ef 100644
3
--- lsmsr/Makefile
4
+++ lsmsr/Makefile
5
@@ -14,12 +14,10 @@ CFLAGS += -Wdeclaration-after-statement
6
 CFLAGS += -Wformat=2
7
 CFLAGS += -Wimplicit
8
 CFLAGS += -Winit-self
9
-CFLAGS += -Wlogical-op
10
 CFLAGS += -Wmissing-declarations -Wredundant-decls
11
 CFLAGS += -Wnested-externs
12
 CFLAGS += -Wpacked
13
 CFLAGS += -Wshadow
14
-CFLAGS += -Wstrict-aliasing=3
15
 CFLAGS += -Wstrict-prototypes -Wmissing-prototypes
16
 CFLAGS += -Wswitch-enum
17
 CFLAGS += -Wundef
(-)files/patch-lsmsr_lsmsr.c (+102 lines)
Line 0 Link Here
1
diff --git lsmsr/lsmsr.c lsmsr/lsmsr.c
2
index b39a9f4..da409b9 100644
3
--- lsmsr/lsmsr.c
4
+++ lsmsr/lsmsr.c
5
@@ -34,6 +34,18 @@
6
 #include "AMD_fam15h.h"
7
 #include "generic_msr.h"
8
 
9
+#if defined(__FreeBSD__)
10
+# include <sys/param.h>
11
+# include <sys/ioctl.h>
12
+# if __FreeBSD_version < 701102
13
+#  define CPUDEV "/dev/cpu%d"
14
+#  include <cpu.h>
15
+# else
16
+#  define CPUDEV "/dev/cpuctl%d"
17
+#  include <sys/cpuctl.h>
18
+# endif
19
+#endif
20
+
21
 /* Todos:
22
  * - add (list and eventually write) support for write-only MSR
23
  * - add decoding support for bit fields
24
@@ -119,13 +131,40 @@ static void version(void)
25
 	fprintf(stdout, "%s version %s\n", g.prog, LSMSR_VERSION);
26
 }
27
 
28
+#if defined(__FreeBSD__)
29
+
30
+static int get_msr_val(unsigned int msr, unsigned long long *val)
31
+{
32
+#if __FreeBSD_version < 701102
33
+	cpu_msr_args_t args;
34
+#else   
35
+	cpuctl_msr_args_t args;
36
+#endif
37
+
38
+	args.msr = msr;
39
+#if __FreeBSD_version < 701102
40
+	if (ioctl(g.fd, CPU_RDMSR, &args) != 0) {
41
+#else
42
+	if (ioctl(g.fd, CPUCTL_RDMSR, &args) != 0) {
43
+#endif
44
+		fflush(stdout);
45
+		fprintf(stderr,
46
+			"could not read MSR 0x%8.8x (%s): %s\n",
47
+			msr, get_reg_name(msr, g.msr_table), strerror(errno));
48
+		return 0;
49
+	}
50
+	*val = args.data;
51
+
52
+	return 0;
53
+}
54
+#else /* !__FreeBSD__ */
55
 static int get_msr_val(unsigned int msr, unsigned long long *val)
56
 {
57
 	off64_t off;
58
 	int err;
59
 
60
 	*val = 0;
61
-	off = lseek64(g.fd, (off64_t) msr, SEEK_SET);
62
+	off = lseek(g.fd, (off64_t) msr, SEEK_SET);
63
 	if (off == (off_t) -1) {
64
 		perror("invalid MSR");
65
 		return 1;
66
@@ -144,11 +183,17 @@ static int get_msr_val(unsigned int msr, unsigned long long *val)
67
 	return 0;
68
 }
69
 
70
+#endif
71
+
72
 static int open_dev(int cpu)
73
 {
74
 	char s[20];
75
 
76
+#ifdef __FreeBSD__
77
+	snprintf(s, sizeof(s), CPUDEV, cpu);
78
+#else
79
 	snprintf(s, sizeof(s), "/dev/cpu/%d/msr", cpu);
80
+#endif
81
 	g.fd = open(s, O_RDONLY);
82
 	if (g.fd < 0)
83
 		fprintf(stderr, "could not open device %s: %s\n", s,
84
@@ -317,6 +362,7 @@ static int set_msr_table(void)
85
 }
86
 
87
 struct reg_spec unknown_msr = {0, "unknown", "(at your own risk)", NULL, NULL};
88
+unsigned int nrCPUs = 1;
89
 
90
 #define OPT_MAX 32
91
 int main(int argc, char *argv[])
92
@@ -325,6 +371,10 @@ int main(int argc, char *argv[])
93
 	int i, li, ret;
94
 	struct reg_spec *reg;
95
 
96
+	nrCPUs = sysconf(_SC_NPROCESSORS_ONLN);
97
+	if (nrCPUs > 65535)
98
+		nrCPUs = 1;
99
+
100
 	ret = 1;
101
 	if((g.prog = rindex(argv[0], '/')))
102
 		++g.prog;
(-)files/patch-mptable.c (-12 lines)
Lines 1-12 Link Here
1
--- mptable.c.orig	2011-09-15 15:37:32.000000000 -0700
2
+++ mptable.c	2011-09-15 15:37:46.000000000 -0700
3
@@ -37,7 +37,9 @@
4
 #include "mptable.h"
5
 #include "x86info.h"
6
 
7
+#ifndef __FreeBSD__
8
 typedef unsigned long vm_offset_t;
9
+#endif
10
 
11
 /* EBDA is @ 40:0e in real-mode terms */
12
 #define EBDA_POINTER			0x040e		  /* location of EBDA pointer */
(-)files/patch-mtrr.c (-21 lines)
Lines 1-21 Link Here
1
--- mtrr.c.orig	2011-09-15 15:38:23.000000000 -0700
2
+++ mtrr.c	2011-09-15 15:38:31.000000000 -0700
3
@@ -8,7 +8,9 @@
4
  */
5
 
6
 #include <stdio.h>
7
+#ifdef __linux__
8
 #include <asm/mtrr.h>
9
+#endif
10
 #include "x86info.h"
11
 
12
 #define IA32_MTRRCAP_SMRR 0x800
13
@@ -25,7 +27,7 @@
14
 
15
 static unsigned int max_phy_addr = 0;
16
 
17
-static char * mtrr_types[MTRR_NUM_TYPES] =
18
+static char * mtrr_types[] =
19
 {
20
     "uncacheable",
21
     "write-combining",
(-)files/patch-rdmsr.c (-54 lines)
Lines 1-54 Link Here
1
--- rdmsr.c.orig	2011-09-15 15:39:28.000000000 -0700
2
+++ rdmsr.c	2011-09-15 15:39:37.000000000 -0700
3
@@ -18,8 +18,15 @@
4
 #include "x86info.h"
5
 
6
 #if defined(__FreeBSD__)
7
+# include <sys/param.h>
8
 # include <sys/ioctl.h>
9
-# include <cpu.h>
10
+# if __FreeBSD_version < 701102
11
+#  define CPUDEV "/dev/cpu%d"
12
+#  include <cpu.h>
13
+# else
14
+#  define CPUDEV "/dev/cpuctl%d"
15
+#  include <sys/cpuctl.h>
16
+# endif
17
 #endif
18
 
19
 #if defined(__FreeBSD__)
20
@@ -27,16 +34,18 @@
21
 int read_msr(int cpu, unsigned int idx, unsigned long long *val)
22
 {
23
 	char cpuname[16];
24
-	unsigned char buffer[8];
25
-	unsigned long lo, hi;
26
 	int fh;
27
 	static int nodriver=0;
28
+#if __FreeBSD_version < 701102
29
 	cpu_msr_args_t args;
30
+#else
31
+	cpuctl_msr_args_t args;
32
+#endif
33
 
34
 	if (nodriver==1)
35
 		return 0;
36
 
37
-	(void)snprintf(cpuname, sizeof(cpuname), "/dev/cpu%d", cpu);
38
+	(void)snprintf(cpuname, sizeof(cpuname), CPUDEV, cpu);
39
 
40
 	fh = open(cpuname, O_RDONLY);
41
 	if (fh==-1) {
42
@@ -46,7 +55,11 @@
43
 	}
44
 
45
 	args.msr = idx;
46
-	if (ioctl(fh, CPU_RDMSR, &args) != 0) {
47
+#if __FreeBSD_version < 701102
48
+	if (ioctl(fh, CPU_RDMSR, &args) != 0) {                                 
49
+#else
50
+	if (ioctl(fh, CPUCTL_RDMSR, &args) != 0) {                                 
51
+#endif
52
 		if (close(fh) == -1) {
53
 			perror("close");
54
 			exit(EXIT_FAILURE);
(-)files/patch-x86info.h (-34 lines)
Lines 1-34 Link Here
1
--- x86info.h.orig	2011-09-15 15:37:57.000000000 -0700
2
+++ x86info.h	2011-09-15 15:38:09.000000000 -0700
3
@@ -220,6 +220,7 @@
4
 
5
 #define _GNU_SOURCE
6
 #define __USE_GNU
7
+#ifdef __linux__
8
 #include <sched.h>
9
 #include <sys/types.h>
10
 #include <unistd.h>
11
@@ -233,5 +234,23 @@
12
 		sched_setaffinity(getpid(), sizeof(set), &set);
13
 	}
14
 }
15
+#elif defined(__FreeBSD__)
16
+#include <sys/types.h>
17
+#include <sys/param.h>
18
+#include <sys/cpuset.h>
19
+static inline void bind_cpu(struct cpudata *cpu)
20
+{
21
+	cpuset_t set;
22
 
23
+	if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
24
+	    sizeof(set), &set) == 0) {
25
+		CPU_ZERO(&set);
26
+		CPU_SET(cpu->number, &set);
27
+		cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
28
+		    sizeof(set), &set);
29
+	}
30
+}
31
+#else
32
+# error "bind_cpu() is not implemented for this platform!"
33
+#endif
34
 #endif /* _X86INFO_H */

Return to bug 214878