[Assorted-commits] SF.net SVN: assorted: [355] cpp-commons/trunk/src/commons
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-10 18:52:18
|
Revision: 355 http://assorted.svn.sourceforge.net/assorted/?rev=355&view=rev Author: yangzhang Date: 2008-02-10 10:52:12 -0800 (Sun, 10 Feb 2008) Log Message: ----------- forked x86asm off cpuid; fixed includes Modified Paths: -------------- cpp-commons/trunk/src/commons/cppcommons.cpp cpp-commons/trunk/src/commons/cpuid.h cpp-commons/trunk/src/commons/files.h cpp-commons/trunk/src/commons/hash.h cpp-commons/trunk/src/commons/strings.h Added Paths: ----------- cpp-commons/trunk/src/commons/x86asm.h Modified: cpp-commons/trunk/src/commons/cppcommons.cpp =================================================================== --- cpp-commons/trunk/src/commons/cppcommons.cpp 2008-02-10 18:45:24 UTC (rev 354) +++ cpp-commons/trunk/src/commons/cppcommons.cpp 2008-02-10 18:52:12 UTC (rev 355) @@ -23,11 +23,12 @@ #include <config.h> #endif -#include "commons/check.h" -#include "commons/cpuid.h" -#include "commons/files.h" -#include "commons/hash.h" -#include "commons/strings.h" -#include "commons/time.h" -#include "commons/threads.h" +#include <commons/check.h> +#include <commons/cpuid.h> +#include <commons/files.h> +#include <commons/hash.h> +#include <commons/strings.h> +#include <commons/time.h> +#include <commons/threads.h> +#include <commons/x86asm.h> Modified: cpp-commons/trunk/src/commons/cpuid.h =================================================================== --- cpp-commons/trunk/src/commons/cpuid.h 2008-02-10 18:45:24 UTC (rev 354) +++ cpp-commons/trunk/src/commons/cpuid.h 2008-02-10 18:52:12 UTC (rev 355) @@ -6,6 +6,8 @@ #ifndef _COMMONS_CPUID_H #define _COMMONS_CPUID_H +#include <commons/x86asm.h> + namespace commons { @@ -19,26 +21,6 @@ "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func)); /** - * Given an extended general-purpose register (e.g. EAX), extract the high - * 8-bit register (AH). - */ - inline unsigned char - high(unsigned int r) - { - return ((r >> 8) & 0xffU); - } - - /** - * Given an extended general-purpose register (e.g. EAX), extract the low - * 8-bit register (AL). - */ - inline unsigned char - low(unsigned int r) - { - return (r & 0xffU); - } - - /** * Get cache line size in bytes on an Intel CPU. * References: * http://softpixel.com/~cwright/programming/simd/cpuid.php Modified: cpp-commons/trunk/src/commons/files.h =================================================================== --- cpp-commons/trunk/src/commons/files.h 2008-02-10 18:45:24 UTC (rev 354) +++ cpp-commons/trunk/src/commons/files.h 2008-02-10 18:52:12 UTC (rev 355) @@ -12,7 +12,7 @@ #include <unistd.h> #include <fcntl.h> -#include "commons/check.h" +#include <commons/check.h> namespace commons { Modified: cpp-commons/trunk/src/commons/hash.h =================================================================== --- cpp-commons/trunk/src/commons/hash.h 2008-02-10 18:45:24 UTC (rev 354) +++ cpp-commons/trunk/src/commons/hash.h 2008-02-10 18:52:12 UTC (rev 355) @@ -36,7 +36,7 @@ { unsigned long h = 0; for (; *s; ++s) - h = 31 * h + x; + h = 31 * h + *s; return size_t(h); } Modified: cpp-commons/trunk/src/commons/strings.h =================================================================== --- cpp-commons/trunk/src/commons/strings.h 2008-02-10 18:45:24 UTC (rev 354) +++ cpp-commons/trunk/src/commons/strings.h 2008-02-10 18:52:12 UTC (rev 355) @@ -5,7 +5,7 @@ #include <strings.h> -#include "commons/check.h" +#include <commons/check.h> namespace commons { Added: cpp-commons/trunk/src/commons/x86asm.h =================================================================== --- cpp-commons/trunk/src/commons/x86asm.h (rev 0) +++ cpp-commons/trunk/src/commons/x86asm.h 2008-02-10 18:52:12 UTC (rev 355) @@ -0,0 +1,29 @@ +#ifndef _COMMONS_X86ASM_H +#define _COMMONS_X86ASM_H + +namespace commons +{ + + /** + * Given an extended general-purpose register (e.g. EAX), extract the high + * 8-bit register (AH). + */ + inline unsigned char + high(unsigned int r) + { + return ((r >> 8) & 0xffU); + } + + /** + * Given an extended general-purpose register (e.g. EAX), extract the low + * 8-bit register (AL). + */ + inline unsigned char + low(unsigned int r) + { + return (r & 0xffU); + } + +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |