Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrot.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS system libraries 00004 * FILE: lib/msvcrt/stdlib/rot.c 00005 * PURPOSE: Performs a bitwise rotation 00006 * PROGRAMER: Ariadne 00007 * UPDATE HISTORY: 00008 * 03/04/99: Created 00009 */ 00010 00011 #include <stdlib.h> 00012 00013 #ifdef _MSC_VER 00014 #pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr) 00015 #endif 00016 00017 unsigned int _rotr( unsigned int value, int shift ); 00018 /* 00019 * @implemented 00020 */ 00021 unsigned int _rotl( unsigned int value, int shift ) 00022 { 00023 int max_bits = sizeof(unsigned int)<<3; 00024 if ( shift < 0 ) 00025 return _rotr(value,-shift); 00026 00027 if ( shift > max_bits ) 00028 shift = shift % max_bits; 00029 return (value << shift) | (value >> (max_bits-shift)); 00030 } 00031 00032 /* 00033 * @implemented 00034 */ 00035 unsigned int _rotr( unsigned int value, int shift ) 00036 { 00037 int max_bits = sizeof(unsigned int)<<3; 00038 if ( shift < 0 ) 00039 return _rotl(value,-shift); 00040 00041 if ( shift > max_bits<<3 ) 00042 shift = shift % max_bits; 00043 return (value >> shift) | (value << (max_bits-shift)); 00044 } 00045 00046 00047 /* 00048 * @implemented 00049 */ 00050 unsigned long _lrotl( unsigned long value, int shift ) 00051 { 00052 int max_bits = sizeof(unsigned long)<<3; 00053 if ( shift < 0 ) 00054 return _lrotr(value,-shift); 00055 00056 if ( shift > max_bits ) 00057 shift = shift % max_bits; 00058 return (value << shift) | (value >> (max_bits-shift)); 00059 } 00060 00061 /* 00062 * @implemented 00063 */ 00064 unsigned long _lrotr( unsigned long value, int shift ) 00065 { 00066 int max_bits = sizeof(unsigned long)<<3; 00067 if ( shift < 0 ) 00068 return _lrotl(value,-shift); 00069 00070 if ( shift > max_bits ) 00071 shift = shift % max_bits; 00072 return (value >> shift) | (value << (max_bits-shift)); 00073 } Generated on Sun May 27 2012 04:36:38 for ReactOS by
1.7.6.1
|