From 6cc1413cce4f33e88059ae573ea53f47af6f11ad Mon Sep 17 00:00:00 2001 From: asterix Date: Tue, 6 Feb 2007 15:22:12 +0000 Subject: [PATCH] Add ROTL and ROTR macros for bit rotating. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@762 38d2e660-2303-0410-9eaa-f027e97ec537 --- cfg/macros.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cfg/macros.h b/cfg/macros.h index ba7b561d..45f0a1ed 100755 --- a/cfg/macros.h +++ b/cfg/macros.h @@ -14,6 +14,9 @@ /*#* *#* $Log$ + *#* Revision 1.11 2007/02/06 15:22:12 asterix + *#* Add ROTL and ROTR macros for bit rotating. + *#* *#* Revision 1.10 2006/09/13 18:31:37 bernie *#* BV8(), BV16(), BV32(): New macros for CPUs with small word size; SWAP_T(): New macro to support old compilers. *#* @@ -339,5 +342,13 @@ #endif /* COMPILER_VARIADIC_MACROS */ +/** + * Macro for rotating bit left or right. + * \{ + */ +#define ROTR(var, rot) (((var) >> (rot)) | ((var) << ((sizeof(var) * 8) - (rot)))) +#define ROTL(var, rot) (((var) << (rot)) | ((var) >> ((sizeof(var) * 8) - (rot)))) +/*\}*/ + #endif /* MACROS_H */ -- 2.25.1