[Mplayer-cvslog] CVS: main cpudetect.c,1.23,1.24 cpudetect.h,1.7,1.8

Arpi of Ize arpi at mplayerhq.hu
Thu Jan 9 19:39:12 CET 2003


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv22616

Modified Files:
	cpudetect.c cpudetect.h 
Log Message:
cpu cache line length detection
from mplayerxp (Nick Kurshev <nickols_k at mail.ru>)


Index: cpudetect.c
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- cpudetect.c	23 Dec 2002 01:24:42 -0000	1.23
+++ cpudetect.c	9 Jan 2003 18:39:09 -0000	1.24
@@ -98,9 +98,9 @@
 	unsigned int regs[4];
 	unsigned int regs2[4];
 
-	caps->isX86=1;
-
 	memset(caps, 0, sizeof(*caps));
+	caps->isX86=1;
+	caps->cl_size=32; /* default */
 	if (!has_cpuid()) {
 	    mp_msg(MSGT_CPUDETECT,MSGL_WARN,"CPUID not supported!??? (maybe an old 486?)\n");
 	    return;
@@ -111,6 +111,7 @@
 	if (regs[0]>=0x00000001)
 	{
 		char *tmpstr;
+		unsigned cl_size;
 
 		do_cpuid(0x00000001, regs2);
 
@@ -132,6 +133,8 @@
 		caps->hasSSE  = (regs2[3] & (1 << 25 )) >> 25; // 0x2000000
 		caps->hasSSE2 = (regs2[3] & (1 << 26 )) >> 26; // 0x4000000
 		caps->hasMMX2 = caps->hasSSE; // SSE cpus supports mmxext too
+		cl_size = ((regs2[1] >> 8) & 0xFF)*8;
+		if(cl_size) caps->cl_size = cl_size;
 	}
 	do_cpuid(0x80000000, regs);
 	if (regs[0]>=0x80000001) {
@@ -142,6 +145,13 @@
 		caps->has3DNow    = (regs2[3] & (1 << 31 )) >> 31; //0x80000000
 		caps->has3DNowExt = (regs2[3] & (1 << 30 )) >> 30;
 	}
+	if(regs[0]>=0x80000006)
+	{
+		do_cpuid(0x80000006, regs2);
+		mp_msg(MSGT_CPUDETECT,MSGL_V,"extended cache-info: %d\n",regs2[2]&0x7FFFFFFF);
+		caps->cl_size  = regs2[2] & 0xFF;
+	}
+	mp_msg(MSGT_CPUDETECT,MSGL_INFO,"Detected cache-line size is %u bytes\n",caps->cl_size);
 #if 0
 	mp_msg(MSGT_CPUDETECT,MSGL_INFO,"cpudetect: MMX=%d MMX2=%d SSE=%d SSE2=%d 3DNow=%d 3DNowExt=%d\n",
 		gCpuCaps.hasMMX,

Index: cpudetect.h
===================================================================
RCS file: /cvsroot/mplayer/main/cpudetect.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- cpudetect.h	9 Dec 2001 17:03:04 -0000	1.7
+++ cpudetect.h	9 Jan 2003 18:39:09 -0000	1.8
@@ -16,6 +16,7 @@
 	int hasSSE;
 	int hasSSE2;
 	int isX86;
+	unsigned cl_size; /* size of cache line */
 } CpuCaps;
 
 extern CpuCaps gCpuCaps;



More information about the MPlayer-cvslog mailing list